Macro to save a specific configuration

Hi all

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)

Thank you.


piece_et_macro.zip

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

 

 


 

Test this. ;-)


enrgistrement_1.swp

Hello

It should work with this macro version.

Kind regards


enrgistrement_1.swp
1 Like

Thank you for your help,

I'll test it during the day (if I have time) and I'll keep you posted.

Hello

I see in your profile that you have the MyCADTools, it is not possible with Integration or batch converter to do what you want?

@+

 

@ remrem, thank you for your answer, I tested the macro you propose but what thing stuck in the config presence test.

@ D.Roger , thank you it works perfectly :-)

@Coyote, unfortunately we can't choose the export coordinate system in batchconverter

I will try to make some additions on the solution of d.roger so it may still be that I need your help.