Getting/Setting Custom GUI elements



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

    On 11/03/2011 at 20:43, xxxxxxxx wrote:

    I am using a CustomGUI element, in this case a Link Field. I don't see any way to Set the object to be in there or to get what object is in there.

    Is there a function to to set this?

    def Command(self, id, msg=None) :
            #Create Shot Cam
            if id==10031:
                Cam=CreateShotCam()
        #Put Cam in the Link field.

    Side question, I set up my UI with ResEdit, how do I use the symbol names(ie IDC_BUTTON35) instead of the number?



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

    On 11/03/2011 at 21:56, xxxxxxxx wrote:

    I think you're confusing dialogs with descriptions.
    It sounds like you're mixing them up and trying to add description stuff to a regular python script.

    Are you creating a plugin?
    Or are you trying to add GUI items to a python script?

    -ScottA



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

    On 11/03/2011 at 22:09, xxxxxxxx wrote:

    I have a plugin that is using a GUI built in Resedit.

    I have a custom GUI element. It's a link slot. I need to know how to set what object goes into that link slot.

    Then I was also wondering how to use the symbol names found in my c4d_symbols.h file in my res folder instead of the numbers themselves.



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

    On 12/03/2011 at 10:15, xxxxxxxx wrote:

    To put something inside the link field use the same method as UserData:

    def Execute(self, tag, doc, op, bt, priority, flags) :   
      firstobj = doc.GetFirstObject()   
      tag[10001] = firstobj  
    

    And here's what the other external files need for the link attribute to work:

      
    This is the link data in the res/description/ *.res file:  
      
        LINK MY_LINK { ACCEPT{ }; }   
      
      
    This is the link data in the res/description/ *.h file:  
      
        MY_LINK = 10001,  
      
      
      
    This is the link data in the res/strings_us/description/ *.str file  
        
        MY_LINK "My Link";  
    

    As far as using the description names instead of their ID values goes. I'm having a lot of trouble with them.
    You should be able to something like this. Assuming you have a description entry of "rotx" in the .res, .h and .str files: 
    tag[c4d.rotx] = 0.0      
    instead of
    tag[1001] = 0.0

    However...Even though it technically works without errors. I'm getting lots of problems with this method. For example if I do this in the Init function. I cannot override it in the execute function.
    However it all works fine if I use the ID values.

    I'm probably just not using it the correct way. But it should work something similar to that way.

    -ScottA



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

    On 12/03/2011 at 12:03, xxxxxxxx wrote:

    Where is that Execute class you mention? The only one I know of is in plugins.CommandData, and it takes only self and doc.

    What's throwing me off I think is that you seem to be using this on a tag, when this isn't on a tag for me, that function I did before the def Command() is part of my dialog class, so I'm setting up what goes on when I click buttons, use the slider etc. So I'm saying when I click this button it does a check for an object and basically returns an object, and then I want to take that object and put it in the link slot. But I've tried:

    self[10030]=obj

    but that throws back a "object does not support item asignment" error.

    Here's what im doing:

    def Command(self, id, msg=None) :
            #Create Shot Cam
            if id==10031:
                Cam=CreateShotCam()
                print Cam
                self[10030]=Cam

    but this does not work. I know that Cam is being set properly because it is generating a camera object. I'm kind of stumped.



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

    On 12/03/2011 at 13:44, xxxxxxxx wrote:

    The answer to your questions depends heavily on which method (dialog or description) you decide to use.  That's why I asked if you were making a plugin or not.

    You said you're building a plugin using ResEdit GUI items. That's a description based GUI..Not a dialog based GUI.
    And if you are using a description based GUI. You don't create a dialog class for those GUI items.
    Instead you use Init, Message, and Execute functions that work in conjunction with the main class that is set to something like class: MyTag(plugins.TagData) : or  MyObject(plugins.ObjectData) :.

    A dialog based GUI is a completely different animal. So it has to be one or the other. Not both.
    -If you decide to use dialogs and dialog classes. Then *.res & *.h files isn't an option anymore.
    -If you decide to use descriptions. Then using the dialog class isn't an option anymore.

    AFAIK. You can't mix a dialog class GUI with the description based ResEdit GUI file structure.
    You have to make a choice.

    -ScottA



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

    On 12/03/2011 at 14:27, xxxxxxxx wrote:

    Ok, so then since I'm using ResEdit, it's description based. Does that mean I don't use the GeDialog class? Under which class are the Init, Message, and Execute Functions?

    I'm afraid I'm fairly new at this. Does this mean I don't use the Command Function from the GeDialog class? Because up until this little snag everything was working just fine in terms of my interface doing things I tell it to when i click buttons and such.

    The Back story is that this is a plugin, initially I was creating all of the gui stuff by hand, before I tried ResEdit. So I had a class that was running Create Layout and such(I still am actually), anywho, It's a plugin doing an async dialog. The idea is this plugin when opened, you could dock it somewhere and have it available the whole time. Most of the other stuff is working aside from some undo support, but I just am not sure how to add an object into that link slot.



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

    On 12/03/2011 at 15:56, xxxxxxxx wrote:

    The SDK has some examples in it that use descriptions. To see how it's done.
    But from what you've said so far it sounds like you're making a menu plugin.  And if you want my opinion. I would say it's probably smartest to stick to using the gui.GeDialog class for a menu plugin. And forget about using ResEdit for this.....At least for now.
    Description based GUI's are mostly used with tag and object creation plugins.

    I think you should probably concentrate on the original problem. Which is inserting an object into a link field. But I haven't seen enough of your code to offer any more advice on that problem.
    Is there any chance you can post more of it to get a better idea of what's going on?

    Keep in my..I'm probably as new at this stuff as you are. So I don't even know if I can help. But someone else here probably could, if we have more code to work with.
    When you said you were trying combine ResEdit stuff with dialog based gizmos. I was just wondering what the heck you were trying to do. 🙂

    -ScottA



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

    On 14/03/2011 at 10:51, xxxxxxxx wrote:

    You've got it backwards Scott - ResEdit only works with the dialog resource syntax for plugins. It doesn't work with the description resource syntax for tags & objects.

    To modify the linkbox customgui (in dialog resource syntax) you need to use c4d.gui.LinkBoxCustomGui. Unfortunately FindCustomGui seems to be missing from R12, so I think you'll have to flush the group containing the linkbox and add the customgui manually in CreateLayout so you have an instance of it accessible from the class.



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

    On 14/03/2011 at 11:07, xxxxxxxx wrote:

    Doh!
    Sorry about that. My memory is very bad these days.

    -ScottA



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

    On 16/03/2011 at 21:16, xxxxxxxx wrote:

    Follow up question:

    So I've properly flushed the group, so now I'm stuck on trying to add the link slot to the group.

    So I tried:

    linkslot=self.AddCustomGui(9999, PLUGIN_ID, "Shot Cam Slot", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0)

    Now, the  two questions I have are:

    1. it does ask for a plugin id, do they mean the group's id or my actual plugin ID?
    2. It also optionally asks for a basecontainer. I'm assuming this BaseContainer is where I specify that I'm using a link slot, but I don't really understand how I do that.

    So I am confused how to create a reference of a link slot to be able to use it. It's much easier to make the link slot in resedit, but I can't reference it with FindCustomGUI or anything :/



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

    On 16/03/2011 at 21:57, xxxxxxxx wrote:

    One last question:

    How does one reference the object in his c4d_symbols.h file by name? So instead of using 10000 or 10030 I could use things like KEY_BUTTON_5 or KEY_BUTTON_10?

    I thought I could just do c4d.KEY_BUTTON_5 but it doesn't work.



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

    On 16/03/2011 at 22:48, xxxxxxxx wrote:

    I don't know how to add or initialise CustomGui elements, so I'm very interested, too.

    I'm not sure, but there's a difference in Descriprions and Dialogs, so that you may can only use the constant in "c4d.MYCONSTANT" format in descriptions, else without "c4d."

    Cheers, nux



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

    On 17/03/2011 at 03:54, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Follow up question:
    So I've properly flushed the group, so now I'm stuck on trying to add the link slot to the group.
    So I tried:
    linkslot=self.AddCustomGui(9999, PLUGIN_ID, "Shot Cam Slot", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0)
    Now, the  two questions I have are:

    1. it does ask for a plugin id, do they mean the group's id or my actual plugin ID?

    Custom GUI elements are also registered plugin elements in CINEMA 4D so if you want to create a custom GUI element you need to pass the ID of the control ( e.g: c4d.CUSTOMGUI_LINKBOX)

    Originally posted by xxxxxxxx

    2. It also optionally asks for a basecontainer. I'm assuming this BaseContainer is where I specify that I'm using a link slot, but I don't really understand how I do that.

    The container can be used to pass parameters to the custom GUI element (e.g: LINKBOX_HIDE_ICON(Bool), LINKBOX_LAYERMODE(Bool),...)

    As nux95 and ScottA already wrote, Descriptions!=GeDialog. AddCustomGui is a member of GeDialog and cannot be used to create descriptions for your tag, object, ... plugin.



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

    On 17/03/2011 at 08:05, xxxxxxxx wrote:

    Just out of curiosity.
    Is there some special reason why you need to use a LINKBOX?
    In all of the dialog based examples I've seen. They use a text box to produce the same drag&drop behavior as the Description based LINK type of GUI.

    There's an example of this in the Coffee SDK called "GUIdemo.cof" that sounds like what you're trying to do.
    It's in the general_docs_plugins/Example Files section.

    -ScottA



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

    On 17/03/2011 at 15:15, xxxxxxxx wrote:

    I still don't understand how to add a custom gui element. I knoe the functionAddCustomGui(), but where do I define what kind of custom gui ?

    Thanks, Niklas



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

    On 17/03/2011 at 15:30, xxxxxxxx wrote:

    The second argument in AddCustomGui(...) is used to define the type of the customgui.



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

    On 17/03/2011 at 15:40, xxxxxxxx wrote:

    But that's the plugin id ? Or is it just wrong documented ?
    What Id's to overload here?

    Thanks, Niklas



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

    On 30/03/2011 at 07:23, xxxxxxxx wrote:

    I've read through all posts but I still don't understand how to GET the object that's dragged into the link box.

    I am using

    msg.GetLink(ID_OF_CUSTOM_GUI_LINKBOX)
    

    in my dialog's

    Command(id, msg=None)
    

    method but it always results in returning None even though I just dragged a cube object into the link.

    EDIT:

    Error message is:

    AttributeError: 'Py2dSnapDialog' object has no attribute 'GetLink'
    

    if I use

    self.GetLink(...)
    

    instead.

    And what's the deal with class c4d.gui.LinkBoxGui?
    So GetLink is defined both on that class and on BaseContainer?

    This is getting abit frustrating... it was for a plugin that I wanted to put up as open source example :/



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

    On 30/03/2011 at 08:44, xxxxxxxx wrote:

    I would like to see a simple working example of this too.

    -ScottA


Log in to reply