TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on April 28, 2017, 12:14:36 PM
-
How to make (entget) work like (entsel). I do not want to select the object "line"; but use the last object "line" drawn.
For example:
(setq ent (entget (entlast)))
(list (entnext) '(x y z))
Where '(x y z) is the (assoc 10 (entget (entlast)))
Will this example work in place of (entsel)?
Thanks for a direction...
-
The following will return the entity name of the last LINE added to the drawing database:
-
Thanks Lee
(lastline) is the same as (entlast)
I'm looking for the :?
(defun C:Walls ()
(setq pt1 (getpoint "\n* Pick beginning point *"))
(setq pt2 (getpoint pt1 "\n* Pick the end point *"))
(command "line" pt1 pt2 "")
(entget (entlast))
(setq wallline ;;(entsel "\n* Select Line to offset...")
firstendpnt (trans (cdr (assoc 10 (entget (car wallline)))) 0 1)
secondendpnt (trans (cdr (assoc 11 (entget (car wallline)))) 0 1)
pnt2 (getpoint "\n* Specify Offset Directiont --> ")
ang1 (angle firstendpnt secondendpnt))
(if (and (> ang1 (/ pi 2.0)) (<= ang1 (* pi 1.5)))
(setq ang1 (+ ang1 pi)))
(command "offset" "3.5" wallline pnt2 "")
(command "change" "l" "" "p" "la" "A-WALL-FULL" "")
(command "offset" "9.0" wallline pnt2 "")
(command "change" "l" "" "p" "la" "A-WALL-EXT" "")
(princ))
-
(lastline) is the same as (entlast)
No it's not.
-
Here is what I got to work:
(defun C:WW2 ()
(ARCH:F_S-VAR)
(defun ARCH:MIDPOINT (w z)
(list (/ (+ (car w) (car z)) 2) (/ (+ (cadr w) (cadr z)) 2)))
(ARCH:LYR "A-WALL-FULL")
(setq pt1 (getpoint "\n* Pick beginning point *"))
(setq pt2 (getpoint pt1 "\n* Pick the end point *"))
(command "line" pt1 pt2 "")
(setq mid (ARCH:MIDPOINT pt1 pt2))
(defun lastline ( / s )
(if (setq s (ssget "_X" '((0 . "LINE"))))(ssname s 0))
)
(entget (entlast))
(setq wallline (list (lastline) mid) ;;(entsel "\n* Select Line to offset...")
firstendpnt (trans (cdr (assoc 10 (entget (car wallline)))) 0 1)
secondendpnt (trans (cdr (assoc 11 (entget (car wallline)))) 0 1)
pnt2 (getpoint "\n* Specify Offset Directiont --> ")
ang1 (angle firstendpnt secondendpnt))
(if (and (> ang1 (/ pi 2.0)) (<= ang1 (* pi 1.5)))
(setq ang1 (+ ang1 pi)))
(command "offset" "3.5" wallline pnt2 "")
(command "change" "l" "" "p" "la" "A-WALL-FULL" "")
(ARCH:LYR "A-WALL-VENR")
(command "offset" "9.0" wallline pnt2 "")
(command "change" "l" "" "p" "la" "A-WALL-EXT" "")
(princ)
(ARCH:F_R-VAR)
(princ))
Thanks Lee
-
@GDF:
Why don't you use:
(list (entlast) pt1)
instead of:
(list (lastline) mid)
?
(defun C:WW2
( / entselLst pt1 pt2 pt3
) (ARCH:F_S-VAR)
(command "_.offset" "3.5" entselLst pt3
"") (ARCH:LYR "A-WALL-FULL")
(command "_.chprop" "_last" "" "_layer" "A-WALL-FULL" "") (command "_.offset" "9.0" entselLst pt3
"") (ARCH:LYR "A-WALL-EXT")
(command "_.chprop" "_last" "" "_layer" "A-WALL-EXT" "") (ARCH:F_R-VAR)
)
-
@GDF:
Why don't you use:
(list (entlast) pt1)
instead of:
(list (lastline) mid)
?
(defun C:WW2
( / entselLst pt1 pt2 pt3
) (ARCH:F_S-VAR)
(command "_.offset" "3.5" entselLst pt3
"") (ARCH:LYR "A-WALL-FULL")
(command "_.chprop" "_last" "" "_layer" "A-WALL-FULL" "") (command "_.offset" "9.0" entselLst pt3
"") (ARCH:LYR "A-WALL-EXT")
(command "_.chprop" "_last" "" "_layer" "A-WALL-EXT" "") (ARCH:F_R-VAR)
)
-
Thanks Roy
-
GDF for future reference (entget (entlast)) will get the last entity but you did not save it to a variable so you can use it, (setq lline (entget (entlast))). But like Lee its the last entity created so you must remember to do it straight after making an entity that you know what type it is.
-
Thanks