×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Need Help With Script File!!!!

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

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

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

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

RE: Need Help With Script File!!!!

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources