This commit is contained in:
Andrej730
2024-05-13 12:27:53 +05:00
parent c3bfd7354f
commit ebd03e9290
56 changed files with 244 additions and 127 deletions
@@ -15,9 +15,11 @@
#
# 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 Optional
def add_layer(file, Name=None) -> None:
def add_layer(file: ifcopenshell.file, Name: Optional[str] = None) -> ifcopenshell.entity_instance:
"""Adds a new layer
An IFC layer is like a CAD layer. Portions of an object's geometry
@@ -41,6 +43,4 @@ def add_layer(file, Name=None) -> None:
ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL-FULL-DIMS-N")
"""
settings = {"Name": Name or "Unnamed"}
return file.create_entity("IfcPresentationLayerAssignment", Name=settings["Name"])
return file.create_entity("IfcPresentationLayerAssignment", Name=Name)
@@ -15,9 +15,11 @@
#
# 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 edit_layer(file, layer=None, attributes=None) -> None:
def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
"""Edits the attributes of an IfcPresentationLayerAssignment
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
:param layer: The IfcPresentationLayerAssignment entity you want to edit
:type layer: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
@@ -38,7 +40,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
ifcopenshell.api.run("layer.edit_layer", model,
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
"""
settings = {"layer": layer, "attributes": attributes or {}}
settings = {"layer": layer, "attributes": attributes}
for name, value in settings["attributes"].items():
setattr(settings["layer"], name, value)
@@ -15,9 +15,10 @@
#
# 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
def remove_layer(file, layer=None) -> None:
def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -> None:
"""Removes a layer
All representation items assigned to the layer will remain, but the
@@ -35,6 +36,4 @@ def remove_layer(file, layer=None) -> None:
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
"""
settings = {"layer": layer}
file.remove(settings["layer"])
file.remove(layer)