2
$\begingroup$

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

enter image description here

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

$\endgroup$
1
  • $\begingroup$ "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 $\endgroup$
    – zeffii
    Dec 11, 2015 at 18:06

1 Answer 1

2
$\begingroup$

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.

enter image description here

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':
        layout.menu("INFO_MT_add", text="Add")
    elif mode_string == 'EDIT_MESH':
        layout.menu("INFO_MT_mesh_add", text="Add")

    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.

enter image description here

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.

$\endgroup$
7
  • $\begingroup$ 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 $\endgroup$
    – saded
    Dec 11, 2015 at 18:12
  • $\begingroup$ Then I suggest you start scripting something smaller and read the the cookbook too $\endgroup$
    – zeffii
    Dec 11, 2015 at 18:16
  • $\begingroup$ how to add there lines $\endgroup$
    – saded
    Dec 11, 2015 at 18:38
  • $\begingroup$ Where add these lines At the beginning of the script? $\endgroup$
    – saded
    Dec 11, 2015 at 18:52
  • $\begingroup$ Let us continue this discussion in chat. $\endgroup$
    – zeffii
    Dec 11, 2015 at 19:06

You must log in to answer this question.

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