Is there a script for R20 to “toggle all SDS generators” on/off? I have one script for R19 (using the old code) that does just that and I find it very valuable since I can turn the smoothing in my scene on and off using the ‘Tab’ key (for example). The plugin I have for R19 is called “HN_and_CN Switch.CSC” (not sure where I have found it), but it doesn’t work in R20.
There is a built-in R20 script to “Toggle parent Generator”, but this one only toggles the active object.. I want to toggle ALL generators at once.
Or is it simple to create a Python script that does this?
For a single child object, to toggle the Parent Generator would be Q, and you like to have that for all SDS.
Select all the SDS in question (perhaps with the Object Manager>Magnifying Glass option/Search).
While all are selected, go to the Main Menu> Select> Selection Filter> Create Selection Object… (Perhaps name it appropriately.)
This holds now all previously selected SDS objects. While the Selection Object is selected, the Attribute Manager> Object> Restore Selection, will recreate this previous selection and shows all attributes in the Attribute manager then. Go to Basics> Enable to check it off or on. Done. The beauty of it is that the list in the Selection object shows clearly what is inside of it. New objects can be dragged to this list, or other existing objects can be deleted.
I tried to use the Script Log and Script manager, to create a short cut, but no luck.
As a side note, perhaps explore the Level of Detail options.
Select all the SDS in question (perhaps with the Object Manager>Magnifying Glass option/Search).
While all are selected, go to the Main Menu> Select> Selection Filter> Create Selection Object… (Perhaps name it appropriately.)
This holds now all previously selected SDS objects. While the Selection Object is selected, the Attribute Manager> Object> Restore Selection, will recreate this previous selection and shows all attributes in the Attribute manager then. Go to Basics> Enable to check it off or on. Done. The beauty of it is that the list in the Selection object shows clearly what is inside of it. New objects can be dragged to this list, or other existing objects can be deleted.
As a side note, perhaps explore the Level of Detail options.
All the best
Thanks Dr Sassi! Great tip about the ‘Selection Object’, I’ve never used that before and I will check into it. For this purpose though I believe a single keyboard shortcut for switching all the SDS generators on/off would be simpler/faster. I really miss my old plugins when using R20..
Can you try this script? It toggles the hypernurbs/sds to on/off.
Wow, this is brilliant! Does exactly what my old “Hypernurbs switch” does in R19. Many thanks for helping with this script so quickly. Just added the ‘Tab’ shortcut and everything seems to work as expected.
RE: For this purpose though I believe a single keyboard shortcut for switching all the SDS generators on/off would be simpler/faster.
Uhm. That was the purpose of the script I made above? Or are you looking for something else?
@bentraje — Your script works perfect, exactly what I was looking for! I replied to you in a post just after the one you quoted, so sorry if there was a misunderstanding. Your script was much appreciated! 😊
Oh no worries. Must have missed it due to successive notifications. Sorry about the unnecessary reply.
If you have other older scripts, I can update them to R20, if they are simple to implement.
I’m glad you found something that that fits your question in this thread.
My best wishes
Good Monday - 29 July 2019 05:57 PM
Thanks Dr Sassi! Great tip about the ‘Selection Object’, I’ve never used that before and I will check into it. For this purpose though I believe a single keyboard shortcut for switching all the SDS generators on/off would be simpler/faster. I really miss my old plugins when using R20..
Oh no worries. Must have missed it due to successive notifications. Sorry about the unnecessary reply.
If you have other older scripts, I can update them to R20, if they are simple to implement.
Have a great day ahead!
Hi again, if you have time and enjoy coding then I just noticed that your script above doesn’t seem to affect SDS/Hypernurb generators that are placed inside a ‘Null Object’. If this is easy to implement then I’d love this feature included in your script.
The old “HN_Switch plugin” I used in R19 also kept all the SDS/Hypernurbs generators “synchronized” when using the script. So if two ‘SDS objects’ were switched OFF and a third was switched ON, before I used the script (hit the Tab key), then the plugin only enabled the two switches that was turned OFF. My next click on the ‘Tab’ key made all the generators turned off (synchronized). Would you have any help of looking at the old plugin to add this functionality also?
Maxon has its very own Developer Forum, and that is the place to go to get in touch with the very best people for Cinema 4D scripting, sharing ideas, etc.
I try to keep that separated to allow for the best outcome. Yes, it is designed for Plugin Developers, hence why I hesitate a little bit, but perhaps one catches fire and Python becomes the favorite tool.
BTW, would you mind putting all SDS on a single Layer? There you could switch the generator on and off.
Sorry, doing this from scratch but based on the script bentraje posted.
Good Monday - 02 August 2019 03:41 AM
...I just noticed that your script above doesn’t seem to affect SDS/Hypernurb generators that are placed inside a ‘Null Object’.
I modified the obj_list references (so nested objects don’t get lost during the recursive call and thus hypernurbs inside null objects should be considered).
Good Monday - 02 August 2019 03:41 AM
The old “HN_Switch plugin” I used in R19 also kept all the SDS/Hypernurbs generators “synchronized” when using the script. So if two ‘SDS objects’ were switched OFF and a third was switched ON, before I used the script (hit the Tab key), then the plugin only enabled the two switches that was turned OFF. My next click on the ‘Tab’ key made all the generators turned off (synchronized). Would you have any help of looking at the old plugin to add this functionality also?
I added a (nasty, bad style) global variable to keep the initial state. On first run it gets the state of the first object, on each additional run it negates it. Does this reflect your desired behavior?
import c4d obj_list = [] basestate = None
def get_all_objects(op):
while op: if op.CheckType(c4d.Osds): obj_list.append(op) get_all_objects(op.GetDown()) op = op.GetNext() return obj_list
def main(): global basestate global obj_list obj_list=[] hyper_nurbs = get_all_objects(doc.GetFirstObject()) for nurbs in hyper_nurbs: if basestate is None: basestate=nurbs[c4d.ID_BASEOBJECT_GENERATOR_FLAG] nurbs[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = not basestate c4d.EventAdd()