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: 

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

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ebunn3
170 Views, 2 Replies

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

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

 

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: ebunn3

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
in reply to: ebunn3

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! 

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