From 18629bd44b22018c2da04a2a0ea746baf7a5e6ce Mon Sep 17 00:00:00 2001 From: Sebastian <61376632+nrgsille76@users.noreply.github.com> Date: Sat, 27 Jul 2024 03:55:00 +0200 Subject: [PATCH] gdtf: Check model dimensions before 3ds transform In some gdtf files the model dimensions are equal with blender dimensions. Check the dimensions before transforming the models. --- gdtf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gdtf.py b/gdtf.py index cc40c4a7..9961c5c3 100644 --- a/gdtf.py +++ b/gdtf.py @@ -24,7 +24,7 @@ import hashlib from types import SimpleNamespace import pathlib -from mathutils import Euler, Matrix +from mathutils import Euler, Matrix, Vector from . import pygdtf from .logging import DMX_Log @@ -233,8 +233,10 @@ def loadModel(profile, model): file_name = os.path.join(extract_to_folder_path, inside_zip_path) try: load_3ds(file_name, bpy.context, FILTER={'MESH'}, KEYFRAME=False, APPLY_MATRIX=False) + obj_dimension = Vector((model.length, model.width, model.height)) for ob in bpy.context.selected_objects: - ob.data.transform(Matrix.Scale(0.001, 4)) + if obj_dimension.to_tuple(3) != ob.dimensions.to_tuple(3): + ob.data.transform(Matrix.Scale(0.001, 4)) except Exception as e: DMX_Log.log.error(f"Error loading a 3DS file {e}") traceback.print_exception(e)