Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I prepared script for analyzing the interference between the components in the assembly product. While i running the script , only the component 5 is highlighted. Please help me to find out the solution for the below issue.
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context😞
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
design.designType = adsk.fusion.DesignTypes.DirectDesignType
root = design.rootComponent
occurrences = root.occurrences
body1 = occurrences.item(0).bRepBodies.item(0)
body2 = occurrences.item(1).bRepBodies
body3 = occurrences.item(2).bRepBodies
body4 = occurrences.item(3).bRepBodies
body5 = occurrences.item(4).bRepBodies
inputcomp = adsk.core.ObjectCollection.create()
inputcomp.add(body1)
inputcomp.add(body2)
inputcomp.add(body3)
inputcomp.add(body4)
inputcomp.add(body5)
input = design.createInterferenceInput(inputcomp)
input.areCoincidentFacesIncluded = True
results = design.analyzeInterference(input)
interferenceBodies = results.createBodies(True)
resultsOccurrence = occurrences.item(occurrences.count-1)
resultsOccurrence.activate()
# Fit the view
viewport = app.activeViewport
viewport.fit()
bod = 0
for res in results:
comp1Name = res.entityOne.parentComponent.name
comp2Name = res.entityTwo.parentComponent.name
bodyVolume = str(round(res.interferenceBody.volume, 2))
interferenceBodies.item(bod).name = 'Interference between ' + comp1Name + ' & ' + comp2Name
ui.messageBox('There is interference between ' + comp1Name + ' and ' + comp2Name + ' with a volume of ' + bodyVolume + ' cubic centimeters')
bod += 1
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.