Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

combine intersect feature target body selection

3 REPLIES 3
Reply
Message 1 of 4
aams86
592 Views, 3 Replies

combine intersect feature target body selection

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.

3 REPLIES 3
Message 2 of 4
BrianEkins
in reply to: aams86

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
Message 3 of 4
aams86
in reply to: BrianEkins

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?

Message 4 of 4
BrianEkins
in reply to: aams86

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report