mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
layer.add_layer_with_style
This commit is contained in:
@@ -27,6 +27,7 @@ If you want to associated a whole element to a "layer", consider using
|
||||
|
||||
from .. import wrap_usecases
|
||||
from .add_layer import add_layer
|
||||
from .add_layer_with_style import add_layer_with_style
|
||||
from .assign_layer import assign_layer
|
||||
from .edit_layer import edit_layer
|
||||
from .remove_layer import remove_layer
|
||||
@@ -36,6 +37,7 @@ wrap_usecases(__path__, __name__)
|
||||
|
||||
__all__ = [
|
||||
"add_layer",
|
||||
"add_layer_with_style",
|
||||
"assign_layer",
|
||||
"edit_layer",
|
||||
"remove_layer",
|
||||
|
||||
@@ -35,9 +35,7 @@ def add_layer(file: ifcopenshell.file, name: str = "Unnamed") -> ifcopenshell.en
|
||||
may also use this layer information for filtering.
|
||||
|
||||
:param name: The name of the layer. Defaults to "Unnamed".
|
||||
:type name: str, optional
|
||||
:return: The newly created IfcPresentationLayerAssignment element
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# IfcOpenShell - IFC toolkit and geometry engine
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of IfcOpenShell.
|
||||
#
|
||||
# IfcOpenShell is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# IfcOpenShell is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# 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 Union, Literal, Sequence
|
||||
|
||||
IfcLogical = Union[bool, Literal["UNKNOWN"]]
|
||||
|
||||
|
||||
def add_layer_with_style(
|
||||
file: ifcopenshell.file,
|
||||
name: str = "Unnamed",
|
||||
on: IfcLogical = "UNKNOWN",
|
||||
frozen: IfcLogical = "UNKNOWN",
|
||||
blocked: IfcLogical = "UNKNOWN",
|
||||
styles: Sequence[ifcopenshell.entity_instance] = (),
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new layer with style
|
||||
|
||||
:param name: The name of the layer.
|
||||
:param on: Whether layer is visible.
|
||||
:param frozen:
|
||||
:param blocked: Whether layer elements are blocked from manipulation.
|
||||
:param styles: Styles to be used as default for representation item.
|
||||
:return: The newly created IfcPresentationLayerWithStyle element
|
||||
|
||||
Example:
|
||||
|
||||
ifcopenshell.api.layer.add_layer_with_style(
|
||||
model,
|
||||
name="AI-WALL-FULL-DIMS-N",
|
||||
on=True,
|
||||
frozen=False,
|
||||
blocked=False,
|
||||
stlyes=[curve_style]
|
||||
)
|
||||
"""
|
||||
return file.create_entity(
|
||||
"IfcPresentationLayerWithStyle",
|
||||
Name=name,
|
||||
LayerOn=on,
|
||||
LayerFrozen=frozen,
|
||||
LayerBlocked=blocked,
|
||||
LayerStyles=styles,
|
||||
)
|
||||
@@ -33,12 +33,9 @@ def assign_layer(
|
||||
|
||||
:param items: The list of IfcRepresentationItems to assign to the layer. This
|
||||
should be the items from the object's IfcShapeRepresentation.
|
||||
:type items: list[ifcopenshell.entity_instance]
|
||||
:param layer: The IfcPresentationLayerAssignment layer to assign the
|
||||
item to.
|
||||
:type layer: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -26,11 +26,8 @@ def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, att
|
||||
IfcPresentationLayerAssignment, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@ def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -
|
||||
relationship to the layer will be removed.
|
||||
|
||||
:param layer: The IfcPresentationLayerAssignment entity to remove
|
||||
:type layer: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -31,11 +31,8 @@ def unassign_layer(
|
||||
removed to keep IFC valid.
|
||||
|
||||
:param items: A list IfcRepresentationItem elements to unassign
|
||||
:type items: list[ifcopenshell.entity_instance]
|
||||
:param layer: The IfcPresentationLayerAssignment to unassign from
|
||||
:type layer: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user