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

    SDKBrowser::SetPresetAnnotation

    SDK Help
    0
    8
    657
    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 22/09/2014 at 10:12, xxxxxxxx wrote:

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

      ---------
      Hi everyone,

      I'm working on an internal C++ plugin that creates a cat4d file from a cvs file. To achieve this I am using the SDKBrowser class from lib_browser.h.

      As I cannot find any example of how to work with SDKBrowser, I started knocking up simple code that walks an existing catalog structure. SDKBrowser::GetPresetAnnotation() works great to read an annotation, but I cannot seem to set an annotation using SDKBrowser::SetPresetAnnotation().

              String annotation;
              if (SDKBrowser::GetPresetAnnotation(db_index, url, annotation)) {
                  GePrint("GetPresetAnnotation: " \+ annotation); // This works
              }
              
              if (SDKBrowser::SetPresetAnnotation(db_index, url, String("test annotation"))) { // SetPresetAnnotation always fails!
                  
                  SDKBrowser::UpdateNotification(airtransport_node);
                  
                  SDKBrowser::GetPresetAnnotation(db_index, url, annotation);
                  GePrint("SetPresetAnnotation: " \+ annotation);
              }
      

      What am I doing wrong?

      Thanks
      Julien

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

        On 10/10/2014 at 14:00, xxxxxxxx wrote:

        Hi Julien,

        I'd like to help you with the issue you're experiencing with SDKBrowser::SetPresetAnnotation().  However, I need a more elaborate chunk of code from you, as I don't have enough basic information with your code snippet.  I'd especially like to see how you define and set the parameters, db_index and url, since you are having issues with one or both of them indirectly.

        Please provide as much code as you can so that I can reproduce its functionality on my end quickly.  I'm new to C4D, so not much is obvious to me in the C4D plugin coding context yet.

        I'd also like to know if you are experiencing the same issue with GetPresetName()/ SetPresetName().  That is, does GetPresetName() work but SetPresetName() fail?

        Thanks,

        Joey

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

          On 05/11/2014 at 08:08, xxxxxxxx wrote:

          Since it's been almost a month, and yet no reply from Julien / jrigal (and no other postings before or since from him), I will close this topic as solved and only come back to it if notified of a new posting.

          Joey Gaspe
          SDK Support Engineer

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

            On 05/11/2014 at 08:20, xxxxxxxx wrote:

            Hi Joey,

            sorry for not coming back to you with more details about this problem. It has not been resolved but I wanted to check with R16 before posting here again.

            Best
            Julien

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

              On 05/11/2014 at 10:55, xxxxxxxx wrote:

              Hi Julien,

              In that case, I'll remove the [SOLVED] tag to the title.  Come back to us when you can with more details or if you do resolve it on your own, sharing your solution would be welcomed!  Don't forget, we're here to help.

              Thanks,

              Joey Gaspe
              SDK Support Engineer

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

                On 05/11/2014 at 13:01, xxxxxxxx wrote:

                Here is a complete R13 example that creates a custom preset and adds the selected object to it.
                It also writes annotation notes in the object's Info tab.

                Bool SimplePlugin::Execute(BaseDocument *doc)  
                {  
                  //The object that we will save to a new preset library  
                  BaseObject *obj = doc->GetActiveObject();  
                  if(!obj) return FALSE;   
                  
                  //The name for the new preset  
                  String presetName = "MyPreset";  
                  
                  //The path to the library/browser folder in AppData  
                  Filename cbPath = GeGetC4DPath(C4D_PATH_LIBRARY_USER);  
                  if (!cbPath.Content()) return SDKBrowser::InvalidPresetDb;  
                  
                  //The full path to the new preset  
                  String fullPath = cbPath.GetString() + "//browser//" + presetName;  
                  
                  //The path to the new preset(needed for the RegisterPresetLibrary() function next)  
                  String dbUrl = "preset://" + presetName;  
                  
                  //We have to register the new preset using RegisterPresetLibrary()  
                  //If we don't register it. The preset will disappear when we close C4D   
                  LONG dbIndex = SDKBrowser::RegisterPresetLibrary(dbUrl, presetName, fullPath);  
                  
                  //Create a URL type variable using the location of the newly created preset  
                  SDKBrowserURL url(String("preset://MyPresets/MyObject"));  
                  
                  //Get the database index for the newly created preset  
                  LONG index = SDKBrowser::GetDbIndex(String("preset://MyPresets"));  
                    
                  //Add the object to the preset library  
                  SDKBrowser::CreatePresetNode(index, url, CBPluginTypeObjectPreset);  
                  SDKBrowser::SavePresetObject(url, obj);  
                  
                  //The preset folder is always index #0  
                  //The first item added to this folder is index #1 ... and so on   
                  String annotation = "First Object's Annotion Notes";  
                  SDKBrowser::SetPresetAnnotation(1, url, annotation);  
                  
                  if(SDKBrowser::GetPresetAnnotation(1, url, annotation))   
                  {  
                      GePrint("GetPresetAnnotation: " + annotation);  
                  }  
                  
                  
                  EventAdd();  
                  return TRUE;  
                }
                

                -ScottA

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

                  On 05/11/2014 at 17:12, xxxxxxxx wrote:

                  First of all, thank you for your code ScottA!

                  I had a closer look at what I was doing, and I think I found the error.
                  I was working on Catalog items (cat4d, which I failed to mention in my first post). When I use the same code on Preset items (as per Scott's code), everything ist fine.

                  Does this mean Catalog items cannot be edited by the SDK?

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

                    On 05/11/2014 at 17:31, xxxxxxxx wrote:

                    We can't even search through the factory presets. So it wouldn't surprise me if we can't add, subtract, or edit things in them too.

                    I posted all of my notes about the CB in this thread:
                    https://developers.maxon.net/forum/topic/7513/9403_how-to-use-getdbindex&KW=SDKBrowser&PID=37178#37178

                    Yannick taught me how to use them. So he's the guy that would probably know for sure.
                    But I don't know how you'd contact him anymore.

                    -ScottA

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