disable placing text if not possible
This commit is contained in:
parent
3ecd3177c1
commit
2d8ec86edc
1 changed files with 17 additions and 2 deletions
19
__init__.py
19
__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'}
|
||||
|
|
Loading…
Reference in a new issue