ETYPE or SORT LISP question

Discussion in 'AutoCAD' started by vmuntean, Mar 14, 2008.

  1. vmuntean

    vmuntean Guest

    Hello,

    I just run into a problem with one of my lisp functions. Depending on
    the type of entity selected (line, polyline etc), I need to run a
    different command.

    I added ETYPE in the (defun list and then I tried to write an if
    statement that does the following:

    if the user selected just polylines then a command should be run

    if the user selected polylines AND anything else (this should include
    the scenario where the user selects lines/arcs/..... but NO polylines)
    another command should be run.

    (if (=etype "polyline") (progn
    (command "pedit"...)
    ))
    should there be an else between the different if statements?

    Is there a way to ask for AND/OR?

    (if (or (=etype "line") (=etype "arc") (=etype "circle") (=etype
    "ellipse")........)(progn
    (command "pedit"...)
    ))

    Not sure if the sytax is correct, but that's not even the main
    problem. I kept getting back the error - no function definition: ETYPE
    and I wasn't sure on how to get around that.

    Someone also mentioned that once the user selects all the required
    entities there is a way to sort them into two lists - one that
    contains all the polylines and run the command line and into another
    list that contains everything else and then run the other command
    line.

    There may be other ways as well. I hope this makes sense.

    Thank you in advance for your help,
    Vlad
     
    vmuntean, Mar 14, 2008
    #1
  2. vmuntean

    vmuntean Guest

    Or perhaps I may be able to do this another way. Depending on what
    entities are selected, one of the two command lines that I need to run
    will return an "Unknown command" message. If I could write an if
    statement that will say

    if "unknown command", then move to the next command line.

    I am not sure if this is possible or what the sytax may be, but I
    think it will work if it can be done.

    Thank you,
    Vlad
     
    vmuntean, Mar 14, 2008
    #2
  3. *
    | Or perhaps I may be able to do this another way. Depending on what
    | entities are selected, one of the two command lines that I need to run
    | will return an "Unknown command" message. If I could write an if
    | statement that will say
    |
    | if "unknown command", then move to the next command line.
    |
    | I am not sure if this is possible or what the sytax may be, but I
    | think it will work if it can be done.
    |
    | Thank you,
    | Vlad
    |
    | On Mar 14, 12:25 pm, wrote:
    | > Hello,
    | >
    | > I just run into a problem with one of my lisp functions. Depending on
    | > the type of entity selected (line, polyline etc), I need to run a
    | > different command.
    | >
    | > I added ETYPE in the (defun list and then I tried to write an if
    | > statement that does the following:
    | >
    | > if the user selected just polylines then a command should be run
    | >
    | > if the user selected polylines AND anything else (this should include
    | > the scenario where the user selects lines/arcs/..... but NO polylines)
    | > another command should be run.
    | >
    | > (if (=etype "polyline") (progn
    | > (command "pedit"...)
    | > ))

    The code as shown will not work because "=etype" is not an
    autolisp function. You should write (if (= etype "polyline") ....
    Notice that there is a space betwen the equal sign and the
    symbol etype.
     
    Eduardo Muñoz, Mar 16, 2008
    #3
  4. vmuntean

    vmuntean Guest

    Thank you, that seems to have worked since I no longer receive the
    etype error. Here is what I have now:

    (setq etype (cdr (assoc 0 ssl)))
    (if (= etype "polyline") (progn
    (command "" "pedit" "m" SS1 "" "c" "")))
    ;(setq etype (cdr (assoc 0 ss1)))
    (if (member etype
    '("3DFACE" "ARC" "ATTDEF" "CIRCLE" "DIMENSION" "ELLIPSE" "HATCH"
    "INSERT" "LINE" "MTEXT" "POINT" "SOLID" "TEXT") ) (progn
    (command " " "pedit" "m" ss1 "" "" "j" "" "c" "")))

    What I am trying to do is when the user has a single, or multiple
    polylines selected, it runs :
    (command "" "pedit" "m" SS1 "" "c" "")

    When the user has anyting else selected (polylines and lines, just
    lines, arcs etc) it should run:
    (command " " "pedit" "m" ss1 "" "" "j" "" "c" "")

    Thank you in advance for any help.
    Vlad
     
    vmuntean, Mar 18, 2008
    #4
  5. vmuntean

    vmuntean Guest

    Someone mentioned that I can sort different types of entities from a
    selection into lists. Let's say I have a selection called ss1 which
    includes lines, arcs, circles and splines. Can I take the selection
    and separate the splines into a list, run the command line for splines
    and then place the remaining entities in a separate list and run the
    other command?

    Any help greately appreciated.
    Vlad
     
    vmuntean, Mar 19, 2008
    #5
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.