Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Analyze Interference creates bodies with different origin

Anonymous

Analyze Interference creates bodies with different origin

Anonymous
Not applicable

I'm using the Design.AnalyzeInterfernce features to help visualize the relationship between a component and the bodies near it. However when the bodies to visualize this are generated sometimes the intersection bodies show up in a completely different place. I think happens when the component has been moved, causing the origin of the component to be different than the root component. Is there a way to stop this. Here are some code sections that I'm using to analyze and visualize the interference, and here is image of the problem. The gree cylinder is its own component that was moved into that interfing space and the red section is the resulting interference result that is positioned incorrectly (it should be between the cylinders).

def analyzeInteference(self, bodies):
        self.deleteChildren()
        bodyCollection = adsk.core.ObjectCollection.create()#collection of bodies in assertion and local area to calculate interference
        for bodyName in bodies:
            assert bodies[bodyName].parentComponent.name != self.name
            if bodies[bodyName].isValid:
                bodyCollection.add(bodies[bodyName])
        bodyCollection.add(self.getDefaultOcc())
        interferenceInput = self.design.createInterferenceInput(bodyCollection)
        interferenceResults = self.design.analyzeInterference(interferenceInput)
        releventCount = 0
        for interferenceResult in interferenceResults:
            if interferenceResult.entityOne.parentComponent.name != self.name:
                if interferenceResult.entityTwo.parentComponent.name == self.name:#entity one is foreign, and entity2 is assertion
                    interferenceResult.isCreateBody = True
                    releventCount+=1
                else:
                    interferenceResult.isCreateBody = False
            elif interferenceResult.entityTwo.parentComponent.name != self.name:
                if interferenceResult.entityOne.parentComponent.name == self.name:#entity2 is foreign, and entity1 is assertion
                    interferenceResult.isCreateBody = True
                    releventCount+=1
                else:
                    interferenceResult.isCreateBody = False
            else:
                interferenceResult.isCreateBody = False
        return interferenceResults, releventCount
    def intersectingBodies(self, interferenceResults):
        self.deleteChildren()
        myIntersectionCopy = createNewComponent(self.component)
        myIntersectionCopy.name = "Intersections"
        myIntersectionCopy.attributes.add("visualArtifact", "visualArtifact","0")
        if interferenceResults is not None and interferenceResults.count > 0:
            baseFeat = myIntersectionCopy.features.baseFeatures.add()
            baseFeat.name = 'Inteference Results'
            baseFeat.startEdit()            
            intResult = adsk.fusion.InterferenceResult.cast(None)
            for intResult in interferenceResults:
                if intResult.isCreateBody:
                    body = myIntersectionCopy.bRepBodies.add(intResult.interferenceBody, baseFeat)
                    body.name = 'Interference ' + body.name
            baseFeat.finishEdit()
        return myIntersectionCopy

Capture.PNG

0 Likes
Reply
725 Views
4 Replies
Replies (4)

ekinsb
Alumni
Alumni

I can't tell from the image where the original bodies are in the assembly structure and where you are creating the interference bodies.  My guess is that it looks like you might be creating the intersection bodies in "Part".  The interference results will be returned with respect to the world coordinate system which is the same as the root component.  If the "Part" occurrence has not been moved then it's coordinate system will line up with the world, but if it has been moved and you're drawing the results in that component, the results will also be moved the same amount.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes

Anonymous
Not applicable

This makes sense, but is there a way to change that behavior or to analyze the interference results with respect to the component that the results will be created in? The Part is where the results are being created and it has been moved, but I want the interference result I'm generating it to be visualized with respect to the whole design rather than that component. 

0 Likes

ekinsb
Alumni
Alumni

Interference is always calculated in the context of the design (which is world space) and the results are returned in that space.  The only way I can think of to get what you want is to transform the result body to counteract the transform of the occurrence you want to create it in.  Today, I think the only way to do that is to create the body and then use a Move feature using the inverse of the matrix you get back from the transformation property of the occurrence.

 

I think one way to better visualize what you've got is to make a copy of the "Part" occurrence and move it so it's away from the existing occurrence.  Now when you create the result bodies you'll see two sets, one set for each occurrence.  Remember that you're creating geometry in a component, which is always world space, but then you're viewing that component through an occurrence, which can be transformed.  This help topic goes into more detail about this.

 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes

Anonymous
Not applicable

I see, I will try the transformation work around. The reason that I keep the results in the component is because this visualization is part of a larger system I'm developing and the components are the best way to maintain the relationships between bodies in the data. Oh well.

0 Likes