Shaderlink / Texbox in GeDialog ?



  • On 12/02/2017 at 06:02, xxxxxxxx wrote:

    hi there,

    i am failing to get a working shaderlink / texbox in my GeDialog!

    working with resource files allowed me to add a texbox with:
    SHADER MY_SHADER { FIT_H; SCALE_H; }

    but sadly the gui then doesn't react to any interaction

    i tried the following in GeDialogs CreateLayout(self) :

    _self.MyShader = self.FindCustomGui(MY_SHADER,c4d.CUSTOMGUI_TEXBOX)
    --> just returns True, so probably doesn't work

    self.MyShader = self.FindCustomGui(MY_SHADER,c4d.CUSTOMGUI_LINKBOX)
    --> returns a CustomGui but then:

    color = c4d.BaseShader(c4d.Xcolor)
    self.SetLink(MyShader, color)
    --> crashes c4d_

    so the question is: is it possible to have a working texbox in a GeDialog?
    and if yes, how would one get there?

    best, theo



  • On 13/02/2017 at 02:03, xxxxxxxx wrote:

    Hi,

    I'm afraid I haven't good news. It's not possible to use a SHADER gadget inside a dialog with the Python API.

    TexBoxGui that provides access to SHADER resource is missing in the Python API.
    This explains why self.FindCustomGui() returns True because the actual TexBoxGui object can't be returned.

    Calling self.FindCustomGui() with CUSTOMGUI_LINKBOX (good try but not recommended at all 🙂) returns a "false" LinkBoxGui and crashes as the actual dialog gadget isn't a LinkBox.



  • On 13/02/2017 at 02:10, xxxxxxxx wrote:

    hi and thanks for your answer...

    there is a post about it here, too... but it is from 2010
    https://plugincafe.maxon.net/topic/4376/3957_texbox-in-dialogs

    but can i ask to understand...
    would it work to add a texbox/shader in a GeDialog in c++?
    so it is just a problem of the python SDK?

    and if fundamentally not possible in GeDialog with python... are there other ways?
    can you construct the missing parts yourself?
    It must be possible somehow to open a window, display a texbox, and get some input, not?

    my goal is simply to have my own window where i can choose a texture or shader
    and then set/insert it in a material shader slot.



  • On 16/02/2017 at 07:59, xxxxxxxx wrote:

    nothing?

    python + texbox = absolutely impossible?

    shouldnt that be set on the todo list for the sdk? .)



  • 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



  • 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 :(



  • 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



  • 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 🙂



  • 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? .)



  • 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.



  • 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



  • 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.



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

    ... mhh... i read the news here ...
    https://developers.maxon.net/docs/Cinema4DPythonSDK/html/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?



  • 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.



  • 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)


Log in to reply