Jump to content

Title Block Attribute Script


crmosoldier
 Share

Recommended Posts

Hey guys,

 

I have been looking everywhere for simple script to edit the attributes in my title block but im not having much luck.

 

What I want to do is edit the revision information in a title block for a number of drawings. I have looked into doing this with a lisp and I have a lisp that works but I have to run this for each individual drawing.

 

The reason I am looking do do this with a script is so I can select multiple drawings using ScriptPro and run the script that way.

 

Does anyone have an example of a script I can use to do this?

 

Thanks!!

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    11

  • crmosoldier

    11

  • bradwitt17

    4

  • Lee Mac

    2

Top Posters In This Topic

Posted Images

Thanks pBe,

 

I have used an ODBX lisp of Lee-Mac's to do exactly what i want and its perfect except that it moves the attributes which means i have to open every drawing anyway.

 

The reason im looking for a simple script is so that i can run it agains drawings selected through SriptPro, im only dealing with 10's of drawings and not 100's in most cases so the fact that its slower doesnt realy worry i me, I just want it so that if i have a script i can just edit it as needed for each job, i dont want to have to run a script maker for every drawing set to then run a lisp. (hope im making sense, im new to scripts and lisp's).

Link to comment
Share on other sites

The attributes are as follows:

 

DWG_REV0_NO

DWG_REV0_DESC

DWG_REV0_BY

DWG_REV0_DATE

DWG_REV0_CHK

DWG_REV0_APPR

 

This group of attributes is repeated 4 more times but with 1, 2, 3 & 4 in place of 0

Link to comment
Share on other sites

And how many of these Blocks in a single drawing?

 

Are you wanting to edit the last rev number? or input a new rev?

 

say for example

Current Rev is B at DWG_REV_NO2

and you need to put a new Rev which is C at DWG_REV0_NO3?

But you cant tell what the current DWG_REV0_NO box number is the latest one? what i meant was there is no way of knowing which DWG_REV0_NO the last one used until you open the drawing.

 

so DWG_REV0_NO will vary from one drawing to another?

Link to comment
Share on other sites

1 block in a single drawing

 

Not exactly sure what your asking but I will try to give you a bit more info and see if you can get what your asking from that.

 

The attributes on the title block are shown in the attached picture.

tp.jpg

 

I imagine that if i had a script i would have all of this info in it and for say revision A i would only fill in the values for that row (attributes containing REV0) and then when it was time for revision B i would then fill in the values for the second row (attributes containing REV1).

 

Hope this helps

Link to comment
Share on other sites

Oh ok sorry i get it now,

When im upreving 1 drawing in a set i will uprev the rest of the drawings also, so every drawing in a set will show the same revision info

Link to comment
Share on other sites

Last question(s)

Titleblock at Paperspace?

absolutely same Data for all sheets?

 

OK.. i will show you two ways to to that:

1. Autocad Native command

2. A lisp program

 

Hang on

Link to comment
Share on other sites

First look into Gatte

 

the script as folows

gatte

block

blockname

TAGNAME

NewValue

......

 

And thats for every Tag name

 

Now for the lisp program with script

 

this will be the first few lines of your script:

 

(setq mlst '("DWG_REV0_NO[color=blue][b]1[/b][/color]" [b][color=sienna]"A"[/color][/b] "DWG_REV0_DESC[color=blue][b]1[/b][/color]" [b][color=sienna]"WHATEVER"[/color][/b] "DWG_REV0_BY[color=blue][b]1[/b][/color]" [b][color=sienna]"ME" [/color][/b]"DWG_REV0_DATE[color=blue][b]1[/b][/color]" [b][color=sienna]"YOU"[/color][/b] "DWG_REV0_CHK[b][color=blue]1[/color][/b]" [color=sienna][b]"HIM"[/b][/color] "DWG_REV0_APPR[b][color=blue]1[/color][/b]" [color=sienna][b]"THEM"[/b][/color]))
(setq mlst (vl-propagate 'mlst))
_.open "D:\Path\sheet1.dwg" (RunIt mlst) _.save  _Y _.close
_.open "D:\Path\sheet2.dwg" (RunIt mlst) _.save  _Y _.close

 

where the one in red are the numbers you need to change and the blue ones aer the literal string /new string

 

(defun RunIt (lst)
 (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
 (vlax-for itm (vla-get-ModelSpace aDoc)
   (if (and
  (eq (vla-get-objectname itm) "AcDbBlockReference")
  (eq (vla-get-effectivename itm) "[b]YourBlockName"[/b])
)
     (mapcar (function
 (lambda (j)
   (if (setq AtM (member (vla-get-tagstring j) lst))
     (vla-put-textstring j (cadr AtM))
   )
 )
      )
      (vlax-invoke itm 'GetAttributes)
     )
   )
 )
 (princ)
)

 

Hope this helps

Edited by pBe
Link to comment
Share on other sites

I have used an ODBX lisp of Lee-Mac's to do exactly what i want and its perfect except that it moves the attributes which means i have to open every drawing anyway.

 

An unfortunate bug of ObjectDBX that Autodesk never fixed :(

Link to comment
Share on other sites

An unfortunate bug of ObjectDBX that Autodesk never fixed :(

 

You know what Lee, i was wondering about that too.. I encountered the same problem back then when I was trying to recreate you BFIND program :)

On a different note:

How did you manage to modiy drawings currently open on another session with your BFind code?

 

BTW: you dont happen to have a twin? triplets perhaps? you are all over the place :lol:

Link to comment
Share on other sites

How did you manage to modiy drawings currently open on another session with your BFind code?

 

Here is a shorter / simpler program to study, demonstrating the same method to modify open drawings.

 

BTW: you dont happen to have a twin? triplets perhaps? you are all over the place :lol:

 

:lol:

Link to comment
Share on other sites

Thanks pBe,

 

So what do each of these bits of code do?

 

I have saved the second one as a .lsp and put my title block name in but im unsure of what else i have to do...

Link to comment
Share on other sites

i see, i will write a supporting lisp code for you so you may able to try it on your own

 

Hang in there. :)

 

EDIT:

Reminder:

1. The runit code should be loaded on every drawing: (Startup Suite/Acaddoc.lsp)

2. You have the script ready to run:

This format

_.open "D:\path\sheet1.dwg" (RunIt mlst) _.save _Y _.close

_.open "D:\path\sheet2.dwg" (RunIt mlst) _.save _Y _.close

 

 

[color=black](defun c:runscr (/ *IntGet1 RevV RevDes RevBy RevDte  RevChk RevApp)[/color]
[color=black](defun *IntGet1 (fn msg flg )(initget 1)[/color]
[color=black](setq val ((eval fn) flg msg))[/color]
[color=black](if (eq val "")(progn (princ "Null Input Try again")[/color]
[color=black](*IntGet1 fn msg flg))) val     [/color]
[color=black])[/color]
[color=black](if (not suf) (setq suf 1))[/color]
[color=black]    (setq suf (cond[/color]
[color=black]                   ((getint (strcat "\nEnter Revision Number Suffix < " (itoa suf) " >: ")))[/color]
[color=black]                   (suf)))[/color]
[color=black](setq RevV (strcase (*IntGet1 'Getstring "\nEnter New Revision Value: " nil))[/color]
[color=black]    RevDte (strcase (*IntGet1 'Getstring "\nEnter New Revision Date: " nil))[/color]
[color=black]    RevDes (strcase (*IntGet1 'Getstring "\nEnter New Revision Descriptiom: " T))[/color]
[color=black]    RevBy (strcase (*IntGet1 'Getstring "\nEnter By: " nil))[/color]
[color=black]    RevChk (strcase (*IntGet1 'Getstring "\nEnter Checked: " nil))[/color]
[color=black]    RevApp (strcase (*IntGet1 'Getstring "\nEnter Approved: " nil)))[/color]
[color=black](setq mlst[/color]
[color=black]    (apply 'append[/color]
[color=black](mapcar '(lambda (j k)[/color]
[color=black]   (list (strcat "DWG_REV" (itoa suf) j) (eval k)))[/color]
[color=black]  '("_NO" "_DESC" "_BY" "_DATE" "_CHK" "_APPR")[/color]
[color=black]'(RevV RevDes RevBy RevDte  RevChk RevApp))[/color]
[color=black]     )[/color]
[color=black]   )[/color]
[color=black](vl-propagate 'mlst)[/color]
[color=black](setq Fl (getfiled "Select Script file: " "" "scr" )[/color]
[color=black](command "_.script" fl)[/color]
[color=black](princ)[/color]
[color=black])[/color]

 

Command: RUNSCR

Enter Revision Number Suffix : 2

Enter New Revision Value : B

Enter New Revision Date : 19oct11

Enter New Revision Descriptiom : General Revision

Enter By : pBe

Enter Checked : HIM

Enter Approved : BOSS

 

A window will prompt you to select your saved Sript file

 

Hope this Helps

 

 

BTW: i ws completely off with my first list

"DWG_REV0_NO1" should be ("DWG_REV1_NO" silly me :)

Edited by pBe
Link to comment
Share on other sites

Thanks and sorry pBe, im still lost :unsure:

What is the (Startup Suite/Acaddoc.lsp) you refer to?

And what do I do with these different bits of code and in what order do I run them?

 

So is the whole process not as easy as I thought it would be, I was thinking there would be a way to have a script that just uses say ATTEDIT, chooses my template by name and then changes the attribute tags to the new values I have put in the script, i would then select multiple drawings using ScriptPro... Not that easy?

Link to comment
Share on other sites

Why not using Autocad electrical, you can run project wide scripts. Works faster then ScriptPro. A projecr can contain all the drwings.

 

Pmxcad

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
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.

 Share


×
×
  • Create New...