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: 

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

4 REPLIES 4
Reply
Message 1 of 5
JesusFreke
230 Views, 4 Replies

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

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)

 

4 REPLIES 4
Message 2 of 5
kandennti
in reply to: JesusFreke

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()))
Message 3 of 5
JesusFreke
in reply to: JesusFreke

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.

Message 4 of 5
kandennti
in reply to: JesusFreke

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.

Message 5 of 5
KrisKaplan
in reply to: JesusFreke

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

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