How to take pictures of the different faces of a cube on Fusion 360 (using an Add-in or a Script)

How to take pictures of the different faces of a cube on Fusion 360 (using an Add-in or a Script)

201933238
Explorer Explorer
532 Views
3 Replies
Message 1 of 4

How to take pictures of the different faces of a cube on Fusion 360 (using an Add-in or a Script)

201933238
Explorer
Explorer

I am really new with Fusion 360 and I would like to create an Add-in or a Script that would allow me to take pictures of the different faces of a 3D object and save them. I've made something that seems like it could work, but Visual studio keep telling me that I can't use the command AppearanceCapture and AppearanceCaptureOptions. While later I would like to make a program that could work with any 3D shape, for now I simply want to be able to get pictures of the different faces of a cube (baby steps).

 

Could any one of you help me with my problem or give me idea on how I could do this?

Linked to this post is the code I've made.

 

Thank you in advance!

0 Likes
Accepted solutions (1)
533 Views
3 Replies
Replies (3)
Message 2 of 4

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I wrote the following function to capture images of different views (you can call it from script's run() function):

 

def save_view_images():
    WIDTH = 400
    HEIGHT = 300

    app = adsk.core.Application.get()
    des: adsk.fusion.Design = adsk.fusion.Design.cast(app.activeProduct)

    for nv in des.namedViews:
        nv.apply()
        app.activeViewport.saveAsImageFile(f'/99tmp/views/{nv.name}.png', WIDTH, HEIGHT)

 

 

It reads the custom views you have defined in the current design:

Jorge_Jaramillo_0-1695346353582.png

 

And save an image of every view. This is the result:

Jorge_Jaramillo_1-1695346551250.png

 

I hope this could help you out.

 

Regards,

Jorge Jaramillo

Software Engineer

 

Message 3 of 4

201933238
Explorer
Explorer

Hi,

 

Thank you very much for helping me with this matter. The solution you gave me is miles beyond what I was originally thinking of doing.

 

I added your solution to a new fusion 360 script however it doesn't seem to be working (the fault is most likely that I forgot to add something).

 

Sans titre.png

 

201933238_0-1695609856392.png

When I try to run the script I am met with this :

Sans titre2.png

Again, I am certain the problem is linked to the fact that I forgot something. Could you help me understand what I am missing please.

 

Regards,

A student who is interested in learning python

 

 

0 Likes
Message 4 of 4

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

Hi @201933238 ,

 

The Design.namedViews property is new in September-2023 updated version:

Jorge_Jaramillo_0-1695616160682.png

 

Make sure you have the latest Fusion 360 update and it will run without errors.

I'm running on this version:  app.version='2.0.17244'

 

Regards,

Jorge Jaramillo

Software Engineer