Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Save As Parasolid

API and Macros

Save As Parasolid

by  StarrRider  Posted    (Edited  )
The following macro was created to ease the process for Exporting Sheetmetal parts into another programs. It provide a single click SaveAs in the Parasolid file format to a Specific Directory.
The MyPath variable should be changed to specify a directory on your system or commented out so that the current directory is used. The file saved will have the same name as the original model.
WARNING: This Macro provides a prompt, does the SaveAs, and then closes the model. If you make changes to the model and have not saved them, those changes will be lost!
The way I normally use this macro is to load a dozen sheet metal files and run the macro on each of them. When there are no more files visable then everything done.
By changing the Extension in the NewName variable, other filetypes can be saved including Tiff and Iges.

This macro works with SW2001+ - I have not tried it with SW2003

' ********************************************************
' Save As Parasolid.swb - Recorded on 02/10/02 by Lee Bell
' ********************************************************
Dim SwApp, Model As Object
Dim MyPath, ModName, NewName As String
Dim MB As Boolean

Sub main()
Set SwApp = CreateObject("SldWorks.Application")
' This ensures that there are files loaded in SWX

Set Model = SwApp.ActiveDoc
If Model Is Nothing Then
MB = MsgBox("This routine requires files to be loaded before it is ran" + Chr(13) + _
"Please load a file and run the routine again", vbCritical)
Exit Sub
End
End If

' Use the current directory
MyPath = CurDir
' Or specify the directory you want to use
' Comment out the next line if you want to use the current directory
'MyPath = "C:\Where\Ever\Directory\You\Want\"

ModName = Model.GetTitle
NewName = Left(ModName, Len(ModName) - 7) + ".X_T"
MB = MsgBox("Saving " + NewName + " To" + Chr(13) + MyPath, vbCritical)

Model.SaveAs2 MyPath + NewName, 0, True, False

Set Model = Nothing
SwApp.CloseDoc ModName
End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search