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

    Shaderlink / Texbox in GeDialog ?

    PYTHON Development
    0
    15
    2.3k
    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

      On 16/02/2017 at 10:00, xxxxxxxx wrote:

      What you want to do does not require having a shader link in the dialog.
      All you need is a way to target the specific image or shader type. And then a way to target the specific material you want to add it to.
      Also maybe even what channels(color, bump, etc...) do want to add the image to?

      For example. One way of doing this is to:
      -Use a textbox for the user to enter the target material's name
      -Use a Filename gadget to get the image's path on your HD that you want to add to the material.
      In your code. You then get the string value from the Filename gadget. And the string value from the textbox. Then use that to insert the image into the target material like this:

         mat = doc.GetFirstMaterial()  
        if mat is None: return False  
        
        file = the string value of your Filename gadget  
        if len(file) == 0: return False  
        
        #Get the specific material based on what the user entered in the textbox  
        #Then add the image file to the color channel's shader link  
        while mat:  
            if mat.GetName() == your textbox value:  
                colorChanel = mat[c4d.MATERIAL_COLOR_SHADER]  
                shdr = c4d.BaseList2D(c4d.Xbitmap)  
                shdr[c4d.BITMAPSHADER_FILENAME] = file  
                mat.InsertShader( shdr )  
                mat[c4d.MATERIAL_COLOR_SHADER]  = sha  
        
            mat = mat.GetNext()
      

      Or.
      What about maybe using a combobox gadget to get all of the existing materials rather than a textbox?
      Then the user just selects the one they want to add the image to, rather than typing the name.
      There's so many ways to do this kind of thing. There's no way to really answer your question.
      Don't let the fact that we can't physically have a material link in the dialog get in your way.
      Try to think about how you can work around it.

      -ScottA

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

        On 16/02/2017 at 11:11, xxxxxxxx wrote:

        no no...

        i wanted to code a helper plugin to setup materials
        for that i must be able to select textures and all shaders, noise, layer, etc etc

        so i would need a texbox 😞

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

          On 16/02/2017 at 12:05, xxxxxxxx wrote:

          My point is that there are many ways to do what you want without using the shaderlink custom gui.
          For example. You can iterate through a material/materials and get&set the shader links manually.

          import c4d  
            
          shdrlist = []  
            
          def ShaderSearch(shader) :  
            next = shader.GetNext()  
            down = shader.GetDown()   
            if down: ShaderSearch(down)  
            if next: ShaderSearch(next)  
              
            shdrlist.append(shader.GetName())     
            
          def main() :  
              
            mat = doc.GetActiveMaterial()  
            if mat is None: return  
              
            shdr = mat.GetFirstShader()  
            if shdr is None: return  
              
            ShaderSearch(shdr)  
            print shdrlist  
              
            c4d.EventAdd()  
              
          if __name__=='__main__':  
            main()
          

          Where you get the images or shaders that you want to add. And how you want the user to do that task is relative. All depending on your specific desired workflow.
          The shaderlink custom gui might be the most obvious thing to use. But it's not your only option.

          For visualizations. I've written dialog plugins that show the active material using a bitmap button to display it. That can be updated by clicking on them. A UserArea could also be used for this. This gets around the limitation of not being able to use a material gadget in a GeDialog.
          The sdk as so many options in it that you should be able to do almost anything you want to do. But you might have to do them by hand, instead of using a pre made gadget.

          -ScottA

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

            On 17/02/2017 at 01:26, xxxxxxxx wrote:

            Yes, the TextBox GUI works with the C++ API.

            And I've already added TexBoxGui to the Python API todo list 🙂

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

              On 17/02/2017 at 03:05, xxxxxxxx wrote:

              @ ScottA:
              i would need to be able to choose from all available shaders in c4d, not from the shaders of a selected material.
              the goal is to have the same choice for a shader like when you would be in the material editor itself.

              @ Yannick:
              good news 🙂 !
              but that probably wont go that fast, will it? .)

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

                On 17/02/2017 at 05:17, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                good news 🙂 !
                but that probably wont go that fast, will it? .)

                Missing classes and functions are regularly added to the Python API.

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

                  On 20/05/2017 at 01:37, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  Originally posted by xxxxxxxx

                  good news 🙂 !
                  but that probably wont go that fast, will it? .)

                  Missing classes and functions are regularly added to the Python API.

                  was there a progress regarding texbox/shader?

                  does it work to add a texbox/shader in a GeDialog in python by now?

                  my project is kinda stuck till then...
                  and i dont even know where i could see a change,
                  i guess such details are not in the release notes

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

                    On 21/05/2017 at 03:11, xxxxxxxx wrote:

                    Such details are in the Python documentation "What's New"
                    page. Additions to the Python API usually only come with a
                    new C4D release, so you'll have to wait until R19.

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

                      On 06/09/2017 at 00:33, xxxxxxxx wrote:

                      ... mhh... i read the news here ...
                      https://developers.maxon.net/docs/py/2023_2/misc/api_changelist_R19.html

                      but i think the Shaderlink / Texbox / SHADER gadget inside a dialog wasn't added to the Python API 😕

                      is that correct and is it still on the todo list?

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

                        On 06/09/2017 at 05:22, xxxxxxxx wrote:

                        Hi,

                        unfortunately the TexBox CustomGUI didn't make it into R19. Sorry. To our excuse, we never said it would.
                        But at least I can confirm, it is still on our ToDo list.

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

                          On 06/09/2017 at 23:09, xxxxxxxx wrote:

                          No excuse needed, it wasn't promised at all 🙂

                          But is there a chance that this gets added in between major releases
                          (in other words anytime soon-ish) ?

                          or is it more likely to take a year or two?
                          (i guess it is not tagged with high priority)

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