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)

Initialize self. See help(type(self)) for accurate signature.

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_item_shape_aspect(representation: ifcopenshell.entity_instance, item: ifcopenshell.entity_instance) ifcopenshell.entity_instance | None

Gets the shape aspect relating to an item

Parameters:
  • representation – The IfcShapeRepresentation that the item is part of

  • item – The IfcRepresentationItem you want to get the shape aspect of

Returns:

IfcShapeAspect, or None if none exists

ifcopenshell.util.representation.get_material_style(material: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance, ifc_class: str = 'IfcSurfaceStyle') ifcopenshell.entity_instance | None

Get a presentation style associated with a material

Parameters:
  • material – the IfcMaterial

  • context – IfcGeometricRepresentationContext that the style belongs to

  • ifc_class – The class name of the type of style you need, typically IfcSurfaceStyle for 3D styling.

Returns:

IfcPresentationStyle

ifcopenshell.util.representation.get_part_of_product(element: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance) ifcopenshell.entity_instance | None

Gets the product definition or representation map of an element

This is typically used for setting shape aspects. Note that this will return None for IFC2X3 element types.

Parameters:
  • element – An IfcProduct or IfcTypeProduct

  • context – A IfcGeometricRepresentationContext

Returns:

IfcProductRepresentationSelect

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.get_representations_iter(element: ifcopenshell.entity_instance) Generator[ifcopenshell.entity_instance, None, None]

Get an iterator with element’s IfcShapeRepresentations.

Parameters:

element – An IfcProduct or IfcTypeProduct

ifcopenshell.util.representation.guess_type(items: Sequence[ifcopenshell.entity_instance]) str | None

Guesses the appropriate RepresentationType attribute based on a list of items

Parameters:

items – A list of IfcRepresentationItem, typically in an IfcShapeRepresentation

Returns:

The appropriate RepresentationType value, or None if no valid value

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_base_items(representation: ifcopenshell.entity_instance) Generator[ifcopenshell.entity_instance, None, None]

Resolve representation to it’s base items resolving mapped items and boolean results to it’s operands.

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