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: 

UnExpected Bounding Box results

4 REPLIES 4
Reply
Message 1 of 5
saurabh.verma
281 Views, 4 Replies

UnExpected Bounding Box results

I am trying to get the bounding box by selecting a circle of a butterfly type control valve  through the code. and getting unexpected results .

The geometry is itself far away from the origin but the bounding box values comes with including the origin.

 

This is code written below explaining how i am getting  bounding boxing for Inlet.

 

Ptr<BRepEdge> inletEdge = rotationInput.InletEdge;
Ptr<BRepCoEdges> inletCoEdges = inletEdge->coEdges();

Ptr<BoundingBox3D> InletBBox = BoundingBox3D::create(Point3D::create(), Point3D::create());
for (size_t i = 0; i < inletCoEdges->count(); i++)
{
Ptr<BRepCoEdge> inletCoEdge = inletCoEdges->item(i);
Ptr<BRepLoop> loop = inletCoEdge->loop();
InletBBox->combine(loop->boundingBox());
}

 

original results 

min x= -10, min y= -10, min z= 0,

max x= 10 max y= 10, max z=36.25

 

wherein we expect different values for z.

 

 

4 REPLIES 4
Message 2 of 5
ekinsb
in reply to: saurabh.verma

A CoEdge is a 2D object.  It represents an edge in the parametric space of a surface so the Z will always be 0 and the X and Y will be in the parameter space of the surface.  If you want 3D information you need to use the BRepEdge object.  What exactly is it that you're trying to do?


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5
saurabh.verma
in reply to: ekinsb

Replying on behalf of saurabh verma

Yes,I am actually trying to get the bounding box all coordinates values and
centroid of that circle, by selecting a circle on the geometry.
Yes for this case BRepEdge would suffice my purpose.Any sample of getting
bounding box and centroid using BRepEdge would be very helpful.

--

Prakhar Nigam| Member Of Technical Staff
*Centre for Computational Technologies - CCTech*

1 Akshay Residency | 50 Anand Park | Aundh | Pune | 411007 | India
Ph: +91 20 40098381/82 | M: +7768942662 | www.cctech.co.in

*CCTech** - "**Transforming human life by democratization of technology**"*
Message 4 of 5
saurabh.verma
in reply to: ekinsb

Replying on behalf of saurabh verma

Yes,I am actually trying to get the bounding box all coordinates values and
centroid of that circle, by selecting a circle on the geometry.
Yes for this case BRepEdge would suffice my purpose.Any sample of getting
bounding box and centroid using BRepEdge would be very helpful.

--

Prakhar Nigam| Member Of Technical Staff
*Centre for Computational Technologies - CCTech*

1 Akshay Residency | 50 Anand Park | Aundh | Pune | 411007 | India
Ph: +91 20 40098381/82 | M: +7768942662 | www.cctech.co.in

*CCTech** - "**Transforming human life by democratization of technology**"*
Message 5 of 5
ekinsb
in reply to: saurabh.verma

There's been an oversight in the API design and getting the bounding box from an edge is not currently possible. I've written some code below that demonstrates a workaround to use another function and calculating the bounding box from it.  I've also added an issue into the API backlog to support getting the bounding box from an edge so it will be available in the future.

 

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        edge = adsk.fusion.BRepEdge.cast(ui.selectEntity('Select an edge.', 'Edges').entity)
        
        # Because the boundingBox property is missing on the BRepEdge object, calculate
        # it ourselves.
        curveEval = edge.evaluator
        (returnValue, startParameter, endParameter) = curveEval.getParameterExtents()
        (returnValue, coords) = curveEval.getStrokes(startParameter, endParameter, 0.001)

        minVal = coords[0].copy()
        maxVal = coords[0].copy()
        for i in range(1, len(coords)):
            if coords[i].x < minVal.x:
                minVal.x = coords[i].x
            
            if coords[i].y < minVal.y:
                minVal.y = coords[i].y

            if coords[i].z < minVal.z:
                minVal.z = coords[i].z
                
            if coords[i].x > maxVal.x:
                maxVal.x = coords[i].x

            if coords[i].y > maxVal.y:
                maxVal.y = coords[i].y

            if coords[i].z > maxVal.z:
                maxVal.z = coords[i].z
        
        ui.messageBox('Range:\n   Min:' + str(minVal.asArray()) + 
                      '\n   Max:' + str(maxVal.asArray()))
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

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