Hello guys,
I want to find a dynamic block by name in my DWG, across multi layouts (sometimes 15 layouts possible).
The goal is:
1. find the DB
2. goto the layout where the DB is found
3. select the DB
4. do the command UpdateField on the selection
5. Done
Seems simpel to do, but It only works if:
- the DB is on the last layout
- or by manually setup when I select Layout20.
Thanks for your feedback.
(defun c:UpdateTB (/ laylist)
(vl-load-com)
(setq laylist (layoutlist))
(foreach x laylist
(setvar "ctab" x)
(selblkbyname "Titleblock_template_v2_0")
;*** Update (command "updatefield") if DB found ***
);ForEach
;this part should be included somewhere above
(setvar "ctab" "Layout20")
(selblkbyname "Titleblock_template_v2_0")
(command "updatefield")
)
(defun selblkbyname (name / e n out ss x rjp-getblockname)
(vl-load-com)
(defun rjp-getblockname (obj)
(if (vlax-property-available-p obj 'effectivename)
;(progn ;True
(vla-get-effectivename obj)
;);progn
(vla-get-name obj)
);if
);defun
(if (setq ss (ssget "_X" '((0 . "INSERT")))
n -1
out (ssadd))
(while (setq e (ssname ss (setq n (1+ n))))
(if (wcmatch (rjp-getblockname (vlax-ename->vla-object e)) name)
(progn ;True
(ssadd e out)
(setq bn (rjp-getblockname (vlax-ename->vla-object e)))
;(alert bn)
);progn
);if
);while
);if
(sssetfirst nil out)
(princ)
)
This sounds like something for the customization forum, but do you have fields to update automatically? I do that.
Rick Jackson
Survey CAD Technician VI
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Can't find what you're looking for? Ask the community or share your knowledge.