+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Apr 2008
    Posts
    43

    Default How do I make a selection set of size 1 from the last entity

    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.

  2. #2
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    Code:
    (setq ss (entlast))

  3. #3
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Or better yet

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

  4. #4
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    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...

  5. #5
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Apr 2008
    Posts
    43

    Default Then....

    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

Similar Threads

  1. Make a non square selection
    By viriato79 in forum AutoCAD General
    Replies: 8
    Last Post: 7th Jan 2008, 08:37 pm
  2. HELP With routine to make door to any size
    By WileCoyote365 in forum AutoLISP, Visual LISP & DCL
    Replies: 20
    Last Post: 16th Jul 2007, 08:38 am
  3. delay in selection of objects/selection windows
    By RedRobMol in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 31st May 2005, 01:34 pm
  4. Plot size on server is much larger than drawing size
    By chewy-d in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 1st Nov 2003, 03:25 pm
  5. Entity Selection
    By Jabba in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 10th Dec 2002, 01:56 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts