SetWorldContainer bug
-
On 30/07/2017 at 03:22, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 18.057
Platform: Windows ;
Language(s) : PYTHON ;---------
Method c4d.SetWorldContainer() isn't working in Cinema4D R18.057.
The container is not updated and the data remains the same.
With C4D R17 this code works fine.
Perhaps this is somehow connected with this bugimport c4d PLUGINID = 1234588880 def main() : wbc = c4d.GetWorldContainer() if not wbc[PLUGINID]: bc = c4d.BaseContainer() wbc[PLUGINID] = bc bc = wbc.GetContainer(PLUGINID) print bc[1] #check stored value, on next launch the scipt it must be 1.0, but still None bc.SetFloat(1,1.0) wbc.SetContainer(PLUGINID,bc) c4d.SetWorldContainer(wbc) print bc[1] if __name__=='__main__': main()
-
On 31/07/2017 at 03:20, xxxxxxxx wrote:
Hi,
Yes the issue here is related to the other getting containers with [] operator.
The condition if not wbc[PLUGINID] is always entered (returns None) so the container is then always reset.
Use wbc.GetContainer(PLUGINID) instead. -
On 01/08/2017 at 03:59, xxxxxxxx wrote:
ok, im trying to find solution. And now other question about BaseContainer:
this code works fine with R17 and not with R18.057.
Whats wrong with this example?import c4d from c4d import gui #Welcome to the world of Python PLUGIN_ID = 10000025 def main() : data = op.GetDataInstance() bc = data.GetContainer(PLUGIN_ID) color_bc = bc.GetData(1) if not color_bc: color_bc = c4d.BaseContainer() color_bc.SetVector(0,c4d.Vector(0,0,0)) else: i = len(color_bc) color_bc.SetVector(i,c4d.Vector(i,i,i)) bc.SetContainer(1,color_bc) data.SetContainer(PLUGIN_ID,bc) op.SetData(data) bc = data.GetContainerInstance(PLUGIN_ID) color_bc = bc.GetData(1) for i,v in color_bc: print i,v if __name__=='__main__': main()
In all my plug-ins and scripts, I use this method of storing information in an object, document, or program settings containers. But now I just have no idea how this should work. After the release update 18.057 I began to receive a tons of bug reports from users!
-
On 01/08/2017 at 08:15, xxxxxxxx wrote:
In R18.057 GetData() has the same issue as the get [] operator. Use GetContainer() or GetContainerInstance() instead.
In your script the call to op.SetData(data) is useless because you are already working on the data instance. In the beginning of the script data = op.GetDataInstance().