
Je cherche a ajouté un menu pour calculer une propriété d'un mesh de texture quelconque, et avec les tutorials existants, j'ai crée un simple menu, mon problème est comment exécuter ces données.
Concernant le script est comme suit:
- Code : Tout sélectionner
import bpy
from bpy.props import *
def initScenePro(scn):
bpy.types.Scene.Property1 = StringProperty(
name = "W")
scn['Property1'] = ""
bpy.types.Scene.Property2 = StringProperty(
name = "H")
scn['Property2'] = ""
bpy.types.Scene.MyResultDT = StringProperty(name = "Compute")
scn['Property C'] = ""
bpy.types.Scene.PropertyC = StringProperty(
name = "Property C")
scn['PropertyC'] = ""
return
initScenePro(bpy.context.scene)
#
# Menu in Tool region
#
class ToolPanel(bpy.types.Panel):
bl_label = "Custom Property panel"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Cal Property"
def draw(self, context):
layout = self.layout
scn = context.scene
layout.prop(scn, 'Property1')
layout.prop(scn, 'Property2')
layout.operator("ui_custom.result")
layout.prop(scn, 'PropertyC')
#
# Menu in UI region
#
# Clean the scene and create some objects
class UIPanel(bpy.types.Panel):
bl_label = "Custom UI panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_idname = "ui.result"
resultCV = bpy.props.StringProperty()
def draw(self, context):
ob = context.object
layout = self.layout
scn = context.scene
layout.prop(scn, 'PropertyC')
#
# The button prints the values of the properites.
#
class OBJECT_OT_PrintPropsBtn(bpy.types.Panel):
#bl_label = "Custom UI panel"
bl_idname = "ui_custom.result"
bl_label = "Compute"
bl_category = "Cal Property"
def execute(self, context):
scn = context.scene
#print({'INFO'}, scn['MyCustomInt'])
result = string(scn['Property1']) * string(scn['Property2'])
scn['PropertyC'] = str(result)
print("%s" %(str(result)))
return{'FINISHED'}
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.ignit_panel
# return
if __name__ == "__main__":
register()
Pouvez-vous m'aider à corriger ce script