I am sure this has been asked a lot. I stumbled upon some code that would take a viewport custom scale field and link it to an attributed block that initially has a field in it.
I created a dummy block that has 3 attributed fields to it.
Attribute Name
HALF (I have a formula referencing the FULL)
FULL (I have generic field %<\AcVar acadlspasdoc>%)
DOUBLE (I have a formula referencing the FULL)
Anyways, I can get the routine to change the FULL Attribute but the initial formula to the FULL field does not work. The only way I could get it to work was after the fact by selecting the FULL with the current scale.
Am I missing something on how a block would work with formulas?
;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/field-update-customscale-viewport/td-p/3787059
(defun c:test (/ vpObj fldObj vpID util fldtxt)
(vl-load-com)
(setq vpObj (vlax-ename->vla-object
(car (nentsel "\nSelect the viewport: "))
)
fldObj (vlax-ename->vla-object (car (nentsel "\nSelect the Field: ")))
vpID (vla-get-objectid vpObj)
);; setq
(if (> (vl-string-search "x64" (getvar "platform")) 0)
(progn
(setq util (vla-get-Utility
(vla-get-activedocument (vlax-get-acad-object))
)
vpID (vlax-invoke-method
util
"GetObjectIdString"
vpObj
:vlax-False
)
);; setq
);; progn
(setq vpID (vl-princ-to-string (vla-get-Objectid vpObj)))
);; if
;; (setq fldtxt (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
;; vpID
;; ">%).CustomScale \\f \"%sn\">%"
;; )
(setq fldtxt (strcat "%<\\AcObjProp Object(%<\\_ObjId "
vpID
">%).CustomScale \\f \"%lu2%ct1%ps \%qf2816\">%"
)
)
(vla-put-textstring fldObj fldtxt)
(vla-update fldObj)
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
1
)
(princ)
);; test