Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Regression in saving view as image file using API on Mac

BrianEkins
Mentor Mentor
707 Views
4 Replies
Message 1 of 5

Regression in saving view as image file using API on Mac

BrianEkins
Mentor
Mentor

There is a regression in the API functionality to save a view to an image file on Mac.  I know this was working 4 or 5 months ago.  It is still working correctly on Windows but does not work on Mac.  The function saveAsImageFile reports that it was successful, but no image file is created.  Here's a small sample script that can be used to reproduce the problem.  You'll need to change the filename to match your username.

 

import adsk.core, adsk.fusion, adsk.cam, traceback

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

	filename = '/Users/admin/Test.png'
        success = app.activeViewport.saveAsImageFile(filename, 0, 0)
        ui.messageBox(str(success))
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Reply
Reply
0 Likes
708 Views
4 Replies
Replies (4)
Message 2 of 5

goyals
Autodesk
Autodesk

Hi Brian,

 

I looked in to this but not able to reproduced it on Mac. Please look at the attached video. One thing you can try is to save the file at some other location just to ruled out it is write access issue.



Shyam Goyal
Sr. Software Dev. Manager
Reply
Reply
0 Likes
Message 3 of 5

BrianEkins
Mentor
Mentor

Hi Shyam,

 

Thanks for looking at this.  I just tried it again and it probably is a permissions issue.  It fails when using the MAS install (which is what I initially tried) and works when using the autodesk.com install.  The folder I'm writing it to is my user folder.  I also tried this in Fusion's command window and it works with the .com install and fails with MAS and gives a permission error.

 

f = open('/Users/admin/newTest.txt','w')

I don't know where it would be legal for me to write a file to when using the MAS install.  So, I think this is still a bug in that it's returning success when it did fail to create the file, however it's likely not a regression.  I was probably just using the .com version of Fusion when I was using it a few months ago.

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

goyals
Autodesk
Autodesk

I will fix the wrong status returned by this API. Thanks for posting it.



Shyam Goyal
Sr. Software Dev. Manager
Reply
Reply
0 Likes
Message 5 of 5

goyals
Autodesk
Autodesk

I think it allows to create the image file in TEMP directory. Access to the user's directory is denied.



Shyam Goyal
Sr. Software Dev. Manager
Reply
Reply
0 Likes