Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RuntimeError: 2 : InternalValidationError : bSet When extruding a new body

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
mxl2761
1191 Views, 4 Replies

RuntimeError: 2 : InternalValidationError : bSet When extruding a new body

Hello,

 

I am working to extrude the faces of a given component.

 

I managed to iterate over the faces and project them onto a new sketch.

 

I am trying to figure out how to extrude the new sketch that I made. 

 

 

extrude = root.features.extrudeFeatures
new_sketch.project(face)
for prof in new_sketch.profiles:
          extInput = extrude.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)

Where the face is being iterated over based on the object.

I found this based on the documentation and also in another post here:

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/extrudes-createinput-internal-validation-e...

 

This still results in the error : "RuntimeError: 2 : InternalValidationError : bSet"

 

Please let me know if you have any thoughts on what could be causing this.

 

Thanks,

Michael

 

4 REPLIES 4
Message 2 of 5
marshaltu
in reply to: mxl2761

Hello,

 

It would be great if you can post a complete sample to demo the issue. I cannot figure out what's the problem by the piece of codes you posted.

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 5
mxl2761
in reply to: marshaltu

Here is the code I have.

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        #Get all of the root Fusion Objects set up
        app = adsk.core.Application.get()
        ui  = app.userInterface
        product = app.activeProduct
        root = adsk.fusion.Design.cast(product).rootComponent
        extrude = root.features.extrudeFeatures
        #End Get all of the root Fusion Objects set up
        ocs = root.occurrences
        #Get the first component in the root
        components = ocs.item(0).component
        #Get the first body from the component
        body = components.bRepBodies[0]
        
        dis = adsk.core.ValueInput.createByReal(5)
        #iterate over all faces in the object
        for face in body.faces:
            #Add a sketch at the same orientation as the face
            new_sketch = face.body.parentComponent.sketches.add(face)
            #Project the face onto that sketch
            new_sketch.project(face)
            for prof in new_sketch.profiles:
            #Add a simple extrude of the sketch using the sketch profile, a distance and the type
                extInput = extrude.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                extInput.setDistanceExtent(False, dis)
                ex = extrude.add(extInput)
        exit

    except:
        if ui:
            print('Failed:\n{}'.format(traceback.format_exc()))

Thanks

Message 4 of 5
marshaltu
in reply to: mxl2761

Hello,

 

The root cause was because "prof" was entity under sub component and it cannot be used to create extrude directly in root component. You have to create proxy object before using it. 

 

The error message was not clear enough to point root cause out and need be improved in the future.

 

Thanks,

Marshal

 

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        #Get all of the root Fusion Objects set up
        app = adsk.core.Application.get()
        ui  = app.userInterface
        product = app.activeProduct
        root = adsk.fusion.Design.cast(product).rootComponent
        extrude = root.features.extrudeFeatures
        #End Get all of the root Fusion Objects set up
        occ = root.occurrences.item(0)
        #Get the first component in the root
        components = occ.component
        #Get the first body from the component
        body = components.bRepBodies[0]
        
        dis = adsk.core.ValueInput.createByReal(5)
        #iterate over all faces in the object
        for face in body.faces:
            #Add a sketch at the same orientation as the face
            new_sketch = face.body.parentComponent.sketches.add(face)
            #Project the face onto that sketch
            new_sketch.project(face)
            for prof in new_sketch.profiles:
            #Add a simple extrude of the sketch using the sketch profile, a distance and the type
                extInput = extrude.createInput(prof.createForAssemblyContext(occ), adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                extInput.setDistanceExtent(False, dis)
                ex = extrude.add(extInput)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 5 of 5
mxl2761
in reply to: marshaltu

Thanks for the help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report