Code Red > AutoLISP (Vanilla / Visual)

Make (entlast) work like (entsel)

(1/2) > >>

GDF:
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...

Lee Mac:
The following will return the entity name of the last LINE added to the drawing database:

--- Code - Auto/Visual Lisp: ---(defun lastline ( / s )    (if (setq s (ssget "_X" '((0 . "LINE")))) (ssname s 0)))

GDF:
Thanks Lee

(lastline) is the same as (entlast)
I'm looking for the :?


 
--- Code: ---(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))

--- End code ---

Lee Mac:

--- Quote from: GDF on April 28, 2017, 01:04:20 PM ---(lastline) is the same as (entlast)
--- End quote ---

No it's not.

GDF:
Here is what I got to work:


--- Code: ---(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))

--- End code ---

Thanks Lee

Navigation

[0] Message Index

[#] Next page

Go to full version