Can't use MeasureManager.getMinimumDistance on temporary brep objects?

Can't use MeasureManager.getMinimumDistance on temporary brep objects?

JesusFreke
Advocate Advocate
1,003 Views
4 Replies
Message 1 of 5

Can't use MeasureManager.getMinimumDistance on temporary brep objects?

JesusFreke
Advocate
Advocate

I was a bit surprised to find that when I try to use MeasureManager.getMinimumDistance() on temporary brep objects, I get an "invalid argument" error:

 

 

RuntimeError: 3 : invalid argument geometryOne

 

 

The workaround of course is to create an occurrence and add the bodies, and then use the imported, non-temporary bodies. But I generally prefer to work with temporary brep objects when possible, for speed.

 

I was just wondering if there was some technical limitation that prevents this, or maybe it's just an oversight? And if so, could support be added for this?

 

Sample code:

 

    sphere1 = adsk.fusion.TemporaryBRepManager.get().createSphere(Point3D.create(0, 0, 0), 1)
    sphere2 = adsk.fusion.TemporaryBRepManager.get().createSphere(Point3D.create(2, 0, 0), 1)
    result = adsk.core.Application.get().measureManager.measureMinimumDistance(sphere1, sphere2)
    print(result)

 

0 Likes
1,004 Views
4 Replies
Replies (4)
Message 2 of 5

kandennti
Mentor
Mentor

Hi @JesusFreke .

 

When using the MeasureMinimumDistance method, the BRepbody created by TemporaryBRepManager could not be used.

You need to use the BRepbody created by bRepBodies.add.

# Fusion360API Python script
import adsk.core, adsk.fusion, traceback

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app :adsk.fusion.Application = adsk.core.Application.get()
        ui = app.userInterface
        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des :adsk.fusion.Design = app.activeProduct

        Point3D = adsk.core.Point3D
        sphere1 = adsk.fusion.TemporaryBRepManager.get().createSphere(Point3D.create(0, 0, 0), 1)
        sphere2 = adsk.fusion.TemporaryBRepManager.get().createSphere(Point3D.create(3, 0, 0), 1)
        # result = adsk.core.Application.get().measureManager.measureMinimumDistance(sphere1, sphere2) #ng


        root :adsk.fusion.Component = des.rootComponent
        bodies :adsk.fusion.BRepBodies = root.bRepBodies
        des.designType = adsk.fusion.DesignTypes.DirectDesignType
        sphereBody1 = bodies.add(sphere1)
        sphereBody2 = bodies.add(sphere2)
        result = adsk.core.Application.get().measureManager.measureMinimumDistance(sphereBody1, sphereBody2)

        print(result.value)

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

JesusFreke
Advocate
Advocate

Thanks @kandennti, but I'm already aware of this approach, as mentioned in my original post. My question is more for the autodesk folks, if support for temporary brep objects could be added to this api. I'm not familiar with the technical details behind the api of course, but on the surface, it seems like it should be an easy fix.

0 Likes
Message 4 of 5

kandennti
Mentor
Mentor

I'm sorry, I didn't read it carefully.
It would certainly be attractive if I could measure the BRepBody created with TemporaryBRepManager, since it would not corrupt the data.

0 Likes
Message 5 of 5

KrisKaplan
Autodesk
Autodesk

Jesus,

 

The default implementation is based on selections, and transient BRep entities don't support selection (of course, because they don't belong to the scene).

 

But measure can be enabled for transient BRep entities. This change should be available in an early July release. FWIW: This is tracked with issue #FUS-84118.

 

Kris



Kris Kaplan