LinkBox in .res not work



  • On 01/01/2013 at 16:11, xxxxxxxx wrote:

    you din't asign the linkbox gui to a variable. you just used a variable with the name linkBox.

    def CreateLayout(self) :
    	self.LoadDialogResource(IDD_RISORSA)
    	# Here you don't
    	................
      
      
    def Command(self, id, msg) :
    	if id == 10006:
       # but here you use self.linkBox as if a LinkBoxGui has been asigend to it.
       # This line should actually raise a runtime error.
       print self.linkBox.GetLink()
      
    -----------------------------------------------------------------------------------------------------------------
      
    def CreateLayout(self) :
    	self.LoadDialogResource(IDD_RISORSA)
    	# Here you asign it to variable
    	self.linkBox = self.AddCustomGui(MY_LINKBOX, c4d.CUSTOMGUI_LINKBOX, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0)
      
      
    def Command(self, id, msg) :
    	if id == 10006:
       # which you use here to access the LinkBoxClass
       print self.linkBox.GetLink()
    


  • On 02/01/2013 at 05:24, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    you din't asign the linkbox gui to a variable. you just used a variable with the name linkBox.

    def CreateLayout(self) :
    self.LoadDialogResource(IDD_RISORSA)
    # Here you don't
    ................
     
     
    def Command(self, id, msg) :
    if id == 10006:
       # but here you use self.linkBox as if a LinkBoxGui has been asigend to it.
       # This line should actually raise a runtime error.
       print self.linkBox.GetLink()
     
    -----------------------------------------------------------------------------------------------------------------
     
    def CreateLayout(self) :
    self.LoadDialogResource(IDD_RISORSA)
    # Here you asign it to variable
    self.linkBox = self.AddCustomGui(MY_LINKBOX, c4d.CUSTOMGUI_LINKBOX, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0)
     
     
    def Command(self, id, msg) :
    if id == 10006:
       # which you use here to access the LinkBoxClass
       print self.linkBox.GetLink()
    

    littledevil Thank you so much for your help I know that this is how it works.

    but I was wondering how to make it work with a c4d.CUSTOMGUI_LINKBOX in . res file 
    sorry if I can't express myself well :)

    and thanks for the patience that you have shown :)



  • On 02/01/2013 at 06:50, xxxxxxxx wrote:

    well, my example was aimed at a res file solution. you have to always think of how c4d works.
    almost everything has to be broken down into a BaseContainer. so if you have a gui which holds
    a textbox and a checkbox c4d creates somewhere a BaseContainer which looks something like 
    this pseudocode :

    myDialogBc = c4d.BaseContainer()
    myDialogBc[myTextBoxID] = 'TextBoxText'
    myDialogBc[myCheckBoxID] = checkBoxCheckValue
    

    when you call in your dialog :

    self.setString(myTextBoxID, 'new fancy string')
    

    c4d writes this internally into the bc of your dialog. which would be for our pseudo code
    example :

    myDialogBc[myTextBoxID] = 'new fancy string'
    

    but a BaseContainer can only contain certain data types. There are the basic data types like
    string, long and so on and there are CustomDataTypes. those are plugins which tell c4d how to
    store a specific class (which can hold any data) in a BaseContainer(). CustomGuis are a form
    of these CustomDataTypes.

    so when you have a LinkBoxGui in your dialog you have to get the LinkBoxGui class from the
    BaseContainer first and then you can use the methods provided by the class to change/read
    the data.

    # imagine this linkbox has been added in a resfile
    self.AddCustomGui(MY_LINKBOX, c4d.CUSTOMGUI_LINKBOX, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0)
    # we use FindCustomGui to get the class stored in the BaseContainer at our ID
    myLinkBox = self.FindCustomGui(MY_LINKBOX, c4d.CUSTOMGUI_LINKBOX)
    #do something with the linkbox class
    print myLinkBox.GetLink()
    


  • On 02/01/2013 at 12:32, xxxxxxxx wrote:

    ^Using the code method you provided will create a LinkBox gizmo in the dialog. But when you try to grab the object in it the result is always None.

    Here's a complete plugin example.
    When LoadDialogResource() is used. The return from it is always None.
    When LoadDialogResource() is commented out. The Linkbox works and returns what's inside of it properly.

    https://sites.google.com/site/scottayersmedia/res Based Linkbox.zip

    Also note in the .res file the comment I wrote that the accept flag for the linkbox throws an error too! 😠

    This is why I avoid using .res files for dialogs at all costs. And only use them for making dialog based spline GUI's.
    It's either buggy, broken, or just plain not documented properly by Maxon.

    -ScottA



  • On 02/01/2013 at 13:58, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    It's either buggy, broken, or just plain not documented properly by Maxon.

    -ScottA

    Yes ScottA, I'm the same I your opinion 🙂
    Thank you ScottA and Thanks even littledevil Thumbs Up



  • On 02/01/2013 at 16:36, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    ^Using the code method you provided will create a LinkBox gizmo in the dialog. But when you try to grab the object in it the result is always None.

    Here's a complete plugin example.
    When LoadDialogResource() is used. The return from it is always None.
    When LoadDialogResource() is commented out. The Linkbox works and returns what's inside of it properly.

    https://sites.google.com/site/scottayersmedia/.res Based Linkbox.zip

    Also note in the .res file the comment I wrote that the accept flag for the linkbox throws an error too! 😠

    This is why I avoid using .res files for dialogs at all costs. And only use them for making dialog based spline GUI's.
    It's either buggy, broken, or just plain not documented properly by Maxon.

    -ScottA

    that is simply not true. i haven't red your whole example code, but i saw a comment saying 
    c4d crashes when you set the refuse and and accept flags. this is kind of obvious because 
    both these flags are description flags and dialog ressources  are not descriptions. you have 
    also be careful about the lifettime of the linkbox class.

    however here is little example plugin showing the two LinkBox methods which are exposed to
    python in action (GetLink, SetLink). the plugin loads a dialog from a ressource file , creates on 
    init a cube and inserts the cube into the document, then asigns it to the linkbox and as the last 
    action it prints the linkbox content to the console.

    if this really doesn't work for you (which i cannot really believe) this has to be an OS problem.

    http://www.file-upload.net/download-7003752/LinkBoxGui.zip.html

    import os, sys, string
      
    import c4d
    from c4d import bitmaps, documents, gui, plugins
      
    PID = 1000001
      
    class fhLinkBoxDialog(gui.GeDialog) :
        def __init__(self) :
            self.LinkBox = None
      
        def CreateLayout(self) :
            geRessource = plugins.GeResource()
            geRessource.Init(os.path.dirname(__file__))
            result = self.LoadDialogResource(10001, geRessource, 0)
    	if (result) :
            	linkBox = self.FindCustomGui(10002, c4d.CUSTOMGUI_LINKBOX)
      
            	cube = c4d.BaseObject(c4d.Ocube)
            	doc = c4d.documents.GetActiveDocument()
            	doc.InsertObject(cube)
      
            	linkBox.SetLink(cube)
            	print linkBox.GetLink(doc, c4d.Ocube)
            return result   
      
    class fhLinkBoxExample(plugins.CommandData) :
        def __init__(self) :
            self.ManagerDialog = fhLinkBoxDialog()
      
        def Execute(self, doc) :
            screen = gui.GeGetScreenDimensions(0, 0, True)
            result = self.ManagerDialog.Open(dlgtype  = c4d.DLG_TYPE_ASYNC,
                                                                  pluginid = PID,
                                        			      xpos     = int(screen['sx2'] / 2) - 300,
                                       			      ypos     = int(screen['sy2'] / 2) - 300)
            return result
      
    if __name__ == "__main__":
        dir, f = os.path.split(__file__)
        c4d.plugins.RegisterCommandPlugin (id   = PID,
                                           str  = "fhLinkBox",
                                           help = "",
                                           info = 0,
                                           dat  = fhLinkBoxExample(),
                                           icon = None)
    


  • On 02/01/2013 at 17:35, xxxxxxxx wrote:

    Doh!
    Thanks for posting that code ferdinand.
    I was returning True in my CreateLayout() method instead of returning the resource variable.
    No wonder I was getting None type errors. 😊

    @Caleidos4d,
    I updated my example file because it works properly now.
    Just drop any object into the linkbox gizmo and click the "execute" button. And it will get the name of the object in the linkbox.

    The other gizmos don't do anything they're just there as filler. So ignore them.
    Let me know when you've got the file. Because I'm going to delete it.

    -ScottA



  • On 12/01/2013 at 11:45, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    @Caleidos4d,
    I updated my example file because it works properly now.
    Just drop any object into the linkbox gizmo and click the "execute" button. And it will get the name of the object in the linkbox.

    The other gizmos don't do anything they're just there as filler. So ignore them.
    Let me know when you've got the file. Because I'm going to delete it.

    -ScottA

    Hi ScottA!
    I realized just now that you've updated the post, I haven't had time to download the updated version of the file, thanks anyway 🙂



  • On 12/01/2013 at 12:25, xxxxxxxx wrote:

    I wondered what happened to you. 🙂

    It has a bunch of notes and gizmo code in it for my own reference purposes that might be confusing to people. That's why I deleted it.
    If you still want it just send me your e-mail address in a private message and I'll send it to you.

    -ScottA



  • On 12/01/2013 at 12:47, xxxxxxxx wrote:

    i have sended my email address in private messagge, Thank ScottA!!



  • On 12/01/2013 at 16:21, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    I was returning True in my CreateLayout() method
    instead of returning the resource variable.

    c4d.gui.GeDialog.LoadDialogResource() returns a boolean value, just like ~.CreateLayout() expects
    as return type.

    Best,
    -Niklas



  • On 12/01/2013 at 17:09, xxxxxxxx wrote:

    When returning True in the CreateLayout() method. I only get proper results from locally created gizmos using the ADD() type coding method.
    Returning True while using a .res file in the CreateLayout() method results in zero values from my gizmos.

    In order to use a .res file and get proper results from my gizmos.
    This is an example of what I have to use in CreateLayout() :

      
    res = self.LoadDialogResource(ResBasedMenu)  
    self.mylink = self.FindCustomGui(MY_LINK, c4d.CUSTOMGUI_LINKBOX)  
    return res
    

    Same thing goes for C++ plugins.
    Everything is working fine for me now.

    -ScottA



  • On 13/01/2013 at 03:27, xxxxxxxx wrote:

    Hi Scott,
    What Cinema 4D release are you working with? I'm using R14 and do not hit this problem, but
    I remember there have been issues in an old R13 version with FindCustomGui(). However, the
    following code works in R13.051+ (maybe even older versions) including R14 of course.

    class MyDialog(c4d.gui.GeDialog) :  
    def CreateLayout(self) :  
    result = self.LoadDialogResource(res.DLG_TEST)  
    self.link = self.FindCustomGui(res.EDT_LINK, c4d.CUSTOMGUI_LINKBOX)  
    print "Return value of self.LoadDialogResource() :", result  
    # No difference in returning True or `result` here (for me).  
    return True  
    def InitValues(self) :  
    self.SetReal(res.EDT_WIDTH, 100, 0)  
    self.SetReal(res.EDT_HEIGHT, 100, 0)  
    return True  
    def Command(self, id, msg) :  
    if id == res.BTN_OK:  
    op = self.link.GetLink()  
    print "Link in linkbox:", op  
    elif id == res.BTN_CANCEL:  
    self.Close()  
      return True
    

    You can find my complete set-up here, but it requires c4dtools installed.
    Best,
    Niklas



  • On 13/01/2013 at 09:22, xxxxxxxx wrote:

    I think I was using R12 at the time.
    If I get a chance I'll try testing in R13.

    -ScottA


Log in to reply