RuntimeError: 2 : InternalValidationError : bBody ?

RuntimeError: 2 : InternalValidationError : bBody ?

OceanHydroAU
Collaborator Collaborator
537 Views
2 Replies
Message 1 of 3

RuntimeError: 2 : InternalValidationError : bBody ?

OceanHydroAU
Collaborator
Collaborator

Google says: 

Your search - "InternalValidationError" "bBody" - did not match any documents.

 

So, frustratingly, this worked manually in the vscode console a few days ago, and I foolishly didn't take good notes or code it up then (in my defence - it *was* midnight...).  To make matters worse, the vscode console history irritatingly seems to have lost part of my work (seems if you hit up-arrow later, it overwrites former commands - a bug in vscode - arrgh)

 

Anyhow - Now, my code fails, so I'm trying again to do this in the console, but this time: no luck.  Grrr.

 

 

myloft
<adsk.fusion.LoftFeature; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::fusion::LoftFeature > *' at 0x1a16034b0> >

surfaces = adsk.core.ObjectCollection.create()
surfaces.add(myloft)
True

section[8]['foil']['patch']
<adsk.fusion.PatchFeature; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::fusion::PatchFeature > *' at 0x1a2bf6360> >

surfaces.add(section[8]['foil']['patch'])
True

stitchInput = stitches.createInput(surfaces, tolerance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
stitch = stitches.add(stitchInput)
RuntimeError: 2 : InternalValidationError : bBody

 

 

Does anyone have any suggestions?

 

I'm assuming that the LoftFeature and the PatchFeature objects are the correct things to put into the surfaces collection?  Although the "bBody" word is making me wonder if I'm supposed to get/use something else for one of those?

0 Likes
Accepted solutions (1)
538 Views
2 Replies
Replies (2)
Message 2 of 3

OceanHydroAU
Collaborator
Collaborator

Sample:

#Author-Chris
#Description-demo loft from http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-a03e26b4-4a3c-11e6-a2e4-3417ebd41e19

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

         # Create a document.
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)

        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        rootComp = design.rootComponent

        # Create profile 1
        sketchesObj = rootComp.sketches
        sketch0 = sketchesObj.add(rootComp.xZConstructionPlane)
        sketchCirclesObj0 = sketch0.sketchCurves.sketchCircles
        centerPoint = adsk.core.Point3D.create(0, 0, 0)
        sketchCirclesObj0.addByCenterRadius(centerPoint, 5.0)
        profile0 = sketch0.profiles.item(0)

        # Create profile 2
        ctorPlanes = rootComp.constructionPlanes
        ctorPlaneInput1 = ctorPlanes.createInput()
        offset = adsk.core.ValueInput.createByString("10 cm")
        ctorPlaneInput1.setByOffset(rootComp.xZConstructionPlane, offset)
        ctorPlane1 = ctorPlanes.add(ctorPlaneInput1)
        sketch1 = sketchesObj.add(ctorPlane1)
        sketchCirclesObj1 = sketch1.sketchCurves.sketchCircles
        sketchCirclesObj1.addByCenterRadius(centerPoint, 2.0)
        profile1 = sketch1.profiles.item(0)

        # Create profile 3
        ctorPlaneInput2 = ctorPlanes.createInput()
        ctorPlaneInput2.setByOffset(ctorPlane1, offset)
        ctorPlane2 = ctorPlanes.add(ctorPlaneInput2)
        sketch2 = sketchesObj.add(ctorPlane2)
        sketchCirclesObj2 = sketch2.sketchCurves.sketchCircles
        sketchCirclesObj2.addByCenterRadius(centerPoint, 10.0)
        profile2 = sketch2.profiles.item(0)

        # Create loft feature input
        loftFeats = rootComp.features.loftFeatures
        loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        loftSectionsObj = loftInput.loftSections
        loftSectionsObj.add(profile0)
        loftSectionsObj.add(profile1)
        loftSectionsObj.add(profile2)
        loftInput.isSolid = False

        # Create loft feature
        surface1=loftFeats.add(loftInput)



        # Now make some patches too
        patches = sketch0.parentComponent.features.patchFeatures # patches = rootComp.features.patchFeatures
        patchInput = patches.createInput(profile0, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        patch0=patches.add(patchInput)

        patchInput = patches.createInput(profile2, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        patch2=patches.add(patchInput)


        # Now stitch them together
        surfaces = adsk.core.ObjectCollection.create()
        surfaces.add(patch0)
        surfaces.add(surface1)

        # Define tolerance with 1 cm.
        tolerance = adsk.core.ValueInput.createByReal(1.0)
        
        # Create a stitch input to be able to define the input needed for an stitch.
        stitches = rootComp.features.stitchFeatures
        stitchInput = stitches.createInput(surfaces, tolerance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        
        # Create a stitch feature.
        stitch = stitches.add(stitchInput)

        worked=1

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Message 3 of 3

OceanHydroAU
Collaborator
Collaborator
Accepted solution

🏅(award for answering the most number of his own questions in one day...)

 

Turns out I need to add a "sub part"   .bodies.item(0)  of those things:

        surfaces.add(patch0.bodies.item(0))
        surfaces.add(surface1.bodies.item(0))

... looks like someone forgot to check input types on that API function call.

0 Likes