Newbie to Autolisp

Discussion in 'AutoCAD' started by eddiev, Aug 10, 2004.

  1. eddiev

    eddiev Guest

    I am trying to make a shortcut for the justifytext command. The routine I have so far is:

    (defun c:JT()
    (print " JUSTIFY TEXT TO MIDDLE CENTER ")
    (command "JUSTIFYTEXT")
    (princ)
    )

    My question is .... "how do I get the lisp routine to pause the command so I can select the text?" I want it to continue and apply the "MC" for middle center justification.
     
    eddiev, Aug 10, 2004
    #1
  2. Use the pause method

    (defun c:JT()
    (print " Justify Text To Middle Center ")
    (command "JUSTIFYTEXT" pause "" "MC")
    (princ)
    )
     
    Allen Johnson, Aug 10, 2004
    #2
  3. eddiev

    J. Logan Guest

    This doesn't address your Lisp question. But the macro below.

    ^C^CTjust MC

    Placed in a custom button achieves the same thing. Select the text to
    justify then press the button.

    J. Logan

    so I can select the text?" I want it to continue and apply the "MC" for
    middle center justification.
     
    J. Logan, Aug 10, 2004
    #3
  4. eddiev

    Tom Smith Guest

    As mentioned, pause is one way to make a command wait for user input, but
    (as in this case) it can be cranky and crude. In general it's better to get
    input from the user first and then feed it to the command:

    (defun c:JT(/ sset)
    (princ "\nJUSTIFY TEXT TO MIDDLE CENTER ")
    (if (setq sset (ssget '((-4 . "<or") (0 . "TEXT") (0 . "MTEXT")(-4 .
    "or>"))))
    (command "JUSTIFYTEXT" sset "" "MC"))
    (princ))

    The ssget lets you use any selection method, but filters the selection to
    only text and mtext. Then the command is run if anything was selected.
     
    Tom Smith, Aug 10, 2004
    #4
  5. eddiev

    eddiev Guest

    Thanks Tom, You are a big help again! You helped me with the toolbar stuff. Your routine is a bit more complicated then mine. I would like to learn more on the "language" of the lisp commands. Is there something I could read that would be like a dictionary or something that will give me info on the terminology? Like what do the -4's represent, what is the sset and setq stuff like that.

    Thanks again Tom

    You are the man!!
     
    eddiev, Aug 10, 2004
    #5
  6. eddiev

    MP Guest

    when all else fails, check the help files
    help | developer help | contents | lisp reference
    stuff. Your routine is a bit more complicated then mine. I would like to
    learn more on the "language" of the lisp commands. Is there something I
    could read that would be like a dictionary or something that will give me
    info on the terminology? Like what do the -4's represent, what is the sset
    and setq stuff like that.
     
    MP, Aug 10, 2004
    #6
  7. eddiev

    Tom Smith Guest

    No problem. I just learned from the docs that come with Acad, way back when
    they were printed manuals. There are some websites with good tutorials.
    http://www.afralisp.com/ has a lot of good tips and sample programs.

    Look in help, in the lisp reference under ssget and also look at selection
    set filter lists. In this filter list, the 0 codes obviously refer to entity
    types. The -4 is a special codes like "and" and "or." In this case I wanted
    to only allow selection of either text or mtext.

    It turns out I really didn't need to do that, since justifytext seems to
    have a built-in filter, but it's not a bad habit to only allow selection of
    things that your program can work with. It works just as well with no
    filtering:

    (defun c:JT(/ sset)
    (princ "\nJUSTIFY TEXT TO MIDDLE CENTER ")
    (if (setq sset (ssget))
    (command "JUSTIFYTEXT" sset "" "MC"))
    (princ))



    stuff. Your routine is a bit more complicated then mine. I would like to
    learn more on the "language" of the lisp commands. Is there something I
    could read that would be like a dictionary or something that will give me
    info on the terminology? Like what do the -4's represent, what is the sset
    and setq stuff like that.
     
    Tom Smith, Aug 10, 2004
    #7
  8. eddiev

    eddiev Guest

    Tom that is a pretty cool website thanks. I am sure we will be chatting again. Thanks for everything!!
     
    eddiev, Aug 10, 2004
    #8
  9. eddiev

    Paul Turvill Guest

    .... or, more simply,
    (if (setq sset (ssget '((0 . "TEXT,MTEXT"))))
    ...

    "or>"))))
     
    Paul Turvill, Aug 11, 2004
    #9
  10. eddiev

    Tom Smith Guest

    ... or, more simply,
    Good catch, Paul. I tend to forget the extra wcmatch tests available with
    strings.
     
    Tom Smith, Aug 11, 2004
    #10
  11. eddiev

    Dommy2Hotty Guest

    Afralisp has been to me by far THE most useful site for LISP.
     
    Dommy2Hotty, Aug 12, 2004
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.