One has to create a new mesh, then copy the data of the source object, then link to the scene. Here's the short function I'm using to do this.
# The following function is adapted from # Nick Keeline "Cloud Generator" addNewObject # from object_cloud_gen.py (an addon that comes with the Blender 2.6 package) # def duplicateObject(scene, name, copyobj): # Create new mesh mesh = bpy.data.meshes.new(name) # Create new object associated with the mesh ob_new = bpy.data.objects.new(name, mesh) # Copy data block from the old object into the new object ob_new.data = copyobj.data.copy() ob_new.scale = copyobj.scale ob_new.location = copyobj.location # Link new object to the given scene and select it scene.objects.link(ob_new) ob_new.select = True return ob_new
Thank very much for this :). It was usefully for me. It's glad to known that many people can make the life easy with little things. Thanks very much again and again :):). Have a good day
ReplyDeleteAgreed, it's really useful that someone should simply outline the pretty non-intuitive way of duplicating objects for the beginning blender scripter like myself
ReplyDeleteThank U very much. Really Usefull code. You right when you say than " a web search failed to return a simple, clear solution."... I have spend a lot of hours trying to get information about it. Realy the blender documentation about API sucks.
ReplyDeleteI'm thinking to go to Maya and abandonate Blender:
(sorry for my english.)
Now I'm following you in google ====b
This will do it pretty easy:
ReplyDeletebpy.ops.object.duplicate_move_linked()
Thanks! -=B
Delete