internal validation error when analysing interference multiple times in a script

internal validation error when analysing interference multiple times in a script

Anonymous
Not applicable
331 Views
1 Reply
Message 1 of 2

internal validation error when analysing interference multiple times in a script

Anonymous
Not applicable

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.Capture.PNG

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)
0 Likes
332 Views
1 Reply
Reply (1)
Message 2 of 2

marshaltu
Autodesk
Autodesk
Hello,

We missed the thread. I gave a try in the latest Fusion 360(2.0.2088). It seemed that the script worked well. Please give double check and let us know if it is still reproducible.

Thanks,
Marshal


Marshal Tu
Fusion Developer
>
0 Likes