Jump to content

Update title block attributes in multiple drawings


t357

Recommended Posts

Hello,

I am new in doing lisp routines, and use AutoCAD 2007. I am trying to do a simple lisp routine to update title block attributes in multiple drawings (customer name, project name etc). The title block is a block including multiple attributes and fields. My intention is to move the drawings I want to update in a designated folder, to make it easier. I have a very simple script and a batch file to process a lisp routine on all drawings from that folder. Normally I access the attributes from title block with ATTEDIT or -ATTEDIT, but in order to do the lisp routine I need

to use only line commands. Even if I use -ATTEDIT and enter the block and attribute tags I am not getting the display of the attribute value, and I am prompted to select the block with the mouse, that ruins my lisp routine. Any idea how to do it? Thanks.

Link to comment
Share on other sites

  • Replies 144
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    58

  • au-s

    23

  • JeepMaster

    9

  • wakibd

    7

I used to do this with scripts, no LISP involved - but can I remember how? NO!

 

The command I need allows you to select a block by NAME and then has many options which I am sure includes your use. If I remember tonight I'll post a reply and if not I'll try to remember to look at work tomorrow.

Link to comment
Share on other sites

...but in order to do the lisp routine I need

to use only line commands.

 

Firstly, what do you mean by the above? You can only use command line functions?

 

If I were to make a LISP routine to perform this task, there are two routes you could you follow, either cycling through the Attributes and updating them through the DXF codes, or enter them through VL.

 

I am happy to help you in this, but could you specify a bit more what exactly needs updating please. For example, block name, attribute tag names, etc etc.

Link to comment
Share on other sites

Thanks for your response,

 

I need to use ony command lines in order to incorporate them in a lisp routine (or a script), that would run on multiple drawings.

 

The title block contains attributes with values for: project name, project number, customer name, etc. The block and attribute tags

remain unchanged from one project to another, only the values have to be changed, and I want to change these values with a routine instead of manually (open each drawing and change them).

Link to comment
Share on other sites

Well, I suppose i could write a LISP how I would do it and you could see if it works with your script or not.

 

Just need to know the actual block name, attribute tag names for which the attribute values need to be changed and what these need to be changed to.

 

Cheers

 

Lee

Link to comment
Share on other sites

it would appear I used -ATTEDIT in my script. I will attach an extract of my code which may give you some clues as to how I used it and whether it would work for you.

 

; This is a blank script file for use on Shaffer Borders.
; Drag this into a drawing to change the STS drawing number
;
; revert to Rev A and change Title Line 5
; type the new values in the script below (3 places)
; REMEMBER to save the modified file
;
; the OLD project number MUST exist!
;
OPEN
[DWG]
-ATTEDIT
N
N
Shaffer_D_Size
STS_DWG_NO
*
; type old project number on next line
U038
; type new project number on next line
U043
-ATTEDIT
Y
Shaffer_D_Size
RV
*
W
0
0
35
20
V
R
A

Link to comment
Share on other sites

Sorry for taking so long to respond, I am on western Canada, 8 hours time difference.

 

Dbroada, thank you for the script. I will try to incorporate it.

 

Lee Mac, thank you for offering to help me. The block name is T-A002A, and there is a long list of attributes (around 120). I will only give you three tag names if you want to do a test: ECA-AREA-NAME, ECA-TITLE1, ECA-FACILITY. I also attached the drawing, if you want to play with it.

 

Thanks, Ted

TB.dwg

Link to comment
Share on other sites

Based on the script from Dbroada I did a successful test with line commands as follows:

 

Command: -ATTEDIT

Edit attributes one at a time? [Yes/No] : N

Edit only attributes visible on screen? [Yes/No] : N

Enter block name specification : T-A002A

Enter attribute tag specification : ENG-1

Enter attribute value specification :

1 attributes selected.

Enter string to change: .

Enter new string: CD

 

The trick I learned is to answer NO to editing only attributes visible on screen. This can be converted to a lisp or a script file.

 

It would be great to be able to do it without having to enter the old string...

Link to comment
Share on other sites

Can't test on that drawing, as I only have '04, and so can't open it, but try this on your atts:

 

