Plugin Specific Data not set
-
On 13/10/2017 at 10:40, xxxxxxxx wrote:
Hi,
Our plugin has been saving data to the active document for a couple of years now without issue, however we recently had one client contact us where the data would not write/read. This is happening on multiple of their workstations running Win10 and C4D v18.
Here is the code we use to save and retrieve the information.
> import c4d
>
> plugin_ID=1000001 #tmp ID for testing
>
>
>
>
> # WRITE
>
> doc=c4d.documents.GetActiveDocument()
>
> container=c4d.BaseContainer()
>
> myString=container.SetString( 9111, "This is my string" )
>
> doc[plugin_ID] = container
>
>
>
>
> # READ
>
> doc=c4d.documents.GetActiveDocument()
>
> container=doc.GetDataInstance()
>
> newString =container[plugin_ID].GetData( 9111 )
>
> print ' STRING: %s' % newStringThis has been working successfully for multiple clients except this one specific client. We also tried changing the read to this:
>
>
>
> # READ
>
> doc=c4d.documents.GetActiveDocument()
>
> container = doc[plugin_ID]
>
> newString = container.GetString( 9111 )
>
> print ' STRING: %s' % newStringThis also produced the same result of no data read on their workstations... this does work on ours.
We thought that there may have been a conflicting plugin id but couldn't find evidence of that. Is there another reason that we are missing that would keep data from being saved to a document?
On a side note the same client says that they do not have the issue in C4D v19.
Any help would be greatly appreciated...
Andrew -
On 16/10/2017 at 03:38, xxxxxxxx wrote:
Hi and Welcome to the Plugin Cafe!
This is a known issue that got introduced in R18.057 (R18 SP3). It was fixed in R19.024 (R19 SP1). Unfortunately there's no fix for R18.
The operator [] gives corrupt/invalid containers and this also affects other functions returning containers.
The workaround in R18.057 is to use GetContainer()/GetContainerInstance() instead.Note the IDs in the range reserved for development (1000001-1000010) should not be used to set data into a document's container.
Because these IDs are only meant for testing and data should be saved into a document using arequested plugin ID
[URL-REMOVED].
Also, the IDs within the range 1000000-1001000 are reserved for special document's scene hooks.
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 16/10/2017 at 11:25, xxxxxxxx wrote:
Thanks Yannick! Glad to see I'm not crazy.
All good on the plugin ID btw... I just slugged that in for demo purposes.
While we're on the container topic, what is the preferred read method:
container=doc.GetDataInstance()
or
container = doc[plugin_ID]Thanks,
Andrew -
On 17/10/2017 at 04:19, xxxxxxxx wrote:
Originally posted by xxxxxxxx
While we're on the container topic, what is the preferred read method:
container = doc.GetDataInstance()
or
container = doc[plugin_ID]These lines does not perform the same operation.
doc.GetDataInstance() returns the data container instance for the document. While doc[plugin_ID] returns the plugin_ID sub-container of the document data container.
With the data container instance another line is needed to retrieve the sub-container.Note doc[plugin_ID] returns a copy of the sub-container so if it is changed, it must be assigned back.
Using the [] operator in Python to access parameters is preferred because it is faster to write and more pythonic. Unfortunately it is broken in R18.057.