Post #680: ![](https://blenderartists.org/user_avatar/blenderartists.org/leafar/48/661663_2

πŸ“‹ Metadata

  • Author: roaoao
  • Date: 2017-05-20 21:46:54
  • Type: answer
  • Quality Score: 8/10
  • Reply to: post_00679

🏷️ Tags

macro scripting advanced solved

  • Macro Editor
  • Python Scripting

πŸ’¬ Content

Leafar:

But why the other object is still selected??

Updated script:

from .bl_utils import uname; new_name = uname(D.objects,  C.active_object.name); bpy.ops.mesh.separate(type='SELECTED');  bpy.ops.object.mode_set(mode='OBJECT');  bpy.ops.object.select_all(action='DESELECT'); C.scene.objects.active =  D.objects[new_name]; D.objects[new_name].select = True;  bpy.ops.object.mode_set(mode='EDIT')

Leafar:

And now I realize that the perfect script is duplicating first the selection of the faces, verts or edges.
DonΒ΄t you think?

Yes, both tools can be useful. Use this code instead:

from .bl_utils import uname; new_name = uname(D.objects, C.active_object.name); bpy.ops.mesh.duplicate(); bpy.ops.mesh.separate(type='SELECTED'); bpy.ops.object.mode_set(mode='OBJECT'); bpy.ops.object.select_all(action='DESELECT'); C.scene.objects.active = D.objects[new_name]; D.objects[new_name].select = True; bpy.ops.object.mode_set(mode='EDIT')

πŸ”— View on Blender Artists