Modular electric urban vehicles

Show off your FreeCAD projects here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
F_Rosa
Posts: 265
Joined: Thu Feb 18, 2016 10:39 pm
Location: São Paulo
Contact:

Re: Modular electric urban vehicles

Post by F_Rosa »

One more.
Attachments
Perspectiva_composicoes_06.jpg
Perspectiva_composicoes_06.jpg (132.39 KiB) Viewed 1942 times
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: Modular electric urban vehicles

Post by paullee »

That's impressive, as always :D
F_Rosa
Posts: 265
Joined: Thu Feb 18, 2016 10:39 pm
Location: São Paulo
Contact:

Re: Modular electric urban vehicles

Post by F_Rosa »

paullee wrote: Wed Oct 12, 2022 5:02 pm That's impressive, as always :D
Thank you!

By the way, could anybody help me to create a macro to run the animation and automatically save the respective images rendered by povray?
And/or would anyone know how to export to povray including the animation sequences produced in FC? :roll:
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: Modular electric urban vehicles

Post by howetuft »

Hello,

Nice renders, really!
would anyone know how to export to povray including the animation sequences produced in FC?
Not sure it's possible. As far as I am concerned, Pov-Ray is not designed for animation, neither Render WB. Your first approach (animate in FreeCAD and render at each step) seems better.

could anybody help me to create a macro to run the animation and automatically save the respective images
I'm not skilled in animation in FreeCAD, but I can give you a hint with Render.
This Python statement will trigger rendering and eventually return the path to the rendered file:

Code: Select all

output_file = project.Proxy.render(wait_for_completion=True)
(given that project is a variable pointing to your project...)

So, if you can loop into your animation, you could render at each step and save the output. Something like that:

Code: Select all

import Render
project = App.getDocument("YourDocument").getObject("YourPovrayProject")

for <something looping into the animation>:
    output_file = project.Proxy.render(wait_for_completion=True)
    <save output_file into a specific location with a specific filename>
Just take into account that Render will reuse the same output_file from a rendering to another, so you'll have to generate a specific filename at each step...
alexu
Posts: 30
Joined: Tue Nov 26, 2019 2:14 pm

Re: Modular electric urban vehicles

Post by alexu »

howetuft wrote: Fri Oct 14, 2022 8:19 am Hello,

Nice renders, really!
would anyone know how to export to povray including the animation sequences produced in FC?
Not sure it's possible. As far as I am concerned, Pov-Ray is not designed for animation, neither Render WB. Your first approach (animate in FreeCAD and render at each step) seems better.
Pov-Ray has its own Screen Description Language (http://www.povray.org/documentation/3.7.0/r3_0.html) that fully supports animation. You would have to write a FC script that understands the FC animation language and translate it into the Pov-Ray animation language.
F_Rosa
Posts: 265
Joined: Thu Feb 18, 2016 10:39 pm
Location: São Paulo
Contact:

Re: Modular electric urban vehicles

Post by F_Rosa »

Thank you, howetuft, for the feedback!

I would like to better explain the two suggestions.

1. Perform the animations rendered within FC.
  • 1.1. Create the render project (Povray Project, for example) by configuring it and defining the name and destination folder of the created images (they would be automatically numbered, as created and saved);
    1.2. Create the animation sequence (with ExplodedAssembly, for example);
    1.3. Select the render project and animation and click the render animation button.

2. Perform the animations rendered outside of FC.
  • 2.1. Same as 1.1.;
    2.2. Same as 1.2.;
    2.3. Select the render project and animation and click the renderer export button (Povray, for example).
    2.4. Open the exported file in the corresponding program and perform the animations, they would be saved automatically according to the settings made in step 2.1.

For isolated rendered images, performing them within FC is much more practical and faster, as all project changes are already updated in the next render. However, as animations are generally time-consuming (hours, and sometimes days), performing them independently, and if possible in background, seems advantageous.

What, in my view, would be necessary to carry out the steps described:
  • Steps 1.1. and 2.1. - The option to define the folder and file name is already present in the render project's property window (although I haven't managed to use it successfully yet), it would be necessary to add the possibility of automatic numbering of the created images;
    Steps 1.2. and 2.2. - For a rendered animation, you would have to create an instruction indicating that at each step of the animation (Animation Step) the render would be performed;
    Step 1.3. - Totally new item. In your suggestion

    Code: Select all

    import Render
    project = App.getDocument("YourDocument").getObject("YourPovrayProject")
    
    for <something looping into the animation>:
        output_file = project.Proxy.render(wait_for_completion=True)
        <save output_file into a specific location with a specific filename>

    I understand that for <something looping into the animation> would enter the instruction to perform each step of a given animation sequence, correct?
    In <save output_file into a specific location with a specific filename> wouldn't it be possible to include an instruction to number the output files automatically?

    Step 2.3. Partly new item. In this case, the animation instructions would be added when exporting the file to the renderer.
    Step 2.4. In the case of Povray, as alexu mentions, the animations are possible.
