flopo Posted May 16, 2011 Share Posted May 16, 2011 Hello guys, Using a lisp, i draw few entities; how can i select them? I mean, last "n" entities drawn inside a lisp. Thanks! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 16, 2011 Share Posted May 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
LibertyOne Posted May 16, 2011 Share Posted May 16, 2011 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 ) Quote Link to comment Share on other sites More sharing options...
irneb Posted May 16, 2011 Share Posted May 16, 2011 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 ) Quote Link to comment Share on other sites More sharing options...
LibertyOne Posted May 16, 2011 Share Posted May 16, 2011 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. Quote Link to comment Share on other sites More sharing options...
irneb Posted May 16, 2011 Share Posted May 16, 2011 Exactly! It's how I created my Select Result routine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.