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

    [Python] InitResourceBitmap

    Bugs
    0
    21
    14.1k
    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 13/02/2012 at 19:10, xxxxxxxx wrote:

      I'm afraid I can't give you any answers to that one marc.
      In C++ it's very simple like this:

        //C++ example that puts a sphere icon on a customGui button  
        
        GroupBegin(0,BFH_LEFT,2,0,"MySecondGroup",0);  
            {  
         BaseContainer bc;                             //Create a container to hold our custom button gizmo              
         bc.SetLong(BITMAPBUTTON_BORDER, BORDER_OUT);  //Make the button style raised so it looks like a button  
         bc.SetBool(BITMAPBUTTON_BUTTON, TRUE);          //Make it act like a button  
         myButton = (BitmapButtonCustomGui* )AddCustomGui(10001,CUSTOMGUI_BITMAPBUTTON,"MY BUTTON", 0L,80,80,bc); //Adds the BitmapButton GUI to the dialog      
         myButton->SetImage(Osphere, FALSE);         //Adds the sphere icon to the button  
            }  
        GroupEnd();
      

      But in python there is no casting. And the SDK has no code to help in the conversion.

         #Python version that does **not** work  
      #Keeps saying SetImage() is using the wrong type  
        
            self.GroupBegin(0, c4d.BFH_SCALEFIT|c4d.BFH_SCALEFIT, 1, 1, "Bitmap Example",0)  
        
            bc = c4d.BaseContainer()                            #Create a new container to store the button image    
            bc.SetLong(c4d.BITMAPBUTTON_BORDER, c4d.BORDER_OUT) #Sets the border to look like a button  
            bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)  #<-------------------#Does not seem to to work in R13?   
         
            self.myBitButton=self.AddCustomGui(MY_BITMAP_BUTTON, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 30, 30, bc)  
            self.myBitButton = gui.BitmapButtonCustomGui   
            self.myBitButton.SetImage(c4d.Osphere, False,False) #<----Error: Not the right object type!!!  
        
            self.GroupEnd()
      

      I've been using a direct file path method to load images(even icons). And waiting for someone to post a working example of BitmapButtonCustomGui with python.

      If nobody helps you. And you need an alternative(using hard a coded path). I'll post my file path method if you need it.

      -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 14/02/2012 at 01:26, xxxxxxxx wrote:

        Originally posted by xxxxxxxx

        But in python there is no casting. And the SDK has no code to help in the conversion.

        #Python version that does **not** work  
        #Keeps saying SetImage() is using the wrong type  
           
        self.myBitButton=self.AddCustomGui(MY_BITMAP_BUTTON, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 30, 30, bc)  
        self.myBitButton = gui.BitmapButtonCustomGui   
        self.myBitButton.SetImage(c4d.Osphere, False,False) #<----Error: Not the right object type!!!  
        

        I've been using a direct file path method to load images(even icons). And waiting for someone to post a working example of BitmapButtonCustomGui with python.

        AddCustomGui() returns a BitmapButtonCustomGui object in this case... Python has no casting but it's dynamic.

        Originally posted by xxxxxxxx

        self.myBitButton = gui.BitmapButtonCustomGui
        

        And with this line you just assign BitmapButtonCustomGui type.

        BitmapButtonCustomGui.SetImage() is used to load custom images from a filename string, bitmap or icon data dictionary. To load an image from an ID there's BITMAPBUTTON_ICONID1 and BITMAPBUTTON_ICONID2 container entries of the settings for the BitmapButtonCustomGui:

        bc.SetLong(c4d.BITMAPBUTTON_ICONID1, c4d.Osphere)
        
        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 14/02/2012 at 07:20, xxxxxxxx wrote:

          Scott...Thanks so much for the help! I am a total newbie at this and you were a tremendous help!

          Yannick...YOU ROCK!!!!!

          I am very much a beginner at all of this. I am a designer by trade and choice, but am using Python to push my abilities in C4D. I must say that this was a hurdle I wasn't sure if I could beat, but you have saved the day! MANY MANY THANKS!

          This worked like a charm:
          self.GroupBegin(0, c4d.BFH_CENTER | c4d.BFH_CENTER, 2, 0, "", 0) #id, flags, cols, rows, title, groupflags
          ############# ICON BUTTON ###################
                bc = c4d.BaseContainer()                            ######Create a new container to store the button image 
                bc.SetLong(c4d.BITMAPBUTTON_ICONID1, c4d.RESOURCEIMAGE_MOVE) #####Sets Button Icon
                bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
                self.myBitButton=self.AddCustomGui(BUTTON_SELECT_MOVE, c4d.CUSTOMGUI_BITMAPBUTTON, "Bend", c4d.BFH_CENTER | c4d.BFV_CENTER, 32, 32, bc)
                self.myBitButton = gui.BitmapButtonCustomGui

          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 14/02/2012 at 07:23, xxxxxxxx wrote:

            add this with the info on :
            http://chicagoc4d.com/C4DPythonSDK/modules/c4d.bitmaps/index.html?highlight=initresource#c4d.bitmaps.InitResourceBitmap

            and thats it!

            Again, THANKS GUYS!

            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 14/02/2012 at 08:02, xxxxxxxx wrote:

              Now I just have to find the objects that arent on that list haha. I know they exist b/c C4D uses icons for them lol.

              The hunt continues...

              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 14/02/2012 at 08:18, xxxxxxxx wrote:

                Search your MAXON folder for this file: "interface_icons.txt"
                It has a list of the icons and their ID#s.

                You also don't need this line of code:self.myBitButton = gui.BitmapButtonCustomGui
                I only posted it because I didn't know how to work it into the solution. I just put in there so whoever wanted to take a look at the problem had all the pieces to work with.

                Here a complete R13 script example of a button with an icon on it:

                import c4d,os  
                from c4d import gui,bitmaps  
                  
                MY_BITMAP_BUTTON = 1003  
                  
                class MyDialog(c4d.gui.GeDialog) :  
                  
                  def CreateLayout(self) :  
                        
                      self.SetTitle("My Python Dialog")  
                  
                      self.GroupBegin(0, c4d.BFH_SCALEFIT|c4d.BFH_SCALEFIT, 1, 1, "Bitmap Example",0)  
                  
                      bc = c4d.BaseContainer()                            ######Create a new container to store the button image   
                      bc.SetLong(c4d.BITMAPBUTTON_BORDER, c4d.BORDER_OUT) #Sets the border to look like a button  
                      bc.SetLong(c4d.BITMAPBUTTON_ICONID1, c4d.RESOURCEIMAGE_MOVE) #####Sets Button Icon  
                      bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True) #<---Does Not animate in R13!?  
                      self.myBitButton=self.AddCustomGui(MY_BITMAP_BUTTON, c4d.CUSTOMGUI_BITMAPBUTTON, "My Button", c4d.BFH_CENTER | c4d.BFV_CENTER, 50, 50, bc)  
                   
                      self.GroupEnd()  
                      return True  
                  
                  #Do something when the button is pressed  
                  def Command(self, id, msg=None) :  
                      if id==MY_BITMAP_BUTTON:  
                         print "Hello"    
                    
                      return True  
                  
                if __name__=='__main__':  
                  dlg = MyDialog()  
                  dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=100, defaulth=100)
                

                I still don't know why buttons don't animate when it's clicked in R13. Like they used to do in 12.

                -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 14/02/2012 at 08:39, xxxxxxxx wrote:

                  Thanks Scott!

                  I was just being stupid haha. I already had the ID's for those elsewhere in my code...all I had to do was scroll down haha.

                  Thanks again! HUGE help

                  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 14/02/2012 at 08:40, xxxxxxxx wrote:

                    btw...when you say "animate"...do you mean the down/toggle state. When the user clicks it?

                    I am using R13 and when I click these they have what appears to be a "down" state.

                    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 14/02/2012 at 08:57, xxxxxxxx wrote:

                      Yeah. That's what I'm referring to.
                      It does not animate in R13 for me if I use: bc.SetLong(c4d.BITMAPBUTTON_BORDER, c4d.BORDER_OUT)

                      However, It does animate using this layout format in R12.
                      Something must have changed.
                      I'm not sure if it's a bug or not. But I prefer the way it worked in R12.

                      -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 14/02/2012 at 12:00, xxxxxxxx wrote:

                        Scott,

                        I have the icons implemented and they are working great!

                        When I click on the icon, a border appears around it while the mouse button is held down... giving it the impression of a downstate. The appearance of the icon itself doesnt change, but the border indicates the down state. Tested in R12 and R13 and the functionality is the same in both.

                        I see what you are saying about the toggle state in your case. You want to add the BORDER_OUT to make it look more like a button, and you want that to change when clicked.

                        I will keep my eyes peeled and if I run across something I will post it here 🙂

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

                          On 19/08/2016 at 01:49, xxxxxxxx wrote:

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