input dialog box blender

2019-03-26 17:54发布

How to make a simple entry dialog box (like in the image) in blender and processing the text entered through python.I am unable to find any good tutorial on this.

simple entry box

1条回答
走好不送
2楼-- · 2019-03-26 18:38

For the dialog box the answer from how to show a message from a blender script? might be a starting point.

But I think a better approach is integrating input into the panel like e.g.
String example

To do this you have to add a StringProperty to your add-on and place it inside your panel (see Addon Tutorial for more information). The basic steps are:

def draw(self, context) :
    col = self.layout.column(align = True)
    col.prop(context.scene, "my_string_prop")

...

def register() :
    bpy.types.Scene.my_string_prop = bpy.props.StringProperty \
      (
        name = "My String",
        description = "My description",
        default = "default"
      )

...

def unregister() :
    del bpy.types.Scene.my_string_prop

...

You can access the string by context.scene.my_string_prop

There is another mode to integrate input. When you add for example a text to your scene you can change the parameters after the operator has been called and see the changes immediately:

Add text object

Changing Location will move the newly created text object at another place. I haven't worked with this but it should be similar to the code above.

查看更多
登录 后发表回答