# Display the Operator properties of an Active Add Primitive operator

is it possible to display the Operator properties of an Active Add Primitive operator in a Custom Panel as in the following figure:

For cylinder, I have enter radius and height, ...

• "Number of Cube?" what you expect the number beside it to do, make 50 randomly placed cubes? .. or divide the cube in 50 sections per side – zeffii Dec 11 '15 at 18:06

You can display them, but i think you will get convoluted code.

def draw(self, context):

# ... earlier stuff.

operators = bpy.data.window_managers["WinMan"].operators
if operators and operators[-1].name == 'Add UV Sphere':
this_op = operators[-1]
col = layout.column()
col.prop(this_op.properties, 'segments')


But you'll notice you can drag the slider, it will update the visible value but not update the actual value of the active operator.

Then dynamically populating the UI with properties:

 >>> bpy.data.window_managers["WinMan"].operators[-1].properties.items()
...[('size', 2.0), ('view_align', 0), ('enter_editmode', 0), ('layers', <bpy id property array [20]>), ('location', <bpy id property array [3]>), ('segments', 9)]


so..

def draw(self, context):
obj = context.active_object
mode_string = context.mode
edit_object = context.edit_object

layout = self.layout
col = layout.column()
col.label(text="Generate objects:")

if mode_string == 'OBJECT':
elif mode_string == 'EDIT_MESH':

operators = bpy.data.window_managers["WinMan"].operators
if operators and operators[-1].name == 'Add UV Sphere':
this_op = operators[-1]
col = layout.column()
for k, v in this_op.properties.items():
col.prop(this_op.properties, k)


Would produce this, by inspecting the items in the properties of the current operator.

But, there are fundamental problems with this. You would have to limit somehow the kind of Operators to show in this list. Right now i've limited to Add UV Sphere, if you don't do that it will show all most recent Operator properties even if they aren't a Primitive operator..

So you might construct a set of Operator names to allow..

showable = {'Add UV Sphere', 'Add Cube', ....... }
if operators and operators[-1].name in showable:
# ... display them as shown above


And still you won't be able to tweak these props. :(

Seen as the operator has a perfectly good Operator Properties panel accessible from F6, and the panel also appears in the 'TOOLS' shelf, I'm inclined to discourage trying to do this. -- But it's an interesting thought experiment.

• I do not know where I put additions As well as for each body of his properties For example, the cylinder diameter and its height – saded Dec 11 '15 at 18:12
• Then I suggest you start scripting something smaller and read the the cookbook too – zeffii Dec 11 '15 at 18:16
• how to add there lines – saded Dec 11 '15 at 18:38
• Where add these lines At the beginning of the script? – saded Dec 11 '15 at 18:52
• – zeffii Dec 11 '15 at 19:06