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

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

Anonymous
Not applicable
2,053 Views
4 Replies
Message 1 of 5

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

Anonymous
Not applicable

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

 

0 Likes
Accepted solutions (1)
2,054 Views
4 Replies
Replies (4)
Message 2 of 5

marshaltu
Autodesk
Autodesk

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 Developer
>
0 Likes
Message 3 of 5

Anonymous
Not applicable

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

0 Likes
Message 4 of 5

marshaltu
Autodesk
Autodesk
Accepted solution

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 Developer
>
Message 5 of 5

Anonymous
Not applicable

Thanks for the help.

0 Likes