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: 

Participant Bodies after 01/2017 update

1 REPLY 1
Reply
Message 1 of 2
nnamfoh
284 Views, 1 Reply

Participant Bodies after 01/2017 update

I'm trying to use the new participantbodies feature from the update on an Join Extrusion, but it throws a weird error. 

Here is my code.

def buildBolt( parentComp, diameter, length, withHead = False):
    sketches = parentComp.sketches
    xZPlane = parentComp.xZConstructionPlane
    center = parentComp.originConstructionPoint.geometry
    extrudes = parentComp.features.extrudeFeatures
    bodies = []
    if withHead:
        sketch = sketches.add(xZPlane)
        sketch.sketchCurves.sketchCircles.addByCenterRadius(center, (diameter+.3)/2)
        prof = sketch.profiles[0]
        extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        distanceExtent = adsk.fusion.DistanceExtentDefinition.create(adsk.core.ValueInput.createByReal(.2))
        extInput.setOneSideExtent(distanceExtent, adsk.fusion.ExtentDirections.NegativeExtentDirection)
        extrude = extrudes.add(extInput)
        for body in extrude.bodies:
            Globals.ui.messageBox(str(body.classType()))
            bodies.append(bodies)
    try:
        bodySketch = sketches.add(xZPlane)
        bodySketch.sketchCurves.sketchCircles.addByCenterRadius(center, diameter/2)
        prof = bodySketch.profiles[0]
        extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.JoinFeatureOperation)
        distanceExtent = adsk.fusion.DistanceExtentDefinition.create(adsk.core.ValueInput.createByReal(length))
        extInput.setOneSideExtent(distanceExtent, adsk.fusion.ExtentDirections.PositiveExtentDirection)
        extInput.participantBodies = bodies
        extrude = extrudes.add(extInput)
    except: 
        Globals.ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

The resulting error is thrown at "extInput.particpantBodies = bodies"

 

 

TypeError: in method 'extrudeFeatureInput__set_participantBodies', argument 2 of type 'std::vector<adsk::core::Ptr<adsk::fusion::BRepBody >?, std::allocator<adsk::core::Ptr< adsk::fusion::BRepBody > > > const &'

Since this feature is so new could this be a bug? I can work around it, but I would really like to know what I'm doing wrong.

 

1 REPLY 1
Message 2 of 2
marshaltu
in reply to: nnamfoh

Hello,

 

It looked like a typo error in your code. The line marked as red should be "bodies.append(body)".

 

Thanks,

Marshal

 

        for body in extrude.bodies:
            Globals.ui.messageBox(str(body.classType()))
            bodies.append(bodies)


Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

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