Skip to content

Commit acd5941

Browse files
committed
Moved P3D can_export to module init
1 parent 95494b2 commit acd5941

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Arma3ObjectBuilder/io_p3d/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@
1010
from ..utils_io import ExportFileHandler
1111

1212

13+
# Simple check to not even start the export if there are
14+
# no LOD objects in the scene.
15+
def can_export(operator, context):
16+
scene = context.scene
17+
export_objects = scene.objects
18+
19+
if operator.use_selection:
20+
export_objects = context.selected_objects
21+
22+
for obj in export_objects:
23+
if (not operator.visible_only or obj.visible_get()) and obj.type == 'MESH' and obj.a3ob_properties_object.is_a3_lod and obj.parent == None:
24+
return True
25+
26+
return False
27+
28+
1329
class A3OB_OT_import_p3d(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
1430
"""Import Arma 3 MLOD P3D"""
1531

@@ -322,7 +338,7 @@ def draw(self, context):
322338
pass
323339

324340
def execute(self, context):
325-
if not exporter.can_export(self, context):
341+
if not can_export(self, context):
326342
op_report(self, {'ERROR'}, "There are no LODs to export")
327343
return {'FINISHED'}
328344

Arma3ObjectBuilder/io_p3d/exporter.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,6 @@
2020
from ..logger import ProcessLogger, ProcessLoggerNull
2121

2222

23-
# Simple check to not even start the export if there are
24-
# no LOD objects in the scene.
25-
def can_export(operator, context):
26-
scene = context.scene
27-
export_objects = scene.objects
28-
29-
if operator.use_selection:
30-
export_objects = context.selected_objects
31-
32-
for obj in export_objects:
33-
if (not operator.visible_only or obj.visible_get()) and obj.type == 'MESH' and obj.a3ob_properties_object.is_a3_lod and obj.parent == None:
34-
return True
35-
36-
return False
37-
38-
3923
def create_temp_collection(context):
4024
temp = bpy.data.collections.get("A3OB_temp")
4125
if temp is None:

0 commit comments

Comments
 (0)