Python code to add objects to the 3D Cursor
I added a cube and looked at the Python Console
bpy.ops.mesh.primitive_cube_add(enter_ editmode=False, align='WORLD', location=(0, 0, 0)))
The code looked like this
When you run this code, it adds the cube to the first location you put it in, not the location of the 3D Cursor (location=(0, 0, 0))
I want to use this add-on, so the Python code has to be one line
https://github.com/InamuraJIN/CommandRecorder
How do I add an Object to the 3D Cursor's position?
Translated with www.DeepL.com/Translator (free version)
scene = context.scene
then in operatorlocation=scene.cursor.location
or alternatively usealign='CURSOR'
See blender.stackexchange.com/questions/13828/… and blender.stackexchange.com/questions/164734/… $\endgroup$bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=scene.cursor.location
andbpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, scene = context.scene, location=scene.cursor.location
$\endgroup$bpy.ops.mesh.primitive_cube_add(size=2, location=bpy.context.scene.cursor.location)
orbpy.ops.mesh.primitive_cube_add(size=2, align='CURSOR')
Enter edit mode False is default. Defaults need not be included in call. $\endgroup$