Skip to content

Commit

Permalink
working on more generic export_origin with export_typographic_origin_…
Browse files Browse the repository at this point in the history
…x/export_typographic_origin_y bools [ref #19]
  • Loading branch information
stenson committed Mar 19, 2024
1 parent e4b0f11 commit 14308f3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
8 changes: 5 additions & 3 deletions ST2/exporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def draw(self, context):
row = layout.row()

row.label(text="Options")
row.prop(data, "export_geometric_origins", icon="TRANSFORM_ORIGINS", icon_only=True)
#row.prop(data, "export_geometric_origins", icon="TRANSFORM_ORIGINS", icon_only=True)
row.prop(data, "export_meshes", icon="OUTLINER_OB_MESH", icon_only=True)

#row = layout.row()
Expand All @@ -253,7 +253,10 @@ def draw(self, context):
col.enabled = data.export_meshes
col.prop(data, "export_rigidbody_active", icon="RIGID_BODY", icon_only=True)

# row = layout.row()
row = layout.row()
#row.label("Origin")
row.prop(data, "export_origin", text="Origin")

# row.label(text="New Objects")
# row.prop(data, "export_style", text="", expand=True)

Expand Down Expand Up @@ -301,7 +304,6 @@ def draw(self, context):
row = layout.row()

row.label(text="Options")
#row.prop(data, "export_geometric_origins", icon="TRANSFORM_ORIGINS", icon_only=True)

row.prop(data, "export_every_x_frame", text="Frame Interval")
row.prop(data, "export_meshes", icon="OUTLINER_OB_MESH", icon_only=True)
Expand Down
24 changes: 23 additions & 1 deletion ST2/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,29 @@ class ST2PropertiesGroup(bpy.types.PropertyGroup):
# exporting

export_meshes: bpy.props.BoolProperty(name="Export as Meshes", default=True)
export_geometric_origins: bpy.props.BoolProperty(name="Export with Geometric Origins", default=True)

#export_geometric_origins: bpy.props.BoolProperty(name="Export with Geometric Origins", default=True)

export_origin: bpy.props.EnumProperty(name="Export Origin",
description="Where should origin be relative to bounding box?",
items=[
("EXISTING", "Existing", ""),
("GEOMETRIC", "Geometric", ""),
("N", "North", ""),
("NE", "Northeast", ""),
("E", "East", ""),
("SE", "Southeast", ""),
("S", "South", ""),
("SW", "Southwest", ""),
("W", "West", ""),
("NW", "Northwest", ""),

],
default="EXISTING")

export_typographic_origin_x: bpy.props.BoolProperty(name="Export Typographic Origin X", default=True)
export_typographic_origin_y: bpy.props.BoolProperty(name="Export Typographic Origin Y", default=True)

export_apply_transforms: bpy.props.BoolProperty(name="Export with Applied Transforms", default=True)
export_rigidbody_active: bpy.props.BoolProperty(name="Export with Active Rigid Body", default=False)
export_every_x_frame: bpy.props.IntProperty(name="Export Every X Frame", default=1, min=1, max=50)
Expand Down
24 changes: 19 additions & 5 deletions ST2/typesetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,22 @@ def export(glyph=None, idx=None):
txtObj.obj.location = self.obj.location
txtObj.obj.rotation_euler = self.obj.rotation_euler

origin_pt = None
origin = self.st2.export_origin
typo_origin_x = self.st2.export_typographic_origin_x
typo_origin_y = self.st2.export_typographic_origin_y

if glyph and idx is not None:
if self.st2.export_stagger_y:
txtObj.locate_relative(y=idx*self.st2.export_stagger_y)
if self.st2.export_stagger_z:
txtObj.locate_relative(z=idx*self.st2.export_stagger_z)

if glyph:
amb = glyph.ambit(tx=not typo_origin_x, ty=not typo_origin_y)
if origin not in ["EXISTING", "GEOMETRIC"]:
origin_pt = amb.point(origin)
txtObj.draw(glyph, set_origin=False, fill=False)
# TODO option to set typographic origins
else:
txtObj.draw(p, set_origin=False, fill=False)

Expand Down Expand Up @@ -453,6 +460,7 @@ def hide(hidden):
self.scene.frame_set(frame)

txtObj.obj.select_set(True)

if self.st2.export_meshes:
bpy.ops.object.convert(target="MESH")
if self.st2.export_apply_transforms:
Expand All @@ -462,8 +470,10 @@ def hide(hidden):
txtObj.obj.rigid_body.type = "ACTIVE"
#bpy.ops.object.transform_apply(location=0, rotation=1, scale=1, properties=0)
pass
if self.st2.export_geometric_origins:

if origin == "GEOMETRIC":
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')

txtObj.obj.select_set(False)

if parent:
Expand All @@ -477,7 +487,7 @@ def hide(hidden):
if self.st2.export_rotate_y:
txtObj.rotate(y=math.degrees(self.st2.export_rotate_y))

return txtObj
return txtObj, origin_pt

if glyphwise:
if shapewise:
Expand All @@ -488,9 +498,13 @@ def hide(hidden):
# p.mapv(lambda _p: _p.explode())

for idx, glyph in enumerate(p):
output.append(export(glyph, idx=idx))
res, origin_pt = export(glyph, idx=idx)
output.append(res)
if origin_pt is not None:
res.set_origin(*origin_pt, 0)
else:
output.append(export())
res, origin_pt = export()
output.append(res)

return output

Expand Down

0 comments on commit 14308f3

Please sign in to comment.