MacroFeature insertComFeature Error

Hello,

Im trying to create a MacroFeature in C# but always have the same error... can someone explain why? 

im using the SwEx Framework by the way...

UnionDada is an instance of RailUnionData (second image)

SolidworksApi/macros
Answers 3
AT
AT 2021-04-08 Best Answer

Hi Bruno,

You need to explicitly decorate the TopFace and StartFace properties with ParameterSelectionAttribute attribute to tell it should be serialized as selection. Primitive types (string, int, double) serialized as data, while bodies should be serialized as selection or edit body and other entities as selection entities. Some more information here: Managing selection of SOLIDWORKS macro feature 

Please let me know if any questions or issues,

Thanks,

Artem 

AT
AT 2021-04-08

InsertComFeature method returns a pointer to IFeature. You can call the 2016 SOLIDWORKS API Help - MakeSubFeature Method (IFeature) to make a sub feature. This would make the relation in the tree (similar to sketch and extrude). This doesn't necessarily introduces the parent-child relationship. To add the parent-child you need to use the ParameterSelectionAttribute (same as you use for faces). Note if your top or front face that you added as parameter already belongs to this feature than parent child relationship will be created automatically, otherwise create new property which corresponds to feature you want to add relation to.

In this case you might want to use different models for property page and macro feature as you might not want to have feature selection of your pmpage or just use the IgnoreBindingAttribute to avoid creation of control for the page and only use it in macro feature. 

BF
BF 2021-04-08

Hello Artem,

It works, thank you very much.

now other question arrived, how my features get embed in the macro feature? i create a sketch and a feature cut, and would like to have them as child of the MacroFeature...