name 'viewport_var' is not defined

name 'viewport_var' is not defined

chiefmech.nika
Explorer Explorer
665 Views
1 Reply
Message 1 of 2

name 'viewport_var' is not defined

chiefmech.nika
Explorer
Explorer

Failed:

Traceback (most recent call last):

File "C:/Users/chief/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/NewScript1/NewScript1.py", line 31, in run

returnValue = viewport_var.saveAsImageFile(fileName, 500, 500)

NameError: name 'viewport_var' is not defined

 

I want to make a script that will take a photo of every detail and save it. As far as I understand, the program asks me for an object, I don't quite understand which one or how to add it. Help, thanks.

 

 

0 Likes
Accepted solutions (1)
666 Views
1 Reply
Reply (1)
Message 2 of 2

tykapl.breuil
Advocate
Advocate
Accepted solution

The viewport_var variable is unassigned.

You can find the object over at app.activeViewPort which will give you the current viewport ie what you see on the screen. The saveAsImageFile method then amounts to taking a screen capture like you would do through the button in the file dropdown.

However, that means the image you will export will be the same for all of the components, you might want to try hiding the components before calling the viewport.fit() function that automatically sets the camera in order to put every visible object on frame (more or less pressing home on the viewcube).