0
$\begingroup$

For example, as you can see in the keymap preferences, there are operators that have properties, like this Smooth Vertices:

enter image description here

With this little code row.operator("mesh.vertices_smooth") I can make a button to execute this operator in my UI panel

enter image description here

So how can I do the same with those properties and checkboxes, for them to show up in my custom panel, so then I can set some settings before clicking the button?

This is in blender 2.8 by the way..

Thanks...

$\endgroup$
0
$\begingroup$

You can set new property like this:

bpy.types.Scene.my_use_x=bpy.props.BoolProperty()
row.prop(context.scene, 'my_use_x')

And set property of operator like this:

operator = row.operator("mesh.vertices_smooth")
operator.use_x = context.scene.my_use_x
operator.use_y = False
operator.factor = 2

I do not use blender 2.8 and I did not test this. But it should work.

$\endgroup$
  • $\begingroup$ Thanks for answering. Also I should probably say that I'm a python newbie, so I almost have no clue how to deal with your code haha. But I'll see what I can do with it. Thanks again. $\endgroup$ – TheRedWaxPolice May 8 '19 at 21:27
  • $\begingroup$ If this answer solved Your problem, please accept it. If not, I can still help You. $\endgroup$ – Piotr Kowalczyk May 12 '19 at 20:54
  • $\begingroup$ Hi, I'm sorry, it's my first time asking a question here on this site, so I don't know how things work here, no idea how to accept something. I upvoted your answer but somehow it doesn't show up either. And no, unfortunately I wasn't able to achieve what I want yet, as I have no idea how to deal with your code. All I want is to display those number fields in my custom panel, so I can use them there instead of going to the keymap settings. $\endgroup$ – TheRedWaxPolice May 13 '19 at 14:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.