Hi all!
a little while ago i downloaded and modified a "export to Parasolid (X_T.)" macro and changed it to enable me to enter a revision number / letter to the end of the part name.
i was wondering if there was any way that i could modify this to use it in an assembly to export either
a) a selected group of parts ?
or
b) all parts as separate Parasolid files ?
i have attached the macro for anyone to have a look at (or use if you find it useful)
Great start from Deepak Gupta! Try the following modifications. You may still need to work out separate revisions per part, etc. If you have anything selected in an open assembly, it will save those components. If nothing is selected, it saves the entire model.
'====================================
' ******************************************************************************
' Save Part/Assembly as Parasolid
' Written by Deepak Gupta (www.gupta9665.wordpress.com)
' ******************************************************************************
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim RevNo As String
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
FileTyp = swModel.GetType
If FileTyp <> swDocDRAWING Then
UFRev.Show
RevNo = UFRev.TBRev
If swModel.GetType = swDocASSEMBLY Then
Dim sm As SelectionMgr
Set sm = swModel.SelectionManager
If sm.GetSelectedObjectCount = 0 Then
boolstatus = SaveParasolid(swModel, RevNo)
Else
Dim i As Integer
For i = 1 To sm.GetSelectedObjectCount
Dim selComp As Component2
Set selComp = sm.GetSelectedObjectsComponent(i)
Dim compModel As ModelDoc2
Set compModel = selComp.GetModelDoc
boolstatus = SaveParasolid(compModel, RevNo)
Next
End If
Else
boolstatus = SaveParasolid(swModel, RevNo)
End If
MsgBox "Part/Assembly Saved as Parasolid"
Else
MsgBox "Current document is not a Part/Assembly." & Chr(13) & Chr(13) _
& "Please load/activate a SolidWorks " & Chr(13) _
& "Part/Assembly and try again.", vbExclamation
End If
Else
MsgBox "No active Part/Assembly found in SolidWorks." & Chr(13) & Chr(13) _
& "Please load/activate a SolidWorks " & Chr(13) _
& "Part/Assembly and try again.", vbExclamation
End If
End Sub
'------------------
Private Function SaveParasolid(swModel As ModelDoc2, RevNo As String) As Boolean
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String
filePath = swModel.GetPathName
PathSize = Strings.Len(filePath)
PathNoExtension = Strings.Left(filePath, PathSize - 7)
NewFilePath = PathNoExtension & " REV " & RevNo & ".X_T"
boolstatus = swModel.SaveAs3(NewFilePath, 0, 0)
SaveParasolid = boolstatus
End Function