Scripting - adding text notes to screenshot images

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
mnc5
Posts: 26
Joined: Tue Nov 07, 2017 7:34 pm

Scripting - adding text notes to screenshot images

Post by mnc5 »

Hello community,
I would like to ask for advice here.

I am running an animation in FreeCAD (moving/rotating parts in the assembly) and want to create a gif animation. The way I do it is to make a screenshot of FreeCAD active view at every step in animation.

Code: Select all

FreeCADGui.activeDocument().activeView().saveImage('Image Path'+ f"{i:04d}.png",1000,1000,'White')
Then I use another python script (imageio library) to bundle all these images together (two or three hundreds) into gif file.

(?) So, my question is whether I can add some text notes on these images before/while saving them in FreeCAD? I want to add some changeable variables, like degrees of rotation, timing, transition for some of the parts; therefore batch editing of these images after they are already saved seems to be complicated. The only way I see how to do it is to integrate these changeable variables into the image file names and then post-process them via some kind of python script. But this is obviously far from being an elegant solution :D.

(?) Follow-up question. If I have several FreeCAD files open (have several views) is it possible to capture the image from all of them at the same and not only from the activeView ?

Thanks!
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Scripting - adding text notes to screenshot images

Post by heda »

#1 Draft_Label
#2 dunno, but it is always possible to use qt's snip, which can be the whole screen if you like - check out Macro_Snip for inspiration.
mnc5
Posts: 26
Joined: Tue Nov 07, 2017 7:34 pm

Re: Scripting - adding text notes to screenshot images

Post by mnc5 »

heda wrote: Sat Jul 16, 2022 1:45 pm #1 Draft_Label
Thanks for reference. Spent some time searching, but couldn't figure it out, so maybe you could also advise on how to add a draft.label or draft.text parallel to the current view of the viewpoint (i.e. perpendicular to the camera view, so it is properly visible on the screenshot).
User avatar
Roy_043
Veteran
Posts: 8573
Joined: Thu Dec 27, 2018 12:28 pm

Re: Scripting - adding text notes to screenshot images

Post by Roy_043 »

Change the "Display Mode" of the text.
Post Reply