Script to modify an attributed title blocks specific tag width factor

Script to modify an attributed title blocks specific tag width factor

Anonymous
Not applicable
1,144 Views
5 Replies
Message 1 of 6

Script to modify an attributed title blocks specific tag width factor

Anonymous
Not applicable

Hello,
I've put 30 min into to searching and got no where.

 

I'd like to write a script I can implement on a drawing package that will modify a specific tag's Width Factor form 1 to .7 within an attributed Title Block. I've done hundreds of value modifications using the -attedit command. But I can't figure out how to access the text options.
Thanks in advance,
Mike

 

ie value change:

attedit (command)
n         (one at a time)
n         (visible on screen)

           (enter)

Block Name

Existing Tag Value
New Tag Value

 

0 Likes
1,145 Views
5 Replies
Replies (5)
Message 2 of 6

john.uhden
Mentor
Mentor

You can change the attribute text properties if you use the Enhanced Attribute Editor command EATTEDIT, or just double-click on the attribute.

I can't imagine that you have dozens of title blocks in one drawing, so you probably really don't need a custom program since you have the EATTEDIT command.

John F. Uhden

0 Likes
Message 3 of 6

Anonymous
Not applicable

I have 1000 drawings (Title Blocks) I need to change the size of this tag to get the text to fit.

 

When using attedit you may write the script so that -attedit command is used and allows the dialog box to stay closed and continue to make the change. eattedit does not allow this. Acad will shoot back "unknown command" In other words how do I get eattedit to work via script so I can run that script and walk away?

0 Likes
Message 4 of 6

john.uhden
Mentor
Mentor

So it seems you are asking for more than a simple function, but rather need to batch process 1000 drawings.

John F. Uhden

0 Likes
Message 5 of 6

john.uhden
Mentor
Mentor

Okay.

 

Here is a function to help you out...

 

(defun Attwidth (Block Tag Width / ss i e obj Att Atts FindAtt)
  (defun FindAtt (Atts tag / Att Found)
    (if (= (type (car Atts)) 'ENAME)
      (setq Atts (mapcar 'entget Atts))
      ;; Note that Atts is local, so there's no harm in changing them
    )
    (foreach Att Atts
      (if (= (strcase Tag)(strcase (cdr (assoc 2 Att))))
        (setq Found Att)
      )
    )
    Found
  )

  (and
    (setq ss (ssget "X" (list '(0 . "INSERT")(cons 2 block)'(66 . 1))))
    (repeat (setq i (sslength ss))
      (setq e (ssname ss (setq i (1- i))))
      (setq obj (vlax-ename->vla-object e))
      (setq Atts (vla-getAttributes obj))  ;; variant
      (setq Atts (vlax-variant-value Atts)) ;; safearray
      (setq Atts (vlax-safearray->list Atts))  ;; list of vla-objects
      (setq Atts (mapcar 'vlax-vla-object->ename Atts)) ;; list of enames
      (and
        (setq Att (FindAtt Atts Tag)) ;; entity data
        (setq Att (subst (cons 41 Width)(assoc 41 Att) Att))
        (entmod Att)
        (entupd e)
      )
    )
  )
)

John F. Uhden

Message 6 of 6

Anonymous
Not applicable

LOL,

You .lsp people scare me. Actually I program Siemens S7 PLC's. Automotive won't pay you for learning Lisp. So I had to move on. Wish I had the time to learn it.  Currently I use AutoScript to implement .scr that I write for doing multiple .dwgs. But as you know, the abilities are humble compared to .lsp. And many .lsp are compiled now. I'm going to copy your info and load it. That's pretty big! Thanks so much for taking the time. I'll report back asap.

Thx again,

Mike

0 Likes