mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Move props from 'Other' preferences tab to preferences #6733
To prevent users confusion since it's a general Blender UX to expect here general preferences, not per-blend file settings.
This commit is contained in:
@@ -187,7 +187,7 @@ class IfcStore:
|
||||
if not os.path.isfile(path):
|
||||
return
|
||||
extension = path.split(".")[-1]
|
||||
props = tool.Project.get_project_props()
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
if extension.lower() == "ifczip":
|
||||
with tempfile.TemporaryDirectory() as unzipped_path:
|
||||
with zipfile.ZipFile(path, "r") as zip_ref:
|
||||
@@ -197,7 +197,7 @@ class IfcStore:
|
||||
return
|
||||
elif extension.lower() == "ifcxml":
|
||||
IfcStore.file = ifcopenshell.file(ifcopenshell.ifcopenshell_wrapper.parse_ifcxml(path))
|
||||
elif props.should_stream:
|
||||
elif prefs.should_stream:
|
||||
IfcStore.file = ifcopenshell.open(path, should_stream=True)
|
||||
else:
|
||||
IfcStore.file = ifcopenshell.open(path)
|
||||
|
||||
@@ -158,15 +158,6 @@ class BIMBSDDProperties(PropertyGroup):
|
||||
description="Whether to display and assign only properties from IFC dictionary",
|
||||
default=False,
|
||||
)
|
||||
load_preview_dictionaries: BoolProperty(
|
||||
name="Load Preview Dictionaries", description="Load dictionaries marked as Preview status", default=False
|
||||
)
|
||||
load_inactive_dictionaries: BoolProperty(
|
||||
name="Load Inactive Dictionaries", description="Load dictionaries marked as Inactive status", default=False
|
||||
)
|
||||
load_test_dictionaries: BoolProperty(
|
||||
name="Load Test Dictionaries", description="Load dictionaries that are for testing only", default=False
|
||||
)
|
||||
classification_psets: CollectionProperty(name="Classification Psets", type=BSDDPset)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -186,9 +177,6 @@ class BIMBSDDProperties(PropertyGroup):
|
||||
keyword: str
|
||||
should_filter_ifc_class: bool
|
||||
use_only_ifc_properties: bool
|
||||
load_preview_dictionaries: bool
|
||||
load_inactive_dictionaries: bool
|
||||
load_test_dictionaries: bool
|
||||
classification_psets: bpy.types.bpy_prop_collection_idprop[BSDDPset]
|
||||
|
||||
@property
|
||||
|
||||
@@ -1594,14 +1594,15 @@ class ExportIFC(bpy.types.Operator, ExportHelper):
|
||||
|
||||
def execute(self, context):
|
||||
project_props = tool.Project.get_project_props()
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
project_props.use_relative_project_path = self.use_relative_path
|
||||
if project_props.should_disable_undo_on_save:
|
||||
if prefs.should_disable_undo_on_save:
|
||||
old_history_size = tool.Ifc.get().history_size
|
||||
old_undo_steps = context.preferences.edit.undo_steps
|
||||
tool.Ifc.get().history_size = 0
|
||||
context.preferences.edit.undo_steps = 0
|
||||
IfcStore.execute_ifc_operator(self, context)
|
||||
if project_props.should_disable_undo_on_save:
|
||||
if prefs.should_disable_undo_on_save:
|
||||
tool.Ifc.get().history_size = old_history_size
|
||||
context.preferences.edit.undo_steps = old_undo_steps
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -300,7 +300,6 @@ class BIMProjectProperties(PropertyGroup):
|
||||
)
|
||||
should_use_cpu_multiprocessing: BoolProperty(name="CPU Multiprocessing", default=True)
|
||||
should_merge_materials_by_colour: BoolProperty(name="Merge Materials by Colour", default=False)
|
||||
should_stream: BoolProperty(name="Stream Data From IFC-SPF (Only for advanced users)", default=False)
|
||||
should_load_geometry: BoolProperty(name="Load Geometry", default=True)
|
||||
should_clean_mesh: BoolProperty(
|
||||
name="Clean Meshes",
|
||||
@@ -362,9 +361,6 @@ class BIMProjectProperties(PropertyGroup):
|
||||
description="Load indexed maps (UV and color maps)",
|
||||
default=True,
|
||||
)
|
||||
should_disable_undo_on_save: BoolProperty(
|
||||
name="Disable Undo When Saving (Faster saves, no undo for you!)", default=False
|
||||
)
|
||||
links: CollectionProperty(name="Links", type=Link)
|
||||
active_link_index: IntProperty(name="Active Link Index")
|
||||
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema", update=update_export_schema)
|
||||
@@ -458,7 +454,6 @@ class BIMProjectProperties(PropertyGroup):
|
||||
geometry_library: Literal["opencascade", "cgal", "cgal-simple", "hybrid-cgal-simple-opencascade"]
|
||||
should_use_cpu_multiprocessing: bool
|
||||
should_merge_materials_by_colour: bool
|
||||
should_stream: bool
|
||||
should_load_geometry: bool
|
||||
should_clean_mesh: bool
|
||||
should_cache: bool
|
||||
@@ -474,7 +469,6 @@ class BIMProjectProperties(PropertyGroup):
|
||||
element_offset: int
|
||||
element_limit: int
|
||||
load_indexed_maps: bool
|
||||
should_disable_undo_on_save: bool
|
||||
links: bpy.types.bpy_prop_collection_idprop[Link]
|
||||
active_link_index: int
|
||||
export_schema: str
|
||||
|
||||
@@ -334,6 +334,20 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
description="When modifying openings, other elements of the model will display with some transparency.\n0 is fully transparent and 100 is fully opaque",
|
||||
)
|
||||
|
||||
bsdd_load_preview_dictionaries: BoolProperty(
|
||||
name="Load Preview Dictionaries", description="Load dictionaries marked as Preview status", default=False
|
||||
)
|
||||
bsdd_load_inactive_dictionaries: BoolProperty(
|
||||
name="Load Inactive Dictionaries", description="Load dictionaries marked as Inactive status", default=False
|
||||
)
|
||||
bsdd_load_test_dictionaries: BoolProperty(
|
||||
name="Load Test Dictionaries", description="Load dictionaries that are for testing only", default=False
|
||||
)
|
||||
should_disable_undo_on_save: BoolProperty(
|
||||
name="Disable Undo When Saving (Faster saves, no undo for you!)", default=False
|
||||
)
|
||||
should_stream: BoolProperty(name="Stream Data From IFC-SPF (Only for advanced users)", default=False)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
svg2pdf_command: str
|
||||
svg2dxf_command: str
|
||||
@@ -355,6 +369,11 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
decorator_color_error: tuple[float, float, float, float]
|
||||
decorator_color_background: tuple[float, float, float, float]
|
||||
opening_focus_opacity: int
|
||||
bsdd_load_preview_dictionaries: bool
|
||||
bsdd_load_inactive_dictionaries: bool
|
||||
bsdd_load_test_dictionaries: bool
|
||||
should_disable_undo_on_save: bool
|
||||
should_stream: bool
|
||||
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
layout = self.layout
|
||||
@@ -395,12 +414,14 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
layout.prop(self, "spatial_elements_unselectable")
|
||||
|
||||
def draw_model_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
||||
# TODO: move props to preferences.
|
||||
props = tool.Model.get_model_props()
|
||||
layout.prop(props, "occurrence_name_style")
|
||||
if props.occurrence_name_style == "CUSTOM":
|
||||
layout.prop(props, "occurrence_name_function")
|
||||
|
||||
def draw_directories(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
||||
# TODO: move props to preferences.
|
||||
props = tool.Blender.get_bim_props()
|
||||
row = layout.row(align=True)
|
||||
row.prop(props, "data_dir")
|
||||
@@ -415,6 +436,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
row.operator("bim.select_dir", icon="FILE_FOLDER", text="").data_path = "preferences.tmp_dir"
|
||||
|
||||
def draw_drawing_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
||||
# TODO: move props to preferences.
|
||||
props = tool.Blender.get_bim_props()
|
||||
layout.prop(props, "pset_dir")
|
||||
dprops = tool.Drawing.get_document_props()
|
||||
@@ -447,14 +469,12 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
|
||||
def draw_other_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
||||
layout.prop(self, "opening_focus_opacity")
|
||||
props = tool.Project.get_project_props()
|
||||
layout.prop(props, "should_disable_undo_on_save")
|
||||
layout.prop(props, "should_stream")
|
||||
bprops = tool.Bsdd.get_bsdd_props()
|
||||
layout.prop(self, "should_disable_undo_on_save")
|
||||
layout.prop(self, "should_stream")
|
||||
layout.label(text="bSDD:")
|
||||
layout.prop(bprops, "load_preview_dictionaries")
|
||||
layout.prop(bprops, "load_inactive_dictionaries")
|
||||
layout.prop(bprops, "load_test_dictionaries")
|
||||
layout.prop(self, "bsdd_load_preview_dictionaries")
|
||||
layout.prop(self, "bsdd_load_inactive_dictionaries")
|
||||
layout.prop(self, "bsdd_load_test_dictionaries")
|
||||
|
||||
|
||||
# Scene panel groups
|
||||
|
||||
@@ -107,20 +107,22 @@ class Bsdd(bonsai.core.tool.Bsdd):
|
||||
|
||||
@classmethod
|
||||
def get_dictionary(cls, uri: str) -> bsdd.DictionaryContractV1:
|
||||
props = cls.get_bsdd_props()
|
||||
response = cls.client.get_dictionary(dictionary_uri=uri, include_test_dictionaries=props.load_test_dictionaries)
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
response = cls.client.get_dictionary(
|
||||
dictionary_uri=uri, include_test_dictionaries=prefs.bsdd_load_test_dictionaries
|
||||
)
|
||||
if dicts := response.get("dictionaries"):
|
||||
return dicts[0]
|
||||
|
||||
@classmethod
|
||||
def get_dictionaries(cls) -> list[bsdd.DictionaryContractV1]:
|
||||
props = cls.get_bsdd_props()
|
||||
response = cls.client.get_dictionary(include_test_dictionaries=props.load_test_dictionaries)
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
response = cls.client.get_dictionary(include_test_dictionaries=prefs.bsdd_load_test_dictionaries)
|
||||
dicts = response.get("dictionaries") or []
|
||||
statuses = ["Active"]
|
||||
if props.load_preview_dictionaries:
|
||||
if prefs.bsdd_load_preview_dictionaries:
|
||||
statuses.append("Preview")
|
||||
if props.load_inactive_dictionaries:
|
||||
if prefs.bsdd_load_inactive_dictionaries:
|
||||
statuses.append("Inactive")
|
||||
return list(filter(lambda d: d["status"] in statuses, dicts))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user