Is this the right place to ask Python questions?

If not, please tell me of the correct forum.

(in case yes)
I was playing around in Blender this morning, and created this (Materialized and rendered in Omniverse Create because I know it better):

So I thought it would make a good first Add On for me to practice in Blender. I love the scripting window where as I do things in Blender, I can learn the Python behind it. This makes learning to use the API much easier.

My Question is:

  1. This is the code generated when you duplicate and move an object (I modified the x axis manually to 0). Is all this necessary to duplicate and move an object, or is there a shorter version for duplicate and set the y and z axis? I have to duplicate about 12 times, so if any of these parameters are optional that would be ideal.

bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={“linked”:False, “mode”:‘TRANSLATION’},
TRANSFORM_OT_translate={“value”:(0, 1.27, .4), “orient_axis_ortho”:‘X’, “orient_type”:‘GLOBAL’,
“orient_matrix”:((1, 0, 0), (0, 1, 0), (0, 0, 1)), “orient_matrix_type”:‘GLOBAL’, “constraint_axis”:(False, False, False),
“mirror”:False, “use_proportional_edit”:False, “proportional_edit_falloff”:‘SMOOTH’, “proportional_size”:1, “use_proportional_connected”:False,
“use_proportional_projected”:False, “snap”:False, “snap_elements”:{‘INCREMENT’}, “use_snap_project”:False, “snap_target”:‘CLOSEST’, “use_snap_self”:True,
“use_snap_edit”:True, “use_snap_nonedit”:True, “use_snap_selectable”:False, “snap_point”:(0, 0, 0), “snap_align”:False, “snap_normal”:(0, 0, 0), “gpencil_strokes”:False,
“cursor_transform”:False, “texture_space”:False, “remove_on_cancel”:False, “view2d_edge_pan”:False, “release_confirm”:False, “use_accurate”:False, “use_automerge_and_split”:False})

Thanks

It’s not necessarily the best place for it, but also not the worst.

You should look at the API documentation here: https://docs.blender.org/api/master/

In particular the documentation for:
bpy.ops.object.duplicate_move

Which is just a wrapper that uses both of the following operators:
bpy.ops.object.duplicate
bpy.ops.transform.translate

The documentation will describe all the “(optional)” parameters that can be omitted if the defaults are ok.

From Community — blender.org, both the #python channel on blender.chat or using Blender Stack Exchange might be better for this type of question in the future.

1 Like

I ended up creating a method so I could just pass in y, z, but still a lot of code can be
eliminated I suspect.

Thank you, I will read up on the docs.

Is there a better place to ask?

The Blender stack exchange is your best place to get in-depth and responsive help.

1 Like

I am barred from Stack Overflow for the crime of telling someone whose question I answered what opensource project the answer came from.

Oh well, hopefully I don’t have any questions.