1) block with text attribute(s) (not Mtext)
2) scale of block x = y (z = 1)
3) normally zero rotation
4) attributes: same name, same quantity
Purpose: synchronize some of the properties of the block definition with activeX
Questions:
1) is the example below a good approach to the problem?
2) What is the best way to update the insertion point as according to the scale?
(defun TestBlk ( / VlaDoc BksCol BlkIns LayBlk AttLst AttObj)
(setq VlaDoc (vla-get-Activedocument (vlax-get-Acad-Object)))
(setq BksCol (vla-get-blocks VlaDoc))
(setq BlkDef (vla-item BksCol "pippo"))
(setq LayBlk (vla-get-block (vla-item (vla-get-layouts VlaDoc) "Model")))
(vlax-for ObjFor LayBlk
(if
(and
(= (vla-get-objectname ObjFor) "AcDbBlockReference")
(= (vla-get-hasattributes ObjFor) :vlax-true)
(= (strcase (vla-get-Name ObjFor)) (strcase "pippo"))
)
(setq BlkIns ObjFor BlkScl (vla-get-XScaleFactor ObjFor))
)
)
(vlax-for ObjFor BlkDef
(if (= (vla-get-objectname ObjFor) "AcDbAttributeDefinition")
(setq AttLst (cons (list (vla-get-TagString ObjFor) ObjFor) AttLst))
)
)
(foreach ObjFor (vlax-invoke BlkIns 'GetAttributes)
(if (setq AttObj (cadr (assoc (vla-get-TagString ObjFor) AttLst)))
(progn
(vla-put-Alignment ObjFor (vla-get-Alignment AttObj))
(vla-put-Layer ObjFor (vla-get-Layer AttObj))
(vla-put-Linetype ObjFor (vla-get-Linetype AttObj))
(vla-put-ScaleFactor ObjFor (vla-get-ScaleFactor AttObj))
(vla-put-StyleName ObjFor (vla-get-StyleName AttObj))
(vla-put-Rotation ObjFor (vla-get-Rotation AttObj))
(vla-put-Height ObjFor (* BlkScl (vla-get-Height AttObj)))
; (vla-put-InsertionPoint ObjFor (vla-get-InsertionPoint AttObj))
)
)
)
(princ)
)