Last edited by F_Rosa on Fri Oct 14, 2022 8:57 pm, edited 1 time in total.
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: Modular electric urban vehicles

Post by howetuft »

Well, your suggestions are interesting but they both require heavy development in Render (don't forget Render is not restricted to povray)... and I'm not really avalaible at now.

My suggestion is just to write a lightweight macro/Python script to do the job. If you need to make it run in background, you can use FreeCAD console.

To refine my code, I would propose (not tested yet):

Code: Select all

import shutils
import Render

project = App.getDocument("YourDocument").getObject("YourPovrayProject")
NUMBER_OF_STEPS = ...  # Fill in the right value

<reset animation>

for i in range(NUMBER_OF_STEPS):
    <move the animation one step forward>
    output_file = project.Proxy.render(wait_for_completion=True)
    shutils.move(output_file, f"path/to/target/file{i:05}")
I'll try to test it this week-end...
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: Modular electric urban vehicles

Post by howetuft »

@F_Rosa Unfortunately, no good news: I couldn't get my idea above to work (I can't get the animation to take a fine enough unit step...).
There might be ways to make it work with some specific development in the workbench, but that would take a lot of time, and I'm already busy with another complex task (texture implementation)...
The conclusion is that, at this stage, Render is limited to its primary goal, which is taking snapshots.

However, if you really need rendered animations, there is an integration solution with Blender (Sverchok) that allows to take advantage of Blender's power and especially of its animation features, at the cost of a higher setup complexity: that may be a solution...
F_Rosa
Posts: 265
Joined: Thu Feb 18, 2016 10:39 pm
Location: São Paulo
Contact:

Re: Modular electric urban vehicles

Post by F_Rosa »

howetuft wrote: Sat Oct 15, 2022 6:25 am @F_Rosa Unfortunately, no good news: I couldn't get my idea above to work (I can't get the animation to take a fine enough unit step...).
There might be ways to make it work with some specific development in the workbench, but that would take a lot of time, and I'm already busy with another complex task (texture implementation)...
I understand and thank you for your effort. It would be necessary to create a subcommand to advance only one step at a time, perhaps derived from the PlayForward command of the ExplodedAssembly Workbench, for example.
howetuft wrote: Sat Oct 15, 2022 6:25 am However, if you really need rendered animations, there is an integration solution with Blender (Sverchok) that allows to take advantage of Blender's power and especially of its animation features, at the cost of a higher setup complexity: that may be a solution...
The idea is to expand the representation of animations performed in FC, in general. As there are already workbenches for animations and rendering, the intention would be to integrate them.

I know Blender well, but I've never used Sverchok. Thanks for the tip.
Last edited by F_Rosa on Mon Oct 17, 2022 3:35 pm, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Modular electric urban vehicles

Post by Kunda1 »

If you need help with scripting, ask on the python and macro subforum.

BTW, awesome work!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply