When you write this: "Using a macro feature this is not possible."
Do you say this because you believe you can only return one body with a macro feature? I know that the API Help says you can only return one body, but this is NOT true. You simply return an array with all of the bodies.
Thanks for the reply and my apologies for my late response but I was on a holiday last week.
Yes, I do know that I have an array with all the bodies. I was only saying that the API help states that only one body is returned / valid.
See the following in the SolidWorks API help - Inserting Macro Features:
The last line in the api help stating that only one body becomes part of the model and that any other bodies are lost makes me wonder if it is possible to achieve my goal.
I used the previously mentioned array of bodies with the Feature.SetBodiesToKeep method but with no result.
Do I need to do something with the array of bodies before using them with this method? e.g. Make a copy of them so that they are valid bodies or something else?
The API Help is incorrect. You can return multiple bodies. However there are a few scenarios where a bug can make it seem as though this is not working. See attached video I created when I was discussing this with API Support.
This bug was fixed in 2014. You need to use IMacroFeatureData::EnableMultiBodyConsume set to True in order to prevent this issues from occurring.
If you are still having issues with macro features and want professional support, go to the web site in my signature and email me and we can talk.
Macro feature bugs demo.zip 5.2 MB
While watching your video I noticed something. You return the newly created bodies to SolidWorks in your regenerate method. I only returned true.This must have slipped me when I've read the API help. I have changed it and after a lot of testing I finally got it working. Since I am using C# I had to wrap the body2 instances into an array of DispatchWrapper instances.
When returning such an array it worked. I tried it first in SW2014 Beta3 then in SW2012, which we currently use.
I did not need to use IMacroFeatureData:EnableMultiBodyConsume however.
Many thanks for the help, it is greatly appreciated.