Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Entsel & SSGet combined

  1. #1
    Active Member
    Join Date
    2008-02
    Location
    Toronto, On
    Posts
    59
    Login to Give a bone
    0

    Default Entsel & SSGet combined

    So I'm trying to come up with a way to allow the user to select blocks one at a time, or in large swaths, but I want things to happen to each block right after it's selected. (autofill an attribute, or similar)

    Is there some way to get ssget to report each SS that is made, independent of the user pressing enter? Or is there a way to transparently change from entsel mode to ssget mode if the user selects nothing, but use the point that the user selected as the first corner of a window...

    Put another way:
    Entsel returns the entity name (and some more) immediately when the user selects the entity.
    SSGet allows the user to select individual entities, but just keeps adding them to a buffer until the user presses enter. Is there a way to get ssget to terminate everytime a selection is made, regardless of enter.

    Here's what I have so far, but the user has to press "M" while selecting to switch to ssget mode...
    Currently it just draws a circle at the block insertion point.

    Code:
    (defun C:SelTest ( / En SS Len Cnt Loop)
    
      (setq Loop T)
      
      (while Loop
    
        (initget "End Multiple")
        (setq En (entsel "\nSelect entities or [End/Multiple]: "))
    
        (cond ((= En "End")
    	   (setq Loop nil)
    	   );end or
    
    	  ((= En "Multiple")
    	   (if (setq SS (ssget))
    	     (progn
    	       (setq Len (sslength SS)
    		     Cnt -1
    		     )
    	       (while (< (setq Cnt (1+ Cnt)) Len)
    		 (setq En (ssname SS Cnt))
    		 (DrawCircleAt En)
    		 );end while
    	       );end progn
    	     );end if
    	   )
    
    	  ((null En)
    	   (princ "\nNo object selected!")
    	   )
    
    	  (T
    	   (DrawCircleAt (car En))
    	   );end T
    	  );end cond
        );end while
      
      (princ)
      );end defun
    
    
    (defun DrawCircleAt (En / )
    
      (command "CIRCLE"
    	   (cdr (assoc 10 (entget En)))
    	   0.25
    	   );end command
    
      (princ)
      );end defun
    Last edited by JaCAD; 2012-10-24 at 04:36 PM.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Code:
    (if (or (setq ss (car (entsel)))
            (and (princ "\nSwitching from \"ENTSEL\" to \"SSGET\" ")
                 (princ)
                 (setq ss (ssget))
            )
        )
      (cond ((= 'ENAME (type ss))
             (prompt "\n** You used \"ENTSEL\" ** ")
            )
            ((prompt "\n** You used \"SSGET\" ** "))
      )
      (prompt "\n** Nothing selected ** ")
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Isn't that what (ssget "_:S") supposed to do? the single selection mode shall have precedence over window/crossing mode.
    If you happen to missed an object or picked a blank area, it will then use W/C mode and end the selection without the need to press enter.

    Code:
    (defun c:test ()(vl-load-com)
    (while  (setq ss (ssget "_:S" '((0 . "INSERT")(66 . 1))))
      	(redraw)
    	(repeat (setq i (sslength ss))
    	(princ (if (> i 1) "\nWindow/Crossing Selection mode" "\nSingle Selection mode"))
    	;;; 	Your code here to modify the attributes		;;;
    	;;;  expressions below are for testing purpose only	;;;
    	(vla-getboundingbox (vlax-ename->vla-object (setq e (ssname ss 0))) 'll 'ur)
    	(setq pts (list (vlax-safearray->list ll)(vlax-safearray->list ur))
    		llf (Car pts)
    	 	lrt (list (caadr pts)(cadar pts))
    	        upr (cadr pts)
    	        ulf (list (caar pts)(cadadr pts)))
           (grvecs (list -1 ulf upr  -1 upr lrt  -1 lrt llf -1 llf ulf ))
    	;;;  expressions above are for testing purpose only	;;;
    	;;; 	Your code here to modify the attributes		;;;
           (ssdel e ss)))
      (princ)
      )
    Last edited by pbejse; 2012-10-20 at 12:59 AM.

  4. #4
    Active Member
    Join Date
    2008-02
    Location
    Toronto, On
    Posts
    59
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Thank you pbejse, this is exactly what I needed, and will simplify matters greatly.

    I was not familiar with that and a few other selection modes, so this has opened up some new possibilities.

  5. #5
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Good for you jacad, now edit your first post and wrap those codes using code tags
    Code:
    ..your code ..
    You are welcome. glad it helps.

  6. #6
    Active Member
    Join Date
    2008-02
    Location
    Toronto, On
    Posts
    59
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Thanks to pbejse, I was able to reduce the previous code to the following:

    Code:
    (defun C:SelTest2 ( / SS Len Cnt)
    
      (while (setq SS (ssget "_:S"))
        (setq Len (sslength SS)
    	  Cnt -1
    	  )
        (while (< (setq Cnt (1+ Cnt)) Len)
          (drawCircleAt (ssname SS Cnt))
          );end while
        );end while
    
      (princ)
      );end defun
    
    
    (defun DrawCircleAt (En / )
    
      (command "CIRCLE"
    	   (cdr (assoc 10 (entget En)))
    	   0.25
    	   );end command
    
      (princ)
      );end defun
    And I also learned the Code BB tag. I can't keep up this level of productivity for long...
    Thanks again!

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Quote Originally Posted by JaCAD View Post
    Thanks to pbejse, I was able to reduce the previous code to the following:

    Code:
    (defun C:SelTest2 ( / SS Len Cnt)
    
      (while (setq SS (ssget "_:S"))
        (setq Len (sslength SS)
    	  Cnt -1
    	  )
        (while (< (setq Cnt (1+ Cnt)) Len)
          (drawCircleAt (ssname SS Cnt))
          );end while
        );end while
    
      (princ)
      );end defun
    _tan
    
    
    (defun DrawCircleAt (En / )
    
      (command "CIRCLE"
    	   (cdr (assoc 10 (entget En)))
    	   0.25
    	   );end command
    
      (princ)
      );end defun
    And I also learned the Code BB tag. I can't keep up this level of productivity for long...
    Thanks again!
    You might want to add a selection set filter, or even a CONDitional statement to determine which to pull from which types of entities, as not every entity has only one DXF code 10 (some have multiple).

    Also, you might consider using ENTMAKE in lieu of the Circle Command for efficiency.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    Active Member
    Join Date
    2008-02
    Location
    Toronto, On
    Posts
    59
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Quote Originally Posted by RenderMan View Post
    You might want to add a selection set filter, or even a CONDitional statement to determine which to pull from which types of entities, as not every entity has only one DXF code 10 (some have multiple).

    Also, you might consider using ENTMAKE in lieu of the Circle Command for efficiency.

    Thanks for the advice, RenderMan.
    I was only using DrawCircleAt so that I could see that things were happening as I was selecting blocks. In reality, the entity name is being sent to a different function which is auto-incrementing a specific attribute inside of the block, and there's a great deal of error checking going on there. The selection set is also created with a filter, so only specific block types can be selected.

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Quote Originally Posted by JaCAD View Post
    Thanks for the advice, RenderMan.
    I was only using DrawCircleAt so that I could see that things were happening as I was selecting blocks. In reality, the entity name is being sent to a different function which is auto-incrementing a specific attribute inside of the block, and there's a great deal of error checking going on there. The selection set is also created with a filter, so only specific block types can be selected.
    No worries; just going off of the code you posted.

    Cheers!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Entsel & SSGet combined

    Quote Originally Posted by JaCAD View Post
    Thanks for the advice, RenderMan.
    I was only using DrawCircleAt so that I could see that things were happening as I was selecting blocks. In reality, the entity name is being sent to a different function which is auto-incrementing a specific attribute inside of the block, and there's a great deal of error checking going on there. The selection set is also created with a filter, so only specific block types can be selected.
    No worries; just going off of the code you posted.

    Cheers!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Trying to Change LISP from ENTSEL to SSGET
    By stusic in forum AutoLISP
    Replies: 8
    Last Post: 2012-11-29, 09:07 PM
  2. Help with using entsel or nentselp
    By MWKINCAID1 in forum AutoLISP
    Replies: 3
    Last Post: 2007-03-10, 12:10 AM
  3. SSGET returns error - bad SSGET list
    By tany0070 in forum AutoLISP
    Replies: 2
    Last Post: 2007-03-09, 07:26 AM
  4. Point from entsel
    By wommack in forum AutoLISP
    Replies: 10
    Last Post: 2006-12-15, 06:01 PM
  5. Entsel
    By fletch97 in forum AutoLISP
    Replies: 3
    Last Post: 2005-07-07, 04:37 PM

Posting Permissions

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