Here are two examples .
Or..Code:(setq line1 (entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2))))
TharwatCode:(entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2))) (setq line1 (entlast))


Registered forum members do not see this ad.
Hello guys,
Using a lisp, i draw few entities; how can i select them? I mean, last "n" entities drawn inside a lisp. Thanks!
Here are two examples .
Or..Code:(setq line1 (entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2))))
TharwatCode:(entmakex (list (cons 0 "LINE")(cons 10 p1) (cons 11 p2))) (setq line1 (entlast))
how about something like this?
Code:;;--------------------------------------------------------------;; ;; 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 )
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.:Code:(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.
once this function is defined, you can go about placing it in your code where ever you see fit.Code:(defun set-bookmark () (setq ent-mark (entlast)) )
once a bookmark is set, there are endless possibilities of what you can do with the selection sets.Code:;; ...your code... (set-bookmark) ;; ...your code...
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.
Bookmarks