select multileader by style

select multileader by style

Paul.GrafPZAZ7
Advocate Advocate
82 Views
2 Replies
Message 1 of 3

select multileader by style

Paul.GrafPZAZ7
Advocate
Advocate

I am trying to write a routine that will select all the multileaders in a drawing by a stylename and move them to a new layer.

I am having problems getting the program to select a multileader by a specific style. It reports that there are no multileader in the drawing with the style name of "AEC_KN_Keynotes".  

 

Here is a screen shoot of the multileader: 

PaulGrafPZAZ7_0-1789413677664.png

 

(defun c:sml ( / styleEnt ss )
(setq styleEnt (tblobjname "mleaderstyle" "AEC_AC_Keynotes"))
(if styleEnt
(progn
(setq ss (ssget "X" (list '(0 . "MULTILEADER") (cons 340 styleEnt) '(67 . 1))))
(if ss
(progn
(sssetfirst nil ss)
(princ (strcat "\nSuccess: Selected " (itoa (sslength ss)) " Multileaders."))
)
(princ "\nNotice: No Multileaders found with style 'AEC_AC_Keynotes' in Paper Space.")
)
)
(princ "\nError: The MLeader style 'AEC_AC_Keynotes' does not exist in this drawing.")
)
(princ)
)

 

Attached is my drawing & lisp file. Any help would be appreciated.

 

Paul

 

 

0 Likes
83 Views
2 Replies
Replies (2)
Message 2 of 3

komondormrex
Mentor
Mentor

try to ssget all mleaders first, then filter out those that don't use the requested style.

0 Likes
Message 3 of 3

Paul.GrafPZAZ7
Advocate
Advocate

I just got this to work:

 

(defun c:sml2 ( / ss i ent obj styleName selectList )
(vl-load-com)
;; 1. Select all Multileaders strictly in Paper Space (Layouts)
(setq ss (ssget "X" '((0 . "MULTILEADER") (67 . 1))))

(if ss
(progn
;; Create an empty selection set to hold matches
(setq selectList (ssadd))
(setq i 0)

;; 2. Loop through each MLeader and check its Style Name property
(repeat (sslength ss)
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent))
(setq styleName (vlax-get-property obj 'StyleName))

;; If it matches our target style, add it to the final selection list
(if (= (strcase styleName) (strcase "AEC_AC_Keynotes"))
(ssadd ent selectList)
)
(setq i (1+ i))
)

;; 3. Highlight and grip the matched MLeaders if any were found
(if (> (sslength selectList) 0)
(progn
(sssetfirst nil selectList)
(princ (strcat "\nSuccess: Selected " (itoa (sslength selectList)) " Multileaders using style 'AEC_AC_Keynotes'."))
)
(princ "\nNotice: Multileaders found in Paper Space, but none match style 'AEC_AC_Keynotes'.")
)
)
(princ "\nNotice: Absolutely no Multileaders exist in Paper Space.")
)
(princ)
(command "-layer" "make" "C-ANNO-KEY" "color" "2" "" "")
(command "_.CHPROP" selectList "" "_LA" "C-ANNO-KEY" "")
)

 

 

0 Likes