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

    Storing BaseContainer inside object

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 952 Views
    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 Offline
      Helper
      last edited by

      On 17/06/2018 at 23:56, xxxxxxxx wrote:

      Hi guys, relative beginner with Python scripting but i've making good progress with a small internal plugin i've been working on for our studio. One thing i'm having trouble on, is saving a list generated by the plugin inside the document (or more specifically, the plugin object) so that the list is stored for next time the doc is opened/plugin is run and everything works as intended. Without copying the huge mess that is my code itself, i've create a cut down version of what i'm trying to do (which doesn't work).
          
             #To make and set the container:
             string_list = ['image_path1', 'image_path2']
             
             bc = c4d.BaseContainer()
             
             for index , image_path in enumerate(string_list) :
                 bc[index] = image_path
                 print bc[index]
             
             op[MYPLUGINVARIALBLE] = bc
             
             #To get the container again:
      bc = op[MYPLUGINVARIALBLE]
      print bc
             
             for index, image_path in bc:
                 print index, image_path

      So i'm correctly assigning the strings to the base container and i'm creating and that prints as expected when testing. Then, I assign my object (with unique ID assigned to MYPLUGINVARIABLE) s the newly created base container.

      So then, I test trying to bring back the base container and printing the values which is the part that doesn't seem to work. When I assign 'bc' to be the value stored with my unique plugin ID, this prints (what I assume is) correctly as a base container.

      The part that doesn't work, which is where my code falls over and implies that i'm likely doing some silly, is that when I iterate through the values stored in this base container (which should be the string values) nothing is actually there and it doesn't seem to be working as I expect it to in my head.

      This little part of the code has been holding me up for a few weeks now so any help would be appreciated - even if i'm completely off the right track then it would be great if someone could point me in the right direction.

      Thanks,

      Col

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

        On 18/06/2018 at 08:37, xxxxxxxx wrote:

        Hi Col,

        welcome to the Plugin Café forums 🙂

        Which version of Cinema 4D are you working in?
        There was a bug with retrieving BaseContainers in R18, which got fixed with R19 SP1. To me it sounds a bit like you may experience this bug. Fortunately you can work around it, see this thread: Plugin Specific Data not set

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

          On 18/06/2018 at 23:47, xxxxxxxx wrote:

          Hi Andreas, thanks for the help!

          We are using R18 in the studio but I actually got this working perfectly yesterday using SetContainer and GetContainer thanks to some help from another user.

          Good to know that the initial way I was trying it wasn't 100% down to my lack of experience and may have been a bug!

          Thanks again for the help.

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