After learned about new changes in blender API, I had to update script from 2.8 into 3.0 using :
instead of =
.
So following the changes in this script to 3.0...
class ALP_OT_Params(Operator):
# Old
#text= bpy.props.StringProperty(name= "Enter Object Name", default= "")
# Update
text: bpy.props.StringProperty(name= "Enter Object Name", default= "")
def excute(self,context):
new_obj_name = self.text
obj = bpy.context.object
obj.name = new_obj_name
I am getting type error at this string obj.name = new_obj_name
.
From blender console, The error stating...
TypeError: bpy_struct: item.attr = val: Object.name expected a bytes type, not str
I am not exactly sure what error was, but I am assuming it have something to do with changes in this string text:
. I didn't have problem or getting any error on text=
before Before Blender made API changes. What am I missing?
Couldn't find any information around that might help me to resolve my issues any suggestions?
UPDATE: Full script requested by @Gorgious & @Marty Fouts
import bpy
from bpy.types import Operator
from bpy.props import StringProperty
class ALP_OT_Params(Operator):
"""Opens Add Cube with New name Dialog Box"""
bl_idname = "alp.ot_params"
bl_label = "Add Cube Popup Dialog"
text: StringProperty(name="Enter Text", default="")
@classmethod
def poll(cls, context):
return True
def execute(self, context):
new_obj_name = self.text
bpy.ops.mesh.primitive_cube_add()
obj = bpy.context.object
obj.name = new_obj_name
return {"FINISHED"}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def register():
bpy.utils.register_class(ALP_OT_Params)
def unregister():
bpy.utils.unregister_class(ALP_OT_Params)
if __name__ == "__main__":
register()
bpy.ops.alp.ot_params('INVOKE_DEFAULT')
ERROR
UPDATE: File from Blender 3.1.0
excute
a typo ? It should beexecute
$\endgroup$