File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -192,14 +192,16 @@ def export(self):
192192 return result
193193
194194 def _pre_export (self , origin_objects ):
195- """Move the objects based on the origin."""
195+ """Transform the objects based on the origin."""
196196 for obj in origin_objects :
197197 self .objects .unlink (obj ) # pylint: disable=no-member
198198
199199 bpy .ops .object .select_all (action = 'DESELECT' )
200200
201+ inverse_origin_matrix = origin_objects [0 ].matrix_world .copy ()
202+ inverse_origin_matrix .invert_safe ()
201203 for obj in self .top_level_objects :
202- obj .location -= origin_objects [ 0 ]. location # TODO: Do a full transform based on the origin object?
204+ obj .matrix_world = inverse_origin_matrix @ obj . matrix_world
203205
204206 for obj in self .objects :
205207 obj .select_set (True )
@@ -208,9 +210,10 @@ def _pre_export(self, origin_objects):
208210 obj .name = trimmed_name
209211
210212 def _post_export (self , origin_objects ):
211- """Reset object locations."""
213+ """Reset object transforms."""
214+ origin_matrix = origin_objects [0 ].matrix_world .copy ()
212215 for obj in self .top_level_objects :
213- obj .location += origin_objects [ 0 ]. location
216+ obj .matrix_world = origin_matrix @ obj . matrix_world
214217
215218 for obj in origin_objects :
216219 self .objects .link (obj ) # pylint: disable=no-member
You can’t perform that action at this time.
0 commit comments