Picking entities (lines) in LISP

Discussion in 'AutoCAD' started by jkgreene, Jul 12, 2004.

  1. jkgreene

    jkgreene Guest

    Wasup,
    Is there a better way to pick a line, say for triming or rotateing, in a LISP command? Right now I just set a point on that line and tell the LISP to pick that point, but it does not always work, only sometimes.
     
    jkgreene, Jul 12, 2004
    #1
  2. jkgreene

    T.Willey Guest

    The best way for people to help you is for you to post your code so they can see what you are doing. Like how are you selecting the line (entsel.. (nentsel... (nentselp.... or with a group (ssget... What point are you using?

    Post your code and tell them how you think it should react.

    Tim
     
    T.Willey, Jul 12, 2004
    #2
  3. jkgreene

    Rudy Tovar Guest

    I agree with T.Willey...

    You need to post the code and give us an example of what you're trying to
    accomplish.

    If you use (setq e (entsel "\nAny Prompt Here: ")) it assigns the entity
    selected name, and approx. location of where you selected the 'LINE'.

    Example: (<Entity name: 74c0a90> (-1360.98 -124.934 0.0))

    If you set the value (setq data (entget (car e))) it returns the entity data

    Example:
    ((-1 . <Entity name: 74c0a90>) (0 . "LINE") (5 . "101F2") (100 .
    "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 -1389.51 -145.841
    0.0)
    (11 -1330.54 -85.0222 0.0) (210 0.0 0.0 1.0))

    It now displays the entity type, in this case a "LINE" (0 . "LINE"), handle
    (5. "101F2") startpoint (10 -1389.51 -154.841 0.0) endpoint
    (11 -1330.54 -85.0222 0.0)

    Additional data is displayed if the the entity has had it's properties
    manipulated, line 'color' assoc 62 and 6 for 'linetype'.

    Now to actually write the code you'd need to structure it correctly and rule
    out errors or bugs.

    Example:

    (defun c:SL (/ e d t)
    (while (setq e (entsel "\nSelect LINE: "))
    (setq d (entget (car e))
    t (cdr (assoc 0))
    )
    (if (= t "LINE")
    (progn
    ;Do_what_ever
    )
    )
    )
    (princ)
    )

    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi


    LISP command? Right now I just set a point on that line and tell the LISP
    to pick that point, but it does not always work, only sometimes.
     
    Rudy Tovar, Jul 12, 2004
    #3
  4. jkgreene

    jkgreene Guest

    The following is the complete code that I am using, you probably do not need to complete code, but here it is any ways. I put stars ** next to the lines where the question is based on. I am just simply rotating something was drawn in the top portion of the LISP command, but there has got to be an easier way to select the lines for rotation. The way that ya'll see is me doing a setq to a point on that line and telling the rotate command to select that point, hence selecting the entire line. Your help is much needed and I thank you.
    (defun dtr (a)
    (* a (/ pi 180.0))
    )
    (defun C:win2br ()
    (Command "ortho" "off" "")
    (Command "osmode" "3" "")
    (setvar "cmdecho" 0)
    (graphscr)
    (setq ip (getpoint "\n Enter the Center Point of the Window on the Interior Wall:"))
    (Command "osmode" "0" "")
    (setq a (getdist "\n Enter the Width of the Window:"))
    (setq b (getdist "\n Enter the Wall Thickness:"))
    (setq c (* a 0.5))
    (setq c1 (+ a 4))
    (setq c2 (* b 0.5))
    (setq c3 (* c2 0.5))
    (setq d (polar ip (dtr 180) c))
    (setq e (polar d (dtr 270) 4))
    (setq f (polar e (dtr 180) 2))
    (setq g (polar f (dtr 270) 7.5))
    (setq h (polar g (dtr 0) c1))
    (setq i (polar h (dtr 90) 7.5))
    (setq j (polar i (dtr 180) 2))
    (setq k (polar j (dtr 90) 4))
    (setq l (polar g (dtr 90) 3.5))
    (setq m (polar h (dtr 90) 3.5))
    (setq n (polar d (dtr 270) 1.5))
    (setq o (polar n (dtr 270) 1))
    (setq p (polar k (dtr 270) 1.5))
    (setq q (polar p (dtr 270) 1))
    (setq r (polar e (dtr 0) 2))
    (setq s (polar d (dtr 270) 2))
    (setq u (polar j (dtr 90) 2))
    (setq v (polar n (dtr 0) 2))
    (setq w (polar o (dtr 0) 0.5))
    (setq x (polar g (dtr 0) 0.5))
    (Command "-layer" "s" "A-WNDW-SILL" "")
    (command "line" f g "")
    (command "line" g h "")
    (command "line" h i "")
    (Command "-layer" "s" "A-WALL" "")
    (command "line" j k "")
    (command "line" d e "")
    (Command "-layer" "s" "A-GLAZ" "")
    (command "line" n p "")
    (command "line" o q "")
    **(command "rotate" r l m s u v w x "" ip "90" "")
    (setq y (polar ip (dtr 0) 4))
    (setq b1 (polar ip (dtr 0) 9.5))
    (setq z (+ c 2))
    (setq a1 (polar y (dtr 90) z))
    (setq a2 (polar y (dtr 270) z))
    (command "trim" "all" "" y "")
    (command "trim" "all" "" b1 "")
    (Command "-layer" "s" "A-WALL-HEAD" "")
    (command "line" a1 a2 "")
    (Command "osmode" "171" "")
    (Command "ortho" "On" "")
    (Command "cmdecho" 1)
    )
     
    jkgreene, Jul 12, 2004
    #4
  5. jkgreene

    Rudy Tovar Guest

    Tell you what, just download MASi Express Tools, and I'll give you a FREE
    License. Draws doors and windows in 2d and more to follow for you FREE.

    If you're not interested, I'll take a look at the code.
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi

    need to complete code, but here it is any ways. I put stars ** next to the
    lines where the question is based on. I am just simply rotating something
    was drawn in the top portion of the LISP command, but there has got to be an
    easier way to select the lines for rotation. The way that ya'll see is me
    doing a setq to a point on that line and telling the rotate command to
    select that point, hence selecting the entire line. Your help is much
    needed and I thank you.
     
    Rudy Tovar, Jul 13, 2004
    #5
  6. jkgreene

    T.Willey Guest

    Does it work the way you want, except the picking lines part? If that is your only problem, you could add your lines to a selection set after you draw them. Then you just rotate the selection set, and trim using the selection set as you cutting lines.

    Some of you lines could be written different also.
    ie.
    (Command "ortho" "off" "") <- has one to many enters
    should be
    (command "ortho" "off")
    but you could do this with "setvar" also
    (setvar "orthomode" 0)

    Tim
     
    T.Willey, Jul 13, 2004
    #6
  7. jkgreene

    jkgreene Guest

    Yes it works the way I have it, but not always. Tell me more about the selection set and how to set that up?
     
    jkgreene, Jul 13, 2004
    #7
  8. jkgreene

    jkgreene Guest

    Thanks, but this LISP is tailored to what my boss wants, in accordance with layers, and ledges. Thanks though
     
    jkgreene, Jul 13, 2004
    #8
  9. jkgreene

    T.Willey Guest

    (defun C:win2br ()
    (Command "ortho" "off")
    (Command "osmode" "3")
    (setvar "cmdecho" 0)
    (graphscr)
    (setq ip (getpoint "\n Enter the Center Point of the Window on the Interior Wall:"))
    (Command "osmode" "0")
    (setq a (getdist "\n Enter the Width of the Window:"))
    (setq b (getdist "\n Enter the Wall Thickness:"))
    (setq ss (ssadd)); make a bland selection set
    (setq c (* a 0.5))
    (setq c1 (+ a 4))
    (setq c2 (* b 0.5))
    (setq c3 (* c2 0.5))
    (setq d (polar ip (dtr 180) c)
    e (polar d (dtr 270) 4)
    f (polar e (dtr 180) 2)
    g (polar f (dtr 270) 7.5)
    h (polar g (dtr 0) c1)
    i (polar h (dtr 90) 7.5)
    j (polar i (dtr 180) 2)
    k (polar j (dtr 90) 4)
    l (polar g (dtr 90) 3.5)
    m (polar h (dtr 90) 3.5)
    n (polar d (dtr 270) 1.5)
    o (polar n (dtr 270) 1)
    p (polar k (dtr 270) 1.5)
    q (polar p (dtr 270) 1)
    r (polar e (dtr 0) 2)
    s (polar d (dtr 270) 2)
    u (polar j (dtr 90) 2)
    v (polar n (dtr 0) 2)
    w (polar o (dtr 0) 0.5)
    x (polar g (dtr 0) 0.5)
    ); end setq
    (Command "-layer" "s" "A-WNDW-SILL" "")
    (command "line" f g "")
    (ssadd (entlast) ss)
    (command "line" g h "")
    (ssadd (entlast) ss)
    (command "line" h i "")
    (ssadd (entlast) ss)
    (Command "-layer" "s" "A-WALL" "")
    (command "line" j k "")
    (ssadd (entlast) ss)
    (command "line" d e "")
    (ssadd (entlast) ss)
    (Command "-layer" "s" "A-GLAZ" "")
    (command "line" n p "")
    (ssadd (entlast) ss)
    (command "line" o q "")
    (ssadd (entlast) ss)
    (command "rotate" ss "" ip "90")

    ;(command "rotate" r l m s u v w x "" ip "90" "")<- took this one out

    (setq y (polar ip (dtr 0) 4)
    b1 (polar ip (dtr 0) 9.5)
    z (+ c 2)
    a1 (polar y (dtr 90) z)
    a2 (polar y (dtr 270) z)
    ); end setq
    (command "trim" ss "" y b1 "")

    ;(command "trim" "all" "" y ""<- took this one out
    ; "trim" "all" "" b1 ""<- took this one out
    ;); end command<- took this one out

    (Command "-layer" "s" "A-WALL-HEAD" "")
    (command "line" a1 a2 ""
    "osmode" "171"
    "ortho" "On"
    "cmdecho" 1
    ); end command
    )

    See if this works for you, I combined some of the stuff and wrote in new code other places for the selection set (real fast though) seems to work on my comp. If you have any questions post, and someone will answer if not me. It's time for me to go home.

    Tim
     
    T.Willey, Jul 13, 2004
    #9
  10. jkgreene

    Rudy Tovar Guest

    Cool, but if you get a chance take a look at MASi.
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi

    with layers, and ledges. Thanks though
     
    Rudy Tovar, Jul 13, 2004
    #10
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.