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.scenethen in operatorlocation=scene.cursor.locationor alternatively usealign='CURSOR'See https://blender.stackexchange.com/questions/13828/precisely-move-the-3d-cursor and https://blender.stackexchange.com/questions/164734/how-to-move-selected-object-to-the-curser-location-using-a-python-command/164779#164779 – batFINGER Jul 04 '20 at 06:06
– InamuraJIN Jul 04 '20 at 06:15bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=scene.cursor.locationandbpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, scene = context.scene, location=scene.cursor.locationbpy.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. – batFINGER Jul 04 '20 at 06:18