On 03/01/2015 at 13:28, xxxxxxxx wrote:
Sorry for a dumb question, but how do I store plugins first launch date (Day/Month/Year) using WriteRegInfo() :
To be honest, I have no idea how to pass string to buffer
Thanks in advance.
On 05/01/2015 at 15:42, xxxxxxxx wrote:
Here's an example of how to pass a byte string to a ByteSeq buffer. You'll have to change the plugin ID and get the properly formatted launch date.
import c4d def main() : # Save and load the date Day/Month/Year, so 10 bytes WriteDateBuffer = "05/01/2015" # Create a byte sequence to hold the string WriteDateByteSeq = c4d.storage.ByteSeq(None, 10) # Copy the string into the byte sequence WriteDateByteSeq[0:10] = WriteDateBuffer # Write the user specific data c4d.plugins.WriteRegInfo(1000001, WriteDateByteSeq) # Read the user specific data to make sure it was written correctly ReadDateByteSeq = c4d.plugins.ReadRegInfo(1000001, 10) print WriteDateBuffer print WriteDateByteSeq print ReadDateByteSeq return
Setting a byte sequence is explained in the __setitem__ section of the Python SDK documentation:
SDK Support Engineer
On 05/01/2015 at 20:21, xxxxxxxx wrote:
Is there a way to delete this kind of byte sequence data?
The reason I ask is because once someone creates this. It stays there permanently.
Even if the plugin is deleted!
Just like storing data in the WorldContainer.
I really don't appreciate people filling my memory with permanent garbage like this. Unless there is some mechanism in place to delete it if the plugin is deleted.
On 06/01/2015 at 03:08, xxxxxxxx wrote:
Hi Joey. Appreciate your help. Yes, read your code like 100 and now I get it:) Thank you.
ScottA, in order to delete that info, I think this will work:
emptyByteSequence = c4d.storage.ByteSeq(None, 1) c4d.plugins.WriteRegInfo(PLUGIN_ID, emptyByteSequence)
ScottA, you have a good point here.
However, is there a better way to store that data?
On 06/01/2015 at 07:32, xxxxxxxx wrote:
^I personally prefer to store any data like this in either tags or the document itself.
That way it's never permanently stored on the user's system.
These are small bits of data. And if a couple of people store a few things on my system it's really no big deal.
But if a lot of people start doing this. And/or someone decides to store a large array of data in there. Then that becomes a problem.
On 06/01/2015 at 08:06, xxxxxxxx wrote:
Glad to help! I can confirm that your code to delete the info works. I retrieved the data both at the beginning and end of the script with your code and without, and get the expected results of either the data being removed or still being there, respectively.
As for ScottA's question about a better way to store data, I have a few suggestions:
- Store it in a file, perhaps C4D's HyperFile functionality could help? Either way, creating your own data file is probably the best option.
- If you're certain you or your clients only work on Windows, you can perhaps use the registry. I don't know Mac OS X that well, but apparently there are a few roughly equivalent options, such as Property Lists.
Note: Offering cross platform compatibility is the reason why there are various options within C4D that appear to replicate, even if only in a minimal way, other operating system data storage options.
SDK Support Engineer
On 06/01/2015 at 09:45, xxxxxxxx wrote:
Just for clarity.
I'm not against people using the WorldContainer or the WriteRegInfo() as long as they do something to delete the data if the plugin gets removed. Which is difficult because the SDK does not have anything that does this.
Providing a simple script with your plugin that the users can run is enough (although a bit clumsy).
But it would be a nice option to have in the SDK to be able to scan all currently installed plugins. And delete any stored data that previous plugins might have created.
Not sure if that's possible or not.
On 06/01/2015 at 10:02, xxxxxxxx wrote:
Originally posted by xxxxxxxx
But it would be a nice option to have in the SDK to be able to scan all currently installed plugins. And delete any stored data that previous plugins might have created.Not sure if that's possible or not.-ScottA
Not really viable because if a plugin is temporarily removed its stored info is deleted, then when the user wants to use the plug again all its data is gone.
TBH I don't understand the concern about a few bytes or few kbytes in the days of terabyte-sized HDs.
On 06/01/2015 at 10:35, xxxxxxxx wrote:
^This thinking is why I need to format my HD roughly every six months Steve.
It's the old "It's only 30cents a day pitch".
By itself it's not a big deal. But the problem is if everyone does it. Then you no longer pay just 30cents a day. You start paying out big money every day.
The amount of data being left on my computer after I delete a program is astounding!
Programmers are doing it more and more these days. And now IMO it's an epidemic.
So I've become very aware of this issue in my own coding practices. And I've pledged to never leave data behind in anything I write. No matter how small it is.
On 06/01/2015 at 11:01, xxxxxxxx wrote:
Now think how long it takes you to reformat your HD and reinstall all the data (and OS and software?) and how much that costs if your time is money. Then consider how you could save all that time (money) by buying a larger HD and forgetting about the few bytes a C4D plugin writes to the registry or wherever.
On 06/01/2015 at 12:08, xxxxxxxx wrote:
I second that Scott. If there's a way NOT to store something in memory, then don't. I raised this question simply because IT CAN BE DONE in Cinema, that's all. Not because I will go and store unnecessary info in c4d.plugins.WriteRegInfo(pluginid, buffer).