Command:
CHANGE
Select objects: Specify opposite corner: 10 found
Select objects:
Specify change point or [Properties]: p
Enter property to change
[Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotati
ve]: a
Make Annotative? [Yes/No] <No>:
Enter property to change
[Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotati
ve]:
(defun c:t ( / ss ssent Block BlockName blocks ch)
(vl-load-com)
(prompt "\nSelect block")
(setq ss (ssget ":S"))
(setq ssent (ssname ss 0))
(setq Block (vlax-ename->vla-object ssent))
(setq BlockName (vla-get-effectivename Block))
(setq blocks (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
)
(initget 1 "Annotative a Non-annotative n")
(setq ch
(getkword
"\nDo you want to make block Annotative or Non-annotative (A/N) : "
)
)
(vlax-for bl blocks
(cond ((and (= (vla-get-name bl) BlockName) (= ch "Annotative"))
;(vla-put-Annotative bl :vlax-true)
(command "change" ssent "" "P" "A" "Yes" "")
)
((and (= (vla-get-name bl) BlockName) (= ch "Non-annotative"))
;(vla-put-Annotative bl :vlax-false)
(command "change" ssent "" "P" "A" "No" "")
)
)
)
(princ)
)
(defun listsubent (bname / data datalst)
(setq data (tblobjname "BLOCK" bname))
(setq data (entget data '("*")))
(setq data (acet-dxf -2 data))
(setq datalst (cons data datalst))
(setq data (entget data '("*")))
(while data
(setq data (entnext (acet-dxf -1 data)))
(if (/= data nil)
(progn
(setq datalst (cons data datalst))
(setq data (entget data '("*")))
))
)
(setq datalst (reverse datalst))
)
;(defun c:t ( / ss ssent blocks Block BlockName inspt rotang Xeffscf Yeffscf Zeffscf subentlst sssubents ch)
(defun c:t nil
(vl-load-com)
(prompt "\nSelect block")
(setq ss (ssget ":S"))
(setq ssent (ssname ss 0))
(setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(setq Block (vlax-ename->vla-object ssent))
(setq BlockName (vla-get-effectivename Block))
(setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint Block))))
(setq rotang (vla-get-rotation Block))
(setq Xeffscf (vla-get-Xeffectivescalefactor Block))
(setq Yeffscf (vla-get-Yeffectivescalefactor Block))
(setq Zeffscf (vla-get-Zeffectivescalefactor Block))
(setq subentlst (listsubent BlockName))
(setq sssubents (ssadd))
(foreach sub subentlst
(ssadd sub sssubents)
)
(vlax-for bl blocks
(if (= (vla-get-name bl) BlockName)
(vla-put-explodable bl :vlax-true)
)
)
; (command "group" "" BlockName "" ssent "")
(vla-explode Block)
(vla-delete Block)
(initget 1 "Annotative a Non-annotative n")
(setq ch
(getkword
"\nDo you want to make block Annotative or Non-annotative (A/N) : "
)
)
(if (= ch "Annotative") (setq ch "Yes"))
(if (= ch "Non-annotative") (setq ch "No"))
; (command "select" "g" BlockName "")
; (setq sssubents (ssget "P"))
(sssetfirst nil sssubents)
; (command "block" BlockName "Y" "A" ch "" inspt sssubents "")
; (command "insert" BlockName inspt Xeffscf rotang)
(princ)
)
(defun c:t ( / ss ssent blocks Block BlockName inspt rotang rotangd Xeffscf Yeffscf Zeffscf sssubents ch)
(vl-load-com)
(prompt "\nSelect block")
(setq ss (ssget ":S"))
(setq ssent (ssname ss 0))
(setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(setq Block (vlax-ename->vla-object ssent))
(setq BlockName (vla-get-effectivename Block))
(setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint Block))))
(setq rotang (vla-get-rotation Block))
(setq rotangd (* (/ 180 PI) rotang))
(setq Xeffscf (vla-get-Xeffectivescalefactor Block))
(setq Yeffscf (vla-get-Yeffectivescalefactor Block))
(setq Zeffscf (vla-get-Zeffectivescalefactor Block))
(vlax-for bl blocks
(if (= (vla-get-name bl) BlockName)
(vla-put-explodable bl :vlax-true)
)
)
(command "EXPLODE" ssent "")
(initget 1 "Annotative a Non-annotative n")
(setq ch
(getkword
"\nDo you want to make block Annotative or Non-annotative (A/N) : "
)
)
(setq sssubents (ssget "P"))
(if (= ch "Annotative")
(progn
(setq ch "Yes")
(command "block" BlockName "Y" "A" ch "Y" inspt sssubents "")
(command "insert" BlockName inspt Xeffscf Yeffscf rotangd)
))
(if (= ch "Non-annotative")
(progn
(setq ch "No")
(command "block" BlockName "Y" "A" ch "Y" inspt sssubents "")
(command "insert" BlockName inspt Xeffscf rotangd)
))
(princ)
)
(defun c:t ( / ucsf ch blocks bllst ss i ssent Block BlockName inspt rotang rotangd Xeffscf Yeffscf Zeffscf sssubents ans )
(vl-load-com)
(if (eq (getvar 'worlducs) 0)
(progn
(command "_.UCS" "_W")
(setq ucsf t)
)
)
(initget 1 "Annotative Non-annotative")
(setq ch
(getkword
"\nDo you want to make selected blocks Annotative or Non-annotative [A/N] : "
)
)
(setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for bl blocks
(setq bllst (cons (list (vla-get-name bl) bl (vla-get-isxref bl)) bllst))
)
(prompt "\nSelect blocks with or without attributes that reside on unlocked layer(s)...")
(setq ss (ssget "_:L" '((0 . "INSERT"))))
(if ss
(repeat (setq i (sslength ss))
(setq ssent (ssname ss (setq i (1- i))))
(setq Block (vlax-ename->vla-object ssent))
(setq BlockName (vla-get-effectivename Block))
(setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint Block))))
(setq rotang (vla-get-rotation Block))
(setq rotangd (* (/ 180 PI) rotang))
(setq Xeffscf (vla-get-Xeffectivescalefactor Block))
(setq Yeffscf (vla-get-Yeffectivescalefactor Block))
(setq Zeffscf (vla-get-Zeffectivescalefactor Block))
(if (and (assoc BlockName bllst) (eq (last (assoc BlockName bllst)) :vlax-false))
(vla-put-explodable (cadr (assoc BlockName bllst)) :vlax-true)
)
(command "_.EXPLODE" ssent)
(while (< 0 (getvar 'cmdactive))
(command "")
)
(setq sssubents (ssget "_P"))
(if (= ch "Annotative")
(progn
(setq ans "Yes")
(command "_.ROTATE" sssubents "" "_non" inspt (- rotangd))
(command "_.BLOCK" BlockName "_Y" "_A" ans "_N" "_non" inspt sssubents "")
(command "_.INSERT" BlockName "_non" inspt Xeffscf Yeffscf rotangd)
)
(progn
(setq ans "No")
(command "_.ROTATE" sssubents "" "_non" inspt (- rotangd))
(command "_.BLOCK" BlockName "_Y" "_A" ans "_N" "_non" inspt sssubents "")
(command "_.INSERT" BlockName "_non" inspt Xeffscf rotangd)
)
)
)
(prompt "\nEmpty sel.set... Retry routine with some blocks selected next time...")
)
(if ucsf
(command "_.UCS" "_P")
)
(princ)
)
I can't guarantee, but have you tried to iterate through selection set without singe option...Code: [Select](defun c:t ( / ucsf ch blocks bllst ss i ssent Block BlockName inspt rotang rotangd Xeffscf Yeffscf Zeffscf sssubents ans )
(vl-load-com)
(if (eq (getvar 'worlducs) 0)
(progn
(command "_.UCS" "_W")
(setq ucsf t)
)
)
(initget 1 "Annotative Non-annotative")
(setq ch
(getkword
"\nDo you want to make selected blocks Annotative or Non-annotative [A/N] : "
)
)
(setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for bl blocks
(setq bllst (cons (list (vla-get-name bl) bl (vla-get-isxref bl)) bllst))
)
(prompt "\nSelect blocks with or without attributes that reside on unlocked layer(s)...")
(setq ss (ssget "_:L" '((0 . "INSERT"))))
(if ss
(repeat (setq i (sslength ss))
(setq ssent (ssname ss (setq i (1- i))))
(setq Block (vlax-ename->vla-object ssent))
(setq BlockName (vla-get-effectivename Block))
(setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint Block))))
(setq rotang (vla-get-rotation Block))
(setq rotangd (* (/ 180 PI) rotang))
(setq Xeffscf (vla-get-Xeffectivescalefactor Block))
(setq Yeffscf (vla-get-Yeffectivescalefactor Block))
(setq Zeffscf (vla-get-Zeffectivescalefactor Block))
(if (and (assoc BlockName bllst) (eq (last (assoc BlockName bllst)) :vlax-false))
(vla-put-explodable (cadr (assoc BlockName bllst)) :vlax-true)
)
(command "_.EXPLODE" ssent)
(while (< 0 (getvar 'cmdactive))
(command "")
)
(setq sssubents (ssget "_P"))
(if (= ch "Annotative")
(progn
(setq ans "Yes")
(command "_.ROTATE" sssubents "" "_non" inspt (- rotangd))
(command "_.BLOCK" BlockName "_Y" "_A" ans "_N" "_non" inspt sssubents "")
(command "_.INSERT" BlockName "_non" inspt Xeffscf Yeffscf rotangd)
)
(progn
(setq ans "No")
(command "_.ROTATE" sssubents "" "_non" inspt (- rotangd))
(command "_.BLOCK" BlockName "_Y" "_A" ans "_N" "_non" inspt sssubents "")
(command "_.INSERT" BlockName "_non" inspt Xeffscf rotangd)
)
)
)
(prompt "\nEmpty sel.set... Retry routine with some blocks selected next time...")
)
(if ucsf
(command "_.UCS" "_P")
)
(princ)
)
If you have attributed blocks, then you'll have to do it in another way... You have to try without me as I am not sure how to quickly write it...
[EDIT : Code changed to accept attributed blocks...]