[Bf-python] makeparent()

models at paposo.com models at paposo.com
Mon Nov 10 04:14:06 CET 2003


It me again :)

Im working on the lattice module and am running into problems with make parent() in object.c
I run this script:

###############
import Blender
from Blender import Lattice
from Blender.Lattice import *
from Blender import Object
from Blender import Scene

myOb = Object.New('Lattice')
myLat = Lattice.New()
myLat.setPartitions(5,5,5)
myLat.setLatKeyTypes(LINEAR, CARDINAL, BSPLINE)
myLat.setMode(OUTSIDE)

myOb.link(myLat)
myCube = Object.Get('Cube')  <---------------- primative cube from .blend file
myOb.makeParent([myCube])  <--------- crashes blender

sc = Scene.getCurrent()
sc.link(myOb)

Blender.Redraw()
############

The crash comes when I exit blender:

##########
BLI_remlink(ListBase * 0x0121fafc, void * 0x0120679b) line 246 + 19 bytes
free_libblock(ListBase * 0x0121fafc, void * 0x0120679b) line 470 + 13 bytes
free_main(Main * 0x0121fa3c) line 507 + 19 bytes
free_blender() line 169 + 11 bytes
exit_usiblender() line 534

void BLI_remlink(ListBase *listbase, void *vlink)
{
 struct Link *link= vlink;
 if (link == 0) return;
 if (listbase == 0) return;
 if (link->next) link->next->prev = link->prev;  <------------------- this line crashes
..........
############

The crash comes because of this line in Object.c Object_makeparent():

/* We don't need the child object anymore. */
  Py_DECREF ((PyObject *) child);

It doesn't make sense to decrement child since it's not a PyObject - it's a pointer to the Py_Object's datablock that's being passed in. Am I missing something here?

Also there is a part of makeparent that's missing:

child->parent = parent;

The parent needs to be sent for the link to occur (the cool little dashed line :o). But when I do this I get some wacked out behavior from the displists when I move the child object around. It reshapes itself to the size of the parent object. ???






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20031109/41ff7eec/attachment.html>


More information about the Bf-python mailing list