mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Fix Ruff UP034 (extraneous-parentheses)
https://docs.astral.sh/ruff/rules/extraneous-parentheses/
This commit is contained in:
@@ -100,7 +100,7 @@ class BcfXml:
|
|||||||
extensions = mdl_extensions.Extensions()
|
extensions = mdl_extensions.Extensions()
|
||||||
|
|
||||||
xs = "{http://www.w3.org/2001/XMLSchema}"
|
xs = "{http://www.w3.org/2001/XMLSchema}"
|
||||||
root = etree.parse(io.BytesIO((self.extension_schema)))
|
root = etree.parse(io.BytesIO(self.extension_schema))
|
||||||
|
|
||||||
attrs = bcf.agnostic.extensions.get_extensions_attributes(extensions)
|
attrs = bcf.agnostic.extensions.get_extensions_attributes(extensions)
|
||||||
xsd_to_attrs = {v.subattr_xsd_name: k for k, v in attrs.items()}
|
xsd_to_attrs = {v.subattr_xsd_name: k for k, v in attrs.items()}
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ class AddBcfBimSnippet(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
props = tool.Bcf.get_bcf_props()
|
props = tool.Bcf.get_bcf_props()
|
||||||
props_are_filled = all(
|
props_are_filled = all(
|
||||||
(getattr(props, attr) for attr in ("bim_snippet_reference", "bim_snippet_schema", "bim_snippet_type"))
|
getattr(props, attr) for attr in ("bim_snippet_reference", "bim_snippet_schema", "bim_snippet_type")
|
||||||
)
|
)
|
||||||
if not props_are_filled:
|
if not props_are_filled:
|
||||||
cls.poll_message_set("Some BIM snippet fields are empty.")
|
cls.poll_message_set("Some BIM snippet fields are empty.")
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ class GetRepresentationIfcParameters(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
assert obj and tool.Geometry.has_mesh_properties((data := obj.data))
|
assert obj and tool.Geometry.has_mesh_properties(data := obj.data)
|
||||||
core.get_representation_ifc_parameters(tool.Geometry, obj=obj)
|
core.get_representation_ifc_parameters(tool.Geometry, obj=obj)
|
||||||
parameters = tool.Geometry.get_mesh_props(data).ifc_parameters
|
parameters = tool.Geometry.get_mesh_props(data).ifc_parameters
|
||||||
self.report({"INFO"}, f"{len(parameters)} parameters found.")
|
self.report({"INFO"}, f"{len(parameters)} parameters found.")
|
||||||
@@ -1691,7 +1691,7 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if obj == self.target:
|
if obj == self.target:
|
||||||
continue
|
continue
|
||||||
if obj.type != self.target_type:
|
if obj.type != self.target_type:
|
||||||
obj.select_set((False))
|
obj.select_set(False)
|
||||||
continue
|
continue
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
|
||||||
@@ -1752,7 +1752,7 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
copied_item = ifcopenshell.util.element.copy_deep(
|
copied_item = ifcopenshell.util.element.copy_deep(
|
||||||
ifc_file, item, exclude=("IfcCartesianPointList",)
|
ifc_file, item, exclude=("IfcCartesianPointList",)
|
||||||
)
|
)
|
||||||
new_points = processed_point_lists.get((points := item.Points))
|
new_points = processed_point_lists.get(points := item.Points)
|
||||||
if new_points is None:
|
if new_points is None:
|
||||||
new_points = ifcopenshell.util.element.copy_deep(ifc_file, points)
|
new_points = ifcopenshell.util.element.copy_deep(ifc_file, points)
|
||||||
dim = item.Dim
|
dim = item.Dim
|
||||||
@@ -2365,7 +2365,7 @@ class EnableEditingRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
item.tags += ","
|
item.tags += ","
|
||||||
item.tags += tag
|
item.tags += tag
|
||||||
|
|
||||||
if tool.Geometry.has_mesh_properties((data := obj.data)):
|
if tool.Geometry.has_mesh_properties(data := obj.data):
|
||||||
representation = tool.Geometry.get_data_representation(data)
|
representation = tool.Geometry.get_data_representation(data)
|
||||||
assert representation
|
assert representation
|
||||||
|
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
return new
|
return new
|
||||||
|
|
||||||
def get_library_element_index(self, lib_element: LibraryElement) -> int:
|
def get_library_element_index(self, lib_element: LibraryElement) -> int:
|
||||||
return next((i for i in range(len(self.library_elements)) if self.library_elements[i] == lib_element))
|
return next(i for i in range(len(self.library_elements)) if self.library_elements[i] == lib_element)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
is_editing: bool
|
is_editing: bool
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ def calculate_height(obj: bpy.types.Object) -> float:
|
|||||||
|
|
||||||
|
|
||||||
def calculate_edges_lengths(objs: list[bpy.types.Object], context: bpy.types.Context):
|
def calculate_edges_lengths(objs: list[bpy.types.Object], context: bpy.types.Context):
|
||||||
return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges if e.select)))
|
return calculate_mesh_quantity(objs, context, lambda bm: sum(e.calc_length() for e in bm.edges if e.select))
|
||||||
|
|
||||||
|
|
||||||
def calculate_faces_areas(objs: list[bpy.types.Object], context: bpy.types.Context) -> float:
|
def calculate_faces_areas(objs: list[bpy.types.Object], context: bpy.types.Context) -> float:
|
||||||
return calculate_mesh_quantity(objs, context, lambda bm: sum((f.calc_area() for f in bm.faces if f.select)))
|
return calculate_mesh_quantity(objs, context, lambda bm: sum(f.calc_area() for f in bm.faces if f.select))
|
||||||
|
|
||||||
|
|
||||||
def calculate_volumes(objs: list[bpy.types.Object], context: bpy.types.Context) -> float:
|
def calculate_volumes(objs: list[bpy.types.Object], context: bpy.types.Context) -> float:
|
||||||
|
|||||||
@@ -398,12 +398,12 @@ class ShaderInfo:
|
|||||||
returns a numpy array with the sum of the values of structural activities
|
returns a numpy array with the sum of the values of structural activities
|
||||||
applied loads in each direction, multiplied by the factors in load combinations
|
applied loads in each direction, multiplied by the factors in load combinations
|
||||||
"""
|
"""
|
||||||
values = np.zeros((3))
|
values = np.zeros(3)
|
||||||
for item in activity_list:
|
for item in activity_list:
|
||||||
activity = item[0]
|
activity = item[0]
|
||||||
factor = item[1]
|
factor = item[1]
|
||||||
load = activity.AppliedLoad
|
load = activity.AppliedLoad
|
||||||
temp = np.zeros((3))
|
temp = np.zeros(3)
|
||||||
if load is not None and load.is_a("IfcStructuralLoadPlanarForce"):
|
if load is not None and load.is_a("IfcStructuralLoadPlanarForce"):
|
||||||
temp[0] = load.PlanarForceX if load.PlanarForceX is not None else 0
|
temp[0] = load.PlanarForceX if load.PlanarForceX is not None else 0
|
||||||
temp[1] = load.PlanarForceY if load.PlanarForceY is not None else 0
|
temp[1] = load.PlanarForceY if load.PlanarForceY is not None else 0
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ class Cad:
|
|||||||
d2 = v3 - v2
|
d2 = v3 - v2
|
||||||
|
|
||||||
# Rounding avoids problems when dealing with 180 degrees
|
# Rounding avoids problems when dealing with 180 degrees
|
||||||
d1 = Vector((round(c, 6) for c in d1))
|
d1 = Vector(round(c, 6) for c in d1)
|
||||||
d2 = Vector((round(c, 6) for c in d2))
|
d2 = Vector(round(c, 6) for c in d2)
|
||||||
|
|
||||||
d1.normalize()
|
d1.normalize()
|
||||||
d2.normalize()
|
d2.normalize()
|
||||||
|
|||||||
@@ -1709,7 +1709,7 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
a_quaternion = a.matrix_world.to_quaternion()
|
a_quaternion = a.matrix_world.to_quaternion()
|
||||||
b_quaternion = b.matrix_world.to_quaternion()
|
b_quaternion = b.matrix_world.to_quaternion()
|
||||||
for axis in axes:
|
for axis in axes:
|
||||||
if abs((a_quaternion @ axis).angle((b_quaternion @ axis)) - (math.pi / 2)) < 1e-5:
|
if abs((a_quaternion @ axis).angle(b_quaternion @ axis) - (math.pi / 2)) < 1e-5:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class Misc(bonsai.core.tool.Misc):
|
|||||||
assert isinstance(obj.data, bpy.types.Mesh)
|
assert isinstance(obj.data, bpy.types.Mesh)
|
||||||
obj.data.transform(
|
obj.data.transform(
|
||||||
Matrix.Translation(
|
Matrix.Translation(
|
||||||
(obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin))
|
obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
obj.matrix_world.translation = new_origin
|
obj.matrix_world.translation = new_origin
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ class Root(bonsai.core.tool.Root):
|
|||||||
to unlink them.
|
to unlink them.
|
||||||
"""
|
"""
|
||||||
tool.Ifc.unlink(obj=obj)
|
tool.Ifc.unlink(obj=obj)
|
||||||
if tool.Geometry.has_mesh_properties((data := obj.data)):
|
if tool.Geometry.has_mesh_properties(data := obj.data):
|
||||||
tool.Geometry.get_mesh_props(data).ifc_definition_id = 0
|
tool.Geometry.get_mesh_props(data).ifc_definition_id = 0
|
||||||
for material_slot in obj.material_slots:
|
for material_slot in obj.material_slots:
|
||||||
if material := material_slot.material:
|
if material := material_slot.material:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Dxf2Ifc:
|
|||||||
self.file.createIfcFaceOuterBound(
|
self.file.createIfcFaceOuterBound(
|
||||||
self.file.createIfcPolyLoop(
|
self.file.createIfcPolyLoop(
|
||||||
[
|
[
|
||||||
self.file.createIfcCartesianPoint((face[index].dxf.location))
|
self.file.createIfcCartesianPoint(face[index].dxf.location)
|
||||||
for index in range(len(face) - 1)
|
for index in range(len(face) - 1)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ def sync_guids(target_file: ifcopenshell.file, source_file: ifcopenshell.file) -
|
|||||||
# New type with material was added.
|
# New type with material was added.
|
||||||
print(f"WARNING! Couldn't find a matching rel for '{rel}'.")
|
print(f"WARNING! Couldn't find a matching rel for '{rel}'.")
|
||||||
return
|
return
|
||||||
rel_ = next((r for r in related_object_.HasAssociations if r.is_a("IfcRelAssociatesMaterial")))
|
rel_ = next(r for r in related_object_.HasAssociations if r.is_a("IfcRelAssociatesMaterial"))
|
||||||
assert rel_
|
assert rel_
|
||||||
rel.GlobalId = rel_.GlobalId
|
rel.GlobalId = rel_.GlobalId
|
||||||
elif rel.is_a("IfcRelDeclares"):
|
elif rel.is_a("IfcRelDeclares"):
|
||||||
|
|||||||
@@ -1134,7 +1134,7 @@ def the_object_name_should_display_as_mode(name, mode):
|
|||||||
def the_object_name_is_voided_by_void(name, void):
|
def the_object_name_is_voided_by_void(name, void):
|
||||||
ifc = tool.Ifc.get()
|
ifc = tool.Ifc.get()
|
||||||
element = ifc.by_id(tool.Blender.get_ifc_definition_id(the_object_name_exists(name)))
|
element = ifc.by_id(tool.Blender.get_ifc_definition_id(the_object_name_exists(name)))
|
||||||
assert any((rel for rel in element.HasOpenings if rel.RelatedOpeningElement.Name == void)), "No void found"
|
assert any(rel for rel in element.HasOpenings if rel.RelatedOpeningElement.Name == void), "No void found"
|
||||||
|
|
||||||
|
|
||||||
@then(parsers.parse('the object "{name}" is not voided by "{void}"'))
|
@then(parsers.parse('the object "{name}" is not voided by "{void}"'))
|
||||||
@@ -1158,7 +1158,7 @@ def the_object_name_is_a_void(name):
|
|||||||
ifc = tool.Ifc.get()
|
ifc = tool.Ifc.get()
|
||||||
obj = the_object_name_exists(name)
|
obj = the_object_name_exists(name)
|
||||||
element = ifc.by_id(tool.Blender.get_ifc_definition_id(obj))
|
element = ifc.by_id(tool.Blender.get_ifc_definition_id(obj))
|
||||||
assert any((element.VoidsElements)), "No void was found"
|
assert any(element.VoidsElements), "No void was found"
|
||||||
|
|
||||||
|
|
||||||
@then(parsers.parse('the object "{name}" is not a void'))
|
@then(parsers.parse('the object "{name}" is not a void'))
|
||||||
@@ -1282,7 +1282,7 @@ def the_object_name_is_filled_by_filling(name, name2):
|
|||||||
def the_void_name_is_filled_by_filling(name, filling):
|
def the_void_name_is_filled_by_filling(name, filling):
|
||||||
ifc = tool.Ifc.get()
|
ifc = tool.Ifc.get()
|
||||||
element = ifc.by_id(tool.Blender.get_ifc_definition_id(the_object_name_exists(name)))
|
element = ifc.by_id(tool.Blender.get_ifc_definition_id(the_object_name_exists(name)))
|
||||||
assert any((rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings)), "No filling found"
|
assert any(rel.RelatedBuildingElement.Name == filling for rel in element.HasFillings), "No filling found"
|
||||||
|
|
||||||
|
|
||||||
@then(parsers.parse('the void "{name}" is not filled by "{filling}"'))
|
@then(parsers.parse('the void "{name}" is not filled by "{filling}"'))
|
||||||
@@ -1468,7 +1468,7 @@ def the_object_name_has_a_vertex_at_location(name, location):
|
|||||||
target = Vector([float(co) for co in location.split(",")])
|
target = Vector([float(co) for co in location.split(",")])
|
||||||
verts = []
|
verts = []
|
||||||
for v in obj.data.vertices:
|
for v in obj.data.vertices:
|
||||||
verts.append((obj.matrix_world @ v.co))
|
verts.append(obj.matrix_world @ v.co)
|
||||||
if (verts[-1] - target).length < 0.001:
|
if (verts[-1] - target).length < 0.001:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
assert is_pass, f"No verts found at {location}: {verts}"
|
assert is_pass, f"No verts found at {location}: {verts}"
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class TestCreatingStyles(NewFile):
|
|||||||
subject.create_surface_style_with_textures(material, style_data, texture_data)
|
subject.create_surface_style_with_textures(material, style_data, texture_data)
|
||||||
|
|
||||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||||
|
|
||||||
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
|
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
|
||||||
alpha = 1 - style_data["Transparency"]
|
alpha = 1 - style_data["Transparency"]
|
||||||
@@ -137,7 +137,7 @@ class TestCreatingStyles(NewFile):
|
|||||||
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
||||||
|
|
||||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||||
|
|
||||||
color_to_tuple = lambda x: (x.Red, x.Green, x.Blue)
|
color_to_tuple = lambda x: (x.Red, x.Green, x.Blue)
|
||||||
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
|
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
|
||||||
@@ -250,7 +250,7 @@ class TestCreatingStyles(NewFile):
|
|||||||
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
||||||
|
|
||||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||||
|
|
||||||
image_node = tool.Blender.get_material_node(material, "TEX_IMAGE")
|
image_node = tool.Blender.get_material_node(material, "TEX_IMAGE")
|
||||||
assert image_node.outputs["Color"].links[0].to_socket.name == "Base Color"
|
assert image_node.outputs["Color"].links[0].to_socket.name == "Base Color"
|
||||||
@@ -385,7 +385,7 @@ class TestCreatingStyles(NewFile):
|
|||||||
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
subject.create_surface_style_with_textures(material, rendering_style, texture_style)
|
||||||
|
|
||||||
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
used_node_types = set([n.type for n in material.node_tree.nodes[:]])
|
||||||
assert used_node_types == set((["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"]))
|
assert used_node_types == set(["OUTPUT_MATERIAL", "BSDF_PRINCIPLED", "TEX_IMAGE", "TEX_COORD"])
|
||||||
|
|
||||||
image_node = tool.Blender.get_material_node(material, "TEX_IMAGE")
|
image_node = tool.Blender.get_material_node(material, "TEX_IMAGE")
|
||||||
assert image_node.outputs["Color"].links[0].to_socket.name == "Base Color"
|
assert image_node.outputs["Color"].links[0].to_socket.name == "Base Color"
|
||||||
|
|||||||
@@ -489,14 +489,14 @@ class TestApplyIfcMaterialChanges(NewFile):
|
|||||||
sprops = tool.Style.get_style_props()
|
sprops = tool.Style.get_style_props()
|
||||||
sprops.style_name = "Red"
|
sprops.style_name = "Red"
|
||||||
bpy.ops.bim.add_presentation_style()
|
bpy.ops.bim.add_presentation_style()
|
||||||
red_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Red"))
|
red_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Red")
|
||||||
ifcopenshell.api.style.assign_material_style(ifc_file, red_material, red_style, context)
|
ifcopenshell.api.style.assign_material_style(ifc_file, red_material, red_style, context)
|
||||||
|
|
||||||
blue_material = ifcopenshell.api.material.add_material(ifc_file, "Blue Material")
|
blue_material = ifcopenshell.api.material.add_material(ifc_file, "Blue Material")
|
||||||
bpy.ops.bim.enable_adding_presentation_style()
|
bpy.ops.bim.enable_adding_presentation_style()
|
||||||
sprops.style_name = "Blue"
|
sprops.style_name = "Blue"
|
||||||
bpy.ops.bim.add_presentation_style()
|
bpy.ops.bim.add_presentation_style()
|
||||||
blue_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue"))
|
blue_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue")
|
||||||
ifcopenshell.api.style.assign_material_style(ifc_file, blue_material, blue_style, context)
|
ifcopenshell.api.style.assign_material_style(ifc_file, blue_material, blue_style, context)
|
||||||
|
|
||||||
bpy.ops.bim.enable_adding_presentation_style()
|
bpy.ops.bim.enable_adding_presentation_style()
|
||||||
@@ -508,7 +508,7 @@ class TestApplyIfcMaterialChanges(NewFile):
|
|||||||
|
|
||||||
def setup_elements(self) -> None:
|
def setup_elements(self) -> None:
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
blue_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Blue Material"))
|
blue_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Blue Material")
|
||||||
blue_style = tool.Material.get_style(blue_material)
|
blue_style = tool.Material.get_style(blue_material)
|
||||||
|
|
||||||
# Element type.
|
# Element type.
|
||||||
@@ -552,9 +552,9 @@ class TestApplyIfcMaterialChanges(NewFile):
|
|||||||
self.setup_test()
|
self.setup_test()
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
||||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||||
red_style = tool.Material.get_style(red_material)
|
red_style = tool.Material.get_style(red_material)
|
||||||
blue_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue"))
|
blue_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue")
|
||||||
|
|
||||||
ifcopenshell.api.material.assign_material(ifc_file, material=red_material, products=[element_type])
|
ifcopenshell.api.material.assign_material(ifc_file, material=red_material, products=[element_type])
|
||||||
tool.Material.ensure_material_assigned([element_type], material=red_material)
|
tool.Material.ensure_material_assigned([element_type], material=red_material)
|
||||||
@@ -576,8 +576,8 @@ class TestApplyIfcMaterialChanges(NewFile):
|
|||||||
self.setup_test()
|
self.setup_test()
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
||||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||||
green_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green"))
|
green_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green")
|
||||||
|
|
||||||
# Occurrence with a style.
|
# Occurrence with a style.
|
||||||
element_type_obj = tool.Ifc.get_object(element_type)
|
element_type_obj = tool.Ifc.get_object(element_type)
|
||||||
@@ -601,9 +601,9 @@ class TestApplyIfcMaterialChanges(NewFile):
|
|||||||
def test_assign_material_to_representation_that_has_2_items_and_1_item_has_a_style(self):
|
def test_assign_material_to_representation_that_has_2_items_and_1_item_has_a_style(self):
|
||||||
self.setup_test(and_elements=False)
|
self.setup_test(and_elements=False)
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||||
red_style = tool.Material.get_style(red_material)
|
red_style = tool.Material.get_style(red_material)
|
||||||
green_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green"))
|
green_style = next(i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Green")
|
||||||
|
|
||||||
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 4))
|
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 4))
|
||||||
obj = bpy.data.objects["Cube"]
|
obj = bpy.data.objects["Cube"]
|
||||||
@@ -664,7 +664,7 @@ class TestApplyIfcMaterialChanges(NewFile):
|
|||||||
self.setup_test(and_elements=True)
|
self.setup_test(and_elements=True)
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
element_type = next(ifc_file.by_type("IfcActuatorType").__iter__())
|
||||||
red_material = next((i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material"))
|
red_material = next(i for i in ifc_file.by_type("IfcMaterial") if i.Name == "Red Material")
|
||||||
no_style_material = ifcopenshell.api.material.add_material(ifc_file, "No Style")
|
no_style_material = ifcopenshell.api.material.add_material(ifc_file, "No Style")
|
||||||
obj = bpy.data.objects["Simple"]
|
obj = bpy.data.objects["Simple"]
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) ->
|
|||||||
curve_segment = file.createIfcCurveSegment(
|
curve_segment = file.createIfcCurveSegment(
|
||||||
Transition="DISCONTINUOUS",
|
Transition="DISCONTINUOUS",
|
||||||
Placement=file.createIfcAxis2Placement2D(
|
Placement=file.createIfcAxis2Placement2D(
|
||||||
Location=file.createIfcCartesianPoint(((x, y))),
|
Location=file.createIfcCartesianPoint((x, y)),
|
||||||
RefDirection=file.createIfcDirection((dx, dy)),
|
RefDirection=file.createIfcDirection((dx, dy)),
|
||||||
),
|
),
|
||||||
SegmentStart=file.createIfcLengthMeasure(0.0),
|
SegmentStart=file.createIfcLengthMeasure(0.0),
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class Usecase:
|
|||||||
offset_direction = direction_ratios # offset direction doesn't change if direction_sense is negative
|
offset_direction = direction_ratios # offset direction doesn't change if direction_sense is negative
|
||||||
extrusion_direction = self.file.createIfcDirection(direction_ratios)
|
extrusion_direction = self.file.createIfcDirection(direction_ratios)
|
||||||
if self.direction_sense == "NEGATIVE":
|
if self.direction_sense == "NEGATIVE":
|
||||||
direction_ratios = tuple((-n for n in direction_ratios))
|
direction_ratios = tuple(-n for n in direction_ratios)
|
||||||
extrusion_direction = self.file.createIfcDirection(direction_ratios)
|
extrusion_direction = self.file.createIfcDirection(direction_ratios)
|
||||||
|
|
||||||
perpendicular_offset = self.convert_si_to_unit(self.offset) * abs(1 / cos(self.x_angle))
|
perpendicular_offset = self.convert_si_to_unit(self.offset) * abs(1 / cos(self.x_angle))
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class Usecase:
|
|||||||
self.file.createIfcDirection((1.0, 0.0, 0.0)),
|
self.file.createIfcDirection((1.0, 0.0, 0.0)),
|
||||||
),
|
),
|
||||||
extrusion_direction,
|
extrusion_direction,
|
||||||
self.convert_si_to_unit(self.settings["height"]) * abs((1 / cos(self.settings["x_angle"]))),
|
self.convert_si_to_unit(self.settings["height"]) * abs(1 / cos(self.settings["x_angle"])),
|
||||||
)
|
)
|
||||||
if self.settings["booleans"]:
|
if self.settings["booleans"]:
|
||||||
extrusion = self.apply_booleans(extrusion)
|
extrusion = self.apply_booleans(extrusion)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity
|
|||||||
# What if you didn't?
|
# What if you didn't?
|
||||||
ifcopenshell.api.sequence.unassign_lag_time(model, rel_sequence=sequence)
|
ifcopenshell.api.sequence.unassign_lag_time(model, rel_sequence=sequence)
|
||||||
"""
|
"""
|
||||||
if file.get_total_inverses((current_lag_time := rel_sequence.TimeLag)) == 1:
|
if file.get_total_inverses(current_lag_time := rel_sequence.TimeLag) == 1:
|
||||||
file.remove(current_lag_time)
|
file.remove(current_lag_time)
|
||||||
else:
|
else:
|
||||||
rel_sequence.TimeLag = None
|
rel_sequence.TimeLag = None
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ class Settings:
|
|||||||
def set_(self, *args): ...
|
def set_(self, *args): ...
|
||||||
def setting_names(self): ...
|
def setting_names(self): ...
|
||||||
|
|
||||||
class SvgSerializer (WriteOnlyGeometrySerializer):
|
class SvgSerializer(WriteOnlyGeometrySerializer):
|
||||||
SH_NONE: Any
|
SH_NONE: Any
|
||||||
SH_FULL: Any
|
SH_FULL: Any
|
||||||
SH_LEFT: Any
|
SH_LEFT: Any
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ def offset_date(start, duration, duration_type: DURATION_TYPE, calendar: ifcopen
|
|||||||
months = getattr(duration, "months", 0)
|
months = getattr(duration, "months", 0)
|
||||||
years = getattr(duration, "years", 0)
|
years = getattr(duration, "years", 0)
|
||||||
|
|
||||||
abs_duration = abs((duration.days + months * 30 + years * 12 * 30))
|
abs_duration = abs(duration.days + months * 30 + years * 12 * 30)
|
||||||
date_offset = datetime.timedelta(days=1 if duration.days > 0 else -1)
|
date_offset = datetime.timedelta(days=1 if duration.days > 0 else -1)
|
||||||
while abs_duration > 0:
|
while abs_duration > 0:
|
||||||
if duration_type == "ELAPSEDTIME" or not is_calendar_applicable(current_date, calendar):
|
if duration_type == "ELAPSEDTIME" or not is_calendar_applicable(current_date, calendar):
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class Patcher:
|
|||||||
assert isinstance(wall.data, bpy.types.Mesh)
|
assert isinstance(wall.data, bpy.types.Mesh)
|
||||||
wall.data.transform(
|
wall.data.transform(
|
||||||
Matrix.Translation(
|
Matrix.Translation(
|
||||||
(wall.matrix_world.inverted().to_quaternion() @ (wall.matrix_world.translation - new_origin))
|
wall.matrix_world.inverted().to_quaternion() @ (wall.matrix_world.translation - new_origin)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
wall.matrix_world.translation = new_origin
|
wall.matrix_world.translation = new_origin
|
||||||
|
|||||||
@@ -55,10 +55,8 @@ class Patcher:
|
|||||||
def patch(self):
|
def patch(self):
|
||||||
if isinstance(self.filepaths, Union[str, ifcopenshell.file]):
|
if isinstance(self.filepaths, Union[str, ifcopenshell.file]):
|
||||||
print(
|
print(
|
||||||
(
|
"WARNING. Passing a single file/filepath will be deprecated soon for MergeProjects ifcpatch, "
|
||||||
"WARNING. Passing a single file/filepath will be deprecated soon for MergeProjects ifcpatch, "
|
"replace it with a list of file/filepaths."
|
||||||
"replace it with a list of file/filepaths."
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self.filepaths = [self.filepaths]
|
self.filepaths = [self.filepaths]
|
||||||
for filepath in self.filepaths:
|
for filepath in self.filepaths:
|
||||||
|
|||||||
Reference in New Issue
Block a user