On 10/22/2010 09:13 PM, fink wrote:
> I've tried the code below in 0.8.0.1 release, and 0.8.0.2 from hg, on multiple computers, and K-3D crashes on execution for both. Does it do the same for you?
> import k3d
> doc = context.document
> camera_name = "Camera Top"
> camera_pos = (0, 0, 10)
> camera = k3d.plugin.create("Camera", doc)
> camera.name = camera_name
> camera_position = k3d.plugin.create("FrozenMatrix", doc)
> camera_position.matrix = k3d.translate3(camera_pos)
> #no crash if the following line is commented out
> k3d.property.connect(doc, camera_position.get_property("output_matrix"), \
> existing = k3d.node.lookup_one(doc, camera_name)
So, I've been poking at this off-and-on. It seems that the crash only
happens when deleting a node that has property connections, with
undo-redo disabled. So you could fix this in a couple of ways: first,
you don't need to make property connections just to position the camera,
you could do:
camera = k3d.plugin.create("Camera", context.document)
camera.name = "Camera Top"
camera.input_matrix = k3d.translate3((0, 0, 10))
Second, you could enable the undo/redo mechanism when you delete your
context.document.finish_change_set("Delete top camera")
... this essentially duplicates what happens when you delete something
through the UI, and explains why we haven't noticed this problem there.
It's a good idea to make your scripts undoable anyway, to be a good