2
$\begingroup$

I downloaded this add-on to create L-system (https://github.com/ento/blender-lsystem-addon) and wanted to 1/ Create a L-system object from a script 2/ Change its parameters from a script.

The add-on is working as expected --> The user calls the operator "L-system" (Add > Mesh > L-system). Then in the "toolbox panel"(see image), the user can choose the L-system's parameters.

enter image description here

Now, I would like to the same from a script. Calling the L-system operator is straightforward:

import bpy
bpy.ops.mesh.add_lsystem()

The L-system object is automatically created, but empty! Also, the menu in the toolbox panel doesn't appear.

I don't know how to access the menu's parameters and I don't even know if its possible ... So here is my question: By script, how can I access the toolbox's menu parameter after calling the operator? Note that I tried to load a preset after calling the operator (just in case), but I don't know what is the "menu_idname".

presetPath = "C:\\Users\\adrien\\Desktop\\fav\\default1.py"
bpy.ops.script.execute_preset(filepath=presetPath, menu_idname="")

Thanks in advance for you help!

$\endgroup$

1 Answer 1

2
$\begingroup$

A good rule of thumb is to use auto-complete in the python console, ie type in bpy.ops.mesh.add_lsystem(ctrl-space

>>> bpy.ops.mesh.add_lsystem(
add_lsystem()
bpy.ops.mesh.add_lsystem(nproductions=0, niterations=0, seed=0, start="", radius=0.2, pitch_angle=0.523599, yaw_angle=0.523599, roll_angle=0.523599, tropism=(0, 0, 0), tropismsize=0)

Note: after running manually once it gives the more bloated version with the mods n prods.

>>> bpy.ops.mesh.add_lsystem(
add_lsystem()
bpy.ops.mesh.add_lsystem(nproductions=0, niterations=0, seed=0, start="", radius=0.2, pitch_angle=0.523599, yaw_angle=0.523599, roll_angle=0.523599, tropism=(0, 0, 0), tropismsize=0, prod1="", mod1="", prod2="", mod2="", prod3="", mod3="", prod4="", mod4="", prod5="", mod5="", prod6="", mod6="", prod7="", mod7="", prod8="", mod8="", prod9="", mod9="")

which will give the properties that can be passed to the operator.

For the preset, right click on the preset menu,

enter image description here

which in my case, for a preset named "Default" gives me the following command in the paste buffer

bpy.ops.script.execute_preset(filepath="/home/batfinger/.config/blender/2.77/scripts/presets/operator/mesh.add_lsystem/default.py", menu_idname="WM_MT_operator_presets")
$\endgroup$
1
  • $\begingroup$ Thanks you so much, both of your answers are working great! $\endgroup$ Jun 2, 2016 at 4:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .