Local Render through API

Local Render through API

Anonymous
Not applicable
923 Views
4 Replies
Message 1 of 5

Local Render through API

Anonymous
Not applicable

This is a pickup upon an item at the end of the In-Canvas render thread . . .

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/in-canvas-render-through-api/td-p/9618616 

 

With In-Canvas render of scripted animations  (with limited resolution and with a hack) and Image capture in Design mode (not rendered but any resolution) implemented in the API, now for the real deal . . . Implement Local render (the teapot icon dialog) and save the result through the API.

 

Assuming that the Local Render selection and presets are setup manually, the API must:

  • Execute the render ("push" the Render button in the render dialog) . . . it is already possible to get into this dialog through the API but I'd think that not really necessary with an "Execute Local Render" command.
  • Don't return to the script until the render is finished (the render times are long and the adsk.doEvents() "timing" loop hack is a concern)
  • Access the latest entry in the render gallery and write it to a file path&name defined in the API
  • Hopefully, delete the gallery entry to preclude manual cleanup

Is this possible?

 

Render dialog suggestions: 

  • Frame the model to show the image that will be produced with each format selection (preset and custom)
  • Add 4k to the video preset selections

Thanks

 

 

0 Likes
924 Views
4 Replies
Replies (4)
Message 2 of 5

kandennti
Mentor
Mentor

Hi @Anonymous .

 

"It might be a possibility," not a direct solution.

I found the following on TextCommands.

Fusion.BatchRender       - Starts a local batch render.

https://github.com/kantoku-code/Fusion360_Small_Tools_for_Developers/blob/master/TextCommands/TextCommands_txt_Ver2_0_8176.txt#L636 

I tried everything, but it didn't run.

 

 

This is a completely different story.
"IN CANVAS RENDER", I found a way to determine if it is in process or not.

It seems that you can get a list of currently running tasks when you run the following in TextCommands(Txt)

Application.ListIdleTasks

Here's what it looks like when it's finished rendering.

1.png

 

Here's a rendering in progress.

2.png

 

The way I tried it, there are up to four "RRTRepaintTasks" displayed in one rendering operation.

 

The part of the loop that is currently waiting for the rendering to finish is

            for i in range(40000):
                adsk.doEvents()

"Application.ListIdleTasks" may help you to pick up on this for sure.

0 Likes
Message 3 of 5

Anonymous
Not applicable

kandennti . . . thanks for thinking about this

 

I can't find any discussions of BatchRender that suggest anything beyond using the cloud for renders.

 

On In-Canvas renders, to get decent render quality, the quality must be set to Infinite with the timing loop set to progress well into the render (which never ends without interruption).  In other words, Fusion can't really report when it's "done".    It would be helpful if the In-Canvas render had a render "cycles" input which could be specified as a stop point . . . but it doesn't (while the Local Render appears to have this).   The In-Canvas render script in the linked thread does do the job (setting the loop count experimentally) but the resolution limit (to a sub-region of monitor resolution) is the killer.

 

Hopefully, we'll find the necessary API controls for local render . . . or they will be added soon.

 

----------------------------------

As an aside . . . I've written a Fusion script that exports STL files (locally), one for each component.  By using a component naming convention that embeds the material name in the Fusion component STL filename (name the Fusion components: @Component.name&Material.name#), these files can then be imported into Blender where a blender script parses the object filenames (using the @Anonymous&...# delimiters), extracting the material name and assigns pre-defined materials (defined in a Blender template file) based upon the extracted STL material names, then renders the animation.   While this works, it's a lot more complicated than Fusion Local Render would be. 

 

It's advantage is that Blender has an excellent rendering engine and excellent AI denoise capability.  Blender also uses the GPU which can significantly improve render speed, particularly when combined with the denoiser which reduces the number of render cycles needed for an essentially noise free render. 

 

The disadvantage is that it requires learning at least the Blender basics and can involve a certain amount of Blender customization for different Fusion models.

 

 

Message 4 of 5

kandennti
Mentor
Mentor

I've never used Blender and don't plan to use it in the future, but I'm a little curious about it.

 

Does that mean I can export the STL file and have it processed by a Blender script at the same time?
(Is it possible to manipulate Blender from Fusion360?)

0 Likes
Message 5 of 5

Anonymous
Not applicable

I don't see doing this without a basic knowledge of Blender.   STL files don't include materials so it's necessary to define and assign new materials once the STL objects are imported.  I tried OBJ files (which do include material names) but abandoned this for multiple reasons.  I don't control Blender from Fusion.   My workflow executes a Fusion script to write the STL files.  Then, a Blender script (once in Blender) to import the files, assign materials and render.

 

If you should try Blender (and accept the learning curve) STL export the Fusion root component selecting the option for separate files for each body (so you can assign different materials to different bodies in Blender).  Best that components include only one body.  You'll get as many files as you have bodies.

 

Then import all the component (body) files into Blender.  They will be placed at the correct locations.  From then on, everything must be done in Blender, either manually or with a Blender script.