ifcopenshell.util.representation

Module Contents

class ifcopenshell.util.representation.ResolvedItemDict

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

item: ifcopenshell.entity_instance
matrix: numpy.typing.NDArray[numpy.float64]
ifcopenshell.util.representation.get_context(ifc_file: ifcopenshell.file, context: CONTEXT_TYPE, subcontext: REPRESENTATION_IDENTIFIER | None = None, target_view: TARGET_VIEW | None = None) ifcopenshell.entity_instance | None

Get IfcGeometricRepresentationSubContext by the provided context type, identifier, and target view.

Parameters:
  • context – ContextType.

  • subcontext – A ContextIdentifier string, or any if left blank.

  • target_view – A TargetView string, or any if left blank.

ifcopenshell.util.representation.get_prioritised_contexts(ifc_file: ifcopenshell.file) list[ifcopenshell.entity_instance]

Gets a list of contexts ordered from high priority to low priority

Models can contain multiple geometric contexts. When visualising models, you may want to prioritise visualising certain contexts over others, determined by the context type, identifier, target view, and target scale.

The default prioritises subcontexts, then contexts. It then prioritises 3D, then 2D. It then prioritises bodies, then others. It also prioritises model views, then plan views, then others.

Parameters:

ifc_file – The model containing contexts

Returns:

A list of IfcGeometricRepresentationContext (or SubContext) from high priority to low priority.

ifcopenshell.util.representation.get_representation(element: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance | CONTEXT_TYPE, subcontext: REPRESENTATION_IDENTIFIER | None = None, target_view: TARGET_VIEW | None = None) ifcopenshell.entity_instance | None

Gets a IfcShapeRepresentation filtered by the context type, identifier, and target view

Parameters:
  • element – An IfcProduct or IfcTypeProduct

  • context – Either a specific IfcGeometricRepresentationContext or a ContextType

  • subcontext – A ContextIdentifier string, or any if left blank.

  • target_view – A TargetView string, or any if left blank.

Returns:

The first IfcShapeRepresentation matching the criteria.

ifcopenshell.util.representation.is_representation_of_context(representation: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance | CONTEXT_TYPE, subcontext: REPRESENTATION_IDENTIFIER | None = None, target_view: TARGET_VIEW | None = None) bool

Check if representation has specified context or context type, identifier, and target view.

Parameters:
  • representation – IfcShapeRepresentation.

  • context – Either a specific IfcGeometricRepresentationContext or a ContextType.

  • subcontext – A ContextIdentifier string, or any if left blank.

  • target_view – A TargetView string, or any if left blank.

ifcopenshell.util.representation.resolve_items(representation: ifcopenshell.entity_instance, matrix: numpy.typing.NDArray[numpy.float64] | None = None) list[ResolvedItemDict]
ifcopenshell.util.representation.resolve_representation(representation: ifcopenshell.entity_instance) ifcopenshell.entity_instance

Resolve possibly mapped representation.

Parameters:

representation – IfcRepresentation

Returns:

Representation resolved from mappings

ifcopenshell.util.representation.CONTEXT_TYPE
ifcopenshell.util.representation.REPRESENTATION_IDENTIFIER
ifcopenshell.util.representation.TARGET_VIEW