I want to create a macro to facilitate the export of our files to our machine shop but I am encountering some difficulties related to my lack of "absence" of knowledge in this field.
Here's what I want to do: 1 - check that it is a -> part OK
2 - list configurations -> OK (vConfigNameArr = swModel.GetConfigurationNames)
3 - check for the presence of the configuration named "MACHINING" -> NO: that's where I get stuck 3.1 - if not have an error message "machining configuration absent" or better a drop-down list of configurations: -> OK for the message 3.2 - if yes display the "MACHINING" configuration: -> OK (swModel.ShowConfiguration2 ("MACHINING"))
4 - we force the reconstruction: -> OK
5.1 - we get the active document: -> OK 5.2 - the file path: -> OK 5.3 - we select the "MACHINING" coordinate system: -> OK 5.4 - save in IGES format: -> OK
I hope you can help me. I attach the macro and a tested part (SW2015)
Try something like this: (Returns True if the machining configuration exists)
Function TestConfigUsinage(SwModel as SldWorks.ModelDoc2) as Boolean
configNames = swModel. GetConfigurationNames
For i = 0 To UBound(configNames)
configName = configNames(i)
if configname = "Machining" Then
Return True
End if
Next i
Return false
End Function
Example here: http://help.solidworks.com/2016/english/api/sldworksapi/Get_List_Of_Configurations_Example_VB.htm