Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    How to create In/Exclude Userdata [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 255 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 23/06/2015 at 10:33, xxxxxxxx wrote:

      I might be asking this too soon because I am so new to "adding user data".

      How can I create In/Exclude to User Data?

      My issue is that other posts demonstrate using a datatype, but I see no such datatype relating to In/Exclude.. Usually in Python I try to find an unofficial ID of some sort that I can use in my Python code but I have no idea of how to extrapolate one.

      EDIT: I have found an ID [c4d.DESC_CUSTOMGUI] = 1009290.. but now it's confused between being an in/exclude and real.. I cannot add items and I don't know if it would function..

      Related post (just demonstrates adding to User Data in general)
      https://developers.maxon.net/forum/topic/8797/11606_populate-userdata-via-python--please-help

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 24/06/2015 at 09:14, xxxxxxxx wrote:

        Well I have figured it out. Let me say I want to teach you how I figured it out..
        First I created User Data via the GUI, which allows me to create In/Exclude.. Then I created a Python Tag so that I could review this information from Python's eyes:

        import c4d
          
        def main() :
            myop = op.GetObject()
            desc = myop.GetDescription(c4d.DESCFLAGS_DESC_0) # method of C4DAtom
            for bc, paramid, groupid in desc:
                name = bc[c4d.DESC_NAME]    # bc = basecontainer
                if name:
                    print "-------"
                    print name
                    print "-------"
                    for index, value in bc:
                        print "Index: %i, Value: %s" % (index,str(value))
        

        My in/exclude looked like this

        -------
        Transparent Shaders
        -------
        Index: 21, Value: 1009290
        Index: 17, Value: <c4d.BaseContainer object at 0x1302458b8>
        Index: 1, Value: Transparent Shaders
        Index: 2, Value: Transparency
        Index: 10, Value: 1
        Index: 13, Value: (3, 1, 0)
        Index: 24, Value: 1
        Index: 26, Value: 1
        

        I compared the index/value pairs of the In/Exclude with the other data to extrapolate foreign value(s).. I fumbled a lot with the BaseContainer but the moneyshot was actually at Index 21.. I knew that I can print constants to see their integer form, and I somehow knew to try it with c4d.DESC_CUSTOMGUI. Then, long story short, I found the correct values to get a working In/Exclude. It could be buggy, for all I know, but it's been working flawlessly for me so far. \

        ud_transparency = c4d.GetCustomDataTypeDefault(1009290) 
        ud_transparency[c4d.DESC_NAME] = "transparency"
        ud_transparency[c4d.DESC_SHORT_NAME] = "transparency"
        ud_transparency[c4d.DESC_CUSTOMGUI] = 1009290
        ud_transparency_datatype = nullo.AddUserData(ud_transparency)
          
        ud_transparency_id = cur_ud_id
        cur_ud_id += 1
        

        In the above code, "nullo" was a null object that I wanted to add the userdata to. And so that's how you do it! I hope you enjoyed it.

        P.S. all of these c4d.DESC_* constants can be found in PythonSDK, search c4d.description

        1 Reply Last reply Reply Quote 0
        • First post
          Last post