Macro Colorize

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Macro Colorize

Post by TheMarkster »

With this macro you can set individual colors and transparency levels of faces, edges, and points. Select the subobjects and run the macro. The color picker dialog comes up:
Snip macro screenshot-9bf321.png
Snip macro screenshot-9bf321.png (27.41 KiB) Viewed 5933 times
Select the color and alpha level as desired, and press okay.

Special note on alpha: the default 255 would make the color fully transparent, which is not what will be typically wanted, so I inverted this value to mean fully opaque and 0 = fully transparent.

https://wiki.freecadweb.org/Macro_Colorize

Notice with this cube some of the edges are red and some are default black:
Snip macro screenshot-160316.png
Snip macro screenshot-160316.png (26.49 KiB) Viewed 5933 times
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Macro Colorize

Post by TheMarkster »

Works with sketches, too, but not with the editor open. I guess the editor overrides those colors, but this is a good thing because edge color inside the editor gives a lot of useful information.
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Macro Colorize

Post by TheMarkster »

This can be useful for peeking inside a solid, by making one or more faces transparent and setting the ViewObject Lighting property to Two side.
Snip macro screenshot-992012.png
Snip macro screenshot-992012.png (45.81 KiB) Viewed 5756 times
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Macro Colorize

Post by HoWil »

TheMarkster wrote: Sun Dec 12, 2021 2:12 am This can be useful for peeking inside a solid, by making one or more faces transparent and setting the ViewObject Lighting property to Two side.

Snip macro screenshot-992012.png
Can this be used to select inner faces for FEM wb as described e.g. here https://forum.freecadweb.org/viewtopic. ... 70#p146370?
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Macro Colorize

Post by TheMarkster »

The transparent face still gets preselected when the mouse is hovered over it, and although the preselection is only semi-transparent it still blocks you from selecting objects behind it. I tried turning off color on preselection, but it still blocks you from selecting another face from the inside.
mario52
Veteran
Posts: 4696
Joined: Wed May 16, 2012 2:13 pm

Re: Macro Colorize

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.
Post Reply