Convert Default Modeling Orientation from Y Up to Z Up

Convert Default Modeling Orientation from Y Up to Z Up

ebunn3
Advocate Advocate
681 Views
5 Replies
Message 1 of 6

Convert Default Modeling Orientation from Y Up to Z Up

ebunn3
Advocate
Advocate

Hi all,

 

Is there a way, programmatically, to convert a part that was created using Y Up to a Z Up orientation.  I believe this really only has something to do with how the viewport camera perceives the model.  

 

Eric

0 Likes
Accepted solutions (1)
682 Views
5 Replies
Replies (5)
Message 2 of 6

BrianEkins
Mentor
Mentor

The viewport has a concept of what is "Front" and "Up" and they can be in any direction. The X, Y, and Z directions are constant and never change. If you turn on the "Origin" display in the browser, you'll see the triad that shows the base work planes and axes. Notice that if you change "Front" or "Up" for the viewport that the base coordinate system does not change.

 

A way to do what you want is to use the Move feature to rotate your part, so it's oriented the way you want. 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 6

ebunn3
Advocate
Advocate

Brian,

 

Is there a way to create custom views, other than the standard views?  I painstakingly manually rotated the model created in yUp configuration to something closely resembling a zUp isometric view (screenshot below).  Is there a way to set this up using the API? 

Reason I want to do this is I have a long running macro that works based on the world coordinate system (XYZ) and I'm using the viewport.goHome method to periodically re-orient the view, which works great with a file created using zUp and not great visually when the code runs on a yUp model.  At the end of the macro, I do rotate the occurrence (as you suggested) that is created by the macro so it is upright relative to the yUp configuration. 

 

Thanks,

 

Eric

 

ebunn3_0-1674737344015.png

 

0 Likes
Message 4 of 6

BrianEkins
Mentor
Mentor

Fusion supports "Named Views", which are shown in the browser. Unfortunately, the API does not currently have support for named view.

 

Here's a previous post from @kandennti that provides a workaround, but a direct solution in the API will be much simpler and more reliable.

 

Another possible solution is to do what the named view functionality is doing internally. That is to save all the camera settings for the view orientation you want to save and then apply that camera when you want that view. You could save the camera information in an attribute on the root component, so it's saved with the document.

 

Again, a named view API would be much simpler.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 6

ebunn3
Advocate
Advocate

Thanks again Brian.   I’ll look at the Kandennti post.   

Eric

0 Likes
Message 6 of 6

ebunn3
Advocate
Advocate
Accepted solution

Brian,

 

I found the kandennti post and that lead me to another post by you that helped me put together the attached macro.  This will accomplish what I want to do.  Thanks for all the help.

 

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/trying-to-create-a-python-script-to-animat... 

def move_camera_World_Iso_View():
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        view = app.activeViewport
        #go home
        view.goHome()
        #get the camera
        camera = view.camera
        #set transition to False
        camera.isSmoothTransition = False
        #define upVector to Z
        camera.upVector = adsk.core.Vector3D.create(0,0,1)
        #set isFitView to True
        camera.isFitView=True
        #update camera
        view.camera = camera
        #refresh viewport
        view.refresh()
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Eric

0 Likes