Message 1 of 3
Update attributes in block based on insertion point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi folks,
I'm looking for some help putting a routine together that will:
Allow me to select multiple instances of the same block.
Update two attributes in each block based on the X and Y values of the blocks' insertion points.
Here is some background:
I have a routine that inserts these blocks and populates the two attributes on insertion (based on the picked point). Works like a charm. See code below.
Now however, my client wants to (or has to) move all of these blocks to correct for some misinformation earlier in the project.
So I need to update them all en masse.
thanks in advance for your help as alwasy!
Code that inserts/populates the blocks:
(defun POMDF (/ DZ CRDX CRDY CRDXY CRDA CRDB P DZORIG SCL DIV)
(setvar 'ATTDIA 0)
(setq CL (getvar "CLAYER"))
(cond ((= (getvar "INSUNITS") 1) (setq SCL 1)(setq CRDA 4)(Setq CRDB 1)(setq DIV 12.0))
((= (getvar "INSUNITS") 2) (setq SCL 0.08333)(setq CRDA 4)(Setq CRDB 1)(setq DIV 12.0))
(t (alert "Current DWG set to non-standard units. Check UNITS settings")(exit))
)
;;;;; Bring in block Point Of Test from SCAPE Tags.dwg
(defun open_dbx (dwg / dbx)
(if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
(setq dbx (vlax-create-object "ObjectDBX.AxDbDocument"))
(setq dbx (vlax-create-object
(strcat "ObjectDBX.AxDbDocument."
(substr (getvar "ACADVER") 1 2)
)
)
)
)
(vla-open dbx dwg)
dbx
)
(setq Dbx (open_dbx "V:/AutoCAD 2018/Drawings/SCAPE Tags.dwg"))
(vla-CopyObjects
Dbx
(vlax-safearray-fill
(vlax-make-safearray vlax-vbObject '(0 . 0))
(list (vla-item (vla-get-blocks dbx) "Coordinates Key r02"))
)
(vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
)
(vlax-release-object dbx)
;;;;; Insert and populate block
(command "-layer" "Make" "0-Dims" "Color" "3" "0-Dims" "Ltype" "CONTINUOUS" "" "Plot" "P" "" "")
(setvar "CLAYER" "0-dims")
(setq dz (getvar 'DIMZIN))
(setvar 'DIMZIN 0)
(while (setq p (getpoint "\n Specify point :"))
(setq CRDX (/ (car p) DIV))
(setq CRDY (/ (cadr p) DIV))
(command "_.-insert"
"Coordinates Key r02"
p
SCL
""
"0"
(strcat "E: "(rtos CRDX 2 2) "'")
""
(strcat "N: "(rtos CRDY 2 2) "'")
""
)
)
(setvar "CLAYER" CL)
(setvar 'DIMZIN dz)
)