Jump to content
Sign in to follow this  
eliss

C4D Xpresso show/hide User Data

Recommended Posts

I was wondering if it's possible to show/hide sliders in the user data panel if a Boolean box is checked/unchecked. If so how would I go about doing this?

Thanks in advance.

Share this post


Link to post
Share on other sites

Don't think so. It may be possible with COFFEE/ Python, but not XPresso. XPresso node are just instances of other data sources, not the other way around....

 

Mylenium

Share this post


Link to post
Share on other sites

you can make groups, and then you can fold/unfold menu's.

 

but as far as having xpresso affect that, not sure. maybe some of the more xpresso oriented folks here will be able to help you on this one.

Share this post


Link to post
Share on other sites

Over at Cg Talk there was a discussion on this, if i remember correctly the result was that you were able to do something with Python, but it was cumbersom.

Share this post


Link to post
Share on other sites

How about a check box that disables a slider? Anyone?

 

Don't know how would you do this in Xpresso. But in a true plugin, you You make a subclass of your NodeData class of choice (ObjectData, TagData, etc) and override the GetDEnabling function. There you can grey or ungrey sliders based on their DescIDs. So for example you can say if a check box is False then the Slider returns False from GetDEnabling making it grey out.

Share this post


Link to post
Share on other sites

i edited scotts code a little bit to come up with this file :

 

http://www.mediafire.com/?waqrc3rre8abvgi

 

The User Data is on the Python Tag.

Check / Uncheck the Checkbox User Data and the other User Data magically disappears / reappears.

 

import c4d
from c4d import gui
def main():
     UD = op.GetUserDataContainer() #Get the the container for all UD entries
     for descId, container in UD: #Loop through all the id's in the container
      if descId[1].id == 1: #The specific UD you want to hide
        if op[c4d.ID_USERDATA,2] == 1: #If the checkBox is checked
           container[c4d.DESC_HIDE] = True #Set it to hidden in memory
          op.SetUserDataContainer(descId, container) #Execute that hidden setting from memory
          c4d.EventAdd()
         if op[c4d.ID_USERDATA,2] == 0: #If the checkBox is unchecked
           container[c4d.DESC_HIDE] = False #Set it to hidden in memory
           op.SetUserDataContainer(descId, container) #Execute that hidden setting from memory
          c4d.EventAdd()
if __name__=='__main__':
   main()

 

hope that helps,

d

Share this post


Link to post
Share on other sites

i edited scotts code a little bit to come up with this file :

 

http://www.mediafire...waqrc3rre8abvgi

 

The User Data is on the Python Tag.

Check / Uncheck the Checkbox User Data and the other User Data magically disappears / reappears.

 

import c4d
from c4d import gui
def main():
   UD = op.GetUserDataContainer() #Get the the container for all UD entries
   for descId, container in UD: #Loop through all the id's in the container
    if descId[1].id == 1: #The specific UD you want to hide
      if op[c4d.ID_USERDATA,2] == 1: #If the checkBox is checked
         container[c4d.DESC_HIDE] = True #Set it to hidden in memory
        op.SetUserDataContainer(descId, container) #Execute that hidden setting from memory
        c4d.EventAdd()
       if op[c4d.ID_USERDATA,2] == 0: #If the checkBox is unchecked
         container[c4d.DESC_HIDE] = False #Set it to hidden in memory
         op.SetUserDataContainer(descId, container) #Execute that hidden setting from memory
        c4d.EventAdd()
if __name__=='__main__':
 main()

 

hope that helps,

d

 

Nice one Douwe. I forget the UD has it's own container with parameter options. I had to use that to dynamically build a dropdown menu by reading data from files but the normal descriptions won't do that, but oddly UserData does.

Share this post


Link to post
Share on other sites

Let's say your User Data is on another null object ... how do you target that UD? Right now the Python script is targeting it's own User Data. Stupid question I'm sure!

 

UD = op.GetUserDataContainer() #Get the the container for all UD entries

Share this post


Link to post
Share on other sites

so

- Checkbox sits on the Tag

- UD to hide/unhide sits on a Null named "UserDataHolder"

 

fill in the blanks

def main():
    obj = doc.SearchObject("UserDataHolder")
     UD = obj.GetUserDataContainer()


         if op[c4d.ID_USERDATA,2] == 1: #If the checkBox is checked

           obj.SetUserDataContainer(descId, container)

Share this post


Link to post
Share on other sites

Although this splitting up UserData works in this example,

be aware that GetUserDataContainer() is used to browse through the UD container sequence of the Object it refers to only,

so the UD you want to hide needs to sit on the Object that it's looking at.

 

You probably need to edit that to make it suit your own setup.

 

cheers,

d

Share this post


Link to post
Share on other sites

Although this splitting up UserData works in this example,

be aware that GetUserDataContainer() is used to browse through the UD container sequence of the Object it refers to only,

so the UD you want to hide needs to sit on the Object that it's looking at.

 

You probably need to edit that to make it suit your own setup.

 

cheers,

d

Thanks for the heads-up. I have the Python Tag sitting on a controller Null that has all the UD in it.

I just started learning this stuff the other day. I find the documentation a little difficult to work with.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×