camera scripting

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
zvoros
Posts: 9
Joined: Sun Jul 08, 2018 9:05 am

camera scripting

Post by zvoros »

Hi all,

I'd like to put together an animation, and I would really like to use python. I have a very good reason for that. I've been trying to find a decent description on how to work with the camera, but I seem to come up against hard walls here. While there is scattered information on the subject, the problem is exactly that, that is scattered. I know how to move objects around, I have difficulties with the camera only.

My question is really simple: what do I need to do, if I want to set the camera to position (x, y, z), I want it to look at position (x0, y0, z0), or I want it to have an orientation (the top of its field of view) pointing to (x1, y1, z1), and I want it to have an aperture of phi degrees.

I would be more than happy to work on the documentation, if someone points me in the right direction.

Many thanks,

Zoltán
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: camera scripting

Post by chrisb »

Have a look at the code of the FCCamera addon macro.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: camera scripting

Post by mario52 »

Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
zvoros
Posts: 9
Joined: Sun Jul 08, 2018 9:05 am

Re: camera scripting

Post by zvoros »

Thanks, Chris! This is indeed useful.
zvoros
Posts: 9
Joined: Sun Jul 08, 2018 9:05 am

Re: camera scripting

Post by zvoros »

mario52 wrote: Sun Mar 19, 2023 9:56 pm camera animation Vila Matilde House, working with linked files
Fantastic, thanks! The reason I wanted to use python is that I need to add dynamic text to the scenes.
Last edited by zvoros on Sun Mar 19, 2023 11:09 pm, edited 1 time in total.
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: camera scripting

Post by mario52 »

Hi

Thanks chrisb

@zvoros other

Programmatically setting the center of rotation

Set camera position by script

COIN3D_Snippet

search.php?st=0&sk=t&sd=d&sr=posts&keyw ... f&start=10

Code: Select all

print(Gui.ActiveDocument.ActiveView.getCamera())
reading

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply