I take a string property input via the panel but everytime I try to use it, I get the "<built-in function StringProperty " instead of the raw string itself. I am new to Python. Any help is appreciated.
Usage:
def execute(self, context):
start = bpy.types.Scene.my_string_prop[0]
end = bpy.types.Scene.my_string_prop2[0]
print("start: ",start)
print("end: ",end)
text_string = ''.join([chr(i) for i in range(ord(start), ord(end) + 1)]) #original
print("text_string : ",text_string)
return {'FINISHED'}
Output:
start: <built-in function StringProperty>
end: <built-in function StringProperty>
Traceback (most recent call last):
File "C:\Users\asifn\Desktop\Test.blend\Text", line 35, in execute
TypeError: ord() expected string of length 1, but builtin_function_or_method found
location: <unknown location>:-1
location: <unknown location>:-1
Register:
def register():
bpy.types.Scene.my_string_prop = bpy.props.StringProperty \
(
name = "Start",
maxlen = 1,
default = "!"
)
bpy.types.Scene.my_string_prop2 = bpy.props.StringProperty \
(
name = "End",
maxlen = 1,
default = "!"
)
bpy.utils.register_class(OBJECT_OT_myClass)
bpy.utils.register_class(MyPanel)
Drawing:
class MyPanel(bpy.types.Panel):
bl_label = "My Panel"
bl_idname = "OBJECT_PT_MYPANEL"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
def draw(self, context):
layout = self.layout
scene = context.scene
row = layout.row(align=True)
col = layout.column(align=True)
row.operator("object.myclass")
col = self.layout.column(align = True)
col.prop(context.scene, "my_string_prop")
col.prop(context.scene, "my_string_prop2")
Link to the entire code: https://codeshare.io/G7ErBn