Author Topic: Get entity list of drawn object  (Read 881 times)

0 Members and 1 Guest are viewing this topic.

Lastknownuser

  • Newt
  • Posts: 25
Get entity list of drawn object
« 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

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Get entity list of drawn object
« Reply #1 on: May 19, 2022, 07:28:00 AM »
Code - Auto/Visual Lisp: [Select]

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lastknownuser

  • Newt
  • Posts: 25
Re: Get entity list of drawn object
« Reply #2 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))
)

mhupp

  • Bull Frog
  • Posts: 250
Re: Get entity list of drawn object
« Reply #3 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. )

« Last Edit: May 19, 2022, 08:50:47 AM by mhupp »

Lastknownuser

  • Newt
  • Posts: 25
Re: Get entity list of drawn object
« Reply #4 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!