simplify placement
This commit is contained in:
parent
409e06bd44
commit
4d0c42adb3
3 changed files with 78 additions and 40 deletions
103
__init__.py
103
__init__.py
|
@ -211,7 +211,7 @@ class ABC3D_text_properties(bpy.types.PropertyGroup):
|
|||
)
|
||||
ignore_orientation: bpy.props.BoolProperty(
|
||||
update=update_callback,
|
||||
name="Ignore Orientation",
|
||||
name="Ignore Curve Orientation",
|
||||
default=False,
|
||||
)
|
||||
distribution_type: bpy.props.StringProperty()
|
||||
|
@ -334,12 +334,6 @@ class ABC3D_PT_TextPlacement(bpy.types.Panel):
|
|||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
layout.label(text="Set Properties Objects")
|
||||
layout.row().prop(abc3d, "text")
|
||||
layout.row().prop(abc3d, "letter_spacing")
|
||||
layout.row().prop(abc3d, "font_size")
|
||||
layout.column().prop(abc3d, "translation")
|
||||
layout.column().prop(abc3d, "orientation")
|
||||
placerow = layout.row()
|
||||
placerow.enabled = self.can_place
|
||||
placerow.operator(f"{__name__}.placetext", text='Place Text')
|
||||
|
@ -626,36 +620,79 @@ class ABC3D_OT_PlaceText(bpy.types.Operator):
|
|||
bl_label = "Place Text"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
# t.font_name = font_name
|
||||
# t.face_name = face_name
|
||||
# t.text_object = selected
|
||||
# t.text = scene.abc3d.text
|
||||
# t.letter_spacing = scene.abc3d.letter_spacing
|
||||
# t.font_size = scene.abc3d.font_size
|
||||
# t.translation = scene.abc3d.translation
|
||||
# t.orientation = scene.abc3d.orientation
|
||||
# t.distribution_type = distribution_type
|
||||
def font_items_callback(self, context):
|
||||
items = []
|
||||
fonts = Font.get_loaded_fonts_and_faces()
|
||||
for f in fonts:
|
||||
items.append((f"{f[0]} {f[1]}", f"{f[0]} {f[1]}", ""))
|
||||
return items
|
||||
|
||||
# def invoke(self, context, event):
|
||||
# wm = context.window_manager
|
||||
# return wm.invoke_props_dialog(self)
|
||||
def font_update_callback(self, context):
|
||||
font_name, face_name = self.font.split(" ")
|
||||
self.font_name = font_name
|
||||
self.face_name = face_name
|
||||
|
||||
font_name: bpy.props.StringProperty(
|
||||
options={'HIDDEN'}
|
||||
)
|
||||
face_name: bpy.props.StringProperty(
|
||||
options={'HIDDEN'}
|
||||
)
|
||||
font: bpy.props.EnumProperty(items=font_items_callback,
|
||||
update=font_update_callback
|
||||
)
|
||||
text: bpy.props.StringProperty(
|
||||
name="Text",
|
||||
description="The text.",
|
||||
default="HELLO",
|
||||
maxlen=1024,
|
||||
)
|
||||
# target_object: bpy.props.PointerProperty(
|
||||
# name="The Target Object",
|
||||
# description="The target, which will be populated by character children of text.",
|
||||
# type=bpy.types.Object,
|
||||
# )
|
||||
letter_spacing: bpy.props.FloatProperty(
|
||||
name="Letter Spacing",
|
||||
description="Letter Spacing",
|
||||
default=0.0,
|
||||
)
|
||||
font_size: bpy.props.FloatProperty(
|
||||
name="Font Size",
|
||||
default=1.0,
|
||||
subtype='NONE',
|
||||
)
|
||||
translation: bpy.props.FloatVectorProperty(
|
||||
name="Translation",
|
||||
default=(0.0, 0.0, 0.0),
|
||||
subtype='TRANSLATION',
|
||||
)
|
||||
orientation: bpy.props.FloatVectorProperty(
|
||||
name="Orientation",
|
||||
default=(1.5707963267948966, 0.0, 0.0), # 90 degrees in radians
|
||||
subtype='EULER',
|
||||
)
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
def execute(self, context):
|
||||
global shared
|
||||
scene = bpy.context.scene
|
||||
|
||||
selected = bpy.context.view_layer.objects.active
|
||||
|
||||
abc3d = scene.abc3d
|
||||
abc3d_data = scene.abc3d_data
|
||||
|
||||
if abc3d.target_object:
|
||||
selected = abc3d.target_object
|
||||
selected = bpy.context.view_layer.objects.active
|
||||
|
||||
# if abc3d.target_object:
|
||||
# selected = abc3d.target_object
|
||||
|
||||
if selected:
|
||||
font = abc3d_data.available_fonts[abc3d_data.active_font_index]
|
||||
font_name = font.font_name
|
||||
face_name = font.face_name
|
||||
# font = abc3d_data.available_fonts[abc3d_data.active_font_index]
|
||||
# font_name = font.font_name
|
||||
# face_name = font.face_name
|
||||
|
||||
distribution_type = 'DEFAULT'
|
||||
|
||||
|
@ -666,14 +703,14 @@ class ABC3D_OT_PlaceText(bpy.types.Operator):
|
|||
t = abc3d_data.available_texts.add()
|
||||
t.text_id = text_id
|
||||
|
||||
t.font_name = font_name
|
||||
t.face_name = face_name
|
||||
t.font_name = self.font_name
|
||||
t.face_name = self.face_name
|
||||
t.text_object = selected
|
||||
t.text = scene.abc3d.text
|
||||
t.letter_spacing = scene.abc3d.letter_spacing
|
||||
t.font_size = scene.abc3d.font_size
|
||||
t.translation = scene.abc3d.translation
|
||||
t.orientation = scene.abc3d.orientation
|
||||
t.text = self.text
|
||||
t.letter_spacing = self.letter_spacing
|
||||
t.font_size = self.font_size
|
||||
t.translation = self.translation
|
||||
t.orientation = self.orientation
|
||||
t.distribution_type = distribution_type
|
||||
else:
|
||||
butils.ShowMessageBox(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue