Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

combine intersect feature target body selection

Anonymous

combine intersect feature target body selection

Anonymous
Not applicable

I am working on something that involves taking two selected bodies and finding and creating a new body from their intersection.  I want to access this bodies properties, and then later delete it, but I am having trouble referencing the tool body that was modified during the combine feature.  I have tried a few things and have gotten different results.

 

                            targetBody = selection1Copy
                            toolBodies = adsk.core.ObjectCollection.create()
                            toolBodies.add(selection2)
                            combineIntersectionInput= rootComp.features.combineFeatures.createInput(targetBody, toolBodies)
                            combineIntersectionFeatures = features.combineFeatures
                            combineIntersectionInput = combineIntersectionFeatures.createInput(targetBody, toolBodies)
                            combineIntersectionInput.operation = adsk.fusion.FeatureOperations.IntersectFeatureOperation
                            combineIntersectionInput.isKeepToolBodies = True
                            combineIntersectionFeatures.add(combineIntersectionInput)
                            intersectionBodies = combineIntersectionFeatures.bodies
                            intersectionBodies.deleteMe()

this gives me an error that says attribute error:bodies.  I also tried this:

                            targetBody = selection1Copy
                            toolBodies = adsk.core.ObjectCollection.create()
                            toolBodies.add(selection2)
                            combineIntersectionInput= rootComp.features.combineFeatures.createInput(targetBody, toolBodies)
                            combineIntersectionFeatures = features.combineFeatures
                            combineIntersectionInput = combineIntersectionFeatures.createInput(targetBody, toolBodies)
                            combineIntersectionInput.operation = adsk.fusion.FeatureOperations.IntersectFeatureOperation
                            combineIntersectionInput.isKeepToolBodies = True
                            combineIntersectionFeatures.add(combineIntersectionInput)
                            ui.messageBox('body created')
                            targetBody.deleteMe()

I get an error saying: The target body is lost, try editing this feature to reselect target body.  It appears I am going about this the wrong way or am missing something, but it is not clear to me where I am going wrong here.  Any help would be appreciated.

0 Likes
Reply
848 Views
3 Replies
Replies (3)

BrianEkins
Mentor
Mentor

Let's look at what happens when you use the Combine feature.  You have a target body and one or more tool bodies.  When you create a Combine feature it is using the tool bodies to make a modification to the target body.  There are several options in the command that can change what's created.  If the "New Component" checkbox is checked, then the selected target body is left unchanged but a new component is created with a copy of the target body and it is modified using the tool bodies.  The "Keep Tools" checkbox indicates if the bodies selected as the tool bodies should exist as bodies after the feature is complete.  If checked, they remain in the model as independent bodies.  If unchecked they are consumed by the feature and no longer show up in the browser tree.

 

When you create a Combine feature using the API, what's returned is the Combine feature.  The CombineFeature object has a bodies property which returns the body that was modified by the feature.  This will be the modified body and should be the want you want.  To get back, you can delete the Combine feature, which will return the body to its original state.  Hopefully, this helps.

 

You're current programs are making some assumptions about what the Combine feature does that is different than what I described above and are far from providing what you want.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

Anonymous
Not applicable

Thank you for your reply.  I am going to spend some time exploring this solution.  I have a follow up question now.  Your response is causing me to rethink my approach.  My intent is to explore the properties of the body created by the combine feature (which is providing information about where the bodies overlap), but I do not actually need the new body for anything else.  In this case, do you think it makes more sense to use the interference tool to find the properties of where the bodies overlap?

0 Likes

BrianEkins
Mentor
Mentor

I would probably create a temporary b-rep body.  You can read more about this in a paper I presented at Autodesk University last year.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes