Skip to content
Snippets Groups Projects
Commit 0f616505 authored by Jay Jasper's avatar Jay Jasper Committed by Campbell Barton
Browse files

STL Export: add "global_space" matrix

Added an option to allow the user to export STLs
using an arbitrary (custom) coordinate-space.

This is not exposed in the UI and is intended for script authors
exporting content.

Ref D11517
parent 5aa25f6a
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ from bpy.props import ( ...@@ -43,6 +43,7 @@ from bpy.props import (
CollectionProperty, CollectionProperty,
EnumProperty, EnumProperty,
FloatProperty, FloatProperty,
FloatVectorProperty,
) )
from bpy_extras.io_utils import ( from bpy_extras.io_utils import (
ImportHelper, ImportHelper,
...@@ -227,6 +228,12 @@ class ExportSTL(Operator, ExportHelper): ...@@ -227,6 +228,12 @@ class ExportSTL(Operator, ExportHelper):
('OBJECT', "Object", "Each object as a file"), ('OBJECT', "Object", "Each object as a file"),
), ),
) )
global_space: FloatVectorProperty(
name="Global Space",
description="Export in this reference space",
subtype='MATRIX',
size=(4, 4),
)
@property @property
def check_extension(self): def check_extension(self):
...@@ -249,7 +256,8 @@ class ExportSTL(Operator, ExportHelper): ...@@ -249,7 +256,8 @@ class ExportSTL(Operator, ExportHelper):
"filter_glob", "filter_glob",
"use_scene_unit", "use_scene_unit",
"use_mesh_modifiers", "use_mesh_modifiers",
"batch_mode" "batch_mode",
"global_space",
), ),
) )
...@@ -269,6 +277,9 @@ class ExportSTL(Operator, ExportHelper): ...@@ -269,6 +277,9 @@ class ExportSTL(Operator, ExportHelper):
to_up=self.axis_up, to_up=self.axis_up,
).to_4x4() @ Matrix.Scale(global_scale, 4) ).to_4x4() @ Matrix.Scale(global_scale, 4)
if self.properties.is_property_set("global_space"):
global_matrix = global_matrix @ self.global_space.inverted()
if self.batch_mode == 'OFF': if self.batch_mode == 'OFF':
faces = itertools.chain.from_iterable( faces = itertools.chain.from_iterable(
blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers) blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment