Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Creating Attribute manager controls

    PYTHON Development
    0
    30
    20.8k
    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
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 24/05/2011 at 14:01, xxxxxxxx wrote:

      Nux.
      The reason that file uses numeric ID's is because I use it to remind myself of both ways we can create gizmos. Using Both the .res names method, and the numeric ID method.
      It was just something really simple I could slap a button on to show Rui an example.

      But you're right about the Case.
      If I give it out. I should probably not use lower case names. So I changed that.
      I don't want to promote bad habits. 🙂

      -ScottA

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 25/05/2011 at 01:15, xxxxxxxx wrote:

        Everything was going fine until the time I needed to check what was the button it was pressed.
        I assume it is done inside the Message procedure.
        The message procedure has the following parameters: Message(self, tag, type, data) :
        I placed in there:

        print type
        print data

        and only the data part seems to return something useful in the form:

        {id: (1001, 8, 100000011)}

        The problem is that it appears in the middle of a whole lot more data that I don't need.
        So, how can I extract the information of what button in being pressed?
        Thank you very much in advance for any reply.

        Rui Batista

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 25/05/2011 at 03:26, xxxxxxxx wrote:

          Lol, same question one topic down of this one here. Tongue

          I'm not at home, so i cant test it right now.
          It was something like     _
          if not data: return True
          id = data[0]["id"][0]_  
          or so.

          Cheers, Niklas

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 25/05/2011 at 04:33, xxxxxxxx wrote:

            I tried this:

            def Message(self, tag, type, data) :
            if not data: return True
            but=data[0]['id'][0]
            print but
            return True

            But I still get errors in the console:

            Traceback (most recent call last) :
            File "'Origins.pyp'", line 26, in Message
            TypeError: 'NoneType' object is unsubscriptable
            Traceback (most recent call last) :
            File "'Origins.pyp'", line 26, in Message
            KeyError: 0
            Traceback (most recent call last) :
            File "'Origins.pyp'", line 26, in Message
            KeyError: 0
            Traceback (most recent call last) :
            File "'Origins.pyp'", line 26, in Message
            KeyError: 0
            Traceback (most recent call last) :
            File "'Origins.pyp'", line 26, in Message
            KeyError: 0
            Traceback (most recent call last) :
            File "'Origins.pyp'", line 26, in Message
            KeyError: 0

            Line 26 is: but=data[0]['id'][0]

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 25/05/2011 at 06:38, xxxxxxxx wrote:

              Did you also tried to change the Keys ? I'm no able to try it today.

              try this to check out what returns what.

                
              if not data: return True   
              print data   
              print data[0]   
              print data[0]["id"]   
              print data[0][0]   
              print data[0]["id"][0]   
              print data[0][0]["id"]   
              

              You can then just delete what raises
              an error.

              Cheers

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 25/05/2011 at 07:22, xxxxxxxx wrote:

                None of those worked out. But I'm getting somewhere by trial&error; 😉
                So, what I have now is:

                def Message(self, tag, type, data) :

                if not type: return True
                if type<>18: return True
                print data.values()[0]

                return True

                And, what I get it something like:

                (1001, 8, 100000011)

                So, now I just need a way to extract the first number (the 1001, in this case).
                Any help?

                Rui Batista

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 25/05/2011 at 07:35, xxxxxxxx wrote:

                  I can't even determine the type of the "but" variable 😞
                  If it is in the format (1001, 8, 100000011), it is not an array, right? It is not a dict either, I believe.
                  So, how can I extract the numbers from it?

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 25/05/2011 at 07:38, xxxxxxxx wrote:

                    Ok, it seems to be a tuple but when I print the first element with print but[0], instead of a number, I get:

                    <c4d.DescLevel object at 0x12902c4b0>

                    What I want is a number, as in... 1001
                    How?!? 😉

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 25/05/2011 at 08:24, xxxxxxxx wrote:

                      Hi Rui, you can access this by calling     but[0].id
                      Cheers, Sebastian

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 25/05/2011 at 08:36, xxxxxxxx wrote:

                        YES!!! Thank you soooooo much 🙂

                        Rui Batista

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

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 25/05/2011 at 08:54, xxxxxxxx wrote:

                          Did you get the button to actually work Rui?
                          I can get other things to work like check boxes..But not Buttons:

                          def Message(self, tag, type, bc) :  
                            bc = tag.GetDataInstance();  
                              
                            if bc.GetLong(c4d.XRAY)== True:  #This works  
                              print "CheckBox Enabled"  
                                
                            if bc.GetLong(c4d.CLICK_ME)== True:  #<-----This does not work!!  
                              print "Button Pushed"    
                          

                          Maybe I need to get and check the state of the button?

                          -ScottA

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

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 25/05/2011 at 09:34, xxxxxxxx wrote:

                            Hm I could now look it up and i used this:

                            def GetMessageID(data) :  
                              try:  
                                  return data["id"][0].id  
                              except:  
                                  return None
                            

                            cheers

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

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 25/05/2011 at 14:09, xxxxxxxx wrote:

                              What I have now (and fully working) is something like this:

                              def Message(self, tag, type, data) :

                              if not type: return True
                              if type<>18: return True

                              but=data.values()[0]

                              if but[0].id==1001:
                                  # stuff

                              if but[0].id==1002:
                                  # stuff

                              return True

                              Would this be what you need, Scott?
                              Thank you all for the help 🙂

                              Rui Batista

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

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 25/05/2011 at 15:14, xxxxxxxx wrote:

                                Yeah.. That helps a lot Rui.
                                But it doesn't seem to work with ID names

                                  
                                if but[0].id==1006:     print "button enabled" #<---Works  
                                  
                                if but[0].id==CLICK_ME: print "button enabled" #<---Does Not Work!
                                

                                I'm sure there's a good reason for why the ID names don't work. But it's not the end of the world to have to use the ID numbers.

                                Where did you find this?:type<>18
                                I've never seen that before. And I'm wondering what it means.
                                Is that a C4D SDK thing. Or is that something that is built into the Python language?

                                -ScottA

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

                                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                  On 25/05/2011 at 15:43, xxxxxxxx wrote:

                                  Actually I found out by trial&error.;
                                  I just placed a print type inside the Message procedure. I noted the values. Then I placed a:

                                  if type==(numbers the I noted, one by one) :
                                  print data

                                  And when I compared the type with 18, it printed out:

                                  (1001, 8, 100000011)

                                  Not a very elegant way to find out, but it did the trick. However, I don't know what the 18 means 😉

                                  Rui Batista

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

                                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                    On 25/05/2011 at 16:49, xxxxxxxx wrote:

                                    LOL. Whatever it takes.
                                    You don't want to know what goes through my head in order for me to use pointers in C++ 😉

                                    The main reason I was curious about it is because your code doesn't work when I try to use it on something other than a button. Like say a checkbox for example.
                                    I thought that maybe the "if type<>18: " meant "if the type is a button".
                                    So I was curious if there were other numbers that would allow things like checkboxes to work in a similar manner.

                                    I guess I'll have to try them out too. And see if anything happens.

                                    Thanks for the information.
                                    -ScottA

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

                                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                      On 25/05/2011 at 21:58, xxxxxxxx wrote:

                                      Your ID is not wokring because of the missing prefix. 😉

                                      c4d.CLICK_ME

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

                                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                        On 26/05/2011 at 02:20, xxxxxxxx wrote:

                                        With this simple example of what happened to me I realized once more that the documentation for python in Cinema4D is still very sparcely arranged, lacking a lot of stuff and not very clean in general 😞
                                        One has to do lots of questions, lots of digging in and a whole lot of trial&error; attempts to get even the simplest results 😞

                                        Rui Batista

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

                                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                          On 26/05/2011 at 05:30, xxxxxxxx wrote:

                                          I donÄt understand what you want to do with type != 18.. ?!
                                          The GetMessageID function works fine for me. It returns the pressed GUI Element's ID, i.e. a button's id.

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

                                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                            On 26/05/2011 at 07:21, xxxxxxxx wrote:

                                            Originally posted by xxxxxxxx

                                            Your ID is not wokring because of the missing prefix. 😉

                                            c4d.CLICK_ME

                                            Son of a @#@$#@$#@#@!!!.
                                            I swear to God. That frakin' c4d. prefix is out to get me. 😂
                                            I thought I had finally squashed that prefix demon...Guess not.

                                            Instead of going round and round. And telling us it works for you in two threads nux.
                                            Why not take that plugin example I posted. And add the button code to it and show us?
                                            You have my permission to do that.

                                            -ScottA

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