diff --git a/__init__.py b/__init__.py index d19dfc6..8e016c6 100644 --- a/__init__.py +++ b/__init__.py @@ -277,6 +277,16 @@ class FONT3D_PT_TextPlacement(bpy.types.Panel): bl_space_type = "VIEW_3D" bl_region_type = "UI" + can_place = False + + @classmethod + def poll(self, context): + if type(context.active_object) != type(None) and context.active_object.type == 'CURVE': + self.can_place = True + else: + self.can_place = False + return True + def draw(self, context): layout = self.layout wm = context.window_manager @@ -289,7 +299,12 @@ class FONT3D_PT_TextPlacement(bpy.types.Panel): layout.row().prop(font3d, "text") layout.row().prop(font3d, "letter_spacing") layout.column().prop(font3d, "orientation") - layout.row().operator('font3d.placetext', text='Place Text') + placerow = layout.row() + placerow.enabled = self.can_place + placerow.operator('font3d.placetext', text='Place Text') + if not self.can_place: + layout.label(text="Cannot place Text.") + layout.label(text="Select a curve as active object.") class FONT3D_PT_TextManagement(bpy.types.Panel): bl_label = "Text Management" @@ -474,7 +489,7 @@ class FONT3D_OT_TemporaryHelper(bpy.types.Operator): return {'FINISHED'} class FONT3D_OT_PlaceText(bpy.types.Operator): - """Place Text 3D""" + """Place Text 3D on active object""" bl_idname = f"{__name__}.placetext" bl_label = "Place Text" bl_options = {'REGISTER', 'UNDO'}