mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Run black on IOS-Python
This commit is contained in:
@@ -74,7 +74,5 @@ def add_cost_item(
|
||||
},
|
||||
)
|
||||
elif settings["cost_item"]:
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
file, related_objects=[cost_item], relating_object=settings["cost_item"]
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item], relating_object=settings["cost_item"])
|
||||
return cost_item
|
||||
|
||||
@@ -26,6 +26,7 @@ geometry extrusions).
|
||||
from .. import wrap_usecases
|
||||
from .add_axis_representation import add_axis_representation
|
||||
from .add_boolean import add_boolean
|
||||
|
||||
try:
|
||||
from .add_door_representation import add_door_representation
|
||||
except ModuleNotFoundError as e:
|
||||
@@ -33,6 +34,7 @@ except ModuleNotFoundError as e:
|
||||
from .add_footprint_representation import add_footprint_representation
|
||||
from .add_mesh_representation import add_mesh_representation
|
||||
from .add_profile_representation import add_profile_representation
|
||||
|
||||
try:
|
||||
from .add_railing_representation import add_railing_representation
|
||||
except ModuleNotFoundError as e:
|
||||
@@ -44,6 +46,7 @@ except ModuleNotFoundError as e:
|
||||
print(f"Note: API not available due to missing dependencies: geometry.add_representation - {e}")
|
||||
from .add_slab_representation import add_slab_representation
|
||||
from .add_wall_representation import add_wall_representation
|
||||
|
||||
try:
|
||||
from .add_window_representation import add_window_representation
|
||||
except ModuleNotFoundError as e:
|
||||
|
||||
@@ -857,13 +857,19 @@ class Usecase:
|
||||
z = self.convert_si_to_unit(z)
|
||||
return self.file.createIfcCartesianPoint((x, y, z))
|
||||
|
||||
def create_cartesian_point_list_from_vertices(self, vertices: list[bpy.types.MeshVertex], is_2d=False, is_model_coords=True):
|
||||
def create_cartesian_point_list_from_vertices(
|
||||
self, vertices: list[bpy.types.MeshVertex], is_2d=False, is_model_coords=True
|
||||
):
|
||||
if is_model_coords and self.settings["coordinate_offset"]:
|
||||
if is_2d:
|
||||
xy_offset = Vector((self.settings["coordinate_offset"][0:2]))
|
||||
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy + xy_offset) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList2D(
|
||||
[self.convert_si_to_unit(v.co.xy + xy_offset) for v in vertices]
|
||||
)
|
||||
xyz_offset = Vector((self.settings["coordinate_offset"][0:3]))
|
||||
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co.xyz + xyz_offset) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList3D(
|
||||
[self.convert_si_to_unit(v.co.xyz + xyz_offset) for v in vertices]
|
||||
)
|
||||
if is_2d:
|
||||
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co) for v in vertices])
|
||||
|
||||
@@ -57,7 +57,7 @@ def edit_true_north(file: ifcopenshell.file, true_north: Optional[Union[tuple[fl
|
||||
|
||||
for context in file.by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||
if context.TrueNorth and true_north is None:
|
||||
old_true_north = context.TrueNorth
|
||||
old_true_north = context.TrueNorth
|
||||
context.TrueNorth = None
|
||||
if not file.get_total_inverses(old_true_north):
|
||||
ifcopenshell.util.element.remove_deep2(file, old_true_north)
|
||||
|
||||
@@ -22,6 +22,7 @@ A grid in IFC may contain two or more axes running in two or more directions.
|
||||
"""
|
||||
|
||||
from .. import wrap_usecases
|
||||
|
||||
try:
|
||||
from .create_axis_curve import create_axis_curve
|
||||
except ModuleNotFoundError as e:
|
||||
|
||||
@@ -20,7 +20,10 @@ from typing import Optional
|
||||
|
||||
|
||||
def add_material(
|
||||
file: ifcopenshell.file, name: Optional[str] = None, category: Optional[str] = None, description: Optional[str] = None
|
||||
file: ifcopenshell.file,
|
||||
name: Optional[str] = None,
|
||||
category: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new material
|
||||
|
||||
@@ -50,8 +53,8 @@ def add_material(
|
||||
Note that categories are not available in IFC2X3. This shortcoming is
|
||||
one of the big reasons projects should upgrade to IFC4.
|
||||
|
||||
Additionally, a material's description provides more information beyond
|
||||
its name or category.
|
||||
Additionally, a material's description provides more information beyond
|
||||
its name or category.
|
||||
|
||||
:param name: The name of the material, typically tagged in a finishes
|
||||
drawing or schedule.
|
||||
@@ -78,7 +81,7 @@ def add_material(
|
||||
# "Style" has been specified.
|
||||
ifcopenshell.api.material.assign_material(model, products=[concrete_bench], material=concrete)
|
||||
"""
|
||||
settings = {"name": name or "Unnamed", "category": category, "description": description }
|
||||
settings = {"name": name or "Unnamed", "category": category, "description": description}
|
||||
|
||||
material = file.create_entity("IfcMaterial", **{"Name": settings["name"] or "Unnamed"})
|
||||
if settings["category"]:
|
||||
|
||||
@@ -97,6 +97,7 @@ def assign_profile(
|
||||
|
||||
class Usecase:
|
||||
file: ifcopenshell.file
|
||||
|
||||
def execute(self) -> None:
|
||||
# TODO: handle composite profiles
|
||||
old_profile = self.settings["material_profile"].Profile
|
||||
|
||||
@@ -19,7 +19,9 @@ import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_assigned_material(file: ifcopenshell.file, element: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
def edit_assigned_material(
|
||||
file: ifcopenshell.file, element: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||
) -> None:
|
||||
"""Edits the attributes of an IfcMaterial
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT") -> ifcopenshell.entity_instance:
|
||||
def add_role(
|
||||
file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT"
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds and assigns a new role
|
||||
|
||||
People and organisations must play one or more roles on a project. Roles
|
||||
|
||||
@@ -19,7 +19,9 @@ import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
def edit_organisation(
|
||||
file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]
|
||||
) -> None:
|
||||
"""Edits the attributes of an IfcOrganization
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
|
||||
@@ -95,7 +95,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"Name": settings["name"],
|
||||
}
|
||||
},
|
||||
)
|
||||
file.create_entity(
|
||||
"IfcRelDefinesByProperties",
|
||||
@@ -104,7 +104,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["product"]],
|
||||
"RelatingPropertyDefinition": pset,
|
||||
}
|
||||
},
|
||||
)
|
||||
return pset
|
||||
elif settings["product"].is_a("IfcTypeObject"):
|
||||
@@ -118,7 +118,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"Name": settings["name"],
|
||||
}
|
||||
},
|
||||
)
|
||||
has_property_sets = list(settings["product"].HasPropertySets or [])
|
||||
has_property_sets.append(pset)
|
||||
@@ -142,7 +142,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
**{
|
||||
"Name": settings["name"],
|
||||
"Material": settings["product"],
|
||||
}
|
||||
},
|
||||
)
|
||||
elif settings["product"].is_a("IfcProfileDef"):
|
||||
# in IFC2X3 IfcProfileProperties doesn't have Name and we cannot identify them
|
||||
|
||||
@@ -50,7 +50,9 @@ def edit_prop_template(
|
||||
if enum_values := attributes.get("Enumerators", None):
|
||||
prop_name = attributes.get("Name", None) or getattr(prop_template, "Name", None) or "Unnamed"
|
||||
primary_measure_type = (
|
||||
attributes.get("PrimaryMeasureType", None) or getattr(prop_template, "PrimaryMeasureType", None) or "IfcLabel"
|
||||
attributes.get("PrimaryMeasureType", None)
|
||||
or getattr(prop_template, "PrimaryMeasureType", None)
|
||||
or "IfcLabel"
|
||||
)
|
||||
enum_values = [file.create_entity(primary_measure_type, v) for v in enum_values]
|
||||
if enumerators := prop_template.Enumerators:
|
||||
|
||||
@@ -38,10 +38,7 @@ def add_structural_load_case(
|
||||
"""
|
||||
|
||||
load_case = ifcopenshell.api.root.create_entity(
|
||||
file,
|
||||
ifc_class="IfcStructuralLoadCase",
|
||||
predefined_type="LOAD_CASE",
|
||||
name=name
|
||||
file, ifc_class="IfcStructuralLoadCase", predefined_type="LOAD_CASE", name=name
|
||||
)
|
||||
load_case.ActionType = action_type
|
||||
load_case.ActionSource = action_source
|
||||
|
||||
Reference in New Issue
Block a user