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: 

Transparent capture image

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
nubrandao
187 Views, 5 Replies

Transparent capture image

Hi, i use setup excel sheet from fusion post to get my strategys, in the excell makes a print screen, the problem is that my background color is black, and the image captured imagem cames in black when printing,

 

can somehelp help me change the post to capture imagem with transparent background? 

i know there is a option in capture imagem, but my post has no comand to capture imagem to transparent.

 

nubrandao_0-1727558721794.png

 

5 REPLIES 5
Message 2 of 6
rohit_maneYV8C9
in reply to: nubrandao

Hello @nubrandao ,

Due to limited access to the post engine, we can’t set a background color for the model image, as it’s defined by the line keywords = "MODEL_IMAGE PREVIEW_IMAGE";. Unlike in Fusion, we don’t have direct access to modify settings through the post processor while capturing images.

We could technically change the RGB values using a canvas, drawing the same image pixel by pixel to apply a background color. However, this approach has drawbacks: the background color must be uniform and cannot overlap with the model colors. Additionally, I'm unsure how much processing time it would require, so I wouldn’t recommend it.

Let me know if you have any other idea!!!

Message 3 of 6

You can use the API to set any options in the Rendering workspace. Below is a simple sample that renders the active design with a transparent background.

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent
        
        # Get the RenderManager from the Design and set the resolution of the output image.
        rm = des.renderManager
        render = rm.rendering
        render.resolution = adsk.fusion.RenderResolutions.Mobile1920x1080RenderResolution
        render.isBackgroundTransparent = True

        # Define the filename for this frame.
        filename = 'C:/Temp/RenderSample.png'

        # Start the render.
        future = render.startLocalRender(filename)

        waiting = True
        while waiting:
            if future.renderState != adsk.fusion.LocalRenderStates.ProcessingLocalRenderState:
                waiting = False

        if future.renderState == adsk.fusion.LocalRenderStates.FinishedLocalRenderState:
            ui.messageBox(f'Render is finished to: {filename}.')
        elif future.renderState == adsk.fusion.LocalRenderStates.FailedLocalRenderState:
            ui.messageBox('Rendering Failed.')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 6
nubrandao
in reply to: BrianEkins

I'm going to try thanks 

Message 5 of 6
nubrandao
in reply to: BrianEkins

Can't this command be add to the post setup Excell?

 

At the top?

 

So everytime it runs the post, it will change background to transparent right?

Message 6 of 6
BrianEkins
in reply to: nubrandao

This doesn't change the background. It uses the Rendering functionality associated with the Design to create a new ray-traced image with a transparent background. I don't know if it will work while the Manufacturing workspace is active, but you can try it and see. 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report