mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -41,6 +41,6 @@ def add_layer(file: ifcopenshell.file, name: str = "Unnamed") -> ifcopenshell.en
|
||||
|
||||
Example:
|
||||
|
||||
ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL-FULL-DIMS-N")
|
||||
ifcopenshell.api.layer.add_layer(model, name="AI-WALL-FULL-DIMS-N")
|
||||
"""
|
||||
return file.create_entity("IfcPresentationLayerAssignment", Name=name)
|
||||
|
||||
@@ -46,24 +46,24 @@ def assign_layer(
|
||||
|
||||
# Remember, all geometry needs to specify the context it is part of first.
|
||||
# See ifcopenshell.api.context.add_context for details.
|
||||
model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
|
||||
body = ifcopenshell.api.run("context.add_context", model,
|
||||
model = ifcopenshell.api.context.add_context(model, context_type="Model")
|
||||
body = ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model
|
||||
)
|
||||
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
representation = ifcopenshell.api.geometry.add_wall_representation(model,
|
||||
context=body, length=5, height=3, thickness=0.2)
|
||||
ifcopenshell.api.run("geometry.assign_representation", model,
|
||||
ifcopenshell.api.geometry.assign_representation(model,
|
||||
product=wall, representation=representation)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
|
||||
ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
|
||||
|
||||
# Now let's create a layer that contains walls
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
|
||||
|
||||
# And assign our wall representation item (in this example, there is
|
||||
# only one item) to the layer.
|
||||
ifcopenshell.api.run("layer.assign_layer", model, items=[representation.Items[0]], layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(model, items=[representation.Items[0]], layer=layer)
|
||||
"""
|
||||
settings = {
|
||||
"items": items,
|
||||
|
||||
@@ -36,8 +36,8 @@ def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, att
|
||||
|
||||
.. code:: python
|
||||
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
ifcopenshell.api.run("layer.edit_layer", model,
|
||||
layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
|
||||
ifcopenshell.api.layer.edit_layer(model,
|
||||
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
|
||||
"""
|
||||
settings = {"layer": layer, "attributes": attributes}
|
||||
|
||||
@@ -33,7 +33,7 @@ def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -
|
||||
|
||||
.. code:: python
|
||||
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
|
||||
layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
|
||||
ifcopenshell.api.layer.remove_layer(model, layer=layer)
|
||||
"""
|
||||
file.remove(layer)
|
||||
|
||||
@@ -43,27 +43,27 @@ def unassign_layer(
|
||||
|
||||
# Remember, all geometry needs to specify the context it is part of first.
|
||||
# See ifcopenshell.api.context.add_context for details.
|
||||
model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
|
||||
body = ifcopenshell.api.run("context.add_context", model,
|
||||
model = ifcopenshell.api.context.add_context(model, context_type="Model")
|
||||
body = ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model
|
||||
)
|
||||
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
representation = ifcopenshell.api.geometry.add_wall_representation(model,
|
||||
context=body, length=5, height=3, thickness=0.2)
|
||||
ifcopenshell.api.run("geometry.assign_representation", model,
|
||||
ifcopenshell.api.geometry.assign_representation(model,
|
||||
product=wall, representation=representation)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
|
||||
ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
|
||||
|
||||
# Now let's create a layer that contains walls
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
|
||||
|
||||
# And assign our wall representation item (in this example, there is
|
||||
# only one item) to the layer.
|
||||
ifcopenshell.api.run("layer.assign_layer", model, items=[representation.Items[0]], layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(model, items=[representation.Items[0]], layer=layer)
|
||||
|
||||
# Let's undo it!
|
||||
ifcopenshell.api.run("layer.unassign_layer", model, items=[representation.Items[0]], layer=layer)
|
||||
ifcopenshell.api.layer.unassign_layer(model, items=[representation.Items[0]], layer=layer)
|
||||
"""
|
||||
settings = {
|
||||
"items": items,
|
||||
|
||||
Reference in New Issue
Block a user