ifcopenshell.api.drawing

Create relationships necessary for smart annotations for drawings

Drawings may be generated from modeled elements and annotations. These annotations may have relationships which indicate smart data being populated.

Submodules

Package Contents

ifcopenshell.api.drawing.assign_product(file: ifcopenshell.file, relating_product: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance) ifcopenshell.entity_instance

Associates a product and an object, typically for annotation

Warning: this is an experimental API.

When you want to draw attention to a feature or characteristic (such as a dimension, material, or name) or of a product (e.g. wall, slab, furniture, etc), an annotation object is created. This annotation is then associated with the product so that it can reference attributes, properties, and relationships.

For example, an annotation of a line will be associated with a grid axis, such that when that grid axis moves, the annotation of that grid axis (which is typically truncated to the extents of a drawing) will also move.

Another example might be a label of a furniture product, which might have some text of the name of the furniture to be shown on drawings or in 3D.

Parameters:
  • relating_product (ifcopenshell.entity_instance) – The IfcProduct the object is related to

  • related_object (ifcopenshell.entity_instance) – The object (typically IfcAnnotation) that the product is related to

Returns:

The created IfcRelAssignsToProduct relationship

Return type:

ifcopenshell.entity_instance

Example:

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)
ifcopenshell.api.drawing.edit_text_literal(file: ifcopenshell.file, text_literal: ifcopenshell.entity_instance, attributes: dict[str, Any]) None

Edits the attributes of an IfcTextLiteral

For more information about the attributes and data types of an IfcTextLiteral, consult the IFC documentation.

Parameters:
  • reference (ifcopenshell.entity_instance) – The IfcTextLiteral entity you want to edit

  • attributes (dict) – a dictionary of attribute names and values.

Returns:

None

Return type:

None

Example:

text = model.createIfcTextLiteral()
ifcopenshell.api.drawing.edit_text_literal(model,
    text_literal=text, attributes={"Literal": "MY ANNOTATION"})
ifcopenshell.api.drawing.unassign_product(file: ifcopenshell.file, relating_product: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance) None

Unassigns a product and an object (typically an annotation)

Smart annotation objects can be associated with products so that they can annotate attributes and properties. This function lets you remove the association, so that you may change the assocation with another object later or leave the annotation as a “dumb” annotation.

Parameters:
  • relating_product (ifcopenshell.entity_instance) – The IfcProduct the object is related to

  • related_object (ifcopenshell.entity_instance) – The object (typically IfcAnnotation) that the product is related to

Returns:

None

Return type:

None

Example:

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.drawing.unassign_product(model,
    relating_product=furniture, related_object=annotation)