Author Topic: Attribute Text Width  (Read 431 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 465
Attribute Text Width
« 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.

Lastknownuser

  • Newt
  • Posts: 29
Re: Attribute Text Width
« Reply #1 on: March 29, 2024, 07:03:56 AM »
Try this it should work
Code: [Select]
(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
« Last Edit: March 29, 2024, 07:08:46 AM by Lastknownuser »

MeasureUp

  • Bull Frog
  • Posts: 465
Re: Attribute Text Width
« Reply #2 on: May 06, 2024, 07:07:41 AM »
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.

ribarm

  • Gator
  • Posts: 3297
  • Marko Ribar, architect
Re: Attribute Text Width
« Reply #3 on: May 06, 2024, 07:57:28 AM »
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 :
Code: [Select]
(setq sel (ssget '((0 . "INSERT") (2 . "BLK-01"))));BLK-01
To this :
Code: [Select]
(setq sel (ssget "_X" '((0 . "INSERT") (2 . "BLK-01"))));BLK-01
And then iterate through sel. set 'sel'...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MeasureUp

  • Bull Frog
  • Posts: 465
Re: Attribute Text Width
« Reply #4 on: May 07, 2024, 01:58:09 AM »
Thanks.

I was thinking of using "vla-put-textwidth" but didn't figure it out.
Can anyone help?
Thanks again.

HOSNEYALAA

  • Newt
  • Posts: 105
Re: Attribute Text Width
« Reply #5 on: May 07, 2024, 03:44:56 AM »
can you  addition a sample dwg

MeasureUp

  • Bull Frog
  • Posts: 465
Re: Attribute Text Width
« Reply #6 on: May 07, 2024, 11:17:55 PM »
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.

Code: [Select]
(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)
)
« Last Edit: May 08, 2024, 12:00:50 AM by MeasureUp »

Lastknownuser

  • Newt
  • Posts: 29
Re: Attribute Text Width
« Reply #7 on: May 09, 2024, 04:24:32 AM »
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.

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