crmosoldier Posted October 19, 2011 Posted October 19, 2011 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!! Quote
pBe Posted October 19, 2011 Posted October 19, 2011 Welcome to the forum crmosoldier Be more specific if you can. Besides, it can be done with lisp thru ODBX way faster than script Otherwise try Lee's ScriptWriter program http://lee-mac.com/scriptwriter.html Quote
crmosoldier Posted October 19, 2011 Author Posted October 19, 2011 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). Quote
pBe Posted October 19, 2011 Posted October 19, 2011 OK. Now how many attributes tags are we talking about here? Quote
crmosoldier Posted October 19, 2011 Author Posted October 19, 2011 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 Quote
pBe Posted October 19, 2011 Posted October 19, 2011 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? Quote
crmosoldier Posted October 19, 2011 Author Posted October 19, 2011 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. 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 Quote
crmosoldier Posted October 19, 2011 Author Posted October 19, 2011 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 Quote
pBe Posted October 19, 2011 Posted October 19, 2011 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 Quote
crmosoldier Posted October 19, 2011 Author Posted October 19, 2011 Titleblock is in modelspace Yes, same data for all sheets in a drawing set Quote
crmosoldier Posted October 19, 2011 Author Posted October 19, 2011 I have to go but i will be back tomorrow to check your response, thanks heaps pBe Quote
pBe Posted October 19, 2011 Posted October 19, 2011 (edited) 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 October 19, 2011 by pBe Quote
Lee Mac Posted October 19, 2011 Posted October 19, 2011 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 Quote
pBe Posted October 19, 2011 Posted October 19, 2011 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 Quote
Lee Mac Posted October 19, 2011 Posted October 19, 2011 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 Quote
pBe Posted October 19, 2011 Posted October 19, 2011 Here is a shorter / simpler program to study, demonstrating the same method to modify open drawings. Cool Beans Thanks Lee Quote
crmosoldier Posted October 20, 2011 Author Posted October 20, 2011 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... Quote
pBe Posted October 20, 2011 Posted October 20, 2011 (edited) 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 October 20, 2011 by pBe Quote
crmosoldier Posted October 20, 2011 Author Posted October 20, 2011 Thanks and sorry pBe, im still lost 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? Quote
pmxcad Posted October 20, 2011 Posted October 20, 2011 Why not using Autocad electrical, you can run project wide scripts. Works faster then ScriptPro. A projecr can contain all the drwings. Pmxcad Quote
Recommended Posts
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.