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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Consistent boundaryFillInput.bRepCells.item

Message 1 of 3
297 Views, 2 Replies

Consistent boundaryFillInput.bRepCells.item

I'm hitting an issue where the bRepCells.item on a BoundaryFill aren't consistently the same array index. The 2 Bodies used are a rectangular box and then a doing an Intersect with a cylinder to produce a rounded top. The intersect produces 3 items, but there doesn't appear to be a way to guarantee that the item index is the right one. It also appears dependent on the order of the adsk.core.ObjectCollection.create.add operations. Is there a way to consistently get the correct item?


code snippet:

    circles = sketch.sketchCurves.sketchCircles
    circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(center, 0, 0), radius)

    prof = sketch.profiles.item(0)
    distance = adsk.core.ValueInput.createByReal(length)
    extrude1 = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)

    # BoundaryFill intersect to radius the board
    tools = adsk.core.ObjectCollection.create()

    # Create input
    boundaryFillInput = boundaryFills.createInput(tools, adsk.fusion.FeatureOperations.IntersectFeatureOperation)

    # Specify which cell is kept
    cell = boundaryFillInput.bRepCells.item(1)
    cell.isSelected = True

    # Create the boundary fill



Message 2 of 3
in reply to: Anonymous

I kludged around it by selecting the cellBody that's within 10% volume of the original board body.



    board_body = rootComp.bRepBodies.itemByName(board_body_name)
    board_vol = board_body.volume
    print("BOARD_BODY: ", board_body.volume)

    # Specify which cell is kept
    for x in range(0, boundaryFillInput.bRepCells.count):
        cell = boundaryFillInput.bRepCells.item(x)
        cell_vol = cell.cellBody.volume
        orig_percent = (cell_vol / board_vol) * 100
        print("Cell{0}: {1}\t{2} %".format(x, cell_vol, orig_percent))
        if 90 <= orig_percent <= 100:
            cell.isSelected = True


Message 3 of 3
in reply to: Anonymous

I think something like you've done is the correct answer and not just a workaround.  The order of the results shouldn't be relied upon.  You might find something consistent by controlling the order of the inputs but there's no guarantee that it would remain the same in future versions of Fusion 360.


The solution is to look for something in the results that will identify the body you want.  It could be the volume like you've done but it could also be volumes that have certain shapes, a certain number of faces, or are located in a specific area of the model.  It would differ with each specific case.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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