Is there a way to quickly hide / show controls...?


#1

Specifically, I’m looking to set up some kind of quick keys to show / hide all the various elements in the viewport. I realize that I can go up to the “filter” menu and either hit “ALL” or “NONE” - however, that doesn’t really do it, because I normally like to have certain of those options off all the time, and when I toggle “ALL” then those items get turned on by default.

I guess, what I’m after, is something like “COMMAND + SHIFT + H” in AfterEffects.

Anyone?

Thanks!


#2

I’m going to simplify my question. Forget all the items in the “filter” menu in the viewport. All I want / need to do is find a quick way to toggle on or off the “Sel: Wireframe” from the Display menu for the viewport. That would be great!


#3

Script it!

For example I use this to toggle the display of splines and nulls (typically controllers in character rigs).

Here’s the code (COFFEE). The ‘!’ means ‘not’ in COFFEE so it toggles. You should be able to adapt this for what you need I guess.


var draw = doc->GetActiveBaseDraw();
if(!draw) return;


draw#BASEDRAW_DISPLAYFILTER_NULL = !draw#BASEDRAW_DISPLAYFILTER_NULL;
draw#BASEDRAW_DISPLAYFILTER_SPLINE = !draw#BASEDRAW_DISPLAYFILTER_SPLINE;


#4

Hi, I agree with Horganovski, you can paste this in a new python script, save it and dock it in the layout (or assign an hotkey):


import c4d
from c4d import gui

def main():
    bd = doc.GetActiveBaseDraw()
    filter_state = bd[c4d.BASEDRAW_DATA_WIREFRAMESELECTION]
    if filter_state == 1:
        bd[c4d.BASEDRAW_DATA_WIREFRAMESELECTION] = 0
    else:
        bd[c4d.BASEDRAW_DATA_WIREFRAMESELECTION] = 1   
    c4d.EventAdd()
if __name__=='__main__':
    main()

this should toggle Sel. Wireframe on or off. Horganovski code is more elegant though :slight_smile:


#5

Guys, thank you SO much. I’ll give both script options a shot, and see if I can weed my way through.

Cheers!


#6

Wow — I can’t believe I’ve ignored COFFEE and Python for so long. 3 years into using C4D and I’m constantly surprised at how malleable it is. I had no idea you could drag just about any command or optionbox into the ScriptManager to mess around with it.

The homework never ends — now I’m spending the weekend reading up about COFFEE.

Thanks Horganovski and Visualtricks!


#7

Glad it helps! I’d recommend learning Python over COFFEE though as COFFEE seems to be pretty much dead in terms of development, I don’t think there have been significant updates to it in years. The Python docs are kind of poor in my opinion (they need a lot more examples for one thing like the docs for other apps, ahem!) but worth persevering with as Python seems to give you better access to the workings of C4D.

Cheers,
Brian


#8

Thanks Brian — there are so many places to learn Python online. Do you have a place you would recommend to start training, with a particular focus on getting up to speed with how to use it best in Cinema 4D?


#9

Cineversity has some good tutorials on it, and there is a wiki there that has a lot of useful tidbits of code.

When you wrap your head around how the classes work, it gets easier.

I’d recommend just finding scripts(grab any of the ones on my website) and start picking apart the code(hopefully I commented them).