PDA

View Full Version : Pickling Nodes


Vygreif
02-21-2006, 06:28 PM
Hi,
I'm trying to save nodes as pickled objects, and then loading them later. Does Vizard suppord the pickling of those objects fully?

I currently have this problem:
When the user clicks s, I save the object with the following code:
In this example I'm only saving one object.
if key == 's':
male = viz.add('male.cfg')
objects = viz._GlobalNodeList.values()
f = file("test.sv", "w")
temp = objects[0]
pickle.dump(temp,f,1)
f.close()
When he clicks l I load the code
if key == 'l':
f = file("test.sv", "r")
u = pickle.Unpickler(f)
x = u.load()
viz.add(x)
f.close()

However, when I try this I get the following error:
Traceback (most recent call last):
File "fileinputoutput.py", line 38, in mykeyboard
viz.add(x)
File "C:\Program Files\Vizard25\viz.py", line 4877, in add
s = what.split('.')
AttributeError: VizAvatar instance has no attribute 'split'

Thanks,
YG

farshizzo
02-22-2006, 09:54 AM
Hi,

Vizard nodes do not support pickling operations. You will have to manually retrieve the data you want to save and reapply it when you load it. Also, you can't pass Vizard node objects to the add command.

Vygreif
02-22-2006, 05:41 PM
If I do
n = viz.add('ball.wrl')
viz.get(viz.WHAT)
Would return ball.wrl?

farshizzo
02-23-2006, 10:03 AM
Hi,

Are you asking how to get the filename of an object? That functionality does not exist in Vizard.