Author Topic: ActiveX AttSync question  (Read 1325 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
ActiveX AttSync question
« on: December 06, 2016, 04:31:23 AM »
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?

Code: [Select]
(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)
)