Hi all
I am coming to you hoping to find help.
Context:
I would like to control solidworks assemblies from excel using macros. Basically, excel opens assemblies one after the other, deleting or resolving components in them.
My problem lies in the command to remove these components: I tried to open the part family (via my macros) and modify it but it doesn't work and ends up corrupting the part family. In addition, it creates a lot of errors when the part family is opened at the same time as another excel file.
Possible resolution:
So I found the EditSuppress2() function, but I can't adapt it to my code. If anyone knows this function well and can guide me, I'll give you my piece of code.
Code:
Private Sub CommandButton1_Click()
Dim swApp As Object
Dim Model As ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim ret As Boolean
Set swApp = CreateObject("SldWorks.application")
Set Model = swApp.ActiveDoc
Set swModelDocExt = Model.Extension
boolstatus = swModelDocExt.SelectByID2("Gear Pump<1>", "swSelCOMPONENT", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Model.EditSuppress2()
ret = swModelDocExt.Rebuild(swRebuildOptions_e.swRebuildAll)
End Sub
I thought I saw miracles working here;) I hope to find help.
Have a nice day