mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Adding set items can now specify a name at creation for convenience
This commit is contained in:
@@ -17,10 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.unit
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def add_layer(
|
||||
file: ifcopenshell.file, layer_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
|
||||
file: ifcopenshell.file,
|
||||
layer_set: ifcopenshell.entity_instance,
|
||||
material: ifcopenshell.entity_instance,
|
||||
name: Optional[str] = None,
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new layer to a layer set
|
||||
|
||||
@@ -39,11 +43,9 @@ def add_layer(
|
||||
layer set represents a group of layers. See
|
||||
ifcopenshell.api.material.add_material_set for more information on
|
||||
how to add a layer set.
|
||||
:type layer_set: ifcopenshell.entity_instance
|
||||
:param material: The IfcMaterial that the layer is made out of.
|
||||
:type material: ifcopenshell.entity_instance
|
||||
:param name: An optional name of the layer.
|
||||
:return: The newly created IfcMaterialLayer
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
|
||||
@@ -82,12 +84,8 @@ def add_layer(
|
||||
ifcopenshell.api.material.assign_material(model, products=[wall_type], material=material_set)
|
||||
"""
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
|
||||
settings = {"layer_set": layer_set, "material": material}
|
||||
|
||||
layers = list(settings["layer_set"].MaterialLayers or [])
|
||||
layer = file.create_entity(
|
||||
"IfcMaterialLayer", **{"Material": settings["material"], "LayerThickness": 0.1 / unit_scale}
|
||||
)
|
||||
layers = list(layer_set.MaterialLayers or [])
|
||||
layer = file.create_entity("IfcMaterialLayer", Material=material, LayerThickness=0.1 / unit_scale, Name=name)
|
||||
layers.append(layer)
|
||||
settings["layer_set"].MaterialLayers = layers
|
||||
layer_set.MaterialLayers = layers
|
||||
return layer
|
||||
|
||||
Reference in New Issue
Block a user