AnsweredAssumed Answered

Import step assembly, save as single part

Question asked by Damon Frashure on Jul 14, 2015
Latest reply on Jul 14, 2015 by Simon Turner

I have received a slew of step files from a client and would like a little help with importing the assemblies into parts.  I know i can put them all in subfolders and use the Task Scheduler to import all of them (many use "part 1" as file names so they have to be isolated).  Is there a setting I can use to save the assembly as a part?  Alternatively, Would it be possible to add a statement like swModel.SaveAs(Left(OpenDoc.GetTitle, (Len(OpenDoc.GetTitle) - 7)) + ".sldprt") to code such as this?

 

'----------------------------------------

' Precondition: C:\Test\Part1_203.STEP exists.

' Postconditions: C:\Test\Part1_203.STEP is imported into SolidWorks.

'----------------------------------------

 

Option Explicit

Sub main()

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Set swApp = Application.SldWorks

Dim importData As SldWorks.ImportStepData

Set importData = swApp.GetImportFileData("C:\Test\Part1_203.STEP")

' If ImportStepFile::MapConfigurationData is not set, then default to

' the environment setting swImportStepConfigData; otherwise, override

' swImportStepConfigData with ImportStepFile::MapConfigurationData

ImportData.MapConfigurationData = True

Set Part = swApp.LoadFile4("C:\Test\Part1_203.STEP", "r", importData, longstatus)

swModel.SaveAs(Left(OpenDoc.GetTitle, (Len(OpenDoc.GetTitle) - 7)) + ".sldprt")

End Sub

Outcomes