TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Biscuits on September 27, 2016, 01:54:42 PM
-
Trying to combine several block names in a single selection set to condense this code...there will be additional blocks added at a later date.
How might I tweak this to run the burst one time on all blocks listed rather once for each one?
I mess it up every time I try. Any help would be appreciated. Thanks
;;; Creates a selection set of blocks by the name of
;;; "TIC", "TIC MARK", "SW",
;;; explodes them, making sure they stay on the layer in which they were inserted.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:Tixplode ()
(setq ctab (getvar "ctab"))
(foreach tab (cons "Model" (layoutlist))
(setvar 'CTAB tab)
(while (setq nerd1 (ssget "X" (list (cons 0 "INSERT") (cons 2 "TIC") (cons 410 (getvar 'ctab)))))
(sssetfirst nil nerd1)
(C:Burst)
)
(while (setq nerd2 (ssget "X" (list (cons 0 "INSERT") (cons 2 "TIC MARK") (cons 410 (getvar 'ctab)))))
(sssetfirst nil nerd2)
(C:Burst)
)
;;;;;;;;;;;;;;;;;;
(while (setq nerd3 (ssget "X" (list (cons 0 "INSERT") (cons 2 "SW") (cons 410 (getvar 'ctab)))))
(sssetfirst nil nerd3)
(C:Burst)
)
(setvar "ctab" ctab)
)
(princ)
)
And yes, we need to explode these older blocks for various reasons.
-
Maybe this?
(setq nerd1 (ssget "X" (list (cons 0 "INSERT") (cons 2 "block1, block2, block3") (cons 410 (getvar 'ctab)))))
-
What CAB said, except omit the space after the comma.
-
Your overall code could be shortened up to:
;;; Creates a selection set of blocks by the name of
;;; "TIC", "TIC MARK", "SW",
;;; explodes them, making sure they stay on the layer in which they were inserted.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:Tixplode ( / s )
(if (setq s (ssget "X" (list (cons 0 "INSERT") (cons 2 "TIC,TIC MARK,SW") )))
(progn
(sssetfirst nil s)
(C:Burst)
)
)
(princ)
)
-
-
Be careful with layout tabs that host wildcard chars, e.g. "Layout#1", lest ssget fail to retrieve entities as intended.
(defun _Tame ( text / wild )
( (lambda ( lst nfg / result )
(vl-list->string
(foreach x (reverse lst)
(setq result
(if (member x nfg)
(vl-list* 96 x result)
(cons x result)
)
)
)
)
)
(vl-string->list text)
(vl-string->list "#@.*?~[]-,")
)
)
Usage:
(setq nerd1
(ssget "_X"
(list
'(0 . "INSERT")
'(2 . "tic*,sw")
(cons 410 (_Tame (getvar 'ctab)))
)
)
)
FWIW, Cheers.
Edit: Embedded wildcards and the impact upon ssget is not limited to layout names -- can effect anything with a name: layers, blocks, text styles yada ... but for some reason layout names are prone to the malady more than others (in my experience), ergo my intrusion.
-
Lotsa good reading HERE (https://www.theswamp.org/index.php?topic=35028.msg402471#msg402471) too about selection sets.
-
Thank you all. I got close a few times. Thanks to you guys...mission accomplished.
We need a line of code like:
(ya know what I meant (dang-it))
Thanks again, everyone!
-
Be careful with layout tabs that host wildcard chars, e.g. "Layout#1", lest ssget fail to retrieve entities as intended.
< ... >
Edit: Embedded wildcards and the impact upon ssget is not limited to layout names -- can effect anything with a name: layers, blocks, text styles yada ... but for some reason layout names are prone to the malady more than others (in my experience), ergo my intrusion.
Good stuff MP - FWIW, this (http://lee-mac.com/escapewildcards.html) was my take on it.
-
Lucid, well documented.
<mock_surprise.mpg>