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:
@@ -17,7 +17,9 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
@@ -74,15 +76,15 @@ def assign_object(
|
||||
|
||||
.. code:: python
|
||||
|
||||
project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
|
||||
project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
|
||||
|
||||
# The project contains a site (note that project aggregation is a special case in IFC)
|
||||
ifcopenshell.api.run("aggregate.assign_object", model, products=[element], relating_object=project)
|
||||
ifcopenshell.api.aggregate.assign_object(model, products=[element], relating_object=project)
|
||||
|
||||
# The site has a building
|
||||
ifcopenshell.api.run("aggregate.assign_object", model, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.aggregate.assign_object(model, products=[subelement], relating_object=element)
|
||||
"""
|
||||
settings = {
|
||||
"products": products,
|
||||
@@ -123,14 +125,14 @@ def assign_object(
|
||||
# can be either only aggregated or only contained at the same time
|
||||
# some product might not be able to have a container
|
||||
possibly_contained_products = [p for p in products_without_aggregates if hasattr(p, "ContainedInStructure")]
|
||||
ifcopenshell.api.run("spatial.unassign_container", file, products=possibly_contained_products)
|
||||
ifcopenshell.api.spatial.unassign_container(file, products=possibly_contained_products)
|
||||
|
||||
# unassign elements from previous aggregates
|
||||
for decomposes in previous_aggregates_rels:
|
||||
related_objects = set(decomposes.RelatedObjects) - products
|
||||
if related_objects:
|
||||
decomposes.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": decomposes})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": decomposes})
|
||||
else:
|
||||
history = decomposes.OwnerHistory
|
||||
file.remove(decomposes)
|
||||
@@ -140,13 +142,13 @@ def assign_object(
|
||||
# assign elements to a new aggregate
|
||||
if is_decomposed_by:
|
||||
is_decomposed_by.RelatedObjects = list(set(is_decomposed_by.RelatedObjects) | products)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": is_decomposed_by})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": is_decomposed_by})
|
||||
else:
|
||||
is_decomposed_by = file.create_entity(
|
||||
"IfcRelAggregates",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": list(products),
|
||||
"RelatingObject": relating_object,
|
||||
}
|
||||
@@ -156,8 +158,7 @@ def assign_object(
|
||||
for product in products_to_change:
|
||||
placement = getattr(product, "ObjectPlacement", None)
|
||||
if placement and placement.is_a("IfcLocalPlacement"):
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement",
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
file,
|
||||
product=product,
|
||||
matrix=ifcopenshell.util.placement.get_local_placement(product.ObjectPlacement),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -46,15 +46,15 @@ def unassign_object(file: ifcopenshell.file, products: list[ifcopenshell.entity_
|
||||
|
||||
.. code:: python
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", model, products=[subelement1], relating_object=element)
|
||||
ifcopenshell.api.run("aggregate.assign_object", model, products=[subelement2], relating_object=element)
|
||||
element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(model, products=[subelement1], relating_object=element)
|
||||
ifcopenshell.api.aggregate.assign_object(model, products=[subelement2], relating_object=element)
|
||||
# nothing is returned
|
||||
ifcopenshell.api.run("aggregate.unassign_object", model, products=[subelement1])
|
||||
ifcopenshell.api.aggregate.unassign_object(model, products=[subelement1])
|
||||
# nothing is returned, relationship is removed
|
||||
ifcopenshell.api.run("aggregate.unassign_object", model, products=[subelement2])
|
||||
ifcopenshell.api.aggregate.unassign_object(model, products=[subelement2])
|
||||
"""
|
||||
settings = {"products": products}
|
||||
|
||||
@@ -69,7 +69,7 @@ def unassign_object(file: ifcopenshell.file, products: list[ifcopenshell.entity_
|
||||
related_objects = set(rel.RelatedObjects) - products
|
||||
if related_objects:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
from typing import Any
|
||||
|
||||
@@ -41,8 +41,8 @@ def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instan
|
||||
|
||||
.. code:: python
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("attribute.edit_attributes", model,
|
||||
element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
ifcopenshell.api.attribute.edit_attributes(model,
|
||||
product=element, attributes={"Name": "Waldo"})
|
||||
"""
|
||||
settings = {"product": product, "attributes": attributes or {}}
|
||||
@@ -66,4 +66,4 @@ def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instan
|
||||
elif settings["product"].ObjectType and settings["product"].PredefinedType != "USERDEFINED":
|
||||
settings["product"].PredefinedType = "USERDEFINED"
|
||||
if hasattr(settings["product"], "OwnerHistory"):
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": settings["product"]})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": settings["product"]})
|
||||
|
||||
@@ -74,7 +74,7 @@ def assign_connection_geometry(
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("boundary.assign_connection_geometry", model,
|
||||
ifcopenshell.api.boundary.assign_connection_geometry(model,
|
||||
rel_space_boundary=element,
|
||||
outer_boundary=[(0., 0.), (1., 0.), (1., 1.), (0., 1.)],
|
||||
location=[0., 0., 0.], axis=[1., 0., 0.], ref_direction=[0., 0., 1.],
|
||||
|
||||
@@ -31,10 +31,10 @@ def copy_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_instanc
|
||||
|
||||
# A boring boundary with no geometry. Note that this boundary is
|
||||
# invalid and does not relate to any space or building element.
|
||||
boundary = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary = ifcopenshell.api.root.create_entity(model, ifc_class="IfcRelSpaceBoundary")
|
||||
|
||||
# And now we have two
|
||||
boundary_copy = ifcopenshell.api.run("boundary.copy_boundary", model, boundary=boundary)
|
||||
boundary_copy = ifcopenshell.api.boundary.copy_boundary(model, boundary=boundary)
|
||||
"""
|
||||
settings = {"boundary": boundary}
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ def remove_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_insta
|
||||
|
||||
# A boring boundary with no geometry. Note that this boundary is
|
||||
# invalid and does not relate to any space or building element.
|
||||
boundary = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary = ifcopenshell.api.root.create_entity(model, ifc_class="IfcRelSpaceBoundary")
|
||||
|
||||
# Let's remove it!
|
||||
ifcopenshell.api.run("boundary.remove_boundary", model, boundary=boundary)
|
||||
ifcopenshell.api.boundary.remove_boundary(model, boundary=boundary)
|
||||
"""
|
||||
settings = {"boundary": boundary}
|
||||
|
||||
|
||||
@@ -70,13 +70,13 @@ def add_classification(
|
||||
.. code:: python
|
||||
|
||||
# Option 1: adding a custom clasification from scratch
|
||||
ifcopenshell.api.run("classification.add_classification", model,
|
||||
ifcopenshell.api.classification.add_classification(model,
|
||||
classification="MyCustomClassification")
|
||||
|
||||
# Option 2: adding a popular classification from a library
|
||||
library = ifcopenshell.open("/path/to/Uniclass.ifc")
|
||||
classification = library.by_type("IfcClassification")[0]
|
||||
ifcopenshell.api.run("classification.add_classification", model,
|
||||
ifcopenshell.api.classification.add_classification(model,
|
||||
classification=classification)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.schema
|
||||
@@ -105,20 +105,20 @@ def add_reference(
|
||||
|
||||
# Option 1: adding and assigning a new reference from scratch
|
||||
wall_type = model.by_type("IfcWallType")[0]
|
||||
classification = ifcopenshell.api.run("classification.add_classification",
|
||||
classification = ifcopenshell.api.classification.add_classification(
|
||||
model, classification="MyCustomClassification")
|
||||
ifcopenshell.api.run("classification.add_reference", model,
|
||||
ifcopenshell.api.classification.add_reference(model,
|
||||
products=[wall_type], classification=classification,
|
||||
identification="W_01", name="Interior Walls")
|
||||
|
||||
# Option 2: adding a popular classification from a library
|
||||
library = ifcopenshell.open("/path/to/Uniclass.ifc")
|
||||
lib_classification = library.by_type("IfcClassification")[0]
|
||||
classification = ifcopenshell.api.run("classification.add_classification",
|
||||
classification = ifcopenshell.api.classification.add_classification(
|
||||
model, classification=lib_classification)
|
||||
reference = [r for r in library.by_type("IfcClassificationReference")
|
||||
if r.Identification == "XYZ"][0]
|
||||
ifcopenshell.api.run("classification.add_reference", model,
|
||||
ifcopenshell.api.classification.add_reference(model,
|
||||
products=[wall_type], classification=classification,
|
||||
reference=reference)
|
||||
"""
|
||||
@@ -235,11 +235,11 @@ class Usecase:
|
||||
if root_rel:
|
||||
related_objects = set(root_rel.RelatedObjects) | self.rooted_products
|
||||
root_rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": root_rel})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": root_rel})
|
||||
else:
|
||||
self.file.create_entity(
|
||||
"IfcRelAssociatesClassification",
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatedObjects=list(self.rooted_products),
|
||||
RelatingClassification=reference,
|
||||
|
||||
@@ -40,7 +40,7 @@ def edit_classification(
|
||||
|
||||
classification = model.by_type("IfcClassification")[0]
|
||||
# Change the name of the classification system to "Foo"
|
||||
ifcopenshell.api.run("classification.edit_classification", model,
|
||||
ifcopenshell.api.classification.edit_classification(model,
|
||||
classification=classification, attributes={"Name": "Foo"})
|
||||
"""
|
||||
settings = {"classification": classification, "attributes": attributes or {}}
|
||||
|
||||
@@ -40,7 +40,7 @@ def edit_reference(
|
||||
|
||||
reference = model.by_type("IfcClassification")[0]
|
||||
# Change the name of the reference to "Foo"
|
||||
ifcopenshell.api.run("classification.edit_reference", model,
|
||||
ifcopenshell.api.classification.edit_reference(model,
|
||||
reference=reference, attributes={"Name": "Foo"})
|
||||
"""
|
||||
settings = {"reference": reference, "attributes": attributes or {}}
|
||||
|
||||
@@ -37,7 +37,7 @@ def remove_classification(file: ifcopenshell.file, classification: ifcopenshell.
|
||||
.. code:: python
|
||||
|
||||
classification = model.by_type("IfcClassification")[0]
|
||||
ifcopenshell.api.run("classification.remove_classification", model,
|
||||
ifcopenshell.api.classification.remove_classification(model,
|
||||
classification=classification)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -48,12 +48,12 @@ def remove_reference(
|
||||
.. code:: python
|
||||
|
||||
wall_type = model.by_type("IfcWallType")[0]
|
||||
classification = ifcopenshell.api.run("classification.add_classification",
|
||||
classification = ifcopenshell.api.classification.add_classification(
|
||||
model, classification="MyCustomClassification")
|
||||
reference = ifcopenshell.api.run("classification.add_reference", model,
|
||||
reference = ifcopenshell.api.classification.add_reference(model,
|
||||
products=[wall_type], classification=classification,
|
||||
identification="W_01", name="Interior Walls")
|
||||
ifcopenshell.api.run("classification.remove_reference", model,
|
||||
ifcopenshell.api.classification.remove_reference(model,
|
||||
reference=reference, products=[wall_type])
|
||||
"""
|
||||
settings = {"reference": reference, "products": products}
|
||||
@@ -93,7 +93,7 @@ def remove_reference(
|
||||
related_objects = set(rel.RelatedObjects) - rooted_products
|
||||
if related_objects:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
|
||||
@@ -36,8 +36,8 @@ def add_metric(file: ifcopenshell.file, objective: ifcopenshell.entity_instance)
|
||||
|
||||
.. code:: python
|
||||
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
metric = ifcopenshell.api.run("constraint.add_metric", model,
|
||||
objective = ifcopenshell.api.constraint.add_objective(model)
|
||||
metric = ifcopenshell.api.constraint.add_metric(model,
|
||||
objective=objective)
|
||||
"""
|
||||
settings = {
|
||||
|
||||
@@ -36,7 +36,7 @@ def add_objective(file: ifcopenshell.file) -> ifcopenshell.entity_instance:
|
||||
.. code:: python
|
||||
|
||||
# Create a new objective for code compliance requirements
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
objective = ifcopenshell.api.constraint.add_objective(model)
|
||||
objective.ConstraintGrade = "ADVISORY"
|
||||
objective.ObjectiveQualifier = "CODECOMPLIANCE"
|
||||
# Note: the objective right now is purely qualitative and for
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
from typing import Union
|
||||
|
||||
@@ -77,14 +77,14 @@ class Usecase:
|
||||
if rel:
|
||||
related_objects = set(rel.RelatedObjects) | products_to_assign
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
return self.file.create_entity(
|
||||
"IfcRelAssociatesConstraint",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
"RelatingConstraint": self.constraint,
|
||||
"RelatedObjects": list(products_to_assign),
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ def edit_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance, a
|
||||
|
||||
.. code:: python
|
||||
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
metric = ifcopenshell.api.run("constraint.add_metric", model,
|
||||
objective = ifcopenshell.api.constraint.add_objective(model)
|
||||
metric = ifcopenshell.api.constraint.add_metric(model,
|
||||
objective=objective)
|
||||
ifcopenshell.api.run("constraint.edit_metric", model,
|
||||
ifcopenshell.api.constraint.edit_metric(model,
|
||||
metric=metric, attributes={"ConstraintGrade": "HARD"})
|
||||
"""
|
||||
settings = {"metric": metric, "attributes": attributes or {}}
|
||||
|
||||
@@ -38,8 +38,8 @@ def edit_objective(
|
||||
|
||||
.. code:: python
|
||||
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
ifcopenshell.api.run("constraint.edit_objective", model,
|
||||
objective = ifcopenshell.api.constraint.add_objective(model)
|
||||
ifcopenshell.api.constraint.edit_objective(model,
|
||||
objective=objective, attributes={"ConstraintGrade": "HARD"})
|
||||
"""
|
||||
settings = {"objective": objective, "attributes": attributes or {}}
|
||||
|
||||
@@ -37,8 +37,8 @@ def remove_constraint(file: ifcopenshell.file, constraint: ifcopenshell.entity_i
|
||||
|
||||
.. code:: python
|
||||
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
ifcopenshell.api.run("constraint.remove_constraint", model,
|
||||
objective = ifcopenshell.api.constraint.add_objective(model)
|
||||
ifcopenshell.api.constraint.remove_constraint(model,
|
||||
constraint=objective)
|
||||
"""
|
||||
settings = {"constraint": constraint}
|
||||
|
||||
@@ -33,10 +33,10 @@ def remove_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance)
|
||||
|
||||
.. code:: python
|
||||
|
||||
objective = ifcopenshell.api.run("constraint.add_objective", model)
|
||||
metric = ifcopenshell.api.run("constraint.add_metric", model,
|
||||
objective = ifcopenshell.api.constraint.add_objective(model)
|
||||
metric = ifcopenshell.api.constraint.add_metric(model,
|
||||
objective=objective)
|
||||
ifcopenshell.api.run("constraint.remove_metric", model,
|
||||
ifcopenshell.api.constraint.remove_metric(model,
|
||||
metric=metric)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class Usecase:
|
||||
related_objects -= products
|
||||
if related_objects:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
|
||||
continue
|
||||
|
||||
history = rel.OwnerHistory
|
||||
|
||||
@@ -121,63 +121,63 @@ def add_context(
|
||||
|
||||
# If we plan to store 3D geometry in our IFC model, we have to setup
|
||||
# a "Model" context.
|
||||
model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
|
||||
model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
|
||||
|
||||
# And/Or, if we plan to store 2D geometry, we need a "Plan" context
|
||||
plan = ifcopenshell.api.run("context.add_context", model, context_type="Plan")
|
||||
plan = ifcopenshell.api.context.add_context(model, context_type="Plan")
|
||||
|
||||
# Now we setup the subcontexts with each of the geometric "purposes"
|
||||
# we plan to store in our model. "Body" is by far the most important
|
||||
# and common context, as most IFC models are assumed to be viewable
|
||||
# in 3D.
|
||||
body = ifcopenshell.api.run("context.add_context", model,
|
||||
body = ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
|
||||
|
||||
# The 3D Axis subcontext is important if any "axis-based" parametric
|
||||
# geometry is going to be created. For example, a beam, or column
|
||||
# may be drawn using a single 3D axis line, and for this we need an
|
||||
# Axis subcontext.
|
||||
ifcopenshell.api.run("context.add_context", model,
|
||||
ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Axis", target_view="GRAPH_VIEW", parent=model3d)
|
||||
|
||||
# The 3D Box subcontext is useful for clash detection or shape
|
||||
# analysis, or even lazy-loading of large models.
|
||||
ifcopenshell.api.run("context.add_context", model,
|
||||
ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Box", target_view="MODEL_VIEW", parent=model3d)
|
||||
|
||||
# It's also important to have a 2D Axis subcontext for things like
|
||||
# walls and claddings which can be drawn using a 2D axis line.
|
||||
ifcopenshell.api.run("context.add_context", model,
|
||||
ifcopenshell.api.context.add_context(model,
|
||||
context_type="Plan", context_identifier="Axis", target_view="GRAPH_VIEW", parent=plan)
|
||||
|
||||
# A 2D annotation subcontext for plan views are important for door
|
||||
# swings, window cuts, and symbols for equipment like GPOs, fire
|
||||
# extinguishers, and so on.
|
||||
ifcopenshell.api.run("context.add_context", model,
|
||||
ifcopenshell.api.context.add_context(model,
|
||||
context_type="Plan", context_identifier="Annotation", target_view="PLAN_VIEW", parent=plan)
|
||||
|
||||
# You may also create 2D annotation subcontexts for sections and
|
||||
# elevation views.
|
||||
ifcopenshell.api.run("context.add_context", model,
|
||||
ifcopenshell.api.context.add_context(model,
|
||||
context_type="Plan", context_identifier="Annotation", target_view="SECTION_VIEW", parent=plan)
|
||||
ifcopenshell.api.run("context.add_context", model,
|
||||
ifcopenshell.api.context.add_context(model,
|
||||
context_type="Plan", context_identifier="Annotation", target_view="ELEVATION_VIEW", parent=plan)
|
||||
|
||||
# Let's create a new wall. The wall does not have any geometry yet.
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
|
||||
# Let's use the "3D Body" representation we created earlier to add a
|
||||
# new wall-like body geometry, 5 meters long, 3 meters high, and
|
||||
# 200mm thick
|
||||
representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
|
||||
representation = ifcopenshell.api.geometry.add_wall_representation(model,
|
||||
context=body, length=5, height=3, thickness=0.2)
|
||||
|
||||
# Assign our new body geometry back to our wall
|
||||
ifcopenshell.api.run("geometry.assign_representation", model,
|
||||
ifcopenshell.api.geometry.assign_representation(model,
|
||||
product=wall, representation=representation)
|
||||
|
||||
# Place our wall at the origin
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
|
||||
ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
|
||||
@@ -37,14 +37,14 @@ def edit_context(file: ifcopenshell.file, context: ifcopenshell.entity_instance,
|
||||
|
||||
.. code:: python
|
||||
|
||||
model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
|
||||
model = ifcopenshell.api.context.add_context(model, context_type="Model")
|
||||
# Revit had a bug where they incorrectly called the body representation a "Facetation"
|
||||
body = ifcopenshell.api.run("context.add_context", model,
|
||||
body = ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Facetation", target_view="MODEL_VIEW", parent=model
|
||||
)
|
||||
|
||||
# Let's fix it!
|
||||
ifcopenshell.api.run("context.edit_context", model,
|
||||
ifcopenshell.api.context.edit_context(model,
|
||||
context=body, attributes={"ContextIdentifier": "Body"})
|
||||
"""
|
||||
settings = {"context": context, "attributes": attributes}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -36,19 +37,19 @@ def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instanc
|
||||
|
||||
.. code:: python
|
||||
|
||||
model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
|
||||
model = ifcopenshell.api.context.add_context(model, context_type="Model")
|
||||
# Revit had a bug where they incorrectly called the body representation a "Facetation"
|
||||
body = ifcopenshell.api.run("context.add_context", model,
|
||||
body = ifcopenshell.api.context.add_context(model,
|
||||
context_type="Model", context_identifier="Facetation", target_view="MODEL_VIEW", parent=model
|
||||
)
|
||||
|
||||
# Let's just get rid of it completely
|
||||
ifcopenshell.api.run("context.remove_context", model, context=body)
|
||||
ifcopenshell.api.context.remove_context(model, context=body)
|
||||
"""
|
||||
settings = {"context": context}
|
||||
|
||||
for subcontext in settings["context"].HasSubContexts:
|
||||
ifcopenshell.api.run("context.remove_context", file, context=subcontext)
|
||||
ifcopenshell.api.context.remove_context(file, context=subcontext)
|
||||
|
||||
if getattr(settings["context"], "ParentContext", None):
|
||||
new = settings["context"].ParentContext
|
||||
@@ -63,4 +64,4 @@ def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instanc
|
||||
representations_in_context = settings["context"].RepresentationsInContext
|
||||
file.remove(settings["context"])
|
||||
for element in representations_in_context:
|
||||
ifcopenshell.api.run("geometry.remove_representation", file, representation=element)
|
||||
ifcopenshell.api.geometry.remove_representation(file, representation=element)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
from typing import Union
|
||||
|
||||
@@ -54,22 +54,22 @@ def assign_control(
|
||||
.. code:: python
|
||||
|
||||
# One common usecase is to assign a calendar to a task
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model)
|
||||
task = ifcopenshell.api.run("sequence.add_task", model,
|
||||
calendar = ifcopenshell.api.sequence.add_work_calendar(model)
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(model)
|
||||
task = ifcopenshell.api.sequence.add_task(model,
|
||||
work_schedule=schedule)
|
||||
|
||||
# All subtasks will inherit this calendar, so assigning a single
|
||||
# calendar to the root task effectively defines a "default" calendar
|
||||
ifcopenshell.api.run("control.assign_control", model,
|
||||
ifcopenshell.api.control.assign_control(model,
|
||||
relating_control=calendar, related_object=task)
|
||||
|
||||
# Another common example might be relating a cost item and a product
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
cost_item = ifcopenshell.api.run("cost.add_cost_item", model,
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
cost_item = ifcopenshell.api.cost.add_cost_item(model,
|
||||
cost_schedule=schedule)
|
||||
ifcopenshell.api.run("control.assign_control", model,
|
||||
ifcopenshell.api.control.assign_control(model,
|
||||
relating_control=cost_item, related_object=wall)
|
||||
"""
|
||||
settings = {
|
||||
@@ -92,13 +92,13 @@ def assign_control(
|
||||
related_objects = set(controls.RelatedObjects)
|
||||
related_objects.add(settings["related_object"])
|
||||
controls.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": controls})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": controls})
|
||||
else:
|
||||
controls = file.create_entity(
|
||||
"IfcRelAssignsToControl",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["related_object"]],
|
||||
"RelatingControl": settings["relating_control"],
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
from typing import Union
|
||||
|
||||
@@ -43,15 +43,15 @@ def unassign_control(
|
||||
.. code:: python
|
||||
|
||||
# Let's relate a cost item and a product
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
cost_item = ifcopenshell.api.run("cost.add_cost_item", model,
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
cost_item = ifcopenshell.api.cost.add_cost_item(model,
|
||||
cost_schedule=schedule)
|
||||
ifcopenshell.api.run("control.assign_control", model,
|
||||
ifcopenshell.api.control.assign_control(model,
|
||||
relating_control=cost_item, related_object=wall)
|
||||
|
||||
# And now let's change our mind
|
||||
ifcopenshell.api.run("control.unassign_control", model,
|
||||
ifcopenshell.api.control.unassign_control(model,
|
||||
relating_control=cost_item, related_object=wall)
|
||||
"""
|
||||
|
||||
@@ -72,5 +72,5 @@ def unassign_control(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
from typing import Optional
|
||||
|
||||
@@ -49,30 +51,30 @@ def add_cost_item(
|
||||
.. code:: python
|
||||
|
||||
# The very first cost item must be in a cost schedule
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
|
||||
# You may add cost items as top level item in the schedule
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# Alternatively you may add them as subitems
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_item=item1)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(model, cost_item=item1)
|
||||
"""
|
||||
settings = {"cost_schedule": cost_schedule, "cost_item": cost_item}
|
||||
|
||||
cost_item = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcCostItem")
|
||||
cost_item = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
|
||||
|
||||
if settings["cost_schedule"]:
|
||||
file.create_entity(
|
||||
"IfcRelAssignsToControl",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [cost_item],
|
||||
"RelatingControl": settings["cost_schedule"],
|
||||
},
|
||||
)
|
||||
elif settings["cost_item"]:
|
||||
ifcopenshell.api.run(
|
||||
"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
|
||||
|
||||
@@ -65,15 +65,15 @@ def add_cost_item_quantity(
|
||||
|
||||
.. code:: python
|
||||
|
||||
chair = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
ifcopenshell.api.run("control.assign_control", model,
|
||||
chair = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
ifcopenshell.api.control.assign_control(model,
|
||||
relating_control=item, related_object=chair)
|
||||
|
||||
# Let's assume we want to count the amount of chairs to calculate our cost item
|
||||
# Because this is an IfcQuantityCount the count will be automatically set to "1" chair
|
||||
ifcopenshell.api.run("cost.add_cost_item_quantity", model,
|
||||
ifcopenshell.api.cost.add_cost_item_quantity(model,
|
||||
cost_item=item, ifc_class="IfcQuantityCount")
|
||||
"""
|
||||
settings = {"cost_item": cost_item, "ifc_class": ifc_class}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.util.date
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
@@ -51,14 +51,13 @@ def add_cost_schedule(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
# Now that we have a cost schedule, we may add cost items to it
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
"""
|
||||
settings = {"name": name, "predefined_type": predefined_type}
|
||||
|
||||
cost_schedule = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
cost_schedule = ifcopenshell.api.root.create_entity(
|
||||
file,
|
||||
ifc_class="IfcCostSchedule",
|
||||
predefined_type=settings["predefined_type"],
|
||||
|
||||
@@ -55,40 +55,40 @@ def add_cost_value(file: ifcopenshell.file, parent: ifcopenshell.entity_instance
|
||||
.. code:: python
|
||||
|
||||
# We always need a schedule first prior to adding any cost items
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
|
||||
# Option 1: This cost item will have a full cost of 42.0
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item1)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item1)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 42.0})
|
||||
|
||||
# Option 2: This cost item will have a unit cost of 5.0 per unit
|
||||
# area, multiplied by the quantity of area specified explicitly as
|
||||
# 3.0, giving us a subtotal cost of 15.0.
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item2)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item2)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5.0})
|
||||
quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
|
||||
cost_item=item2, ifc_class="IfcQuantityVolume")
|
||||
ifcopenshell.api.run("cost.edit_cost_item_quantity", model,
|
||||
ifcopenshell.api.cost.edit_cost_item_quantity(model,
|
||||
physical_quantity=quantity, "attributes": {"VolumeValue": 3.0})
|
||||
|
||||
# A cost value may also be specified in terms of the sum of its
|
||||
# subcomponents. In this case, it's broken down into 2 subvalues.
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item1)
|
||||
subvalue1 = ifcopenshell.api.run("cost.add_cost_value", model, parent=value)
|
||||
subvalue2 = ifcopenshell.api.run("cost.add_cost_value", model, parent=value)
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item1)
|
||||
subvalue1 = ifcopenshell.api.cost.add_cost_value(model, parent=value)
|
||||
subvalue2 = ifcopenshell.api.cost.add_cost_value(model, parent=value)
|
||||
|
||||
# This specifies that the value is the sum of all subitems
|
||||
# regardless of their cost category. The first subvalue is 2.0 and
|
||||
# the second is 3.0, giving a total value of 5.0.
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value, attributes={"Category": "*"})
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model,
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value, attributes={"Category": "*"})
|
||||
ifcopenshell.api.cost.edit_cost_value(model,
|
||||
cost_value=subvalue1, attributes={"AppliedValue": 2.0})
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model,
|
||||
ifcopenshell.api.cost.edit_cost_value(model,
|
||||
cost_value=subvalue2, attributes={"AppliedValue": 3.0})
|
||||
"""
|
||||
settings = {"parent": parent}
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.api.control
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -63,26 +64,26 @@ def assign_cost_item_quantity(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# Let's imagine a unit cost of 5.0 per unit volume
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5.0})
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSlab")
|
||||
slab = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSlab")
|
||||
# Usually the quantity would be automatically calculated via a
|
||||
# graphical authoring application but let's assign a manual quantity
|
||||
# for now.
|
||||
qto = ifcopenshell.api.run("pset.add_qto", model, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"NetVolume": 42.0})
|
||||
qto = ifcopenshell.api.pset.add_qto(model, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"NetVolume": 42.0})
|
||||
|
||||
# Now let's parametrically link the slab's quantity to the cost
|
||||
# item. If the slab is edited in the future and 42.0 changes, then
|
||||
# the updated value will also automatically be applied to the cost
|
||||
# item.
|
||||
ifcopenshell.api.run("cost.assign_cost_item_quantity", model,
|
||||
ifcopenshell.api.cost.assign_cost_item_quantity(model,
|
||||
cost_item=item, products=[slab], prop_name="NetVolume")
|
||||
"""
|
||||
usecase = Usecase()
|
||||
@@ -119,8 +120,7 @@ class Usecase:
|
||||
def assign_cost_control(
|
||||
self, related_object: ifcopenshell.entity_instance, cost_item: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
return ifcopenshell.api.run(
|
||||
"control.assign_control",
|
||||
return ifcopenshell.api.control.assign_control(
|
||||
self.file,
|
||||
related_object=related_object,
|
||||
relating_control=cost_item,
|
||||
@@ -142,8 +142,7 @@ class Usecase:
|
||||
# This is a bold assumption
|
||||
# https://forums.buildingsmart.org/t/how-does-a-cost-item-know-that-it-is-counting-a-controlled-product/3564
|
||||
if not self.settings["cost_item"].CostQuantities:
|
||||
ifcopenshell.api.run(
|
||||
"cost.add_cost_item_quantity",
|
||||
ifcopenshell.api.cost.add_cost_item_quantity(
|
||||
self.file,
|
||||
cost_item=self.settings["cost_item"],
|
||||
ifc_class="IfcQuantityCount",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.cost
|
||||
|
||||
|
||||
def assign_cost_value(
|
||||
@@ -47,26 +47,25 @@ def assign_cost_value(
|
||||
.. code:: python
|
||||
|
||||
# Let's create a schedule of rates with a single rate in it of 5.0
|
||||
rate_tables = ifcopenshell.api.run("cost.add_cost_schedule", model,
|
||||
rate_tables = ifcopenshell.api.cost.add_cost_schedule(model,
|
||||
predefined_type="SCHEDULEOFRATES")
|
||||
rate = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=rate)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
rate = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=rate)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5.0})
|
||||
|
||||
# And this schedule will be for our actual cost plan / estimate / etc
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# Now the cost item has the same rate as the one from the schedule of rate's item
|
||||
ifcopenshell.api.run("cost.assign_cost_value", model, cost_item=item, cost_rate=rate)
|
||||
ifcopenshell.api.cost.assign_cost_value(model, cost_item=item, cost_rate=rate)
|
||||
"""
|
||||
settings = {"cost_item": cost_item, "cost_rate": cost_rate}
|
||||
|
||||
if settings["cost_item"].CostValues:
|
||||
[
|
||||
ifcopenshell.api.run(
|
||||
"cost.remove_cost_value",
|
||||
ifcopenshell.api.cost.remove_cost_value(
|
||||
file,
|
||||
parent=settings["cost_item"],
|
||||
cost_value=cost_value,
|
||||
|
||||
+18
-18
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.date
|
||||
import ifcopenshell.util.resource
|
||||
|
||||
@@ -49,44 +49,44 @@ def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcop
|
||||
.. code:: python
|
||||
|
||||
# First, we need a cost schedule and item
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# Let's imagine we have our own formworking crew
|
||||
crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
|
||||
crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
|
||||
|
||||
# ... and they need concrete
|
||||
concrete = ifcopenshell.api.run("resource.add_resource", model,
|
||||
concrete = ifcopenshell.api.resource.add_resource(model,
|
||||
ifc_class="IfcConstructionMaterialResource", parent_resource=crew)
|
||||
ifcopenshell.api.run("control.assign_control", model,
|
||||
ifcopenshell.api.control.assign_control(model,
|
||||
relating_control=item, related_object=concrete)
|
||||
# ... which has a unit price of 42.0 per m3
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=concrete)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=concrete)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 42.0})
|
||||
# ... and a volume of 200m3
|
||||
quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
|
||||
quantity = ifcopenshell.api.resource.add_resource_quantity(model,
|
||||
resource=concrete, ifc_class="IfcQuantityVolume")
|
||||
ifcopenshell.api.run("resource.edit_resource_quantity", model,
|
||||
ifcopenshell.api.resource.edit_resource_quantity(model,
|
||||
physical_quantity=quantity, "attributes": {"VolumeValue": 200.0})
|
||||
|
||||
# Let's say they also need some equipment
|
||||
equipment = ifcopenshell.api.run("resource.add_resource", model,
|
||||
equipment = ifcopenshell.api.resource.add_resource(model,
|
||||
ifc_class="IfcConstructionEquipmentResource", parent_resource=crew)
|
||||
ifcopenshell.api.run("control.assign_control", model,
|
||||
ifcopenshell.api.control.assign_control(model,
|
||||
relating_control=item, related_object=equipment)
|
||||
# ... with a fixed price of 50,000
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=concrete)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=concrete)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 42.0})
|
||||
|
||||
# (42 * 200) + 50000 = 58400 is our calculated cost
|
||||
ifcopenshell.api.run("cost.calculate_cost_item_resource_value", model, cost_item=item)
|
||||
ifcopenshell.api.cost.calculate_cost_item_resource_value(model, cost_item=item)
|
||||
"""
|
||||
settings = {"cost_item": cost_item}
|
||||
|
||||
for cost_value in settings["cost_item"].CostValues or []:
|
||||
ifcopenshell.api.run("cost.remove_cost_value", file, parent=settings["cost_item"], cost_value=cost_value)
|
||||
ifcopenshell.api.cost.remove_cost_value(file, parent=settings["cost_item"], cost_value=cost_value)
|
||||
|
||||
resources = []
|
||||
for rel in settings["cost_item"].Controls or []:
|
||||
@@ -112,6 +112,6 @@ def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcop
|
||||
quantity = quantity / 8 # Assume 8 hour working day - TODO implement resource calendar
|
||||
quantity = round(quantity, 2)
|
||||
formula = "{}*{}".format(cost, quantity)
|
||||
cost_value = ifcopenshell.api.run("cost.add_cost_value", file, parent=settings["cost_item"])
|
||||
cost_value = ifcopenshell.api.cost.add_cost_value(file, parent=settings["cost_item"])
|
||||
cost_value.Name = resource.Name
|
||||
ifcopenshell.api.run("cost.edit_cost_value_formula", file, cost_value=cost_value, formula=formula)
|
||||
ifcopenshell.api.cost.edit_cost_value_formula(file, cost_value=cost_value, formula=formula)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.util.element
|
||||
from typing import Union
|
||||
|
||||
@@ -85,12 +85,9 @@ class Usecase:
|
||||
inverse = ifcopenshell.util.element.copy(self.file, inverse)
|
||||
inverse.RelatingObject = to_element
|
||||
inverse.RelatedObjects = new_cost_items
|
||||
ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=new_cost_items)
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object",
|
||||
self.file,
|
||||
related_objects=new_cost_items,
|
||||
relating_object=to_element,
|
||||
ifcopenshell.api.nest.unassign_object(self.file, related_objects=new_cost_items)
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=new_cost_items, relating_object=to_element
|
||||
)
|
||||
# elif inverse.is_a("IfcRelAssignsToProduct"):
|
||||
# continue
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
|
||||
|
||||
def copy_cost_item_values(
|
||||
@@ -41,22 +41,22 @@ def copy_cost_item_values(
|
||||
.. code:: python
|
||||
|
||||
# Assume we have a schedule with multiple items in it
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# One of the items has a value
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5000.0})
|
||||
|
||||
# Let's copy the value from one item to another
|
||||
ifcopenshell.api.run("cost.copy_cost_item_values", model, source=item1, destination=item2)
|
||||
ifcopenshell.api.cost.copy_cost_item_values(model, source=item1, destination=item2)
|
||||
"""
|
||||
settings = {"source": source, "destination": destination}
|
||||
|
||||
for cost_value in settings["destination"].CostValues or []:
|
||||
ifcopenshell.api.run("cost.remove_cost_item_value", file, cost_value=cost_value)
|
||||
ifcopenshell.api.cost.remove_cost_item_value(file, cost_value=cost_value)
|
||||
copied_cost_values = []
|
||||
for cost_value in settings["source"].CostValues or []:
|
||||
copied_cost_values.append(ifcopenshell.util.element.copy_deep(file, cost_value))
|
||||
|
||||
@@ -38,9 +38,9 @@ def edit_cost_item(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
ifcopenshell.api.run("cost.edit_cost_item", model, cost_item=item, attributes={"Name": "Foo"})
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
ifcopenshell.api.cost.edit_cost_item(model, cost_item=item, attributes={"Name": "Foo"})
|
||||
"""
|
||||
settings = {"cost_item": cost_item, "attributes": attributes or {}}
|
||||
|
||||
|
||||
@@ -38,16 +38,16 @@ def edit_cost_item_quantity(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# This cost item will have a unit cost of 5 and a volume of 3
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5.0})
|
||||
quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
|
||||
cost_item=item, ifc_class="IfcQuantityVolume")
|
||||
ifcopenshell.api.run("cost.edit_cost_item_quantity", model,
|
||||
ifcopenshell.api.cost.edit_cost_item_quantity(model,
|
||||
physical_quantity=quantity, "attributes": {"VolumeValue": 3.0})
|
||||
"""
|
||||
settings = {"physical_quantity": physical_quantity, "attributes": attributes or {}}
|
||||
|
||||
@@ -38,8 +38,8 @@ def edit_cost_schedule(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
ifcopenshell.api.run("cost.edit_cost_schedule", model,
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
ifcopenshell.api.cost.edit_cost_schedule(model,
|
||||
cost_schedule=schedule, attributes={"Name": "Foo"})
|
||||
"""
|
||||
|
||||
|
||||
@@ -41,12 +41,12 @@ def edit_cost_value(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# This cost item will have a total cost of 42
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 42.0})
|
||||
"""
|
||||
settings = {"cost_value": cost_value, "attributes": attributes or {}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.cost
|
||||
import ifcopenshell.util.unit
|
||||
import ifcopenshell.util.element
|
||||
@@ -43,11 +43,11 @@ def edit_cost_value_formula(file: ifcopenshell.file, cost_value: ifcopenshell.en
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value_formula", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value_formula(model, cost_value=value,
|
||||
formula="5000 * 1.19")
|
||||
"""
|
||||
usecase = Usecase()
|
||||
@@ -67,7 +67,7 @@ class Usecase:
|
||||
def edit_cost_value(self, data, parent=None):
|
||||
ifc = data.get("ifc", None)
|
||||
if not ifc:
|
||||
ifc = ifcopenshell.api.run("cost.add_cost_value", self.file, parent=parent)
|
||||
ifc = ifcopenshell.api.cost.add_cost_value(self.file, parent=parent)
|
||||
if "AppliedValue" in data:
|
||||
if data["AppliedValue"]:
|
||||
ifc.AppliedValue = self.file.createIfcMonetaryMeasure(data["AppliedValue"])
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ def remove_cost_item(file: ifcopenshell.file, cost_item: ifcopenshell.entity_ins
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
ifcopenshell.api.run("cost.remove_cost_item", model, cost_item=item)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
ifcopenshell.api.cost.remove_cost_item(model, cost_item=item)
|
||||
"""
|
||||
settings = {"cost_item": cost_item}
|
||||
|
||||
@@ -48,7 +48,7 @@ def remove_cost_item(file: ifcopenshell.file, cost_item: ifcopenshell.entity_ins
|
||||
if inverse.is_a("IfcRelNests"):
|
||||
if inverse.RelatingObject == settings["cost_item"]:
|
||||
for related_object in inverse.RelatedObjects:
|
||||
ifcopenshell.api.run("cost.remove_cost_item", file, cost_item=related_object)
|
||||
ifcopenshell.api.cost.remove_cost_item(file, cost_item=related_object)
|
||||
elif inverse.RelatedObjects == (settings["cost_item"],):
|
||||
history = inverse.OwnerHistory
|
||||
file.remove(inverse)
|
||||
|
||||
@@ -38,12 +38,12 @@ def remove_cost_item_quantity(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
|
||||
cost_item=item, ifc_class="IfcQuantityVolume")
|
||||
# Let's change our mind and delete it
|
||||
ifcopenshell.api.run("cost.remove_cost_item", model,
|
||||
ifcopenshell.api.cost.remove_cost_item(model,
|
||||
cost_item=item, physical_quantity=quantity)
|
||||
"""
|
||||
settings = {"cost_item": cost_item, "physical_quantity": physical_quantity}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ def remove_cost_schedule(file: ifcopenshell.file, cost_schedule: ifcopenshell.en
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
ifcopenshell.api.run("cost.remove_cost_schedule", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
ifcopenshell.api.cost.remove_cost_schedule(model, cost_schedule=schedule)
|
||||
"""
|
||||
settings = {"cost_schedule": cost_schedule}
|
||||
|
||||
@@ -46,7 +46,7 @@ def remove_cost_schedule(file: ifcopenshell.file, cost_schedule: ifcopenshell.en
|
||||
for inverse in file.get_inverse(settings["cost_schedule"]):
|
||||
if inverse.is_a("IfcRelAssignsToControl"):
|
||||
[
|
||||
ifcopenshell.api.run("cost.remove_cost_item", file, cost_item=related_object)
|
||||
ifcopenshell.api.cost.remove_cost_item(file, cost_item=related_object)
|
||||
for related_object in inverse.RelatedObjects
|
||||
if related_object.is_a("IfcCostItem")
|
||||
]
|
||||
|
||||
@@ -38,15 +38,15 @@ def remove_cost_value(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# This cost item will have a unit cost of 5 and a volume of 3
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5.0})
|
||||
|
||||
ifcopenshell.api.run("cost.remove_cost_value", model, parent=item, cost_value=value)
|
||||
ifcopenshell.api.cost.remove_cost_value(model, parent=item, cost_value=value)
|
||||
"""
|
||||
settings = {"parent": parent, "cost_value": cost_value}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.control
|
||||
|
||||
|
||||
def unassign_cost_item_quantity(
|
||||
@@ -41,30 +41,30 @@ def unassign_cost_item_quantity(
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
|
||||
|
||||
# Let's imagine a unit cost of 5.0 per unit volume
|
||||
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
|
||||
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
|
||||
value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
|
||||
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
|
||||
attributes={"AppliedValue": 5.0})
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSlab")
|
||||
slab = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSlab")
|
||||
# Usually the quantity would be automatically calculated via a
|
||||
# graphical authoring application but let's assign a manual quantity
|
||||
# for now.
|
||||
qto = ifcopenshell.api.run("pset.add_qto", model, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"NetVolume": 42.0})
|
||||
qto = ifcopenshell.api.pset.add_qto(model, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"NetVolume": 42.0})
|
||||
|
||||
# Now let's parametrically link the slab's quantity to the cost
|
||||
# item. If the slab is edited in the future and 42.0 changes, then
|
||||
# the updated value will also automatically be applied to the cost
|
||||
# item.
|
||||
ifcopenshell.api.run("cost.assign_cost_item_quantity", model,
|
||||
ifcopenshell.api.cost.assign_cost_item_quantity(model,
|
||||
cost_item=item, products=[slab], prop_name="NetVolume")
|
||||
|
||||
# Let's change our mind and remove the parametric connection
|
||||
ifcopenshell.api.run("cost.unassign_cost_item_quantity", model,
|
||||
ifcopenshell.api.cost.unassign_cost_item_quantity(model,
|
||||
cost_item=item, products=[slab])
|
||||
"""
|
||||
usecase = Usecase()
|
||||
@@ -86,8 +86,7 @@ class Usecase:
|
||||
self.quantities.remove(quantity)
|
||||
self.settings["cost_item"].CostQuantities = list(self.quantities)
|
||||
for product in self.settings["products"]:
|
||||
ifcopenshell.api.run(
|
||||
"control.unassign_control",
|
||||
ifcopenshell.api.control.unassign_control(
|
||||
self.file,
|
||||
related_object=product,
|
||||
relating_control=self.settings["cost_item"],
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.api.owner
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@@ -44,14 +45,14 @@ def add_information(
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
# A document typically has a unique drawing or document name (which
|
||||
# follows a coding system depending on the project), as well as a
|
||||
# title. This should match what is shown on the titleblock or title
|
||||
# page of the document. At a minimum you'd also want to specify a
|
||||
# URI location. The location may be on local, or on a CDE, or any
|
||||
# other platform.
|
||||
ifcopenshell.api.run("document.edit_information", model,
|
||||
ifcopenshell.api.document.edit_information(model,
|
||||
information=document,
|
||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||
@@ -64,7 +65,7 @@ def add_information(
|
||||
file.create_entity(
|
||||
"IfcRelAssociatesDocument",
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
||||
RelatingDocument=information,
|
||||
RelatedObjects=[parent],
|
||||
)
|
||||
|
||||
@@ -46,8 +46,8 @@ def add_reference(file: ifcopenshell.file, information: ifcopenshell.entity_inst
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
ifcopenshell.api.run("document.edit_information", model,
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
ifcopenshell.api.document.edit_information(model,
|
||||
information=document,
|
||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||
@@ -55,12 +55,12 @@ def add_reference(file: ifcopenshell.file, information: ifcopenshell.entity_inst
|
||||
# In this case, we don't specify any more information, and so the
|
||||
# reference is for the entire document, as opposed to a single page or
|
||||
# chapter or section.
|
||||
reference = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
reference = ifcopenshell.api.document.add_reference(model, information=document)
|
||||
|
||||
# Alternatively, we can specify a single section, such as by a
|
||||
# subheading code.
|
||||
reference2 = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
ifcopenshell.api.run("document.edit_reference", model,
|
||||
reference2 = ifcopenshell.api.document.add_reference(model, information=document)
|
||||
ifcopenshell.api.document.edit_reference(model,
|
||||
reference=reference2, attributes={"Identification": "2.1.15"})
|
||||
"""
|
||||
settings = {"information": information}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
from typing import Union
|
||||
@@ -55,15 +55,15 @@ def assign_document(
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
ifcopenshell.api.run("document.edit_information", model,
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
ifcopenshell.api.document.edit_information(model,
|
||||
information=document,
|
||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||
reference = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
reference = ifcopenshell.api.document.add_reference(model, information=document)
|
||||
|
||||
# Let's imagine storey represents an IfcBuildingStorey for the ground floor
|
||||
ifcopenshell.api.run("document.assign_document", model, products=[storey], document=reference)
|
||||
ifcopenshell.api.document.assign_document(model, products=[storey], document=reference)
|
||||
"""
|
||||
settings = {
|
||||
"products": products,
|
||||
@@ -96,12 +96,12 @@ def assign_document(
|
||||
return file.create_entity(
|
||||
"IfcRelAssociatesDocument",
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
||||
RelatedObjects=list(products),
|
||||
RelatingDocument=settings["document"],
|
||||
)
|
||||
|
||||
related_objects = set(rel.RelatedObjects) | products
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, element=rel)
|
||||
ifcopenshell.api.owner.update_owner_history(file, element=rel)
|
||||
return rel
|
||||
|
||||
@@ -40,8 +40,8 @@ def edit_information(
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
ifcopenshell.api.run("document.edit_information", model,
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
ifcopenshell.api.document.edit_information(model,
|
||||
information=document,
|
||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||
|
||||
@@ -40,13 +40,13 @@ def edit_reference(
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
ifcopenshell.api.run("document.edit_information", model,
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
ifcopenshell.api.document.edit_information(model,
|
||||
information=document,
|
||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||
reference = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
ifcopenshell.api.run("document.edit_reference", model,
|
||||
reference = ifcopenshell.api.document.add_reference(model, information=document)
|
||||
ifcopenshell.api.document.edit_reference(model,
|
||||
reference=reference, attributes={"Identification": "2.1.15"})
|
||||
"""
|
||||
settings = {"reference": reference, "attributes": attributes}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.document
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ def remove_information(file: ifcopenshell.file, information: ifcopenshell.entity
|
||||
.. code:: python
|
||||
|
||||
# Add a document
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
# ... and remove it!
|
||||
ifcopenshell.api.run("document.remove_information", model, information=document)
|
||||
ifcopenshell.api.document.remove_information(model, information=document)
|
||||
"""
|
||||
|
||||
if file.schema == "IFC2X3":
|
||||
@@ -48,11 +48,11 @@ def remove_information(file: ifcopenshell.file, information: ifcopenshell.entity
|
||||
references = information.HasDocumentReferences
|
||||
|
||||
for reference in references:
|
||||
ifcopenshell.api.run("document.remove_reference", file, reference=reference)
|
||||
ifcopenshell.api.document.remove_reference(file, reference=reference)
|
||||
|
||||
for rel in information.IsPointer or []:
|
||||
for info in rel.RelatedDocuments:
|
||||
ifcopenshell.api.run("document.remove_information", file, information=info)
|
||||
ifcopenshell.api.document.remove_information(file, information=info)
|
||||
|
||||
for rel in information.IsPointedTo or []:
|
||||
if rel.RelatedDocuments == (information,):
|
||||
|
||||
@@ -34,9 +34,9 @@ def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_ins
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
reference = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
ifcopenshell.api.run("document.remove_reference", model, reference=reference)
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
reference = ifcopenshell.api.document.add_reference(model, information=document)
|
||||
ifcopenshell.api.document.remove_reference(model, reference=reference)
|
||||
"""
|
||||
|
||||
if file.schema == "IFC2X3":
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -41,18 +41,18 @@ def unassign_document(
|
||||
|
||||
.. code:: python
|
||||
|
||||
document = ifcopenshell.api.run("document.add_information", model)
|
||||
ifcopenshell.api.run("document.edit_information", model,
|
||||
document = ifcopenshell.api.document.add_information(model)
|
||||
ifcopenshell.api.document.edit_information(model,
|
||||
information=document,
|
||||
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
|
||||
"Location": "A-GA-6100 - Overall Plan.pdf"})
|
||||
reference = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
reference = ifcopenshell.api.document.add_reference(model, information=document)
|
||||
|
||||
# Let's imagine storey represents an IfcBuildingStorey for the ground floor
|
||||
ifcopenshell.api.run("document.assign_document", model, products=[storey], document=reference)
|
||||
ifcopenshell.api.document.assign_document(model, products=[storey], document=reference)
|
||||
|
||||
# Now let's change our mind and remove the association
|
||||
ifcopenshell.api.run("document.unassign_document", model, products=[storey], document=reference)
|
||||
ifcopenshell.api.document.unassign_document(model, products=[storey], document=reference)
|
||||
"""
|
||||
settings = {
|
||||
"products": products,
|
||||
@@ -77,7 +77,7 @@ def unassign_document(
|
||||
related_objects = set(rel.RelatedObjects) - products
|
||||
if related_objects:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ def assign_product(
|
||||
|
||||
.. code:: python
|
||||
|
||||
furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.run("drawing.assign_product", model,
|
||||
furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.root.create_entity(model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.drawing.assign_product(model,
|
||||
relating_product=furniture, related_object=annotation)
|
||||
"""
|
||||
settings = {
|
||||
@@ -99,13 +99,13 @@ def assign_product(
|
||||
related_objects = list(referenced_by.RelatedObjects)
|
||||
related_objects.append(settings["related_object"])
|
||||
referenced_by.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": referenced_by})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": referenced_by})
|
||||
else:
|
||||
referenced_by = file.create_entity(
|
||||
"IfcRelAssignsToProduct",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["related_object"]],
|
||||
"RelatingProduct": settings["relating_product"],
|
||||
},
|
||||
|
||||
@@ -39,7 +39,7 @@ def edit_text_literal(
|
||||
.. code:: python
|
||||
|
||||
text = model.createIfcTextLiteral()
|
||||
ifcopenshell.api.run("drawing.edit_text_literal", model,
|
||||
ifcopenshell.api.drawing.edit_text_literal(model,
|
||||
text_literal=text, attributes={"Literal": "MY ANNOTATION"})
|
||||
"""
|
||||
settings = {"text_literal": text_literal, "attributes": attributes or {}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ def unassign_product(
|
||||
|
||||
.. code:: python
|
||||
|
||||
furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.run("drawing.assign_product", model,
|
||||
furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.root.create_entity(model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.drawing.assign_product(model,
|
||||
relating_product=furniture, related_object=annotation)
|
||||
|
||||
# Let's change our mind and remove the relationship
|
||||
ifcopenshell.api.run("drawing.unassign_product", model,
|
||||
ifcopenshell.api.drawing.unassign_product(model,
|
||||
relating_product=furniture, related_object=annotation)
|
||||
"""
|
||||
settings = {
|
||||
@@ -71,4 +71,4 @@ def unassign_product(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, element=rel)
|
||||
|
||||
@@ -69,7 +69,7 @@ def add_axis_representation(
|
||||
.. code:: python
|
||||
|
||||
context = ifcopenshell.util.representation.get_context(model, "Plan", "Axis", "GRAPH_VIEW")
|
||||
axis = ifcopenshell.api.run("geometry.add_axis_representation", model,
|
||||
axis = ifcopenshell.api.geometry.add_axis_representation(model,
|
||||
context=context, axis=[(0.0, 0.0), (1.0, 0.0)])
|
||||
"""
|
||||
usecase = Usecase()
|
||||
|
||||
@@ -20,6 +20,7 @@ from __future__ import annotations
|
||||
import collections.abc
|
||||
import ifcopenshell.util.unit
|
||||
from ifcopenshell.util.shape_builder import ShapeBuilder, V
|
||||
import ifcopenshell.api.geometry
|
||||
from ifcopenshell.api.geometry.add_window_representation import create_ifc_window
|
||||
from mathutils import Vector
|
||||
from math import cos, radians
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -66,11 +67,11 @@ class Usecase:
|
||||
types = self.settings["product"].Types
|
||||
if types:
|
||||
for element in types[0].RelatedObjects:
|
||||
mapped_representation = ifcopenshell.api.run(
|
||||
"geometry.map_representation", self.file, **{"representation": self.settings["representation"]}
|
||||
mapped_representation = ifcopenshell.api.geometry.map_representation(
|
||||
self.file, representation=self.settings["representation"]
|
||||
)
|
||||
self.assign_product_representation(element, mapped_representation)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": self.settings["product"]})
|
||||
|
||||
def assign_product_representation(self, product, representation):
|
||||
definition = product.Representation
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
from typing import Optional
|
||||
@@ -59,7 +59,7 @@ def connect_element(
|
||||
|
||||
return file.createIfcRelConnectsElements(
|
||||
ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
||||
Description=settings["description"],
|
||||
RelatingElement=settings["relating_element"],
|
||||
RelatedElement=settings["related_element"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
from typing import Optional
|
||||
@@ -89,7 +89,7 @@ def connect_path(
|
||||
|
||||
return file.createIfcRelConnectsPathElements(
|
||||
ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
||||
Description=settings["description"],
|
||||
RelatingElement=settings["relating_element"],
|
||||
RelatedElement=settings["related_element"],
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import numpy as np
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.unit
|
||||
|
||||
|
||||
@@ -64,8 +64,7 @@ class Usecase:
|
||||
self.settings["p1"][1] = self.convert_unit_to_si(self.settings["p1"][1])
|
||||
self.settings["elevation"] = self.convert_unit_to_si(self.settings["elevation"])
|
||||
|
||||
representation = ifcopenshell.api.run(
|
||||
"geometry.add_wall_representation",
|
||||
representation = ifcopenshell.api.geometry.add_wall_representation(
|
||||
self.file,
|
||||
context=self.settings["context"],
|
||||
length=length,
|
||||
@@ -82,9 +81,7 @@ class Usecase:
|
||||
[0, 0, 0, 1],
|
||||
]
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=self.settings["element"], matrix=matrix
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=self.settings["element"], matrix=matrix)
|
||||
return representation
|
||||
|
||||
def convert_unit_to_si(self, co):
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.unit
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
@@ -77,7 +77,7 @@ class Usecase:
|
||||
new_placement.PlacementRelTo = placement_rel_to
|
||||
self.settings["product"].ObjectPlacement = new_placement
|
||||
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": self.settings["product"]})
|
||||
|
||||
for settings in children_settings:
|
||||
self.settings = settings
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -81,4 +81,4 @@ class Usecase:
|
||||
for item in mapped_representations:
|
||||
self.unassign_product_representation(item["product"], item["representation"])
|
||||
for representation in just_representations:
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, **{"representation": representation})
|
||||
|
||||
@@ -42,7 +42,7 @@ def add_georeferencing(file: ifcopenshell.file, ifc_class: str = "IfcMapConversi
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("georeference.add_georeferencing", model)
|
||||
ifcopenshell.api.georeference.add_georeferencing(model)
|
||||
"""
|
||||
if file.schema == "IFC2X3":
|
||||
if not (project := file.by_type("IfcProject")):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.pset
|
||||
from typing import Optional, Any
|
||||
|
||||
|
||||
@@ -52,12 +53,12 @@ def edit_georeferencing(
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("georeference.add_georeferencing", model)
|
||||
ifcopenshell.api.georeference.add_georeferencing(model)
|
||||
# This is the simplest scenario, a defined CRS (GDA2020 / MGA Zone
|
||||
# 56, typically used in Sydney, Australia) but with no local
|
||||
# coordinates. This is only recommended for horizontal construction
|
||||
# projects, not for vertical construction (such as buildings).
|
||||
ifcopenshell.api.run("georeference.edit_georeferencing", model,
|
||||
ifcopenshell.api.georeference.edit_georeferencing(model,
|
||||
projected_crs={"Name": "EPSG:7856"})
|
||||
|
||||
# For buildings, it is almost always recommended to specify map
|
||||
@@ -65,7 +66,7 @@ def edit_georeferencing(
|
||||
# north. See the diagram in the BlenderBIM Add-on Georeferencing
|
||||
# documentation for correct calculation of the X Axis Abcissa and
|
||||
# Ordinate.
|
||||
ifcopenshell.api.run("georeference.edit_georeferencing", model,
|
||||
ifcopenshell.api.georeference.edit_georeferencing(model,
|
||||
projected_crs={"Name": "EPSG:7856"},
|
||||
coordinate_operation={
|
||||
"Eastings": 335087.17, # The architect nominates a false origin
|
||||
|
||||
@@ -44,11 +44,11 @@ def edit_true_north(file: ifcopenshell.file, true_north: Optional[Union[tuple[fl
|
||||
# Both of these are identical, and indicate that:
|
||||
# - If project north is up the page, true north is in the top left
|
||||
# - The building is therefore facing north east
|
||||
ifcopenshell.api.run("georeference.edit_true_north", model, true_north=30)
|
||||
ifcopenshell.api.run("georeference.edit_true_north", model, true_north=(-0.5, 0.8660254))
|
||||
ifcopenshell.api.georeference.edit_true_north(model, true_north=30)
|
||||
ifcopenshell.api.georeference.edit_true_north(model, true_north=(-0.5, 0.8660254))
|
||||
|
||||
# This unsets true north
|
||||
ifcopenshell.api.run("georeference.edit_true_north", model, true_north=None)
|
||||
ifcopenshell.api.georeference.edit_true_north(model, true_north=None)
|
||||
"""
|
||||
if isinstance(true_north, (float, int)):
|
||||
x, y = ifcopenshell.util.geolocation.angle2yaxis(true_north)
|
||||
|
||||
@@ -58,7 +58,7 @@ def edit_wcs(
|
||||
.. code:: python
|
||||
|
||||
# This is the simplest scenario, resetting the WCS to 0,0,0 with no rotation (recommended)
|
||||
ifcopenshell.api.run("georeference.edit_wcs", model)
|
||||
ifcopenshell.api.georeference.edit_wcs(model)
|
||||
"""
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
|
||||
if np.isclose(rotation, 0):
|
||||
|
||||
@@ -31,9 +31,9 @@ def remove_georeferencing(file: ifcopenshell.file) -> None:
|
||||
|
||||
Example:
|
||||
|
||||
ifcopenshell.api.run("georeference.add_georeferencing", model)
|
||||
ifcopenshell.api.georeference.add_georeferencing(model)
|
||||
# Let's change our mind
|
||||
ifcopenshell.api.run("georeference.remove_georeferencing", model)
|
||||
ifcopenshell.api.georeference.remove_georeferencing(model)
|
||||
"""
|
||||
if file.schema == "IFC2X3":
|
||||
project = file.by_type("IfcProject")[0]
|
||||
|
||||
@@ -48,17 +48,17 @@ def create_axis_curve(
|
||||
.. code:: python
|
||||
|
||||
# A pretty standard rectangular grid, with only two axes.
|
||||
grid = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcGrid")
|
||||
axis_a = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
grid = ifcopenshell.api.root.create_entity(model, ifc_class="IfcGrid")
|
||||
axis_a = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="A", uvw_axes="UAxes", grid=grid)
|
||||
axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
axis_1 = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="1", uvw_axes="VAxes", grid=grid)
|
||||
|
||||
# Assume you have these Blender objects in your active Blender session
|
||||
obj1 = bpy.data.objects.get("AxisA")
|
||||
obj2 = bpy.data.objects.get("Axis1")
|
||||
ifcopenshell.api.run("grid.create_axis_curve", model, axis_curve=obj1, grid_axis=axis_a)
|
||||
ifcopenshell.api.run("grid.create_axis_curve", model, axis_curve=obj2, grid_axis=axis_1)
|
||||
ifcopenshell.api.grid.create_axis_curve(model, axis_curve=obj1, grid_axis=axis_a)
|
||||
ifcopenshell.api.grid.create_axis_curve(model, axis_curve=obj2, grid_axis=axis_1)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
|
||||
@@ -68,10 +68,10 @@ def create_grid_axis(
|
||||
Example:
|
||||
|
||||
# A pretty standard rectangular grid, with only two axes.
|
||||
grid = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcGrid")
|
||||
axis_a = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
grid = ifcopenshell.api.root.create_entity(model, ifc_class="IfcGrid")
|
||||
axis_a = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="A", uvw_axes="UAxes", grid=grid)
|
||||
axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
axis_1 = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="1", uvw_axes="VAxes", grid=grid)
|
||||
"""
|
||||
|
||||
|
||||
@@ -30,18 +30,18 @@ def remove_grid_axis(file: ifcopenshell.file, axis: ifcopenshell.entity_instance
|
||||
Example:
|
||||
|
||||
# A pretty standard rectangular grid, with only two axes.
|
||||
grid = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcGrid")
|
||||
axis_a = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
grid = ifcopenshell.api.root.create_entity(model, ifc_class="IfcGrid")
|
||||
axis_a = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="A", uvw_axes="UAxes", grid=grid)
|
||||
axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
axis_1 = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="1", uvw_axes="VAxes", grid=grid)
|
||||
|
||||
# Let's create a third so we can remove it later
|
||||
axis_2 = ifcopenshell.api.run("grid.create_grid_axis", model,
|
||||
axis_2 = ifcopenshell.api.grid.create_grid_axis(model,
|
||||
axis_tag="2", uvw_axes="VAxes", grid=grid)
|
||||
|
||||
# Let's remove it!
|
||||
ifcopenshell.api.run("grid.remove_grid_axis", model, axis=axis_2)
|
||||
ifcopenshell.api.grid.remove_grid_axis(model, axis=axis_2)
|
||||
"""
|
||||
axis_curve = axis.AxisCurve
|
||||
if len(file.get_inverse(axis_curve)) == 1:
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
from typing import Optional
|
||||
|
||||
@@ -46,7 +46,7 @@ def add_group(
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
|
||||
ifcopenshell.api.group.add_group(model, name="Unit 1A")
|
||||
"""
|
||||
settings = {
|
||||
"name": name or "Unnamed",
|
||||
@@ -57,7 +57,7 @@ def add_group(
|
||||
"IfcGroup",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"Name": settings["name"],
|
||||
"Description": settings["description"],
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
from typing import Union
|
||||
|
||||
@@ -42,8 +42,8 @@ def assign_group(
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
|
||||
ifcopenshell.api.run("group.assign_group", model,
|
||||
group = ifcopenshell.api.group.add_group(model, name="Furniture")
|
||||
ifcopenshell.api.group.assign_group(model,
|
||||
products=model.by_type("IfcFurniture"), group=group)
|
||||
"""
|
||||
settings = {
|
||||
@@ -59,7 +59,7 @@ def assign_group(
|
||||
"IfcRelAssignsToGroup",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": settings["products"],
|
||||
"RelatingGroup": settings["group"],
|
||||
}
|
||||
@@ -70,5 +70,5 @@ def assign_group(
|
||||
if products.issubset(related_objects):
|
||||
return rel
|
||||
rel.RelatedObjects = list(related_objects | products)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
@@ -36,8 +36,8 @@ def edit_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance, att
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
|
||||
ifcopenshell.api.run("group.edit_group", model,
|
||||
group = ifcopenshell.api.group.add_group(model, name="Unit 1A")
|
||||
ifcopenshell.api.group.edit_group(model,
|
||||
group=group, attributes={"Description": "All furniture and joinery included in the unit"})
|
||||
"""
|
||||
settings = {"group": group, "attributes": attributes}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
|
||||
ifcopenshell.api.run("group.remove_group", model, group=group)
|
||||
group = ifcopenshell.api.group.add_group(model, name="Unit 1A")
|
||||
ifcopenshell.api.group.remove_group(model, group=group)
|
||||
"""
|
||||
settings = {"group": group}
|
||||
|
||||
@@ -47,8 +47,7 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
|
||||
except:
|
||||
continue
|
||||
if inverse.is_a("IfcRelDefinesByProperties"):
|
||||
ifcopenshell.api.run(
|
||||
"pset.remove_pset",
|
||||
ifcopenshell.api.pset.remove_pset(
|
||||
file,
|
||||
product=settings["group"],
|
||||
pset=inverse.RelatingPropertyDefinition,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ def unassign_group(
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
|
||||
group = ifcopenshell.api.group.add_group(model, name="Furniture")
|
||||
furniture = model.by_type("IfcFurniture")
|
||||
ifcopenshell.api.run("group.assign_group", model, products=furniture, group=group)
|
||||
ifcopenshell.api.group.assign_group(model, products=furniture, group=group)
|
||||
|
||||
bad_furniture = furniture[0]
|
||||
ifcopenshell.api.run("group.unassign_group", model, products=[bad_furniture], group=group)
|
||||
ifcopenshell.api.group.unassign_group(model, products=[bad_furniture], group=group)
|
||||
"""
|
||||
settings = {
|
||||
"products": products,
|
||||
@@ -59,7 +59,7 @@ def unassign_group(
|
||||
related_objects -= products
|
||||
if related_objects:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
|
||||
@@ -41,8 +41,8 @@ def update_group_products(
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
|
||||
ifcopenshell.api.run("group.update_group_products", model,
|
||||
group = ifcopenshell.api.group.add_group(model, name="Furniture")
|
||||
ifcopenshell.api.group.update_group_products(model,
|
||||
products=model.by_type("IfcFurniture"), group=group)
|
||||
"""
|
||||
settings = {
|
||||
@@ -55,7 +55,7 @@ def update_group_products(
|
||||
"IfcRelAssignsToGroup",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": settings["products"],
|
||||
"RelatingGroup": settings["group"],
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -58,6 +58,6 @@ def add_library(file: ifcopenshell.file, name: str) -> ifcopenshell.entity_insta
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
"""
|
||||
return file.create_entity("IfcLibraryInformation", Name=name)
|
||||
|
||||
@@ -43,11 +43,11 @@ def add_reference(file: ifcopenshell.file, library: ifcopenshell.entity_instance
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
|
||||
# Let's create a reference to a single AHU in our Brickschema dataset
|
||||
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
|
||||
ifcopenshell.api.run("library.edit_reference", model,
|
||||
reference = ifcopenshell.api.library.add_reference(model, library=library)
|
||||
ifcopenshell.api.library.edit_reference(model,
|
||||
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
|
||||
"""
|
||||
settings = {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
from typing import Union
|
||||
@@ -46,19 +46,19 @@ def assign_reference(
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
|
||||
# Let's create a reference to a single AHU in our Brickschema dataset
|
||||
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
|
||||
ifcopenshell.api.run("library.edit_reference", model,
|
||||
reference = ifcopenshell.api.library.add_reference(model, library=library)
|
||||
ifcopenshell.api.library.edit_reference(model,
|
||||
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
|
||||
|
||||
# Let's assume we have an AHU in our model.
|
||||
ahu = ifcopenshell.api.run("root.create_entity", model,
|
||||
ahu = ifcopenshell.api.root.create_entity(model,
|
||||
ifc_class="IfcUnitaryEquipment", predefined_type="AIRHANDLER")
|
||||
|
||||
# And now assign the IFC model's AHU with its Brickschema counterpart
|
||||
ifcopenshell.api.run("library.assign_reference", model, reference=reference, products=[ahu])
|
||||
ifcopenshell.api.library.assign_reference(model, reference=reference, products=[ahu])
|
||||
"""
|
||||
settings = {
|
||||
"products": products,
|
||||
@@ -86,12 +86,12 @@ def assign_reference(
|
||||
return file.create_entity(
|
||||
"IfcRelAssociatesLibrary",
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
||||
RelatedObjects=list(products),
|
||||
RelatingLibrary=settings["reference"],
|
||||
)
|
||||
|
||||
related_objects = set(rel.RelatedObjects) | products
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, element=rel)
|
||||
ifcopenshell.api.owner.update_owner_history(file, element=rel)
|
||||
return rel
|
||||
|
||||
@@ -38,8 +38,8 @@ def edit_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance,
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
ifcopenshell.api.run("library.edit_library", model, library=library,
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
ifcopenshell.api.library.edit_library(model, library=library,
|
||||
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
|
||||
"""
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ def edit_reference(
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
# Let's create a reference to a single AHU in our Brickschema dataset
|
||||
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
|
||||
ifcopenshell.api.run("library.edit_reference", model,
|
||||
reference = ifcopenshell.api.library.add_reference(model, library=library)
|
||||
ifcopenshell.api.library.edit_reference(model,
|
||||
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
|
||||
"""
|
||||
settings = {"reference": reference, "attributes": attributes}
|
||||
|
||||
@@ -35,8 +35,8 @@ def remove_library(file: ifcopenshell.file, library: ifcopenshell.entity_instanc
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
ifcopenshell.api.run("library.remove_library", model, library=library)
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
ifcopenshell.api.library.remove_library(model, library=library)
|
||||
"""
|
||||
|
||||
if file.schema != "IFC2X3":
|
||||
|
||||
@@ -35,10 +35,10 @@ def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_ins
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
reference = ifcopenshell.api.library.add_reference(model, library=library)
|
||||
# Let's change our mind and remove it.
|
||||
ifcopenshell.api.run("library.remove_reference", model, reference=reference)
|
||||
ifcopenshell.api.library.remove_reference(model, reference=reference)
|
||||
"""
|
||||
if file.schema != "IFC2X3":
|
||||
rels = reference.LibraryRefForObjects
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
def unassign_reference(
|
||||
@@ -41,22 +41,22 @@ def unassign_reference(
|
||||
|
||||
.. code:: python
|
||||
|
||||
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
|
||||
library = ifcopenshell.api.library.add_library(model, name="Brickschema")
|
||||
|
||||
# Let's create a reference to a single AHU in our Brickschema dataset
|
||||
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
|
||||
ifcopenshell.api.run("library.edit_reference", model,
|
||||
reference = ifcopenshell.api.library.add_reference(model, library=library)
|
||||
ifcopenshell.api.library.edit_reference(model,
|
||||
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
|
||||
|
||||
# Let's assume we have an AHU in our model.
|
||||
ahu = ifcopenshell.api.run("root.create_entity", model,
|
||||
ahu = ifcopenshell.api.root.create_entity(model,
|
||||
ifc_class="IfcUnitaryEquipment", predefined_type="AIRHANDLER")
|
||||
|
||||
# And now assign the IFC model's AHU with its Brickschema counterpart
|
||||
ifcopenshell.api.run("library.assign_reference", model, reference=reference, products=[ahu])
|
||||
ifcopenshell.api.library.assign_reference(model, reference=reference, products=[ahu])
|
||||
|
||||
# Let's change our mind and unassign it.
|
||||
ifcopenshell.api.run("library.unassign_reference", model, reference=reference, products=[ahu])
|
||||
ifcopenshell.api.library.unassign_reference(model, reference=reference, products=[ahu])
|
||||
"""
|
||||
|
||||
settings = {"reference": reference, "products": products}
|
||||
@@ -78,7 +78,7 @@ def unassign_reference(
|
||||
related_objects = set(rel.RelatedObjects) - products
|
||||
if related_objects:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
|
||||
@@ -54,11 +54,11 @@ def add_constituent(
|
||||
# and a glass glazing panel. Notice we are assigning to the type
|
||||
# only, as all occurrences of that type will automatically inherit
|
||||
# the material.
|
||||
window_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWindowType")
|
||||
window_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWindowType")
|
||||
|
||||
# First, let's create a constituent set. This will later be assigned
|
||||
# to our window element.
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", model,
|
||||
material_set = ifcopenshell.api.material.add_material_set(model,
|
||||
name="Window", set_type="IfcMaterialConstituentSet")
|
||||
|
||||
# Let's create a few materials, it's important to also give them
|
||||
@@ -66,13 +66,13 @@ def add_constituent(
|
||||
# like "show me everything made out of aluminium / concrete / steel
|
||||
# / glass / etc". The IFC specification states a list of categories
|
||||
# you can use.
|
||||
aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
|
||||
glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
|
||||
aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
|
||||
glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
|
||||
|
||||
# Now let's use those materials as two constituents in our set.
|
||||
ifcopenshell.api.run("material.add_constituent", model,
|
||||
ifcopenshell.api.material.add_constituent(model,
|
||||
constituent_set=material_set, material=aluminium)
|
||||
ifcopenshell.api.run("material.add_constituent", model,
|
||||
ifcopenshell.api.material.add_constituent(model,
|
||||
constituent_set=material_set, material=glass)
|
||||
|
||||
# Great! Let's assign our material set to our window type.
|
||||
@@ -80,7 +80,7 @@ def add_constituent(
|
||||
# our window too, but to keep this example simple, geometry is
|
||||
# optional and it is enough to say that this window is made out of
|
||||
# aluminium and glass.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[window_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(model, products=[window_type], material=material_set)
|
||||
"""
|
||||
settings = {"constituent_set": constituent_set, "material": material}
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ def add_layer(
|
||||
# gypsum with steel studs inside. Notice we are assigning to
|
||||
# the type only, as all occurrences of that type will automatically
|
||||
# inherit the material.
|
||||
wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
|
||||
wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
|
||||
|
||||
# First, let's create a material set. This will later be assigned
|
||||
# to our wall type element.
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", model,
|
||||
material_set = ifcopenshell.api.material.add_material_set(model,
|
||||
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
|
||||
|
||||
# Let's create a few materials, it's important to also give them
|
||||
@@ -64,21 +64,21 @@ def add_layer(
|
||||
# like "show me everything made out of aluminium / concrete / steel
|
||||
# / glass / etc". The IFC specification states a list of categories
|
||||
# you can use.
|
||||
gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
|
||||
steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
|
||||
gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
|
||||
steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
|
||||
|
||||
# Now let's use those materials as three layers in our set, such
|
||||
# that the steel studs are sandwiched by the gypsum. Let's imagine
|
||||
# we're setting the layer thickness in millimeters.
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 92})
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 92})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
|
||||
|
||||
# Great! Let's assign our material set to our wall type.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[wall_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(model, products=[wall_type], material=material_set)
|
||||
"""
|
||||
settings = {"layer_set": layer_set, "material": material}
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@ def add_list_item(
|
||||
# and a glass glazing panel. Notice we are assigning to the type
|
||||
# only, as all occurrences of that type will automatically inherit
|
||||
# the material.
|
||||
window_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWindowType")
|
||||
window_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWindowType")
|
||||
|
||||
# First, let's create a list. This will later be assigned to our
|
||||
# window element.
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", model,
|
||||
material_set = ifcopenshell.api.material.add_material_set(model,
|
||||
name="Window", set_type="IfcMaterialList")
|
||||
|
||||
# Let's create a few materials, it's important to also give them
|
||||
@@ -66,19 +66,19 @@ def add_list_item(
|
||||
# like "show me everything made out of aluminium / concrete / steel
|
||||
# / glass / etc". The IFC specification states a list of categories
|
||||
# you can use.
|
||||
aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
|
||||
glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
|
||||
aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
|
||||
glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
|
||||
|
||||
# Now let's use those materials as two items in our list.
|
||||
ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=aluminium)
|
||||
ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=glass)
|
||||
ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=aluminium)
|
||||
ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=glass)
|
||||
|
||||
# Great! Let's assign our material set to our window type.
|
||||
# We're technically not done here, we might want to add geometry to
|
||||
# our window too, but to keep this example simple, geometry is
|
||||
# optional and it is enough to say that this window is made out of
|
||||
# aluminium and glass.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[window_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(model, products=[window_type], material=material_set)
|
||||
"""
|
||||
settings = {"material_list": material_list, "material": material}
|
||||
|
||||
|
||||
@@ -68,15 +68,15 @@ def add_material(
|
||||
.. code:: python
|
||||
|
||||
# Let's create two materials with their respective categories
|
||||
concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete", description="Garage Slab")
|
||||
steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel", description="Corten Steel")
|
||||
concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete", description="Garage Slab")
|
||||
steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel", description="Corten Steel")
|
||||
|
||||
# Let's imagine an urban concrete bench which is purely made out of concrete
|
||||
concrete_bench = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurnitureType")
|
||||
concrete_bench = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurnitureType")
|
||||
|
||||
# Assign the concrete material to that bench. Note that no colour
|
||||
# "Style" has been specified.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[concrete_bench], material=concrete)
|
||||
ifcopenshell.api.material.assign_material(model, products=[concrete_bench], material=concrete)
|
||||
"""
|
||||
settings = {"name": name or "Unnamed", "category": category, "description": description }
|
||||
|
||||
|
||||
@@ -76,11 +76,11 @@ def add_material_set(
|
||||
# gypsum with steel studs inside. Notice we are assigning to
|
||||
# the type only, as all occurrences of that type will automatically
|
||||
# inherit the material.
|
||||
wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
|
||||
wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
|
||||
|
||||
# First, let's create a material set. This will later be assigned
|
||||
# to our wall type element.
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", model,
|
||||
material_set = ifcopenshell.api.material.add_material_set(model,
|
||||
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
|
||||
|
||||
# Let's create a few materials, it's important to also give them
|
||||
@@ -88,21 +88,21 @@ def add_material_set(
|
||||
# like "show me everything made out of aluminium / concrete / steel
|
||||
# / glass / etc". The IFC specification states a list of categories
|
||||
# you can use.
|
||||
gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
|
||||
steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
|
||||
gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
|
||||
steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
|
||||
|
||||
# Now let's use those materials as three layers in our set, such
|
||||
# that the steel studs are sandwiched by the gypsum. Let's imagine
|
||||
# we're setting the layer thickness in millimeters.
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 92})
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 92})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
|
||||
|
||||
# Great! Let's assign our material set to our wall type.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[wall_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(model, products=[wall_type], material=material_set)
|
||||
"""
|
||||
settings = {"name": name or "Unnamed", "set_type": set_type or "IfcMaterialConstituentSet"}
|
||||
|
||||
|
||||
@@ -61,15 +61,15 @@ def add_profile(
|
||||
# Let's imagine we have a steel I-beam. Notice we are assigning to
|
||||
# the type only, as all occurrences of that type will automatically
|
||||
# inherit the material.
|
||||
beam_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeamType", name="B1")
|
||||
beam_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeamType", name="B1")
|
||||
|
||||
# First, let's create a material set. This will later be assigned
|
||||
# to our beam type element.
|
||||
material_set = ifcopenshell.api.run("material.add_profile_set", model,
|
||||
material_set = ifcopenshell.api.material.add_profile_set(model,
|
||||
name="B1", set_type="IfcMaterialProfileSet")
|
||||
|
||||
# Create a steel material.
|
||||
steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
|
||||
steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
|
||||
|
||||
# Create an I-beam profile curve. Notice how we name our profiles
|
||||
# based on standardised steel profile names.
|
||||
@@ -81,11 +81,11 @@ def add_profile(
|
||||
# Define that steel material and cross section as a single profile
|
||||
# item. If this were a composite beam, we might add multiple profile
|
||||
# items instead, but this is rarely the case in most construction.
|
||||
ifcopenshell.api.run("material.add_profile", model,
|
||||
ifcopenshell.api.material.add_profile(model,
|
||||
profile_set=material_set, material=steel, profile=hea100)
|
||||
|
||||
# Great! Let's assign our material set to our beam type.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[beam_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(model, products=[beam_type], material=material_set)
|
||||
"""
|
||||
settings = {"profile_set": profile_set, "material": material, "profile": profile}
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.representation
|
||||
@@ -88,48 +89,48 @@ def assign_material(
|
||||
.. code:: python
|
||||
|
||||
# Let's start with a simple concrete material
|
||||
concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
|
||||
concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
|
||||
|
||||
# Let's imagine a concrete bench made out of a single concrete
|
||||
# material. Let's assign it to the type.
|
||||
bench_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurnitureType")
|
||||
ifcopenshell.api.run("material.assign_material", model,
|
||||
bench_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurnitureType")
|
||||
ifcopenshell.api.material.assign_material(model,
|
||||
products=[bench_type], type="IfcMaterial", material=concrete)
|
||||
|
||||
# Let's imagine there are a two occurrences of this bench. It's not
|
||||
# necessary to assign any material to these benches as they
|
||||
# automatically inherit the material from the type.
|
||||
bench1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
bench2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
ifcopenshell.api.run("type.assign_type", model, related_objects=[bench1], relating_type=bench_type)
|
||||
ifcopenshell.api.run("type.assign_type", model, related_objects=[bench2], relating_type=bench_type)
|
||||
bench1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
bench2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
ifcopenshell.api.type.assign_type(model, related_objects=[bench1], relating_type=bench_type)
|
||||
ifcopenshell.api.type.assign_type(model, related_objects=[bench2], relating_type=bench_type)
|
||||
|
||||
# If we have a concrete wall, we should use a layer set. Again,
|
||||
# let's start with a wall type, not occurrences.
|
||||
wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
|
||||
wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
|
||||
|
||||
# Even though there is only one layer in our layer set, we still use
|
||||
# a layer set because it makes it clear that this is a layered
|
||||
# construction. Let's say it's a 200mm thick concrete layer.
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", model,
|
||||
material_set = ifcopenshell.api.material.add_material_set(model,
|
||||
name="CON200", set_type="IfcMaterialLayerSet")
|
||||
layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
|
||||
ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 200})
|
||||
layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
|
||||
ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 200})
|
||||
|
||||
# Our wall type now has the layer set assigned to it
|
||||
ifcopenshell.api.run("material.assign_material", model,
|
||||
ifcopenshell.api.material.assign_material(model,
|
||||
products=[wall_type], type="IfcMaterialLayerSet", material=material_set)
|
||||
|
||||
# Let's imagine an occurrence of this wall type.
|
||||
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", model, related_objects=[wall], relating_type=wall_type)
|
||||
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(model, related_objects=[wall], relating_type=wall_type)
|
||||
|
||||
# Our wall occurrence needs to have a "set usage" which describes
|
||||
# how the layers relate to a reference line (typically a 2D line
|
||||
# representing the extents of the wall). Usages are special since
|
||||
# they automatically detect the inherited material set from the
|
||||
# type. You'd write similar code for a profile set.
|
||||
ifcopenshell.api.run("material.assign_material", model,
|
||||
ifcopenshell.api.material.assign_material(model,
|
||||
products=[wall], type="IfcMaterialLayerSetUsage")
|
||||
|
||||
# To be complete, let's create the wall's axis and body
|
||||
@@ -137,13 +138,13 @@ def assign_material(
|
||||
# line" which determines where layers are extruded from, and the
|
||||
# body has a thickness of 200mm, same as our total layer set
|
||||
# thickness.
|
||||
axis = ifcopenshell.api.run("geometry.add_axis_representation", model,
|
||||
axis = ifcopenshell.api.geometry.add_axis_representation(model,
|
||||
context=axis_context, axis=[(0.0, 0.0), (5000.0, 0.0)])
|
||||
body = ifcopenshell.api.run("geometry.add_wall_representation", model,
|
||||
body = ifcopenshell.api.geometry.add_wall_representation(model,
|
||||
context=body_context, length=5000, height=3000, thickness=200)
|
||||
ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=axis)
|
||||
ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=body)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
|
||||
ifcopenshell.api.geometry.assign_representation(model, product=wall, representation=axis)
|
||||
ifcopenshell.api.geometry.assign_representation(model, product=wall, representation=body)
|
||||
ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
@@ -160,7 +161,7 @@ class Usecase:
|
||||
# NOTE: we always reassign material, even if it might be assigned before
|
||||
products_to_unassign_material = [p for p in self.products if ifcopenshell.util.element.get_material(p)]
|
||||
if products_to_unassign_material:
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=products_to_unassign_material)
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=products_to_unassign_material)
|
||||
|
||||
if self.settings["type"] == "IfcMaterial" or (
|
||||
self.settings["material"] and not self.settings["material"].is_a("IfcMaterial")
|
||||
@@ -294,7 +295,7 @@ class Usecase:
|
||||
return self.create_material_association(material)
|
||||
previous_related_objects = set(rel.RelatedObjects)
|
||||
rel.RelatedObjects = list(previous_related_objects | self.products)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
def create_material_association(
|
||||
@@ -308,7 +309,7 @@ class Usecase:
|
||||
"IfcRelAssociatesMaterial",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
"RelatedObjects": products,
|
||||
"RelatingMaterial": relating_material,
|
||||
}
|
||||
|
||||
@@ -43,15 +43,15 @@ def assign_profile(
|
||||
# Let's imagine we have a steel I-beam. Notice we are assigning to
|
||||
# the type only, as all occurrences of that type will automatically
|
||||
# inherit the material.
|
||||
beam_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeamType", name="B1")
|
||||
beam_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeamType", name="B1")
|
||||
|
||||
# First, let's create a material set. This will later be assigned
|
||||
# to our beam type element.
|
||||
material_set = ifcopenshell.api.run("material.add_profile_set", model,
|
||||
material_set = ifcopenshell.api.material.add_profile_set(model,
|
||||
name="B1", set_type="IfcMaterialProfileSet")
|
||||
|
||||
# Create a steel material.
|
||||
steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
|
||||
steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
|
||||
|
||||
# Create an I-beam profile curve. Notice how we name our profiles
|
||||
# based on standardised steel profile names.
|
||||
@@ -63,22 +63,22 @@ def assign_profile(
|
||||
# Define that steel material and cross section as a single profile
|
||||
# item. If this were a composite beam, we might add multiple profile
|
||||
# items instead, but this is rarely the case in most construction.
|
||||
profile_item = ifcopenshell.api.run("material.add_profile", model,
|
||||
profile_item = ifcopenshell.api.material.add_profile(model,
|
||||
profile_set=material_set, material=steel, profile=hea100)
|
||||
|
||||
# Great! Let's assign our material set to our beam type.
|
||||
ifcopenshell.api.run("material.assign_material", model, products=[beam_type], material=material_set)
|
||||
ifcopenshell.api.material.assign_material(model, products=[beam_type], material=material_set)
|
||||
|
||||
# Let's create an occurrence of this beam.
|
||||
beam = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeam", name="B1.01")
|
||||
ifcopenshell.api.run("material.assign_material", model,
|
||||
beam = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeam", name="B1.01")
|
||||
ifcopenshell.api.material.assign_material(model,
|
||||
products=[beam], type="IfcMaterialProfileSetUsage")
|
||||
|
||||
# Let's give a 1000mm long beam body representation.
|
||||
body = ifcopenshell.api.run("geometry.add_profile_representation",
|
||||
body = ifcopenshell.api.geometry.add_profile_representation(
|
||||
context=body_context, profile=hea100, depth=1000)
|
||||
ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=beam)
|
||||
ifcopenshell.api.geometry.assign_representation(model, product=beam, representation=body)
|
||||
ifcopenshell.api.geometry.edit_object_placement(model, product=beam)
|
||||
|
||||
# Now let's change the profile to a HEA200 standard profile instead.
|
||||
# This will automatically change the body representation that we
|
||||
@@ -87,7 +87,7 @@ def assign_profile(
|
||||
"IfcIShapeProfileDef", ProfileName="HEA200", ProfileType="AREA",
|
||||
OverallWidth=200, OverallDepth=190, WebThickness=6.5, FlangeThickness=10, FilletRadius=18,
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_profile", model, material_profile=profile_item, profile=hea200)
|
||||
ifcopenshell.api.material.assign_profile(model, material_profile=profile_item, profile=hea200)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
|
||||
@@ -41,10 +41,10 @@ def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instanc
|
||||
|
||||
.. code:: python
|
||||
|
||||
concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
|
||||
concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
|
||||
|
||||
# Let's duplicate the concrete material
|
||||
concrete_copy = ifcopenshell.api.run("material.copy_material", model, material=concrete)
|
||||
concrete_copy = ifcopenshell.api.material.copy_material(model, material=concrete)
|
||||
"""
|
||||
if material.is_a("IfcMaterial"):
|
||||
return _copy_material_with_inverses(file, material)
|
||||
|
||||
@@ -36,8 +36,8 @@ def edit_assigned_material(file: ifcopenshell.file, element: ifcopenshell.entity
|
||||
|
||||
.. code:: python
|
||||
|
||||
concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
|
||||
ifcopenshell.api.run("material.edit_assigned_material", model,
|
||||
concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
|
||||
ifcopenshell.api.material.edit_assigned_material(model,
|
||||
element=concrete, attributes={"Description": "40MPA concrete with broom finish"})
|
||||
"""
|
||||
settings = {"element": element, "attributes": attributes}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user