I am having trouble creating an emitter via python scripting (using Blender 3.2.1).
My problem is the following: suppose I have a cylinder and a plane (which will play the emitter role).
I can create those by writing
import bpy # create plane bpy.ops.mesh.primitive_plane_add() emitter = bpy.context.object emitter.name = "Emitter" # Create cyclinder bpy.ops.mesh.primitive_cylinder_add() my_cyl = bpy.context.object my_cyl.name = "My_Cyl" my_cyl.select_set(False) # Select (only) the emitter objectToSelect = bpy.data.objects[emitter.name].select_set(True) bpy.context.view_layer.objects.active = objectToSelect From there, if I use the graphical user interface (GUI), select the plane, go in "Particle Properties", and click on Add Particle System Slot, the info displays
bpy.context.space_data.context = "PARTICLES" bpy.ops.object.particle_system_add() If in my script I write those above lines, I get the error message
Python: Traceback (most recent call last): File "...\simple_tests.blend\script001.py", line 18, in <module> AttributeError: 'SpaceTextEditor' object has no attribute 'context' My question is: how can I manage to write the script to make it such that the plane is the emitter?