TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lastknownuser on May 19, 2022, 07:24:21 AM

Title: Get entity list of drawn object
Post by: Lastknownuser on May 19, 2022, 07:24:21 AM
Hi! Maybe its a stupid question, but I can't figure it out. Can I draw rectangle for example, and get entity list of it right after drawing it? Instead of first drawing rectangle and then using LISP functions (entget (car (entsel))), is it possible to do all in LISP, first be asked to draw something and then right after drawning it, get and store its entity list? Thanks for any help
Title: Re: Get entity list of drawn object
Post by: ronjonp on May 19, 2022, 07:28:00 AM
Code - Auto/Visual Lisp: [Select]
Title: Re: Get entity list of drawn object
Post by: Lastknownuser on May 19, 2022, 08:02:30 AM
Code - Auto/Visual Lisp: [Select]

I treied, it's not working for me at least not how I run it. Here is the simple code, it saves "ent" the last entity I drew before starting the TEST command

Code: [Select]
(defun c:test ()
(command "_.RECTANG")
(setq ent (entlast))
)
Title: Re: Get entity list of drawn object
Post by: mhupp on May 19, 2022, 08:44:18 AM
Code - Auto/Visual Lisp: [Select]

I treied, it's not working for me at least not how I run it. Here is the simple code, it saves "ent" the last entity I drew before starting the TEST command

Code: [Select]
(defun c:test ()
(command "_.RECTANG")
(setq ent (entlast))
)

Your rectangle command isn't completed and so isn't created yet.

use the following
Code - Auto/Visual Lisp: [Select]
  1. (command "_.RECTANGLE" pt1 pt2) ;with defined points
  2. (command "_.RECTANGLE" pause pause) ;user selects points
  3. (command "_.RECTANGLE" "0,0" "4,6") ;create a rectangle in defined location


Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ()
  2.   (command "_.RECTANGLE" pause pause)
  3.   (setq ent (entlast))
  4. )

Title: Re: Get entity list of drawn object
Post by: Lastknownuser on May 19, 2022, 08:59:49 AM
Code - Auto/Visual Lisp: [Select]

I treied, it's not working for me at least not how I run it. Here is the simple code, it saves "ent" the last entity I drew before starting the TEST command

Code: [Select]
(defun c:test ()
(command "_.RECTANG")
(setq ent (entlast))
)

Your rectangle command isn't completed and so isn't created yet.

use the following
Code - Auto/Visual Lisp: [Select]
  1. (command "_.RECTANGLE" pt1 pt2) ;with defined points
  2. (command "_.RECTANGLE" pause pause) ;user selects points
  3. (command "_.RECTANGLE" "0,0" "4,6") ;create a rectangle in defined location


Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ()
  2.   (command "_.RECTANGLE" pause pause)
  3.   (setq ent (entlast))
  4. )

Oh right, I understand...thanks!