extrudes.createInput Internal Validation Error

extrudes.createInput Internal Validation Error

Anonymous
Not applicable
896 Views
2 Replies
Message 1 of 3

extrudes.createInput Internal Validation Error

Anonymous
Not applicable

What would cause an internal validation error when creating a extrution input?

My source code is below and it gets the error:

RunTimeError 2: InternalValidationError: bSet

def makeBatteries(self):
        sketches = self.RWO.sketches
        zYPlane = self.RWO.yZConstructionPlane
        baseSketch = sketches.add(zYPlane)
        sketchCircles = baseSketch.sketchCurves.sketchCircles
        radius = self.diameter/2
        for i in range(0, int(self.numberOfBatteries)):
            batteryOrigin = adsk.core.Point3D.create( (BatteryIntegrator.batteryBoundry+self.diameter)*i+BatteryIntegrator.batteryBoundry+radius,radius, 0)
            sketchCircles.addByCenterRadius(batteryOrigin, radius)
        extrudes = self.holder.features.extrudeFeatures
        for prof in baseSketch.profiles:
            try:
                extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                distance = adsk.core.ValueInput.createByReal(self.length)
                extInput.setDistanceExtent(False, distance)
                extrudes.add(extInput)
            except:
                self.ui.messageBox(('AddIn Stop Failed: {}').format(traceback.format_exc()))
                traceback.print_exc()
0 Likes
Accepted solutions (1)
897 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni
Accepted solution

I think you need to double-check the values of the class members.  I converted your code into a standalone function to be able to test it since you didn't include the full class and it works as expected.  Here's my test code.

 

def makeBatteries():
    ui = None
    try:
        diameter = 2
        numberOfBatteries = 4
        length = 5
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        sketches = root.sketches
        zYPlane = root.yZConstructionPlane
        baseSketch = sketches.add(zYPlane)
        sketchCircles = baseSketch.sketchCurves.sketchCircles
        radius = diameter/2
        for i in range(0, int(numberOfBatteries)):
            batteryOrigin = adsk.core.Point3D.create((diameter*i)+radius,radius,0)
            sketchCircles.addByCenterRadius(batteryOrigin, radius)
        extrudes = root.features.extrudeFeatures
        for prof in baseSketch.profiles:
            try:
                extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                distance = adsk.core.ValueInput.createByReal(length)
                extInput.setDistanceExtent(False, distance)
                extrudes.add(extInput)
            except:
                ui.messageBox(('AddIn Stop Failed: {}').format(traceback.format_exc()))
                traceback.print_exc()
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks, I'm not sure what is different between our code, but without changing my values, your version works and mine doesn't
0 Likes