[Solved] How to copy properties from one object to another?

I’m working on a script (which to my knowledge has not been done before), which will do both intersect and difference boolean operations at the same time (basically, just cut the mesh).

However, I end up with 2 objects. 1 object is just the original object with the intersect mesh, and the 2nd object is a new object with the difference mesh. The new object jumps to the origin and loses all properties such as scale and rotation.

Is there a comprehensive method of making everything the same on both objects, except for the mesh?

I do not really understand what you try to accomplish but concerning your last question, you could try something like this (untested code):


from copy import copy
 
newobject = copy(oldobject)
newobject.setData(mesh)

Is that pseudocode or can I use that directly? What is the copy module, and where is it documented?

I know the Object module has a Duplicate method, which seems very unintuitive because you have to interface with the Duplicate method indirectly by manipulating which objects are active. Can I just say duplicate this object instance?

it’s not pseudo code, merely untested. The copy module is standard in any python distrubution. Actually it won’t work for two reasons: the new object needs to be associated with the scene and a blender object has no setData() method (is has a getData() method but to set ObData on an object you need to use link(). Blenders API is full of these inconsistencies but most of them will disappear in the 2.5 API) This will work however:


from copy import copy
import Blender
 
oldobject = Blender.Object.Get('Cube')
mesh = Blender.Mesh.Get('Sphere')
newobject = copy(oldobject)
Blender.Scene.GetCurrent().objects.link(newobject)
newobject.link(mesh)

The code assumes you have a ‘Sphere’ and a ‘Cube’ object in your current scene. It still won’t copy materials though as these are not associated (by default) with the object but with the mesh, so you will probably be better of using Duplicate();

Thanks for the help.