Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Add a dynamic description (STATICTEXT) to a plugin

    SDK Help
    0
    8
    788
    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 02/12/2013 at 20:37, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R15 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi guys, I have a little problem, that drives me nuts.

      I have an ObjectData plugin where I do all the main user interface stuff the usual way with a description resource.

      But now I'd like to add a STATICTEXT at the end of ID_OBJECTPROPERTIES from within the source code (dynamically), because the content of this STATICTEXT shouldn't be possible to alter with simply editing the resource files.

      Here is, how I tried it:

        
      Bool MyPlugin::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)  
      {  
        if (!description->LoadDescription(node->GetType())) return FALSE;  
        
        BaseContainer *bc;  
        
        const DescID *single_id = description->GetSingleDescID();  
        DescID desc_id;  
        
        // add a static text field  
        desc_id = DescLevel(ID_OBJECTPROPERTIES, DTYPE_STATICTEXT, 0);  
        if(!single_id || desc_id.IsPartOf(*single_id, NULL))    // important to check for speedup c4d!  
        {  
            bc = description->GetParameterI(desc_id, NULL);  
            if (bc)  
            {  
                BaseContainer container = GetCustomDataTypeDefault(DTYPE_STATICTEXT);    // Create a custom datatype container.  
        
                container.SetLong(MYPLUGIN_INFO, 9000);    // I'm not sure if that makes any sense at all.  
                container.SetString(DTYPE_STATICTEXT,  "Here would be the respective text, that should be added.");    // but I guess it's wrong here  
                container.SetString(DESC_NAME, "Or maybe here?");  
                container.SetString(DESC_SHORT_NAME,  "Or here?");    // very unlikely but just to have it checked  
                container.SetContainer(DTYPE_STATICTEXT, *bc);    // probably wrong too  
            }  
        }  
        
        flags |= DESCFLAGS_DESC_LOADED;  
        
        return ObjectData::GetDDescription(node, description, flags);  
      }  
      

      I also tried it with the "BaseContainer.SetParameter()" function but without success either.

      But as you may see from the source example above, I couldn't even find out the correct ID to assign the text string.

      And most likely it's total crap anyway, how I tried it. !Embarrassed[URL-REMOVED]

      Would be nice, if someone could help me with this topic.

      (By the way, the "MyPlugin" naming is of course only here for this demo purpose, so no comments about that please! !Wink[URL-REMOVED])


      [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

        On 03/12/2013 at 03:30, xxxxxxxx wrote:

        Hi,

        You can declare the static text in the resource file then set its string content in the Init() method of your ObjectData.

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

          On 03/12/2013 at 05:05, xxxxxxxx wrote:

          I agree with Yannick.  The STATICTEXT description resource can be static (declared in the resource file) but you can change the text.  It does not have to be declared in the .str for the resource file.  In your derived Init() method, you can do this:

          node->SetParameter(MYOBJECT_STATICTEXT, GeData("My Text"), DESCFLAGS_SET_0);
          

          where MYOBJECT_STATICTEXT is the description value in your .res file for your ObjectData for the STATICTEXT element.

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

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

            Yes of course that works! 😉

            But I would have prefered if I could manage it completely without the use of the resource files.
            So if someone know how to do it and could show it to me, I'd still be happy. 🙂

            But thank you anyway, Yannick and Robert.
            It's at least a compromise I can live with, if I don't find a better way.

            Kind regards,
            Tom

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

              On 04/12/2013 at 00:51, xxxxxxxx wrote:

              Hi Tom,

              Here is how we can add a STATICTEXT description element dynamically without the use of the resource file:

              Bool DoubleCircleData::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)
              {
                BaseContainer* data = ((BaseObject* )node)->GetDataInstance();
                if (!data)
                  return false;
                
                if (!description->LoadDescription(1001154))
                  return false;
                
                const DescID* singleid = description->GetSingleDescID();
                
                DescID cid = DescLevel(10001, DTYPE_STATICTEXT, 0);
                if(!singleid || cid.IsPartOf(*singleid, NULL))
                {
                  BaseContainer bc = GetCustomDataTypeDefault(DTYPE_STATICTEXT);
                  bc.SetString(DESC_NAME, "statictext");
                  if (!description->SetParameter(cid, bc, DescLevel(ID_OBJECTPROPERTIES)))
                    return true;
                  
                  data->SetString(10001, "The Static Text that will be displayed in the AM");
                }
                
                flags |= DESCFLAGS_DESC_LOADED;
                
                return ObjectData::GetDDescription(node, description, flags);
              }
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 04/12/2013 at 08:42, xxxxxxxx wrote:

                Hi Yannick,

                thank you very much, works like a charm! 😎

                Just out of curiosity:

                Why doesn't the strongly recommended SetParameter() method work like this,

                  
                BaseObject *op = (BaseObject* )node;  
                if (op)  
                {  
                  op->SetParameter(10001, GeData("The Static Text that will be displayed in the AM"), DESCFLAGS_SET_0);  
                }  
                

                instead of accessing the container through GetDataInstance?

                  
                BaseContainer *data = ((BaseObject* )node)->GetDataInstance();  
                if (data)  
                {  
                  data->SetString(10001, "The Static Text that will be displayed in the AM");  
                }  
                

                I'm referring here e.g. to: Please use GetParameter/SetParameter

                Edit:
                Okay, I think it's because I accidently used the "C4DAtom::SetParameter()" instead of the "Description::SetParameter()" function.
                And into the bargain they even have to be called with different parameters:

                Bool C4DAtom::SetParameter(const DescID& id, const GeData& t_data, DESCFLAGS_SET flags)_<_h4_>_vs.

                Bool Description::SetParameter(const DescID& id, const BaseContainer& param, const DescID& group_<_h4_>_h4>So I guess, forget about the "SetParameter()" thing here, as it also works via a BaseContainer.

                Or would there also be a benefit using it instead of the straight way Yannick showed me?

                Kind regards,
                Tom

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

                  On 05/12/2013 at 04:10, xxxxxxxx wrote:

                  Hi,

                  If you are in your own ObjectData and you store a parameter in the data container it is safe to get/set directly its data in the container.

                  C4DAtom::SetParameter() and Description::SetParameter() don't do the same.
                  C4DAtom::SetParameter() sets a parameter value.
                  Description::SetParameter() sets the description container of a parameter.

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

                    On 05/12/2013 at 06:07, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    Hi,

                    If you are in your own ObjectData and you store a parameter in the data container it is safe to get/set directly its data in the container.

                    Thank you for the clarification. 🙂

                    Originally posted by xxxxxxxx

                    C4DAtom::SetParameter() and Description::SetParameter() don't do the same.
                    C4DAtom::SetParameter() sets a parameter value.
                    Description::SetParameter() sets the description container of a parameter.

                    Yep, that is clear so far. 😉
                    That's why I wrote in my edit, that I used the wrong one and how they differ.
                    But perhaps I expressed myself unclear in my last post.
                    Sorry, but english isn't my native language. 😊

                    Kind regards,
                    Tom

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