×
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

File Exporting Macro

File Exporting Macro

File Exporting Macro

(OP)
Good Morning

I am looking for a macro that will export an iges file into the current directory.  I would like to create a button to execute this macro so I don't have to go into the file save as pull down all of the time.

Thanks
Chris

RE: File Exporting Macro

Did you try the api help?  FYI, you could have cut and pasted everyting you need from there into a macro.

Option Explicit

Dim swApp, Part As Object
Dim BoolStatus As Boolean
Dim LongStatus As Long
Dim e As Long
Dim w As Long

Dim Msg As String
Dim PartName, Rev As String


Sub main()

  Set swApp = CreateObject("SldWorks.Application")
  Set Part = swApp.ActiveDoc
    
    If ((Part Is Nothing) Or (Not (Part.GetType Eqv swDocPART))) Then
        Msg = "A part document must be active to use this command!"
        LongStatus = swApp.SendMsgToUser2(Msg, swMbWarning, swMbOk)
        End

    Else
        PartName = Part.GetPathName
        PartName = Left(PartName, Len(PartName) - 7) & ".igs"

        BoolStatus = Part.SaveAs4(PartName, 0, 0, e, w)
        
        If BoolStatus = False Then
            Msg = "Failed to save IGS document!"
            LongStatus = swApp.SendMsgToUser2(Msg, swMbWarning, swMbOk)
        Else
            Msg = "Saved part as " & PartName
            LongStatus = swApp.SendMsgToUser2(Msg, swMbWarning, swMbOk)
        End If
       
    End If
 
    Set Part = Nothing
    Set swApp = Nothing

End Sub

RE: File Exporting Macro

(OP)
Where did you find this in the help file?

Thanks
Chris

RE: File Exporting Macro

Probably SolidWorks.com -> Support -> API Support or Examples.  Both have a bunch of these type of examples.

If you look in the API help, there are a bunch of examples.  They are listed alphabetically rather than topically, so sometimes it is hard to find a specific call, but there are a bunch there.

Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...

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