Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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: 

How do I programmatically control the render settings?

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
754 Views, 7 Replies

How do I programmatically control the render settings?

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?

Tags (2)
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

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?

Message 3 of 8
kandennti
in reply to: Anonymous

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)
Message 4 of 8
Anonymous
in reply to: kandennti

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?

Message 5 of 8
kandennti
in reply to: Anonymous

I'm sorry, I misunderstood.

 

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

Message 6 of 8
goyals
in reply to: kandennti

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
Message 7 of 8
Anonymous
in reply to: goyals

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? 

 

Message 8 of 8
goyals
in reply to: Anonymous

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

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

Post to forums  

Autodesk Design & Make Report