(defun c:aTest (/ ss att)
 (if (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "T-A002A")
      (cons 66 1)(if (getvar "CTAB")(cons 410 (getvar "CTAB"))
             (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (foreach ent (mapcar 'cadr (ssnamex ss))
   (setq att (entnext ent))
   (while (not (eq "SEQEND" (cdadr (entget att))))
     (cond ((eq "ECA-AREA-NAME" (cdr (assoc 2 (entget att))))
        (entmod (subst (cons 1 "TEST1") (assoc 1 (entget att)) (entget att))))
       ((eq "ECA-TITLE1" (cdr (assoc 2 (entget att))))
        (entmod (subst (cons 1 "TEST2") (assoc 1 (entget att)) (entget att)))))
     (setq att (entnext att))))
     (command "_regenall"))
   (princ "\n<!> No Blocks Found <!>"))
 (princ))

 

Pretty simple code, but untested - can be modified if need be :)

Link to comment
Share on other sites

Lee Mac, your lisp works great!

Thank you so much!

This may be used by so many engineering groups, it saves a large amount of drafting time.

 

If you ever want to visit Vancouver in Canada write me an email at teibrich@shaw.ca.

 

Thanks again,

Ted

Link to comment
Share on other sites

Lee Mac, your lisp works great!

Thank you so much!

This may be used by so many engineering groups, it saves a large amount of drafting time.

 

If you ever want to visit Vancouver in Canada write me an email at teibrich@shaw.ca.

 

Thanks again,

Ted

 

Many thanks Ted, glad it works for you - If you need the LISP expanded or modified in any way, just let me know :)

Link to comment
Share on other sites

This may be better suited to you:

 

(defun c:atest    (/ taglist ss ent att tnme)

 (setq    taglist
    '(("ECA-AREA-NAME" . "TEST1")
      ("ECA-TITLE1"    . "TEST2")) ;  <--- List Tags and Values here.
   )

 (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 "T-A002A")
   (cons 66 1) (if    (getvar "CTAB") (cons 410 (getvar "CTAB"))
     (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (foreach ent  (mapcar 'cadr (ssnamex ss))
   (setq att (entnext ent))
   (while (not (eq "SEQEND" (cdadr (entget att))))
     (setq tnme (cdr (assoc 2 (entget att))))
     (if (assoc tnme taglist)
       (entmod (subst (cons 1 (cdr (assoc tnme taglist)))
              (assoc 1 (entget att)) (entget att))))
     (setq att (entnext att))))
     (command "_regenall"))
   (princ "\n<!> No Blocks Found <!>"))
 (princ))

 

I have used an associative list instead.

 

You can list your attribute tag names in the list as shown, and what you require them to be changed to.

 

Hope this helps some more

 

Lee

Link to comment
Share on other sites

Thank you for your help Lee Mac and Dbroada!

I was able to put together the lisp, batch and script files,

with absolute minimal knowledge. Even now I have no clue

what exactly means each part of the script, but am able to use it.

 

Another detail: I entered this thread on three CAD forums: you

were they only people to respond, and actually to solve my problem.

 

You are real Deities! Thanks again guys!

Link to comment
Share on other sites

Thank you for your help Lee Mac and Dbroada!

I was able to put together the lisp, batch and script files,

with absolute minimal knowledge. Even now I have no clue

what exactly means each part of the script, but am able to use it.

 

Another detail: I entered this thread on three CAD forums: you

were they only people to respond, and actually to solve my problem.

 

You are real Deities! Thanks again guys!

 

Thank you for your kind words Ted - you are welcome here anytime. :)

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

I like to add parenthesis or any symbols into several several texts in auto cad by using find and replace command. how can I do that. or any other command or lisp program can do that.

 

cheers

Link to comment
Share on other sites

Hello

 

If I understood the request, here is attached a lisp (french) that changes the value of an attribute of all the drawings in a directory.

 

The idea is to open a drawing, select the attribute in question, then the directory to be processed and the lisp works for you.

 

@+

Pat.zip

Link to comment
Share on other sites

Patrick, how long have you been programming? Your programs are always so advanced :D

 

Hello

 

It's a long time i make lisp :D

You have several on this page. Just take the time to translate.

 

For the lisp pat, I'm just used to objectdbx.:wink:

 

Nothing really wizard.

 

@+

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...