AnsweredAssumed Answered

Macro to create STEP and DXF file

Question asked by Maxim Vervoort on May 5, 2020
Latest reply on May 7, 2020 by Maxim Vervoort

Dear all,


I would like to use a simple macro to do the following automattically. I tried to make one myself but without programming skills it didn't work...


When a part or assembly is opened, and a drawing of this model with same name and in the same folder is already existing:


1)           Save the active model as STEP file in same folder, with same name

               Looks like this I think:


Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.Extension.SaveAs Left(swModel.GetPathName, InStrRev(swModel.GetPathName, ".")) & "STEP", 0, 0, Nothing, 0, 0   



2)         Save the associated drawing (I don't need it to open if this isn't necessairy) as DXF file with same name and in              the same folder. 


3)         Close files. 


That's it!

I don't think it is that difficult but with my limited (=unexisting) programming skills it would take ages till I have a working solution.


Thanks in advance!


Best regards,