Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help With Script File!!!!

Status
Not open for further replies.

Guest
I need to place the following text into 85 drawings: "BT-1383". The text is part of a block attribute in the title block of all of the drawings. I want to know if there was a way to write a script that opens each drawing, places the text into the title block, closes the drawing, and goes to the next drawing. The drawing name format is as follows: 001.dwg,002.dwg,003.dwg,etc. Thanks!
 
Replies continue below

Recommended for you

Here is a starter in VBA. Alt+F11, VBA Editor, New Module, paste the following Sub.
Then in Acad/Tools/Macros/Run
This SUb opens all dwgs in a directory, finds block "title" and closes the dwg.

To modify an attribute, you have to see the Example_getAttributes in VBA Editor menu and include it within the while loop here.

'Option Explicit

Sub BatchEditAttr()
On Error Resume Next
Dim whichblock As AcadBlock
MyDir = "D:\Tigrek\Temp\"
myPath = MyDir & "*.dwg"
'NextDWG = Dir("D:\Tigrek\Temp\*.dwg")
NextDWG = Dir(myPath)
Debug.Print NextDWG
While NextDWG <> &quot;&quot;

Debug.Print NextDWG
NextOpen = MyDir & NextDWG
ThisDrawing.Open (NextOpen)
Set whichblock = ThisDrawing.Blocks.Item(&quot;TITLE&quot;)
Debug.Print whichblock.Name
'To be added here
'Get atribute - see Example_GetAttributes in VBA editor help
'Modify Attribute


NextDWG = Dir
Wend

End Sub
 
Heh, I had this exact problem a few years ago, and now I always use xrefs as title blocks. Makes this sort of change way easier...
Assuming that all your drawings are in the same place, so to speak, (so a XYZ coord on one drawing was in the same place as an xyz coord on any other drawing), I would write a script that deletes your attribute block entirely, leaving you with a blank title block.
You can do this by using ERASE in your script, and then defining a window using XYZ coords. (Which is why all you drawings have to be in teh same place, or you'll not know where you're deleting)
Create an drawing file containing your new title block, and write in your script a line to insert it into your drawings as a block.
You can repeatedly run the script for each drawing using a batch script program like Scripteeze.

Hope that makes sense....!
 
I agree with knobhead. Download scripteeze or if you go want something from autodesk. Search for the migration assistance program that comes with Scriptpro. Scripteeze shareware version only lets you process 20 dwgs at a time. Plus it won't let you save projects. With Scriptpro you can do all the dwgs you want and savve the projects in case you have to process them again sometime doing the same thing or using a different script file. If you need help with the script let me know and I'll try to whip something up for you if I have time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor