Analyze Interference creates bodies with different origin

Not applicable
09-25-2017
12:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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