[Bf-python] Default values for an operator

Constantin Rahn conz at vrchannel.de
Wed Feb 29 15:41:17 CET 2012


Hi,

I want to discuss a problem before I add it to the bug tracker. Not sure 
that it is a bug, or a side effect of a new feature. I was not sure 
where to post, on this list or on BF Committers.

_The situation of the feature of remembering the last parameters for an 
operator_:

Create a Torus (or any Add-on Mesh object), change one parameter (maybe 
the radius). Delete the Torus and add a new one. There the last 
parameters are reused. The radius is the value of the first Torus.
This is a relative new feature, IMHO came with the "Operator Presets", 
but not sure.
In the UI of the Operator, there is a button "Reset" to set the 
parameters back to default values.

The same behavior is for ops called with python.
You can type in console:
/bpy.ops.mesh.primitive_torus_add(major_radius=4.0)/
delete the torus and than type in console:
/bpy.ops.mesh.primitive_torus_add()/
the 2nd torus will have a radius of 4.0, too.

and here starts the bug.

_Strange behavior, bug or feaure?_

printed values are not equal to used values
If you type:
/bpy.ops.mesh.primitive_torus_add/
(without brackets!) than blender print the default values for the torus 
(in our case "/major_radius=1.0/') in the console. But if you add a new 
torus it's radius is 4.0?!?
This feature is maybe usefull for calling with UI, but as a python 
operator it seems buggy. I would expect, that
/bpy.ops.mesh.primitive_torus_add()/
would add a torus with the default values.

How can I add a torus with default values, in case I have added one with 
changed parameters before?
Do I have to set all parameters on adding an object with python? Bec. I 
can't know which parameters are different to default values on calling 
the operator. :(

How can I reset the operator with python?
I can't find an API call to reset it. (like the reset button in the UI)

I hope that someone can help me with my qestions. If not I'll add a 
report to the tracker. Maybe the bug, that the console prints different 
values, than the ones that are used.

happy blending,
Conz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20120229/0327b933/attachment.html>


More information about the Bf-python mailing list