Measure angles between planes

Measure angles between planes

Anonymous
1,169 Views
2 Replies
Message 1 of 3

Measure angles between planes

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
1,170 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @Anonymous .

 

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 

0 Likes
Message 3 of 3

Anonymous
Not applicable

thanks a lot ! It worked as expected 😉

0 Likes