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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Hide DescElements R18

    Scheduled Pinned Locked Moved PYTHON Development
    15 Posts 0 Posters 1.5k 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 29/11/2016 at 13:23, xxxxxxxx wrote:

      HeyScott

      thank you! Now it works and I´m able to do alot of funny stuff.

      def GetDDescription(self, node, description, flags) :  
        data = node.GetDataInstance()  
        
        if not description.LoadDescription(node.GetType()) : return False  
        
        singleID = description.GetSingleDescID()  
        groupID = c4d.DescID(c4d.DescLevel(c4d.GT_GROUP1, c4d.DTYPE_GROUP, node.GetType()))  
        paramID = c4d.DescID(c4d.DescLevel(c4d.GT_REAL))  
        
        if singleID is None or paramID.IsPartOf(singleID)[0]:  
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)  
            if data.GetBool(c4d.GT_HIDE01) == True: bc.SetBool(c4d.DESC_HIDE, True)  
            elif data.GetBool(c4d.GT_HIDE01) == False:  
                bc.SetString(c4d.DESC_NAME, "Real")  
                bc.SetLong(c4d.DESC_UNIT, c4d.DESC_UNIT_METER)  
                bc.SetBool(c4d.DESC_HIDE, False)  
            if not description.SetParameter(paramID, bc, groupID) : return False  
        
        return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
      

      But one of many questions and one note.

      Question:
      If I use

      if c4d.GT_HIDE01: ... 
      

      instead of

      if data.GetBool(c4d.GT_HIDE01) == True: ... 
      

      nothing happens. Why?

      Note:
      If I print paramID.IsPartOf(singleID) cinema crashs.

      Thanks Andreas and Scott and greetings
      rownn

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

        On 29/11/2016 at 14:00, xxxxxxxx wrote:

        The code "if c4d.GT_HIDE01:" asks the question: if this integer.
        But C4D doesn't know what that means without some context.
        So you need to tell C4D to look in the node's container for that integer ( node.GetDataInstance() ).
        That's what the "data" variable is used for in my example.

        It might have been clearer if I named it "bc" or maybe something like "nodeBC".
        I tend to use "data" by habit.

        -ScottA

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

          On 30/11/2016 at 05:38, xxxxxxxx wrote:

          Damn! I used c4d.GT_HIDE01 instead of node[c4d.GT_HIDE01]. That´s embarrassing!!

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

            On 30/11/2016 at 10:22, xxxxxxxx wrote:

            Hi guys,

            glad you seem to have solved the issue already.
            I just want to add, that there's a slight difference between creating a new parameter description and changing an existing one in GetDDescription().
            In the posted snippets it looks like you are creating a new description parameter. At least you are always overwriting the existing description parameter. It's a bit hard to tell, without seeing the resource files. In Scott's example this is definitely the case, if I'm not mistaken.
            You can do so, but in such a case, where you have defined a description parameter in a resource file and just want to hide it, the approach would be slightly different. Instead of creating a new BaseContainer (and then having to care to set up everything the way you want, while you already did so before in the resource file) with GetCustomDataTypeDefault(), you'd rather use Description.GetParameterI() to get the existing BaseContainer of the parameter description and simply modify the needed value (e.g. in this case DESC_HIDE).

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

              On 30/11/2016 at 13:35, xxxxxxxx wrote:

              Hey Andreas,

              thx for that point. It would be nice to hide an element without the need to reset everything else, but Description.GetParameterI( id , ar ) crashs cinema, too.

              def GetDDescription(self, node, description, flags) :  
                
                    data = node.GetDataInstance()  
                
                    if not description.LoadDescription(node.GetType()) : return False  
                
                    singleID = description.GetSingleDescID()  
                    groupID = c4d.DescID(c4d.DescLevel(c4d.GT_GROUP1, c4d.DTYPE_GROUP, node.GetType()))  
                    paramID = c4d.DescID(c4d.DescLevel(c4d.GT_REAL))  
                
                    if singleID is None or paramID.IsPartOf(singleID)[0]:  
                        bc = description.GetParameterI(paramID, []) #c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)  
                        if node[c4d.GT_HIDE01]: bc[c4d.DESC_HIDE] = True  
                        elif not node[c4d.GT_HIDE01]: bc[c4d.DESC_HIDE] = False  
                        if not description.SetParameter(paramID, bc, groupID) : return False  
                
                    return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
              
              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 30/11/2016 at 15:07, xxxxxxxx wrote:

                Try using None instead of "[]" in your GetParameterI() function.

                I added the GetParameterI() version to my example.

                -ScottA

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

                  On 01/12/2016 at 02:34, xxxxxxxx wrote:

                  Hey,

                  Ive already tried using None, but with None cinema freezes.

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

                    On 01/12/2016 at 07:25, xxxxxxxx wrote:

                    Since bc is assigned to GetParameterI() in your code. It will probably crash when it's used in the SetParameter() function.
                    Try it without using SetParameter() at the end. It doesn't seem to be needed when using the  GetParameterI() function to change a description.

                    Like this:

                    bc = description.GetParameterI(paramID, None)      
                    if data.GetBool(1111) == True: bc.SetBool(c4d.DESC_HIDE, True)  
                    if data.GetBool(1111) == False: bc.SetBool(c4d.DESC_HIDE, False)
                    

                    -ScottA

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

                      On 01/12/2016 at 09:04, xxxxxxxx wrote:

                      Yep, Scott is right. Sorry, I forgot to tell yesterday.
                      But still, it shouldn't crash C4D. We are investigating.

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

                        On 02/12/2016 at 04:40, xxxxxxxx wrote:

                        Thank you guys,

                        I though I had tried to uncomment that line, because it makes totally sense. Hmm...
                        Finally the code looks clean and works. I like such a finish.

                        def GetDDescription(self, node, description, flags) :  
                          
                          if not description.LoadDescription(node.GetType()) : return False  
                          
                          singleID = description.GetSingleDescID()  
                          paramID = c4d.DescID(c4d.DescLevel(c4d.GT_REAL))  
                          
                          if singleID is None or paramID.IsPartOf(singleID)[0]:  
                              bc = description.GetParameterI(paramID, None)   
                              if node[c4d.GT_HIDE01]: bc[c4d.DESC_HIDE] = True  
                              else: bc[c4d.DESC_HIDE] = False  
                          
                          return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
                        

                        thx again
                        rownn

                        PS: Thanks 1M times all the guys who implemented that great possibility.

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