TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MeasureUp on March 29, 2024, 02:02:31 AM
-
There is a given attribute named as ATT-01 in a given block BLK-01.
How to change the attribute text width to 0.75?
I did a search here but don't find what I am exactly after.
Thanks in advance.
-
Try this it should work
(defun c:test ( / int sel ent get)
(setq int -1)
(setq sel (ssget '((0 . "INSERT") (2 . "BLK-01"))));BLK-01
(while (setq int (1+ int)
ent (ssname sel int)
);setq
(while (/= (cdr (assoc 0 (setq get (entget (setq ent (entnext ent)))))) "SEQEND")
(if (= (cdr (assoc 2 get)) "ATT-01");ATT-01
(entupd (cdr (assoc -1 (entmod (subst (cons 41 0.75) (assoc 41 get) get)))));0.75
);if
);while
);while
);defun
edit: localised all variables
-
Thanks for the help.
And sorry for the late reply as too busy after Easter.
Another thought...
How to update the text width if it is an attribute in title blocks in a multi-page drawing?
Thanks.
-
Thanks for the help.
And sorry for the late reply as too busy after Easter.
Another thought...
How to update the text width if it is an attribute in title blocks in a multi-page drawing?
Thanks.
Have you tried changing this line :
(setq sel (ssget '((0 . "INSERT") (2 . "BLK-01"))));BLK-01
To this :
(setq sel (ssget "_X" '((0 . "INSERT") (2 . "BLK-01"))));BLK-01
And then iterate through sel. set 'sel'...
-
Thanks.
I was thinking of using "vla-put-textwidth" but didn't figure it out.
Can anyone help?
Thanks again.
-
can you addition a sample dwg
-
There is nothing special in the drawing file or template.
My starting point is an example in the ActiveX section in HELP showed below.
I have no idea to redefine the "oML" in my case by given a title block "BLK-01" and an attribute "ATT-01" based on multi page drawing.
I'd like to learn this method.
Thanks.
(defun c:Example_TextManipulation()
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Define the leader points
(setq points (vlax-make-safearray vlax-vbDouble '(0 . 14)))
(vlax-safearray-fill points '(1 1 0
1 2 0
2 2 0
3 2 0
4 4 0
)
)
(setq i 0)
(setq modelSpace (vla-get-ModelSpace doc))
(setq oML (vla-AddMLeader modelSpace points i))
(vla-put-TextWidth oML 7.4)
)
-
There is nothing special in the drawing file or template.
My starting point is an example in the ActiveX section in HELP showed below.
I have no idea to redefine the "oML" in my case by given a title block "BLK-01" and an attribute "ATT-01" based on multi page drawing.
I'd like to learn this method.
Thanks.
(defun c:Example_TextManipulation()
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Define the leader points
(setq points (vlax-make-safearray vlax-vbDouble '(0 . 14)))
(vlax-safearray-fill points '(1 1 0
1 2 0
2 2 0
3 2 0
4 4 0
)
)
(setq i 0)
(setq modelSpace (vla-get-ModelSpace doc))
(setq oML (vla-AddMLeader modelSpace points i))
(vla-put-TextWidth oML 7.4)
)
Your case is a different thing compared to code attached. If you want to do it with visual lisp (vla), you have to get Attribute Reference ATT-01 of the block BLK-01 and change its width using vla-put-scalefactor.