Skip to main content
grammar, keys, formatting, active object q link
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

opsbpy.ops is a module directly in the bpybpy, not part of theany object class.It stores It holds all availableregistered operators. If you don't specify a region, it will always assume you want to do something in the viewport. Just replace src_objsrc_obj with bpy. However just as it would be when pressing SHIF Dbpy to match the behavior of ShiftD. You should also make sure that the cube is the active objectactive object.

bpy.context.view_layer.objects.active = src_obj
scr_obj.select_set(True)
bpy.ops.object.duplicate(linked=0,mode='TRANSLATION')
new_obj = bpy.context.active_object

ops is a module directly in the bpy, not part of the object class.It stores all available operators. If you don't specify a region, it will always assume you want to do something in the viewport. replace src_obj with bpy. However just as it would be when pressing SHIF D. You should also make sure that the cube is the active object.

bpy.context.view_layer.objects.active = src_obj
scr_obj.select_set(True)
bpy.ops.object.duplicate(linked=0,mode='TRANSLATION')
new_obj = bpy.context.active_object

bpy.ops is a module directly in bpy, not part of any object class. It holds all registered operators. If you don't specify a region, it will always assume you want to do something in the viewport. Just replace src_obj with bpy to match the behavior of ShiftD. You should also make sure that the cube is the active object.

bpy.context.view_layer.objects.active = src_obj
scr_obj.select_set(True)
bpy.ops.object.duplicate(linked=0,mode='TRANSLATION')
new_obj = bpy.context.active_object
Source Link

ops is a module directly in the bpy, not part of the object class.It stores all available operators. If you don't specify a region, it will always assume you want to do something in the viewport. replace src_obj with bpy. However just as it would be when pressing SHIF D. You should also make sure that the cube is the active object.

bpy.context.view_layer.objects.active = src_obj
scr_obj.select_set(True)
bpy.ops.object.duplicate(linked=0,mode='TRANSLATION')
new_obj = bpy.context.active_object