Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

How do I programmatically control the render settings?

Anonymous

How do I programmatically control the render settings?

Anonymous
Not applicable

I want to create a script that presets my render preferences and hits the render button.

I haven't found any documentation on the Render API.

How can I achieve this?

1 Like
Reply
771 Views
7 Replies
Replies (7)

Anonymous
Not applicable

I tried listening for the render settings dialog creation event and calling the doExecute() method to trigger the render with the already existing presets, but this unfortunately doesn't work. 

How can I access the render button and the other controls?

0 Likes

kandennti
Mentor
Mentor

Hi Leon.Vladimirov.

 

I don't know how to access the controls.
But there is a way to execute the command.


I tried and it was possible to start rendering.

#Fusion360API Python script
#Author-kantoku
#Description-sample start rendering

import adsk.core, adsk.fusion, traceback

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

        # new document
        desType = adsk.core.DocumentTypes.FusionDesignDocumentType
        app.documents.add(desType)
        des  :adsk.fusion.Design = app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        # create body
        createBody(root)

        # change workspace
        des.workspaces.itemById('FusionRenderEnvironment').activate()

        # start rendering
        cmdDefs :adsk.core.CommandDefinitions = ui.commandDefinitions
        cmdDef  :adsk.core.CommandDefinition = cmdDefs.itemById('InCanvasRenderCommand')
        cmdDef.execute()

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def createBody(
    comp :adsk.fusion.Component):

    skts = comp.sketches
    skt = skts.add(comp.xZConstructionPlane)
    ctr = adsk.core.Point3D.create(0, 0, 0)
    skt.sketchCurves.sketchCircles.addByCenterRadius(ctr, 5.0)
    
    prof = skt.profiles.item(0)

    exts = comp.features.extrudeFeatures
    newBodyOpe = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
    ext = exts.createInput(prof, newBodyOpe)
    
    dist = adsk.core.ValueInput.createByReal(5)
    ext.setDistanceExtent(True, dist)
    exts.add(ext)
2 Likes

Anonymous
Not applicable

Hi! 
Thank you for your answer.

But unfortunately this is not what I’m looking for. I’m trying to automate cloud rendering. From my understanding this script will render in canvas - which can be done with one press of a button, instead of pressing a button in the cloud render dialog. 

Is there a way to automatically start cloud rendering?

0 Likes

kandennti
Mentor
Mentor

I'm sorry, I misunderstood.

 

I don't know how to operate dialog buttons.
Sorry for not being able to help.

0 Likes

goyals
Autodesk
Autodesk

May be you can try with the below script. You need to save the design before executing this command.

 

cmdDefs = ui.commandDefinitions

cmdDef = cmdDefs.itemById('A360RenderCommand')

cmdDef.execute()



Shyam Goyal
Sr. Software Dev. Manager
0 Likes

Anonymous
Not applicable

Thank you for your answer!

But unfortunately I still can't get my design to render. The command your suggested opens the rending tab, but I still haven't found a way to click the render button inside the tab via code.

 

Do you know how I can achieve this? 

 

0 Likes

goyals
Autodesk
Autodesk

Looks like It is not possible. You can get the render button control in the dialog using below script but there is no 'click 'method available on button control

 

controlDef = cmdDef.controlDefinition

buttonCtrlDef = adsk.core.ButtonControlDefinition.cast(controlDef)

buttonCtrlDef.name

 



Shyam Goyal
Sr. Software Dev. Manager
1 Like