topologicpy.IFC module
- class topologicpy.IFC.IFC
Bases:
objectMethods
AccessGraph(file[, importMode, ...])Creates a TopologicPy Graph representing space adjacency from an IFC file.
DoorSpaceCardinalityReport(file[, ...])Returns a diagnostic report of door/opening-to-space cardinalities in an IFC file.
ElementTypes(file[, includeCounts, silent])Returns the IFC element/entity types found in the input IFC file, sorted alphabetically.
Entities(file[, silent])Returns the parsed IFC STEP entity dictionary from the input IFC file.
EntitiesByPath(path[, silent])Returns the parsed IFC STEP entity dictionary from the IFC file at the input path.
ExportReferenceView(model, path[, schema, ...])Export a TopologicPy-authored model to an IFC4 Reference View-compatible IFC.
FileByPath(path[, silent])Returns the parsed IFC STEP entity dictionary found at the input path.
MeshDataByPath(path[, includeTypes, ...])Returns extracted mesh data using the pure-Python parser.
Object(file[, globalId, ifcId, ifcKey, silent])Returns a dynamic IFCEntity wrapper for one IFC entity.
Objects(file[, includeTypes, excludeTypes, ...])Returns dynamic IFCEntity wrappers for IFC entities in a file.
ObjectsByType(file, ifcType[, includeEmpty, ...])Returns dynamic IFCEntity wrappers for entities of one IFC type.
Properties(file[, includeTypes, ...])Extracts semantic properties, quantities, classifications, and materials from an IFC file.
RelationshipTypes(file[, includeCounts, silent])Returns the IFC relationship entity types found in the input IFC file, sorted alphabetically.
RelationshipTypesByGlobalId(file, globalId)Returns the IFC relationship entity types associated with the IFC element identified by the input GlobalId.
SummaryByPath(path[, silent])Returns a compact summary of the IFC file using the pure-Python parser.
TopologiesByEntities(entities[, ...])Imports IFC product geometry from an already parsed IFC entity dictionary.
TopologiesByFile(file[, includeTypes, ...])Imports IFC product geometry from an IFC file object into TopologicPy topologies.
TopologiesByPath(path[, includeTypes, ...])Imports IFC product geometry from an IFC file path into TopologicPy topologies.
Triples(file[, includeRels, excludeRels, ...])Returns IFC relationship triples from the input IFC file.
- static AccessGraph(file, importMode: str = 'topology', useInternalVertex: bool = False, connectingElementTypes: list = None, useFillingElements: bool = True, includeIsolatedSpaces: bool = True, viaConnectingElements: bool = False, dictionaryMode: str = 'basic', bidirectional: bool = True, ontology: bool = True, tolerance: float = 0.0001, silent: bool = False)
Creates a TopologicPy Graph representing space adjacency from an IFC file.
The returned graph contains one vertex per IfcSpace. Edges are created between spaces that share a boundary-related connector element.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- importModestr , optional
Controls graph vertex placement. If set to “topology”, vertices are placed using a deterministic circular graph layout. If set to “geometry”, vertices are placed at the centre of their parent IFC product representation when such representation data can be evaluated. Objects without usable geometry fall back to deterministic placement. Options are “topology” and “geometry”. Default is “topology”.
- useInternalVertexbool , optional
In geometry mode, if set to True, uses an internal vertex to represent the subtopology. Otherwise, uses its centroid. Default is False.
- connectingElementTypeslist , optional
IFC element types that are allowed to act as adjacency connectors. If set to None, the default is [“IFCDOOR”, “IFCDOORSTANDARDCASE”, “IFCOPENINGELEMENT”]. Wall types are supported, but they are handled through IfcRelSpaceBoundary2ndLevel.CorrespondingBoundary rather than simple shared-wall grouping. Default is None.
- useFillingElementsbool , optional
If set to True, IfcOpeningElement references are resolved through IfcRelFillsElement to their filling elements, usually doors/windows. The opening is still retained and preferred as the via-vertex entity when viaConnectingElements is True. Default is True.
- includeIsolatedSpacesbool , optional
If set to True, all IfcSpace entities are included as vertices even when they have no detected adjacency. If False, only spaces involved in at least one adjacency edge are included. Default is True.
- viaConnectingElementsbool , optional
If set to False, adjacency edges are created directly between spaces. If set to True, each adjacency is routed through a vertex representing the connecting element, preferably the IfcOpeningElement when present, otherwise the resolved connector element. For walls, a separate connecting vertex is created per confirmed corresponding-boundary pair to avoid turning long walls into artificial graph hubs. Default is False.
- dictionaryModestr , optional
The dictionary mode to use for entity dictionaries. Currently supports the same basic entity dictionary behaviour as the IFC parser. Default is “basic”.
- bidirectionalbool , optional
If set to True, edge dictionaries record the edge as bidirectional. Default is True.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Graph
A TopologicPy graph whose vertices are IfcSpace entities and whose edges represent inferred space adjacency through shared or corresponding boundary elements. Returns None if the IFC file cannot be parsed.
- static DoorSpaceCardinalityReport(file, connectorTypes: list = None, includeOpenings: bool = True, includeWindows: bool = False, includeZeroSpaceConnectors: bool = True, highCardinalityThreshold: int = 2, silent: bool = False)
Returns a diagnostic report of door/opening-to-space cardinalities in an IFC file.
The method inspects IfcRelSpaceBoundary relationships to determine how many IfcSpace entities are associated with each connector element. It also uses IfcRelFillsElement to resolve IfcOpeningElement entities to their filling elements, usually IfcDoor or IfcWindow.
A correctly exported door connecting two rooms is normally expected to have a space_count of 2. Doors with one related space may indicate an external door, incomplete space boundaries, or an export issue. Doors with more than two related spaces are usually suspicious and are flagged as high_cardinality.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- connectorTypeslist , optional
IFC connector types to include. If None, defaults to IfcDoor and, optionally, IfcOpeningElement and IfcWindow depending on the other parameters. Default is None.
- includeOpeningsbool , optional
If set to True, unresolved IfcOpeningElement entities are included in the report. Default is True.
- includeWindowsbool , optional
If set to True, IfcWindow and IfcWindowStandardCase are included. Default is False.
- includeZeroSpaceConnectorsbool , optional
If set to True, connector elements found through IfcRelFillsElement are included even if no related IfcSpace was found. Default is True.
- highCardinalityThresholdint , optional
Cardinalities above this number are labelled high_cardinality. Default is 2.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
A list of dictionaries. Each dictionary reports one connector element and the IfcSpace entities associated with it.
- static ElementTypes(file, includeCounts: bool = False, silent: bool = False)
Returns the IFC element/entity types found in the input IFC file, sorted alphabetically.
- static Entities(file, silent: bool = False)
Returns the parsed IFC STEP entity dictionary from the input IFC file.
This method accepts: - a previously parsed IFC entity dictionary, - a path to an IFC file, - a STEP text string, - or an ifcopenshell file-like object that can be serialised to STEP text.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- dict
A dictionary of parsed IFC entities keyed by STEP id. Each value is an IFCFastEntity object. Returns None if parsing fails.
- static EntitiesByPath(path: str, silent: bool = False)
Returns the parsed IFC STEP entity dictionary from the IFC file at the input path.
- Parameters
- pathstr
The input IFC file path.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- dict
A dictionary of parsed IFC entities keyed by STEP id. Each value is an IFCFastEntity object. Returns None if parsing fails.
- static ExportReferenceView(model: Any, path: str, schema: str = 'IFC4', mvd: str = 'RV1.2', project_name: str = 'TopologicPy Project', site_name: str = 'Default Site', building_name: str = 'Default Building', storey_name: str = 'Level 0', length_unit: str = 'METRE', angle_unit: str = 'RADIAN', area_unit: str = 'SQUARE_METRE', volume_unit: str = 'CUBIC_METRE', use_sweeps: bool = True, use_tessellation_fallback: bool = True, transfer_dictionaries: bool = True, validate: bool = True, silent: bool = False) str
Export a TopologicPy-authored model to an IFC4 Reference View-compatible IFC.
- static FileByPath(path: str, silent: bool = False)
Returns the parsed IFC STEP entity dictionary found at the input path.
- static MeshDataByPath(path: str, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', circleSides: int = 24, scale: float = 1.0, ontology: bool = True, silent: bool = False) dict
Returns extracted mesh data using the pure-Python parser.
- static Object(file, globalId: str = None, ifcId: int = None, ifcKey: str = None, silent: bool = False)
Returns a dynamic IFCEntity wrapper for one IFC entity.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- globalIdstr , optional
The GlobalId of the IFC entity to retrieve.
- ifcIdint , optional
The STEP id of the IFC entity to retrieve.
- ifcKeystr , optional
The STEP key of the IFC entity to retrieve, e.g. “#123”.
- silentbool , optional
If True, suppresses error and warning messages. Default is False.
- Returns
- IFCEntity
A dynamic IFC entity wrapper. Returns None if the entity is not found.
- static Objects(file, includeTypes: list = None, excludeTypes: list = None, includeEmpty: bool = True, silent: bool = False)
Returns dynamic IFCEntity wrappers for IFC entities in a file.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- includeTypeslist , optional
IFC entity types to include. Default is None.
- excludeTypeslist , optional
IFC entity types to exclude. Default is None.
- includeEmptybool , optional
If True, include entities with no extracted property payload. Default is True.
- silentbool , optional
If True, suppresses error and warning messages. Default is False.
- Returns
- list
A list of IFCEntity objects.
- static ObjectsByType(file, ifcType: str, includeEmpty: bool = True, silent: bool = False)
Returns dynamic IFCEntity wrappers for entities of one IFC type.
- static Properties(file, includeTypes: list = None, excludeTypes: list = None, keyMode: str = 'global_id', includeEmpty: bool = False, silent: bool = False)
Extracts semantic properties, quantities, classifications, and materials from an IFC file.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- includeTypeslist , optional
IFC entity types to include. If None, all product-like entities are included. Default is None.
- excludeTypeslist , optional
IFC entity types to exclude. Default is None.
- keyModestr , optional
Entity key mode. Options are “global_id”, “id”, or “key”. Default is “global_id”.
- includeEmptybool , optional
If True, entities with no extracted semantic payload are included. Default is False.
- silentbool , optional
If True, suppresses error and warning messages. Default is False.
- Returns
- dict
A dictionary with two main keys:
- {
- “entities”: {
- “<entity_key>”: {
“ifc_id”: int, “ifc_key”: “#123”, “ifc_type”: “IfcWall”, “global_id”: “…”, “name”: “…”, “properties”: {…}, “type_properties”: {…}, “quantities”: {…}, “classifications”: […], “materials”: […], “type”: {…}
}
}, “summary”: {…}
}
- static RelationshipTypes(file, includeCounts: bool = False, silent: bool = False)
Returns the IFC relationship entity types found in the input IFC file, sorted alphabetically.
- static RelationshipTypesByGlobalId(file, globalId: str, includeCounts: bool = False, includeRelationshipIds: bool = False, silent: bool = False)
Returns the IFC relationship entity types associated with the IFC element identified by the input GlobalId.
- static SummaryByPath(path: str, silent: bool = False) dict
Returns a compact summary of the IFC file using the pure-Python parser.
- static TopologiesByEntities(entities, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', clean: bool = False, epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, circleSides: int = 24, topologyType: str = None, scale: float = 1.0, source: str = None, ontology: bool = True, silent: bool = False)
Imports IFC product geometry from an already parsed IFC entity dictionary.
- Parameters
- entitiesdict
The parsed IFC entity dictionary.
- includeTypeslist , optional
The list of IFC entity types to include. If empty, all supported types are included. Default is [].
- excludeTypeslist , optional
The list of IFC entity types to exclude. Default is [].
- dictionaryModestr , optional
The dictionary import mode. Options are “none”, “basic”, and “full”. Default is “basic”.
- cleanbool , optional
If set to True, the imported topologies are cleaned. Default is False.
- epsilonfloat , optional
The geometric epsilon used during import. Default is 0.01.
- angTolerancefloat , optional
The angular tolerance used during import. Default is 0.1.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- circleSidesint , optional
The number of sides used to approximate circular geometry. Default is 24.
- topologyTypestr , optional
The desired output topology type. If set to None, the method returns the most appropriate topology type for each imported product. Default is None.
- scalefloat , optional
The scale factor applied to imported coordinates. Default is 1.0.
- sourcestr , optional
The source file, database, or process identifier assigned to imported topology metadata. Default is None.
- ontologybool , optional
If set to True, ontology metadata and semantic class annotations are added to the imported topologies. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of imported TopologicPy topologies.
- static TopologiesByFile(file, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', clean: bool = False, ontology: bool = True, epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False) list[Any]
Imports IFC product geometry from an IFC file object into TopologicPy topologies.
- Parameters
- fileifcopenshell.file or any
The input IFC file object.
- includeTypeslist , optional
The list of IFC entity types to include. If empty, all supported types are included. Default is [].
- excludeTypeslist , optional
The list of IFC entity types to exclude. Default is [].
- dictionaryModestr , optional
The dictionary import mode. Options are “none”, “basic”, and “full”. Default is “basic”.
- cleanbool , optional
If set to True, the imported topologies are cleaned. Default is False.
- ontologybool , optional
If set to True, ontology metadata and semantic class annotations are added to the imported topologies. Default is True.
- epsilonfloat , optional
The geometric epsilon used during import. Default is 0.01.
- angTolerancefloat , optional
The angular tolerance used during import. Default is 0.1.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of imported TopologicPy topologies.
- static TopologiesByPath(path: str, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', clean: bool = False, ontology: bool = True, epsilon: float = 0.0001, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False) list[Any]
Imports IFC product geometry from an IFC file path into TopologicPy topologies.
- Parameters
- pathstr
The path to the input IFC file.
- includeTypeslist , optional
The list of IFC entity types to include. If empty, all supported types are included. Default is [].
- excludeTypeslist , optional
The list of IFC entity types to exclude. Default is [].
- dictionaryModestr , optional
The dictionary import mode. Options are “none”, “basic”, and “full”. Default is “basic”.
- cleanbool , optional
If set to True, the imported topologies are cleaned. Default is False.
- ontologybool , optional
If set to True, ontology metadata and semantic class annotations are added to the imported topologies. Default is True.
- epsilonfloat , optional
The geometric epsilon used during import. Default is 0.0001.
- angTolerancefloat , optional
The angular tolerance used during import. Default is 0.1.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of imported TopologicPy topologies.
- static Triples(file, includeRels: list = None, excludeRels: list = None, subjectKey: str = 'global_id', objectKey: str = 'global_id', includeMetadata: bool = True, silent: bool = False)
Returns IFC relationship triples from the input IFC file.
Each IfcRel* entity is converted into one or more explicit triples in the form:
- {
“subject”: …, “predicate”: …, “object”: …
}
If includeMetadata is True, each triple also includes IFC ids, STEP keys, entity types, entity names, and relationship metadata.
- Parameters
- filedict, str, or ifcopenshell.file-like object
The input IFC source.
- includeRelslist , optional
A list of IFC relationship types to include. If None, all supported relationship types are included. Default is None.
- excludeRelslist , optional
A list of IFC relationship types to exclude. Default is None.
- subjectKeystr , optional
Identifier to use for the subject. Options are “global_id”, “id”, or “key”. Default is “global_id”.
- objectKeystr , optional
Identifier to use for the object. Options are “global_id”, “id”, or “key”. Default is “global_id”.
- includeMetadatabool , optional
If set to True, additional metadata is included in each triple. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
A list of dictionaries representing IFC relationship triples.
- class topologicpy.IFC.IFCEntity(entity, entities=None, properties=None)
Bases:
objectLightweight dynamic wrapper around an IFCFastEntity.
This class exposes IFC root attributes, extracted properties, quantities, classifications, materials, and type information through Python attribute access.
- Attributes
- Classifications
EntityReturns the wrapped IFCFastEntity.
- IFCId
- IFCKey
- IFCType
- Materials
- Properties
- Quantities
- Type
- TypeProperties
- TypeQuantities
Methods
Attribute(name[, default])Returns an attribute/property safely.
ToDict()Returns a serializable dictionary representation.
is_a
- Attribute(name, default=None)
Returns an attribute/property safely.
- property Classifications
- property Entity
Returns the wrapped IFCFastEntity.
- property IFCId
- property IFCKey
- property IFCType
- property Materials
- property Properties
- property Quantities
- ToDict()
Returns a serializable dictionary representation.
- property Type
- property TypeProperties
- property TypeQuantities
- is_a(name=None)
- class topologicpy.IFC.IFCFastEntity(id: 'int', type: 'str', args: 'list')
Bases:
object- Attributes
- args
- id
- type
Methods
is_a
- args: list
- id: int
- is_a(name: Optional[str] = None)
- type: str
- class topologicpy.IFC.IFCFastTopology
Bases:
objectExperimental pure-Python IFC importer for TopologicPy topologies.
The goal is to benchmark a direct STEP-text parsing route against IFC.TopologiesByFile, which currently uses IfcOpenShell triangulation.
This class is intentionally conservative: unsupported advanced geometry is skipped or approximated rather than evaluated through a full CSG/BREP kernel.
Methods
TopologiesByFile(file[, includeTypes, ...])Imports IFC product geometry from a file path into TopologicPy topologies.
TopologiesByPath(path[, includeTypes, ...])Imports IFC product geometry from a file path into TopologicPy topologies.
MeshDataByPath
MeshDataByProduct
MeshDataByProducts
Parse
ParseBytes
ParseText
ProductsByEntities
SummaryByPath
TopologiesByEntities
- static MeshDataByPath(path: str, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', circleSides: int = 24, scale: float = 1.0, ontology: bool = True, silent: bool = False) dict
- static MeshDataByProduct(product: IFCFastEntity, entities: Dict[int, IFCFastEntity], circleSides: int = 24, scale: float = 1.0) Optional[dict]
- static MeshDataByProducts(products: list, entities: Dict[int, IFCFastEntity], dictionaryMode: str = 'basic', circleSides: int = 24, scale: float = 1.0, ontology: bool = True, source: str = None, silent: bool = False) dict
- static Parse(path: str, silent: bool = False) Dict[int, IFCFastEntity]
- static ParseBytes(data: bytes, silent: bool = False) Dict[int, IFCFastEntity]
- static ParseText(text: str, silent: bool = False) Dict[int, IFCFastEntity]
- static ProductsByEntities(entities: Dict[int, IFCFastEntity], includeTypes: list = [], excludeTypes: list = []) list
- static SummaryByPath(path: str, silent: bool = False) dict
- static TopologiesByEntities(entities: Dict[int, IFCFastEntity], includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', clean: bool = False, epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, circleSides: int = 24, topologyType: str = None, scale: float = 1.0, ontology: bool = True, source: str = None, silent: bool = False) list
- static TopologiesByFile(file, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', clean: bool = False, epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, circleSides: int = 24, topologyType: str = None, scale: float = 1.0, ontology: bool = True, silent: bool = False) list
Imports IFC product geometry from a file path into TopologicPy topologies.
- Parameters
- filestr or ifcopenshell.file-like object
Prefer passing a path string. If an ifcopenshell file-like object is supplied, this method attempts to serialise it to STEP text.
- includeTypeslist , optional
The list of IFC entity types to include. If empty, all supported types are included. Default is [].
- excludeTypeslist , optional
The list of IFC entity types to exclude. Default is [].
- dictionaryModestr , optional
The dictionary import mode. Options are “none”, “basic”, and “full”. Default is “basic”.
- cleanbool , optional
If set to True, the imported topologies are cleaned. Default is False.
- epsilonfloat , optional
The geometric epsilon used during import. Default is 0.01.
- angTolerancefloat , optional
The angular tolerance used during import. Default is 0.1.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- circleSidesint , optional
The number of sides used to approximate circular geometry. Default is 24.
- topologyTypestr , optional
The desired output topology type. If set to None, the method returns the most appropriate topology type for each imported product. Default is None.
- scalefloat , optional
The scale factor applied to imported coordinates. Default is 1.0.
- ontologybool , optional
If set to True, ontology metadata and semantic class annotations are added to the imported topologies. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of imported TopologicPy topologies.
- static TopologiesByPath(path: str, includeTypes: list = [], excludeTypes: list = [], dictionaryMode: str = 'basic', clean: bool = False, epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, circleSides: int = 24, topologyType: str = None, scale: float = 1.0, ontology: bool = True, silent: bool = False) list
Imports IFC product geometry from a file path into TopologicPy topologies.
- Parameters
- pathstr
The path to the input IFC file.
- includeTypeslist , optional
The list of IFC entity types to include. If empty, all supported types are included. Default is [].
- excludeTypeslist , optional
The list of IFC entity types to exclude. Default is [].
- dictionaryModestr , optional
The dictionary import mode. Options are “none”, “basic”, and “full”. Default is “basic”.
- cleanbool , optional
If set to True, the imported topologies are cleaned. Default is False.
- epsilonfloat , optional
The geometric epsilon used during import. Default is 0.01.
- angTolerancefloat , optional
The angular tolerance used during import. Default is 0.1.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- circleSidesint , optional
The number of sides used to approximate circular geometry. Default is 24.
- topologyTypestr , optional
The desired output topology type. If set to None, the method returns the most appropriate topology type for each imported product. Default is None.
- scalefloat , optional
The scale factor applied to imported coordinates. Default is 1.0.
- ontologybool , optional
If set to True, ontology metadata and semantic class annotations are added to the imported topologies. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of imported TopologicPy topologies.