also small optimization in MaterialCreator.create to address ifc a couple times less
This commit is contained in:
Andrej730
2024-09-07 10:55:16 +05:00
parent 13ed4d3a6c
commit e87faa167c
5 changed files with 23 additions and 14 deletions
@@ -33,9 +33,7 @@ def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instanc
style is reused.
:param material: The IfcMaterialDefinition to copy
:type material: ifcopenshell.entity_instance
:return: The new copy of the material
:rtype: ifcopenshell.entity_instance
Example:
@@ -68,9 +66,13 @@ def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instanc
return _copy_material_with_inverses(file, material)
elif material.is_a("IfcMaterialList"):
return _copy_material_with_inverses(file, material)
else:
raise Exception(f"Unexpected material type: '{material.is_a()}' ({material}).")
def _copy_material_with_inverses(file, material):
def _copy_material_with_inverses(
file: ifcopenshell.file, material: ifcopenshell.entity_instance
) -> ifcopenshell.entity_instance:
new = ifcopenshell.util.element.copy(file, material)
for inverse in file.get_inverse(material):
if inverse.is_a("IfcMaterialProperties"):
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def assign_representation_styles(
@@ -112,6 +113,10 @@ def assign_representation_styles(
class Usecase:
file: ifcopenshell.file
settings: dict[str, Any]
results: list[ifcopenshell.entity_instance]
def execute(self):
if not self.settings["styles"]:
return []
@@ -21,7 +21,6 @@ import lark
import numpy as np
import ifcopenshell.api.pset
import ifcopenshell.api.geometry
import ifcopenshell.ifcopenshell_wrapper as W
import ifcopenshell.util
import ifcopenshell.util.attribute
import ifcopenshell.util.fm
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import operator
import test.bootstrap
import ifcopenshell.api.pset
import ifcopenshell.api.root