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: 

Measure angles between planes

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
luc.doppler
513 Views, 2 Replies

Measure angles between planes

Hello,

 

I want to measure the angle between two planes with the measureManager.measureAngle() command. It works fine when measuring angle between construction planes in the root Component, but as soon as I want to measure angles between one plane in the root Component and one plane in a sub sub component (or two planes in a sub sub component) I get a "RuntimeError: 3 : invalid argument geometryOne" error.

 

As I started Fusion only a few weeks ago I don't have a lot of experience of the API and don't understand why I have with issue. I checked the datatypes and both arguments are constructPlanes. When I am measuring it using the inspect tool by hand it works fine...

 

I have seen things about proxy and brep but I think I am directly using the objects here so I should not have a problem...

 

I have attached a Fusion project and the python script

 

Thanks a lot for your time

Labels (1)
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: luc.doppler

Hi @luc.doppler .

 

For entities other than the root component, Proxies are important.

 

・・・
# programme principal
def run(context):
    ui = None
    try:
        # On récupère Fusion 360
        app = adsk.core.Application.get()
        # On récupère l'interface utilisateur de Fusion
        ui  = app.userInterface

        # On récupère la sélection  active (le projet Fusion qui est ouvert/actif)
        activeSelection = adsk.fusion.Design.cast(app.activeProduct)

        # On sélectionne le composant à la racine
        rootComp = activeSelection.rootComponent

        # On sélectionne le pouce
        pouceOcc :adsk.fusion.Occurrence = rootComp.occurrences[0].childOccurrences[0]
        pouceComp = pouceOcc.component

        # Logger utilisateur
        uiDebug = UiLogger(True)

        uiDebug.print(str("Début du script"))
        uiDebug.print(str(datetime.now()))

        # On récupère le plan de référence pour la mesure d'angle
        plan1 = rootComp.constructionPlanes[0]

        # On récupère le plan mobile pour la mesure d'angle
        plan2 = pouceComp.constructionPlanes[0]

        # Proxies
        plan2 = plan2.createForAssemblyContext(pouceOcc) # important!
        # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-bf97ec2d-ef2e-4409-b0ee-eaebd91d74b4
        # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A

        uiDebug.print(str(math.degrees(app.measureManager.measureAngle(plan1,plan2).value)))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

For more information about Proxies, see the bottom of the link.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A 

Message 3 of 3
luc.doppler
in reply to: kandennti

thanks a lot ! It worked as expected 😉

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