mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Save all properties from Preferences UI as actual preferences
Previously some of them were saved only for current .blend file, moving them to preferences will make it more consistent with usual Blender UX. If needed we'll be able to add some way to fine-grain them later. There's also a temporary patch that's going to migrate old .blend-props to new preferences-props to make process less disruptive.
This commit is contained in:
@@ -55,8 +55,8 @@ class TestLoadExpress(NewFile):
|
||||
|
||||
class TestPurgeHdf5Cache(NewFile):
|
||||
def test_run(self):
|
||||
props = tool.Blender.get_bim_props()
|
||||
cache_dir = Path(props.cache_dir)
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
cache_dir = Path(prefs.cache_dir)
|
||||
test_file = cache_dir / "test.h5"
|
||||
test_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
test_file.touch()
|
||||
|
||||
@@ -44,26 +44,29 @@ class TestGenerateOccurrenceName(NewFile):
|
||||
def test_generating_based_on_class(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType(Name="Foobar")
|
||||
props = tool.Model.get_model_props()
|
||||
props.occurrence_name_style = "CLASS"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Wall"
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
with tool.Blender.preserve_prop_value(prefs, "occurrence_name_style"):
|
||||
prefs.occurrence_name_style = "CLASS"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Wall"
|
||||
|
||||
def test_generating_based_on_type_name(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType()
|
||||
props = tool.Model.get_model_props()
|
||||
props.occurrence_name_style = "TYPE"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Unnamed"
|
||||
element_type.Name = "Foobar"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
with tool.Blender.preserve_prop_value(prefs, "occurrence_name_style"):
|
||||
prefs.occurrence_name_style = "TYPE"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Unnamed"
|
||||
element_type.Name = "Foobar"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
|
||||
def test_generating_based_on_a_custom_function(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType()
|
||||
props = tool.Model.get_model_props()
|
||||
props.occurrence_name_style = "CUSTOM"
|
||||
props.occurrence_name_function = '"Foobar"'
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
prefs = tool.Blender.get_addon_preferences()
|
||||
with tool.Blender.preserve_prop_value(prefs, "occurrence_name_style"):
|
||||
prefs.occurrence_name_style = "CUSTOM"
|
||||
prefs.occurrence_name_function = '"Foobar"'
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
|
||||
|
||||
class TestGetBooleans(NewFile):
|
||||
|
||||
Reference in New Issue
Block a user