Conversion from PARTS to WWTP in bulk

It's all in the title friends,

Will anyone have a software or a Macro (even better) to convert several parts into a step in a massive way.

Or even by going directly through the assembly, because basically it is only possible to do this with the export in IGES and not STEP.

I specify that I don't have myCADservices maintenance so not Batchconverter which I know does that very well.

I hope I was clear enough in my request.

Thank you

Hello

If you register your assembly in STEP; the person who will open your WWTP will have to set up in his options or be able to open it with separate pieces and not just one if that's what you want.

Hello. Try this with an open part or assembly. This will save each part as a step file in the same directory.

Option Explicit
Dim lComps As Object
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
    MsgBox "Ouvrir un assemblage ou une pièce"
    Exit Sub
End If
swApp.SetUserPreferenceIntegerValue swUserPreferenceIntegerValue_e.swStepAP, 214
Select Case swModel.GetType
    Case swDocumentTypes_e.swDocASSEMBLY
        Dim swAssy As SldWorks.AssemblyDoc
        Dim swConf As SldWorks.Configuration
        Dim swRootComp As SldWorks.Component2
        Set swAssy = swModel
        Set swConf = swAssy.GetActiveConfiguration
        Set swRootComp = swConf.GetRootComponent3(True)
        Set lComps = CreateObject("Scripting.Dictionary")
        TraverseComponent swRootComp

    Case swDocumentTypes_e.swDocPART
        Save2Step swModel
        
    Case Else
        MsgBox "Ouvrir un assemblage ou une pièce"
        Exit Sub
End Select
End Sub

Sub TraverseComponent(swComp As SldWorks.Component2)
    Dim vChilds As Variant
    Dim vChild As Variant
    Dim swChildComp As SldWorks.Component2
    Dim swModel As ModelDoc2
    vChilds = swComp.GetChildren
    For Each vChild In vChilds
        Set swChildComp = vChild
        Set swModel = swChildComp.GetModelDoc2
        If swModel.GetType = swDocumentTypes_e.swDocASSEMBLY Then
            TraverseComponent swChildComp
        Else
            If Not lComps.Exists(swModel.GetPathName) Then
                lComps.Add swModel.GetPathName, Empty
                Save2Step swModel
            End If
        End If
    Next
End Sub

Private Sub Save2Step(swModel As SldWorks.ModelDoc2)
    Dim FilePath As String
    FilePath = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, ".") - 1) & ".STEP"
    swModel.Extension.SaveAs2 FilePath, 0, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, Empty, False, Empty, Empty
End Sub

 

2 Likes

Thank you JeromeP, it works and it's exactly what I wanted.