Need Help With Script File!!!!
Need Help With Script File!!!!
(OP)
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!





RE: Need Help With Script File!!!!
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 <> ""
Debug.Print NextDWG
NextOpen = MyDir & NextDWG
ThisDrawing.Open (NextOpen)
Set whichblock = ThisDrawing.Blocks.Item("TITLE")
Debug.Print whichblock.Name
'To be added here
'Get atribute - see Example_GetAttributes in VBA editor help
'Modify Attribute
NextDWG = Dir
Wend
End Sub
RE: Need Help With Script File!!!!
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....!
RE: Need Help With Script File!!!!