selection set by multiple handle

selection set by multiple handle

djurk_haas
Advocate Advocate
1,469 Views
3 Replies
Message 1 of 4

selection set by multiple handle

djurk_haas
Advocate
Advocate

Hello,

 

The code below selects the object with handle 5b6.

I need to make a selection set with multiple handles. Is that possible?

E.g. select the handle "5b6"and "132" at once.

 

Thanks in advance

 

(defun C:5b6-handle ( / handle
 ent )
  ;(setq handle (getstring "\nHandle to search for: "))
  (setq handle "5b6")
 (setq ent (handent handle))
  (if ent
    (sssetfirst
 nil (ssadd ent))
  ;Else
    (princ "\nNo such handle
 found.")
  )


  (princ)
)

 

0 Likes
Accepted solutions (1)
1,470 Views
3 Replies
Replies (3)
Message 2 of 4

Moshe-A
Mentor
Mentor
Accepted solution

@djurk_haas hi,

 

check this one:

 

cheers

moshe

 

 

(defun c:select-by-handle (/ ss ent)
 (setq ss (ssadd))

 (foreach handle '("5b6" "132" "bcd1" "fa45" "20a" "20b" "20c" "209")
  (if (setq ent (handent handle))
   (ssadd ent ss)
  )
 ); foreach

 (if (> (sslength ss) 0)
  (sssetfirst ss ss)
  (princ "\nNo such handle(s) found.")
 )

 (princ)
)
Message 3 of 4

l.nikiforov
Explorer
Explorer

When the number of objects to select is large enough, I use the following command, which is much faster than iterating in a loop (especially, if you use ActiveX interface), for example:
"_SELECT (HANDENT "1A2727") (HANDENT "1A2725") (HANDENT "1A2723") (HANDENT "1A2721") (HANDENT "1A26E7")"

and don't forget to deselect everything after executed actions by following command:
"(sssetfirst nil nil)"

0 Likes
Message 4 of 4

braudpat
Mentor
Mentor

Hello @djurk_haas 

 

A similar routine "ZH_Sel" from GC (gile)

 

You can give many handles delimited by commas, and the routine "ZH_Sel" select them

and you can say : Next , Previous , All - And the zoom is automatic ...

 

The Health, Bye, Patrice (The Old French EE Froggy)

 

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes