From: David S. <dsc...@cm...> - 2000-12-27 20:50:01
|
> I'd like to use Visual to model complex items and I'd > like to accomplish these tasks: > > Store the data (pos, axis, color, etc) for > each individual component of a complex item > in a database > > Pull the data from the database and feed it > into Visual > > Automate the process of refreshing the scene > when changes are made to the data > > I picture the Visual window running on one computer > while on another computer I manipulate the data using > standard DB tools. Periodically, the scene will be > refreshed and I can look at the results of my data > manipulation. > > If anyone has learned any nuances of Visual's behavior > that might help me accomplish these tasks, I'd be > grateful for the sharing. As Bruce said, what you want to do has more to do with databases than with Visual. Assuming you can find an appropriate database library for Python, your program will be something like: import visual import some_db_lib db = some_db_lib.opendatabase(...) old_objects = {} while 1: rows = db.execute("select id,class,pos,axis,color from objects") new_objects = {} for id,classname,pos,axis,color in rows: cls = getattr(visual,classname) o = old_objects.get(id) if not o: o = cls(visible=0) elif o.__class__<>cls: # Class changed, make a new object o.visible = 0 o = cls(visible=0) o.pos = pos o.color = color o.axis = axis o.visible = 1 new_objects[id] = o for id in old_objects.keys(): if not new_objects.has_key(id): old_objects[id].visible = 0 old_objects = new_objects |