A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
1 of 2
1
On/off switch all SDS generators (smoothing Hypernurbs)
Posted: 29 July 2019 05:56 AM   [ Ignore ]  
Avatar
Total Posts:  12
Joined  2014-09-14

Hi,

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?

Many thanks in advance!

Profile
 
 
Posted: 29 July 2019 07:00 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Good Monday!

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.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 29 July 2019 04:00 PM   [ Ignore ]   [ # 2 ]  
Total Posts:  292
Joined  2017-09-24

Hi @Good Monday

Can you try this script? It toggles the hypernurbs/sds to on/off.

import c4d

def get_all_objects
(op):
    
    
obj_list []

    
while op:
        if 
op.CheckType(c4d.Osds):
            
obj_list.append(op)
        
get_all_objects(op.GetDown())
        
op op.GetNext()
    return 
obj_list

def main
():
    
    
hyper_nurbs get_all_objects(doc.GetFirstObject())

    for 
nurbs in hyper_nurbs:
        
nurbs[c4d.ID_BASEOBJECT_GENERATOR_FLAG] not nurbs[c4d.ID_BASEOBJECT_GENERATOR_FLAG]
        
    c4d
.EventAdd()

if 
__name__=='__main__':
    
main() 
 Signature 

C4D Body Mechanics Rigs (Gumroad)  //    Website

Profile
 
 
Posted: 29 July 2019 05:57 PM   [ Ignore ]   [ # 3 ]  
Avatar
Total Posts:  12
Joined  2014-09-14
Dr. Sassi - 29 July 2019 07:00 AM

Hi Good Monday!

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

Profile
 
 
Posted: 29 July 2019 06:01 PM   [ Ignore ]   [ # 4 ]  
Total Posts:  292
Joined  2017-09-24

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?

 Signature 

C4D Body Mechanics Rigs (Gumroad)  //    Website

Profile
 
 
Posted: 29 July 2019 06:01 PM   [ Ignore ]   [ # 5 ]  
Avatar
Total Posts:  12
Joined  2014-09-14
bentraje - 29 July 2019 04:00 PM

Hi @Good Monday

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.

All the best,
Frederik

Profile
 
 
Posted: 29 July 2019 11:23 PM   [ Ignore ]   [ # 6 ]  
Avatar
Total Posts:  12
Joined  2014-09-14
bentraje - 29 July 2019 06:01 PM

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! 😊

Profile
 
 
Posted: 29 July 2019 11:31 PM   [ Ignore ]   [ # 7 ]  
Total Posts:  292
Joined  2017-09-24

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!

 Signature 

C4D Body Mechanics Rigs (Gumroad)  //    Website

Profile
 
 
Posted: 30 July 2019 12:15 AM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re very welcome, Frederik.

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

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 30 July 2019 08:24 PM   [ Ignore ]   [ # 9 ]  
Total Posts:  15
Joined  2014-08-26

Had the same issue (global SDS toggle), thanks bentraje and Dr. Sassi for your helpful suggestions!

Profile
 
 
Posted: 01 August 2019 04:22 AM   [ Ignore ]   [ # 10 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re welcome, Pixelschubser.

Cheers

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 02 August 2019 03:41 AM   [ Ignore ]   [ # 11 ]  
Avatar
Total Posts:  12
Joined  2014-09-14
bentraje - 29 July 2019 11:31 PM

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 wink 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?

Many thanks again and have a great weekend! smile

/ Frederik

Profile
 
 
Posted: 02 August 2019 04:20 AM   [ Ignore ]   [ # 12 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Frederik,

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.

https://plugincafe.maxon.net

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.

Have a great weekend

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 02 August 2019 05:41 AM   [ Ignore ]   [ # 13 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

P.S.: DIY Version, which can be set up in a minute, and allows to be reused in the scene as often as needed.

Screen capture and scene file
https://www.amazon.com/clouddrive/share/jd8yKDsMdrM1X2XECD5gqlQ2gZpyle1sNbI6tkDfjiT

Cheers

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 05 August 2019 07:26 PM   [ Ignore ]   [ # 14 ]  
Total Posts:  15
Joined  2014-08-26

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()

if 
__name__=='__main__':
    
main() 
Profile
 
 
Posted: 05 August 2019 10:53 PM   [ Ignore ]   [ # 15 ]  
Total Posts:  292
Joined  2017-09-24

Thanks @Pixelschubser for the help.

@Good Monday
I would have more or less the same implementation with @Pixel’s script smile

 Signature 

C4D Body Mechanics Rigs (Gumroad)  //    Website

Profile
 
 
   
1 of 2
1