Jump to content

select last "n" entities drawn inside a lisp


flopo

Recommended Posts

Hello guys,

Using a lisp, i draw few entities; how can i select them? I mean, last "n" entities drawn inside a lisp. Thanks!

Link to comment
Share on other sites

Here are two examples . :)

 

 (setq line1 (entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2))))

 

Or..

 

(entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2)))
(setq line1 (entlast))

 

Tharwat

Link to comment
Share on other sites

how about something like this?

 

 
;;--------------------------------------------------------------;;
;; SINCE
;; Creates a selection set of all objects created SINCE the
;; selected one.
(defun since (/ ss en)
(setq ss (ssadd))
(setq en (car (entsel "\nSelect first object: ")))
(setq ss (ssadd en ss))
(while (setq en (entnext en))
 (setq ss (ssadd en ss))
)
ss
)

Link to comment
Share on other sites

Another way could be to save the value of entlast just before creating the entities. Then use entnext to step through all that have been made thereafter. E.g.:

(defun c:MyFunc (/ lastEnt ss)
 ;; Save the last entity
 (setq lastEnt (entlast))
 ;; Do some stuff
 ;; ....
 ;; Select all entities created in this function
 (setq ss (ssadd))
 (while (setq lastEnt (entnext lastEnt))
   (ssadd lastEnt ss)
 )
 (sssetfirst nil ss) ;Grip select the set
 (princ) ;Exit cleanly
)

Link to comment
Share on other sites

Another way could be to save the value of entlast just before creating the entities. Then use entnext to step through all that have been made thereafter. E.g.:
(defun c:MyFunc (/ lastEnt ss)
;; Save the last entity
(setq lastEnt (entlast))
;; Do some stuff
;; ....
;; Select all entities created in this function
(setq ss (ssadd))
(while (setq lastEnt (entnext lastEnt))
(ssadd lastEnt ss)
)
(sssetfirst nil ss) ;Grip select the set
(princ) ;Exit cleanly
)

 

This is also a good idea, but I would make a function to set a marker, and another to then retrieve the entities that were made after the marker.

(defun set-bookmark ()
  (setq ent-mark (entlast))
)

 

once this function is defined, you can go about placing it in your code where ever you see fit.

;; ...your code...
(set-bookmark)
;; ...your code...

 

once a bookmark is set, there are endless possibilities of what you can do with the selection sets.

 

You can even set multiple markers and use them to create selection sets "in between" and not just from a certain entity to the end.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...