Message 1 of 5
Not applicable
02-23-2016
01:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm experimenting with different uses of the interference calculation in Fusion 360.
One example I'm trying to create is generating the interference of an interfernce body. For example if you create a venn diagram with 3 triangulated circles you get an interior intersection of the 3 circles and 3 outer portions that are the intersection of only two models. I try to create this using this code (below) but I get a InternalValidationError. What is causing this error. I have similar issues in other scripts wheverer I try to calculate and interference multiple times.
def run(context):
ui = None
try:
global app
app = adsk.core.Application.get()
global ui
ui = app.userInterface
# Create a document.
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
design.designType = adsk.fusion.DesignTypes.DirectDesignType
# Get the root component of the active design.
rootComp = design.rootComponent
features = rootComp.features
# Create sketch circle on the xz plane.
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xZConstructionPlane)
sketchCircles = sketch.sketchCurves.sketchCircles
centerPoint = adsk.core.Point3D.create(0, 0, 0)
sketchCircles.addByCenterRadius(centerPoint, 10)
# Create a collection of entities for extrude
entities0 = adsk.core.ObjectCollection.create()
entities0.add(sketch.profiles.item(0))
# Create a cylinder with ExtrudeFeature using the profile above.
extrudeFeats = features.extrudeFeatures
extrudeFeatureInput = extrudeFeats.createInput(entities0, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
extrudeFeatureInput.isSolid = True
extrudeFeatureInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(2.5))
extrudeFeature = extrudeFeats.add(extrudeFeatureInput)
# Create second body to do interference
sketch = sketches.add(rootComp.xZConstructionPlane)
sketchCircles = sketch.sketchCurves.sketchCircles
centerPoint = adsk.core.Point3D.create(5, 0, 0)
sketchCircles.addByCenterRadius(centerPoint, 10)
entities0.clear()
entities0.add(sketch.profiles.item(0))
# Create a cylinder with ExtrudeFeature using the profile above.
extrudeFeatureInput = extrudeFeats.createInput(entities0, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
extrudeFeatureInput.isSolid = True
extrudeFeatureInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(2.5))
extrudeFeature = extrudeFeats.add(extrudeFeatureInput)
sketch = sketches.add(rootComp.xZConstructionPlane)
sketchCircles = sketch.sketchCurves.sketchCircles
centerPoint = adsk.core.Point3D.create(0, 5, 0)
sketchCircles.addByCenterRadius(centerPoint, 10)
entities0.clear()
entities0.add(sketch.profiles.item(0))
# Create a cylinder with ExtrudeFeature using the profile above.
extrudeFeatureInput = extrudeFeats.createInput(entities0, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
extrudeFeatureInput.isSolid = True
extrudeFeatureInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(2.5))
extrudeFeature = extrudeFeats.add(extrudeFeatureInput)
# Create a collection of bodies
bodies = adsk.core.ObjectCollection.create()
for body in rootComp.bRepBodies:
bodies.add(body)
# Create InterferenceInput
interferencInput = design.createInterferenceInput(bodies)
# Analyze interference
results = design.analyzeInterference(interferencInput)
results.createBodies(True)
intersection = rootComp.occurrences.item(0)
newBodies = adsk.core.ObjectCollection.create()
for body in intersection.component.bRepBodies:
newBodies.add(body)
#get next level of interference
interferenceInput0 = design.createInterferenceInput(newBodies)
results1 = design.analyzeInterference(interferenceInput0)
results.createBodies(True)
Solved! Go to Solution.