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: 

Regression in saving view as image file using API on Mac

4 REPLIES 4
Reply
Message 1 of 5
BrianEkins
355 Views, 4 Replies

Regression in saving view as image file using API on Mac

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
4 REPLIES 4
Message 2 of 5
goyals
in reply to: BrianEkins

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
Message 3 of 5
BrianEkins
in reply to: goyals

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
Message 4 of 5
goyals
in reply to: BrianEkins

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



Shyam Goyal
Sr. Software Dev. Manager
Message 5 of 5
goyals
in reply to: goyals

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

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