Author Topic: sssetfirst not Highlighting  (Read 2879 times)

0 Members and 1 Guest are viewing this topic.

squirreldip

  • Newt
  • Posts: 114
sssetfirst not Highlighting
« on: March 07, 2017, 07:09:41 PM »
I'm creating a routine to highlight linked entities - basically a sub program to my linked entities

I'm trying to set up a right-click and have an entry for "Select Linked" along side the "Select Similar".

So issuing a "(sssetfirst nil ENTSET)" will not highlight the entities unless I issue a "(command "._REGEN)" first...

I'm sure this has been covered off previously but I cannot seem to find the answer.

Any suggestions would be appreciated.

Thanks in advance,
Rob.

tedg

  • Swamp Rat
  • Posts: 811
Re: sssetfirst not Highlighting
« Reply #1 on: March 08, 2017, 11:26:55 AM »
Does the "Pickadd" variable help?
Windows 10 Pro 64bit, AutoCAD 2023, REVIT 2023

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: sssetfirst not Highlighting
« Reply #2 on: March 08, 2017, 12:52:56 PM »
Try issuing (sssetfirst nil nil) prior to your sssetfirst call.

squirreldip

  • Newt
  • Posts: 114
Re: sssetfirst not Highlighting
« Reply #3 on: March 08, 2017, 03:04:01 PM »
Changing "Pickadd" to 0, 1 or 2 has no effect...

Adding "(sssetfirst nil nil)" has no effect...

Here's the code I'm using:
Code: [Select]
(defun SELECTLINKED (/ C C2 ENT ENTSET LINKEDSET SOURCESET)
 (setq SOURCESET (ssget))
 (setq LINKEDSET (ssadd))
 (setq C 0)
 (while (< C (sslength SOURCESET))
  (setq ENT (ssname SOURCESET C))
  (setq ENTSET (RFL:GETALLENT ENT))
  (setq C2 0)
  (while (< C2 (sslength ENTSET))
   (ssadd (ssname ENTSET C2) LINKEDSET)
   (setq C2 (1+ C2))
  )
  (setq C (1+ C))
 )
 (command "._regen")  ; <-- I'd like to be able to get rid of this, slow for large drawings
; (sssetfirst nil nil)
 (sssetfirst nil LINKEDSET)
)

I'm using "(RFL:GETALLENT ENT)" which returns a set with all the entities linked to ENT.  This can be replaced by (ssadd ENT) for testing (not requiring my other routine).
Code: [Select]
(defun SELECTLINKED (/ C C2 ENT ENTSET LINKEDSET SOURCESET)
 (setq SOURCESET (ssget))
 (setq LINKEDSET (ssadd))
 (setq C 0)
 (while (< C (sslength SOURCESET))
  (setq ENT (ssname SOURCESET C))
  (setq ENTSET (ssadd ENT))
  (setq C2 0)
  (while (< C2 (sslength ENTSET))
   (ssadd (ssname ENTSET C2) LINKEDSET)
   (setq C2 (1+ C2))
  )
  (setq C (1+ C))
 )
 (command "._regen")  ; <-- I'd like to be able to get rid of this, slow for large drawings
; (sssetfirst nil nil)
 (sssetfirst nil LINKEDSET)
)

The idea of the command is that you would have an entity selected (or multiple) and you'd be able to right-click on one and have a Shortcut Menu item to execute "(SELECTLINKED) ".  "(SELECTLINKED)" would then highlight everything that is linked to the entities you first had highlighted.

Example for use is, say, in my alignment routines where I draw cross section lines, label alignments or profiles you can select all the linked by running "(SELECTLINKED)" on only one of the entities - there could be thousands of entities.

squirreldip

  • Newt
  • Posts: 114
Re: sssetfirst not Highlighting
« Reply #4 on: March 08, 2017, 04:45:17 PM »
I believe I've found a solution...

Include "I" in the initial ssget call:
Code: [Select]
(ssget "I")
Also needed to revise code to check for nothing selected...

« Last Edit: March 08, 2017, 04:55:44 PM by squirreldip »

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: sssetfirst not Highlighting
« Reply #5 on: March 08, 2017, 06:25:00 PM »
Why you are regening before gripping the selection set?
Also you could regen only the active viewport (which should perform faster):
Code - Auto/Visual Lisp: [Select]
Another option would be to use the vla-Highlight method for every object in the selection set.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

squirreldip

  • Newt
  • Posts: 114
Re: sssetfirst not Highlighting
« Reply #6 on: March 09, 2017, 12:35:54 PM »
Why you are regening before gripping the selection set?
Also you could regen only the active viewport (which should perform faster):
Code - Auto/Visual Lisp: [Select]
Another option would be to use the vla-Highlight method for every object in the selection set.

The regen was required as without the entities would not highlight - they would be selected but nothing on screen (ie if you hit 'Delete' all would be deleated).

In the previous post I found that if I used '(ssget "I")' all worked without needing the regen.  Updated code here:
Code: [Select]
(defun RFL:SELECTLINKED (/ C C2 ENT ENTSET LINKEDSET SOURCESET)
 (if (setq SOURCESET (ssget "I"))
  (progn
   (setq LINKEDSET (ssadd))
   (setq C 0)
   (while (< C (sslength SOURCESET))
    (setq ENT (ssname SOURCESET C))
    (setq ENTSET (RFL:GETALLENT ENT))
    (setq C2 0)
    (while (< C2 (sslength ENTSET))
     (ssadd (ssname ENTSET C2) LINKEDSET)
     (setq C2 (1+ C2))
    )
    (setq C (1+ C))
   )
   (sssetfirst nil LINKEDSET)
   LINKEDSET
  )
  nil
 )
)