Hello - I have a number of drawings that contain numerous instances of a block named TAG-PART. This block contains a number of attributes, one of which is FRAME-QTY.
What I would like to do is to link the value of this attribute in all instances of the block to a custom property in the drawing called QUANTITY.
Right now I have the following code that reads the value of QUANTITY and updates the attribute value, but does not link it.
Any help would be appreciated.
;;============================================================================== ;; Definition: Program (defun c:QtyLinkSetup () ;;============================================================================== ;; Load ActiveX (vl-load-com) ;;============================================================================== ;; Definition: blkset ;; Args: blname ;; Example: (blname "11x17_Fabrication_TB-2013") (defun blkset (blname) (if (not (setq sset (ssget "X" (list (cons 2 blname))))) (setq sset (ssadd)) );end if (if (setq ss-dyn (ssget "X" (list (cons 2 "`*U*")))) (progn (setq num 0) (repeat (sslength ss-dyn) (setq ent (ssname ss-dyn num)) (setq effname (vla-get-EffectiveName (vlax-ename->vla-object ent))) (if (= blname effname) (ssadd ent sset) );end if (setq num (1+ num)) );end repeat );end progn );end if sset );end defun ;;============================================================================== ;; Get Quantity value in drawing properties custom tab (setq acadObject (vlax-get-acad-object) acadDocument (vla-get-ActiveDocument acadObject) suminfo (vlax-get-Property acadDocument 'SummaryInfo) );end setq (vla-getCustomByKey suminfo "QUANTITY" 'qty) ;;============================================================================================== ;; Get "TAG-PART" blocks and link quantity value to drawing custom properties quantity (setq blname "TAG-PART" sset nil ss1 (blkset blname) memb 0 );end setq (if ss1 (repeat (sslength ss1) (progn (setq entname (vlax-ename->vla-object (ssname ss1 memb)) entlist (vlax-safearray->list (vlax-variant-value (vla-getattributes entname))) );end setq (vla-put-textstring (nth 5 entlist) qty) (setq memb (1+ memb)) );end progn );end repeat );end if ;;============================================================================== ;; End routine (princ) );end progn
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@Anonymous wrote:
Hello - I have a number of drawings that contain numerous instances of a block named TAG-PART. This block contains a number of attributes, one of which is FRAME-QTY.
What I would like to do is to link the value of this attribute in all instances of the block to a custom property in the drawing called QUANTITY.
Right now I have the following code that reads the value of QUANTITY and updates the attribute value, but does not link it.
Any help would be appreciated.
Hi gpeneltonHSYMG,
if by 'link it' you mean using a FIELD, try to change
(vla-put-textstring (nth 5 entlist) qty)
to
(vla-put-textstring (nth 5 entlist) "%<\\AcVar CustomDP.QUANTITY>%")
and a regen should be required...
Hope this helps,
Henrique
@Anonymous wrote:
That works perfectly!
Thanks very much Henrique.
You're welcome, gpeneltonHSYMG
Glad I could help
Henrique
Can't find what you're looking for? Ask the community or share your knowledge.