×
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

Macro to change the template for multiple drawing files?

Macro to change the template for multiple drawing files?

Macro to change the template for multiple drawing files?

(OP)
I have about 150 drawing files that need to be changed to have a new drawing template.  Some of the drawings have multiple sheets.

Does anyone have a macro that will batch change all of the drawing files?

RE: Macro to change the template for multiple drawing files?

(OP)
Thanks.  Really I could change either the template or the sheet format.  All of the custom properties needed are in the Parts/Assemblies.  I just need to add and remove certain properties from the drawings for a customer.

Now, how would be the best way to go about applying this macro to all of the files without going through each one manually?  I was thinking it could be done in the SolidWorks Task Scheduler, but I seem to be missing how to run it for certain folders?  

RE: Macro to change the template for multiple drawing files?

Was anyone able to get this problem solved for an entire folder of drawings? I have somewhere around 1200 that need the sheet format changed.

Thanks,
Matt

RE: Macro to change the template for multiple drawing files?

MattBD,

Are you saying that none of the programs listed in the above FAQ worked for you?

cheers

RE: Macro to change the template for multiple drawing files?

Everything looked like it was specific to working with the currently open file. Which one did you have in mind?

I started a macro but am having trouble with the SetupSheet4 function.

-Matt

RE: Macro to change the template for multiple drawing files?

Thanks CBL!

I also want to learn, so if any VB/macro gurus can take a look at this and explain why I can't save the active document in my macro, I'd appreciate it. This is just meant to work - there's very little in the way of functionality or error handling.

-Matt

CODE

' ******************************************************************************
' chgfmt.swb - macro recorded on 08/11/08 by mdenardo
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim MyDir As String
Dim MySheet As String
Dim MyFile As String

Sub main()

Set swApp = Application.SldWorks
MyDir = InputBox("Enter the path that contains the files you want to change.")
MySheet = InputBox("Enter the full path, including file name and extension of the sheet format you want to use.")
MyFile = Dir(MyDir & "\*.slddrw")

Do While MyFile <> ""
    MyFile = Dir()
    FileName = Split(MyFile, ".")
    Set Part = swApp.OpenDoc6(MyDir & "\" & MyFile, 3, 0, "", longstatus, longwarnings)
    swApp.OpenDoc6 MyDir & "\" & MyFile, 3, 0, "", longstatus, longwarnings
    Set Part = swApp.ActivateDoc2(FileName(0) & " - Sheet1", False, longstatus)
    swApp.ActiveDoc.ActiveView.FrameLeft = 0
    swApp.ActiveDoc.ActiveView.FrameTop = 0
    swApp.ActiveDoc.ActiveView.FrameState = 1
    swApp.ActiveDoc.ActiveView.FrameState = 1
    boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.1391084233669, 0.2266029916164, 0, False, 0, Nothing, 0)
    Part.ClearSelection2 True
    Part.SetupSheet4 "Sheet1", 12, 12, 1, 1, False, MySheet, 0.4318, 0.2794, "Default" ', True
    Part.ViewZoomtofit2
    retval1 = Part.Save3()
    Set Part = Nothing
    swApp.CloseDoc FileName(0) & " - Sheet1"
Loop
End Sub

RE: Macro to change the template for multiple drawing files?

Hm. Well, I solved it by changing that line to use the SaveAs method and gave it the same part name as the open part and that worked fine. No idea why Save3 didn't work.

CODE

retval = Part.SaveAs(MyDir & "\" & MyFile)

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