Modeling Orientation Used for Pre-Existing Document (not matching Modeling Preferences in User Preferences)

Modeling Orientation Used for Pre-Existing Document (not matching Modeling Preferences in User Preferences)

ebunn3
Advocate Advocate
633 Views
2 Replies
Message 1 of 3

Modeling Orientation Used for Pre-Existing Document (not matching Modeling Preferences in User Preferences)

ebunn3
Advocate
Advocate

Hi,

 

There is a user preference accessed by calling:  app.preferences.generalPreferences.defaultModelingOrientation which is based on the value set in user preferences.  (see screenshot)

 

If one opens a pre-existing document that was created using Z Up, for example, and this preference had been changed to Y Up,  looking at app.preferences.generalPreferences.defaultModelingOrientation does not reflect how the current open document was built.  

 

The question is:  how would one determine what modeling orientation was used to create the document, Y up or Z Up?  I did see that you can access a property called upVector (app.activeViewport.camera.upVector).  Can this be used to determine whether  Y Up or Z Up was used to create the document?

 

Thanks for the help.

 

Eric

 

 

 

ebunn3_0-1652282492596.png

 

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

kandennti
Mentor
Mentor
Accepted solution

Hi @ebunn3 .

 

I put the screen in front view and determined from the orientation of Camera.upVector.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface

        msg = 'Z Up' if isZUp() else 'Y Up'

        ui.messageBox(msg)

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


def isZUp() -> bool:
    app: adsk.core.Application = adsk.core.Application.get()

    def getFrontName() -> str:
        language = app.preferences.generalPreferences.userLanguage
        if language == adsk.core.UserLanguages.JapaneseLanguage:
            return '前'

        return 'FRONT'

    vp: adsk.core.Viewport = app.activeViewport
    backUp: adsk.core.Camera = vp.camera

    app.executeTextCommand(u'NamedView.RestoreCamera {}'.format(getFrontName()))

    cam: adsk.core.Camera = vp.camera
    upVec: adsk.core.Vector3D = cam.upVector
    res = upVec.isParallelTo(
        adsk.core.Vector3D.create(0,0,1)
    )

    vp.camera = backUp

    return res

 

When making the front view, I was considering using the Camera.viewOrientation property, but when I actually tested it, I could not determine the orientation correctly because of the slow change in orientation.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2e300e0c-478a-4e73-b1ee-e13e83bfe918 


Therefore, we are using TextCommands, and the language settings cannot be correctly determined except for English and Japanese.

Message 3 of 3

balunist
Advocate
Advocate

Is there a better way to determine the orientation a model was created as without manipulating the camera view?   And if not can the orientation movement and restore be hidden somehow?   

Thanks in advance! 

0 Likes