Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
On 03/02/2014 at 12:45, xxxxxxxx wrote:
This is more of a general C4D scripting question but I'm working in Python so I thought this would be the most appropriate place to ask.
When I run my script I want to store the editor and render visibility states of every object in the document. Later I want to be able to return to those stored states.
In researching how to do this it seems that using the c4d.BaseContainer object's SetData(id, data) and GetData(id) methods would be the way to go but I'm a little hazy on the actual details of implementing it.
My current thinking is that I should store the data that pertains to the object in that object. For example, if operating on just one object:
> bc = op.GetDataInstance() > bc.SetData(my_id, op.GetEditorMode()) > The above raises a couple of questions though:
Thanks for your time. Just getting started with Python and C4D scripting so any help you can provide would be much appreciated
>
On 03/02/2014 at 13:23, xxxxxxxx wrote:
Hi darby and welcome to the PluginCafe!
Regarding your "my_id", just make sure it's a unique ID you obtained from the PluginCafe. You are, however, free to use a Plugin ID that you used for registering a plugin since they will not collide within the context of the container.
Best, -Niklas
On 03/02/2014 at 21:38, xxxxxxxx wrote:
Thanks for the help Niklas!
I've made some good progress today although I can't help but think I'm not following best practices. I'll definitely post some code once I have it working. Hopefully you kind folks will tear it to shreds so that I can build it better
There's one small implementation detail for the script I'm writing that I can't seem to work around. I'd like my script to have 2 different behaviors (which I'll call 'A' and 'B'). On first run and every other run after (run 1, 3, 5, etc.) I want behavior A while on the second, fourth, sixth, etc. run I want behavior B.
My intuition says that I need to set a flag that is stored beyond the life of the script, check that flag to see which behavior should occur and then toggle that flag between states at the end of every run.
The problem is that I can't figure out how to reliably set a flag that will exist beyond the short life of each script run. I tried storing it in a new BaseContainer but it would appear that these don't exist in memory beyond the script unless they are associated with a C4D object. Any suggestions?
Much obliged, Darby
On 24/04/2014 at 12:57, xxxxxxxx wrote:
Hey Darby,
You can try saving that data in the active document's BaseContainer.
-Donovan