[Bf-python] Scripting error or bur in API ?

Michel Selten michel.s at home.nl
Wed Aug 27 20:26:04 CEST 2003


On Mon, 2003-08-25 at 02:02, Patrice Ferlet wrote:
> Hello
> 
> I am using Blender 2.28a, and trying to duplicate object in python script.
> 
> I get an object, named "objSrc" which is a mesh.
> 
> I create  a new mesh and use shareFrom method:
> 
> mymesh=Blender.Object.New('Mesh',"test_mesh")
> mymesh.shareFrom(objSrc)
> 
> Here is the python output:
> In Object_GetSelected()
> [Object "Cube"]
> Traceback (most recent call last):
>   File "Text", line 12, in ?
> TypeError: argument 1 is not of type 'Object'

A mesh is always linked to an Object. After all, an Object has all kind
of nice attributes which are general across most of the other object
types within blender including Mesh.
The shareFrom function needs to have an object of type Object as the
argument. So, you shouldn't pass the objSrc to shareFrom, but the
generic Object linked to the Mesh.

> So, i try to remove the "new" method and i have:
> In Object_GetSelected()
> [Object "Cube"]
> Traceback (most recent call last):
>   File "Text", line 12, in ?
> AttributeError: type object 'object' has no attribute 'shareFrom'

Well, mymesh is not initialised in your script yet, so it doesn't know
you would like it to be a blender Object. Since the shareFrom method is
only applicable to the blender Object type, you get the above error.

I hope this helps.

With regards,
	Michel





More information about the Bf-python mailing list