Macro to identify part symmetry in an assembly

Hello

 

I would like to know if it is possible with the help of a macro, to identify if a part contains a symmetrical component function. (see attached image)

Then, thanks to this macro, modify a property (symmetry=yes or symmetry=no for example).

The goal is to automate on MEPs the implementation of an annotation (1+1 symmetrical) for the parts to be bent that have this function, symmetrical component made from an assembly.

Unless someone has a better idea to get this annotation.

Thank you.

Hello

Yes, it should be possible, but it requires some knowledge of VBA programming.

We can draw inspiration from this macro:

http://help.solidworks.com/2014/English/api/sldworksapi/Feature_Suppression_Example_VB.htm

This example shows how to:

  • Cycle through features in a part

  • Get a feature name

Next, check if the feature name contains "symmetry", then add a custom property "SYM" with a value of "YES".

 

For the base it seems not bad, but not sure, I have a doubt because the function to recognize is a folder  (symmetrical component) and not a function and I can't necessarily assign a symmetry to the Copy move function.

 

Otherwise for the VBA since the time I wanted to get into it, there is no more case...

 

As soon as I have a little more time I get started and then I post the result.

1 Like

To complete my previous answer, I would advise you to read my tutorial on the macro I created "save as", which allows you to get into the swing of things!

http://www.lynkoa.com/tutos/3d/macro-enregistrer-sous-avec-solidworks

Otherwise, the specific property to read a custom property is:

CODE = swRefDoc.GetCustomInfoValue("", "code")

 

And to modify it (update the CODE property with the NewCode variable):

retval = SWmoddoc.AddCustomInfo3("", "CODE", 30, NewCode)
SWmoddoc.CustomInfo("CODE") = NewCode

 

As shown here:

http://www.lynkoa.com/forum/3d/api-modification-des-proprietes-personnalisees-part