From 8622628b09aecd2b4d633a41fb23dbe03e61d05d Mon Sep 17 00:00:00 2001 From: GreenDimond <24834740+GreenXenith@users.noreply.github.com> Date: Mon, 17 Feb 2020 17:30:44 -0800 Subject: [PATCH] Fix selection only --- .gitignore | 1 + __init__.py | 2 ++ export_b3d.py | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/__init__.py b/__init__.py index 51b8b54..8202262 100644 --- a/__init__.py +++ b/__init__.py @@ -123,6 +123,8 @@ class ExportB3D(bpy.types.Operator, ExportHelper): def execute(self, context): from . import export_b3d + export_b3d.b3d_parameters["export-selected"] = self.use_selection + keywords = self.as_keywords(ignore=("axis_forward", "axis_up", "filter_glob", diff --git a/export_b3d.py b/export_b3d.py index 0408b05..346f15e 100644 --- a/export_b3d.py +++ b/export_b3d.py @@ -225,10 +225,10 @@ def write_texs(objects=[]): if objects: exp_obj = objects else: - if b3d_parameters.get("export-selected"): - exp_obj = [ob for ob in bpy.data.objects if ob.select] - else: - exp_obj = bpy.data.objects + exp_obj = bpy.data.objects + + if b3d_parameters.get("export-selected"): + exp_obj = [ob for ob in exp_obj if ob.select_get()] if PROGRESS: print(len(exp_obj),"TEXS") @@ -363,10 +363,10 @@ def write_brus(objects=[]): if objects: exp_obj = objects else: - if b3d_parameters.get("export-selected"): - exp_obj = [ob for ob in bpy.data.objects if ob.select] - else: - exp_obj = bpy.data.objects + exp_obj = bpy.data.objects + + if b3d_parameters.get("export-selected"): + exp_obj = [ob for ob in exp_obj if ob.select_get()] if PROGRESS: print(len(exp_obj),"BRUS") if PROGRESS_VERBOSE: progress = 0 @@ -543,10 +543,10 @@ def write_node(objects=[]): if objects: exp_obj = objects else: - if b3d_parameters.get("export-selected"): - exp_obj = [ob for ob in bpy.data.objects if ob.select] - else: - exp_obj = bpy.data.objects + exp_obj = bpy.data.objects + + if b3d_parameters.get("export-selected"): + exp_obj = [ob for ob in exp_obj if ob.select_get()] for obj in exp_obj: if obj.type == "MESH": @@ -1602,6 +1602,7 @@ def save(operator, filepath += ".b3d" obj_list = [] + # use_selection obj_list = bpy.data.objects global the_scene