shareFrom fails

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Leafw
Posts: 0
Joined: Sun Apr 18, 2004 10:53 pm

shareFrom fails

Post by Leafw » Mon May 14, 2007 6:11 am

I create two objects with:

Code: Select all

ob1 = Blender.Object.New('Mesh', 'name1')
ob2 = Blender.Object.New('Mesh', 'name2')
Then I create a Mesh and link it to the first:

Code: Select all

mesh = Blender.Mesh.New('name')
ob1.link(mesh)
Then I share the data:

Code: Select all

ob2.shareFrom(ob1)
And although both print the same when called getType() on:

type 1: Mesh
type 2: Mesh

This is the result:

Traceback (most recent call last):
File "load_shapes_v1.5.0.py", line 302, in bevent
File "load_shapes_v1.5.0.py", line 508, in processData
File "load_shapes_v1.5.0.py", line 893, in place
TypeError: objects are not of same data type


Yes I am puzzled. Blender 2.43 on linux x86.

I understand that Blender.Object.New is deprecated, and that one should use scene.objects.new, and yet, with the latter I fail to see how can I create objects that are NOT linked to a scene, so that then I can just use a a template for numerous other objects that will call shareFrom on it.
Should I just create the mesh and link the mesh directly?

reD_Fox
Posts: 0
Joined: Sat Mar 12, 2005 2:56 pm
Location: Abilene, KS

Post by reD_Fox » Tue May 15, 2007 6:36 pm

Yes, I am a bit puzzled as well. However, it seems you'll probably need to find a work-around. It seems that an object needs to be assigned mesh data before the shareFrom() function recognizes it as having a "Mesh" type. For instance, the following script fails:

Code: Select all

import Blender

ob1 = Blender.Object.New('Mesh', 'name1')
ob2 = Blender.Object.New('Mesh', 'name2')

mesh = Blender.Mesh.New('name')
ob1.link(mesh)

ob2.shareFrom(ob1)
But the next script succeeds (ob2 is first linked to mesh data):

Code: Select all

import Blender

ob1 = Blender.Object.New('Mesh', 'name1')
ob2 = Blender.Object.New('Mesh', 'name2')

mesh = Blender.Mesh.New('name')
mesh1 = Blender.Mesh.New('name1')
ob1.link(mesh)
ob2.link(mesh1)

ob2.shareFrom(ob1)
EDIT: This has been fixed in development code, and will be working properly in the next release - http://lists.blender.org/pipermail/bf-b ... 09962.html

Levi
A three-legged stool never wobbles.

Leafw
Posts: 0
Joined: Sun Apr 18, 2004 10:53 pm

Post by Leafw » Sat May 26, 2007 7:14 am

Thanks red_fox! Let's see if 2.44 fixes it.

Post Reply