Code:(setq ss (entlast))

Registered forum members do not see this ad.
I need to make a selection set of size 1 with that entry being the last entity inserted.




Code:(setq ss (entlast))
Or better yet
~'J'~Code:(setq ss (ssadd)) (ssadd (entlast) ss)
The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)




That method assigns the entity name to a variable. Will probably work for most operations.
To create a true selection set, use ssadd:
(ssadd (entlast) somesetname)
<edit- oops sat on my reply and fatty jumped in>
Last edited by CarlB; 30th Apr 2008 at 06:50 pm. Reason: too slow...

Registered forum members do not see this ad.
What does VLA-GET-ROTATION look for? What entity type?
I'm having a damndable time trying to get this simple little program to work... This takes a block called Standard_Receptacle and makes it so the text is always rotated the same way (Aligned with the receptacle)
The problem is - It askes the user for input point for the receptacle, then it forces them to select the entity again to affect the text rotation...
I just want the rotation to happen on the last entity not a selection set.
That is why was shooting for making a list that is only one entity long - the last one inserted.
Code:(defun C:1 () (setvar "cmdecho" 0) (setq Block "Standard_Receptacle") (setq Layer "E-POWR-WALL-NEW") (setvar "orthomode" 1) (SETVAR "attreq" 0) (setq ds (getvar "dimscale")) (setq ip (getpoint "Insertion Point:")) (setq clay (getvar "clayer")) (command "-layer" "s" Layer "") (command "insert" Block ip ds "" pause) ;************************************************************ (AssertAttributeRotation) ;************************************************************ (SETVAR "attreq" 1) (setvar "clayer" clay) (princ) ) (DEFUN AssertAttributeRotation (/ OBJPLUGLIST PLUGINSERTANGLE SS) ;(setq PlugLIST (ssadd)) ;Makes a Blank List ;(ssadd (entlast) PlugLIST) ;Adds the last entity to the List (WHILE (AND (SETQ ss (SSGET '((0 . "INSERT") (2 . "Standard_Receptacle")))) (SETQ ObjPlugList (KDUB:ss->objlist ss)) ) (FOREACH plugObject ObjPlugList (SETQ plugInsertAngle (VLA-GET-ROTATION plugObject) plugAttributeObject (CAR (VLAX-INVOKE plugObject 'GetAttributes)) ) (COND ((OR (> plugInsertAngle (KDUB:dtr 185)) (< plugInsertAngle (KDUB:dtr 5)) ) (VLA-PUT-ROTATION plugAttributeObject (+ plugInsertAngle (KDUB:dtr 90)) ) (VLA-PUT-ALIGNMENT plugAttributeObject ACALIGNMENTMIDDLELEFT) ) (T (VLA-PUT-ROTATION plugAttributeObject (- plugInsertAngle (KDUB:dtr 90)) ) (VLA-PUT-ALIGNMENT plugAttributeObject ACALIGNMENTMIDDLERIGHT) ) ) (PRINC) ) (DEFUN KDUB:ss->objlist (ss / i returnval) (IF (AND ss (< 0 (SSLENGTH ss))) (PROGN (SETQ i 0) (REPEAT (SSLENGTH ss) (SETQ returnval (CONS (VLAX-ENAME->VLA-OBJECT (SSNAME ss i)) returnval) i (1+ i) ) ) ) ) (IF returnval (REVERSE returnval) nil ) ) (DEFUN KDUB:rtd (ang) (/ (* ang 180.0) PI) ) (DEFUN KDUB:dtr (ang) (* PI (/ ang 180.0)) )
Mhamilton5@neo.rr.com
Last edited by MarkytheSparky; 30th Apr 2008 at 09:04 pm. Reason: Adding Code
Bookmarks