
Not applicable
07-05-2020
10:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Working on a script to generate in-canvas rendered animation from a design mode script that animates a model.
At this point, just working on a building block to render a single frame and save to the first of an image sequence using this script:
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
des :adsk.fusion.Design = app.activeProduct
root :adsk.fusion.Component = des.rootComponent
# Render Workspace
renderWS = ui.workspaces.itemById("FusionRenderEnvironment")
renderWS.activate()
# Render
cmdDefs :adsk.core.CommandDefinitions = ui.commandDefinitions
cmdDef :adsk.core.CommandDefinition = cmdDefs.itemById('InCanvasRenderCommand')
cmdDef.execute()
adsk.doEvents()
# Save Image File
imageFolder = 'F:/CAD Tests/Animation Sequence/'
frameNumber = 0
filename = imageFolder + "Test-" + str(frameNumber).zfill(4) + '.jpg'
app.activeViewport.saveAsImageFile(filename, 0, 0)
adsk.doEvents()
# Design Workspace
designWS = ui.workspaces.itemById("FusionDesignEnvironment")
designWS.activate()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Two problems so far:
- Running script from design mode, it does shift to render mode and renders the model . . . But, while the save file code does work, it captures the initial, pre-rendered image rather than waiting for the render to complete and then save the rendered image.
- The code to switch back to design mode does not work. I've tried "Design" and "Model" but neither works. Correct syntax? I'm assuming that I do need to go back to design mode for each step in the model animation.
Also . . . I'm assuming that the resolution option in app.activeViewport.saveAsImageFile(filename, 0, 0) will not work for the rendered image which, I believe, is limited to monitor resolution (even if it were to upscale the image, it wouldn't really improve the resolution). Is this correct? If so, I'm assuming that resolution could be improved by adding a higher resolution monitor.
Thanks
Solved! Go to Solution.