Hi all,
I am trying to create a macro to automate treatement of imported step files. My goal is, from a file open in SW (from steps to asm), save it as a part and then execute diagnosis import. Unfortunately I am not able to get the current directory of the Active file (particularly a .step file) thru swModel.GetFileName as it returns ""
Below is my code.
Any thoughts ?
Thanks for helping
'Option Explicit
Dim swApp As Object Dim swPart As SldWorks.PartDoc Dim swModel As SldWorks.ModelDoc2 Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim swModelDocExt As SldWorks.ModelDocExtension Dim filewarning As Long Dim fileerror As Long Dim Name As String Dim Folder As String Dim Path As String Dim MyPath As String Dim NewFileName As String Dim Extension As String Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set Part = swApp.ActiveDoc Name = swModel.GetTitle() MsgBox (Name) Folder = swApp.GetFilePath() MsgBox (Folder) Ext = ".sldprt" NewFileName = Folder & "\" & Name & Ext ' MsgBox (NewFileName) ' Save As longstatus = Part.SaveAs3(NewFileName, 0, 2) 'FileName = NewFileName 'Open the SOLIDWORKS part document to export to a STEP file Set swPart = swApp.OpenDoc6(NewFileName, swDocPART, swOpenDocOptions_Silent, "", fileerror, filewarning) Set swModel = swPart 'Get import information Set swImportPartData = swApp.GetImportFileData(swPart) End Sub