input dialog box blender

China☆狼群 提交于 2019-12-04 11:45:13

问题


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.


回答1:


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.

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:

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.



来源:https://stackoverflow.com/questions/15595124/input-dialog-box-blender

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!