ISTPModel abstract#
Interface for managing general non-IFC EXPRESS models following ISO 10303 (STEP) standards.
This interface extends IModel to provide specialized functionality for working with various STEP application protocols (APs) beyond IFC, including:
- AP203: Configuration controlled 3D design of mechanical parts and assemblies
- AP210: Electronic assembly interconnect and packaging design
- AP214: Core data for automotive mechanical design processes
- AP238: Model based integrated manufacturing (STEP-NC)
- AP242: Managed model based 3D engineering
- CIS/2: CIMSteel logical product model for structural steel
Inheritance
Object → IObjectFactory → IModel → ISTPModel
Available Extensions
Constructors#
ISTPModel()#
Properties#
createdAt no setter inherited#
get creation time stamp
Inherited from IModel.
Implementation
//int getTimeStamp();
int get createdAt;
hashCode no setter inherited#
The hash code for this object.
A hash code is a single integer which represents the state of the object that affects operator == comparisons.
All objects have hash codes. The default hash code implemented by Object represents only the identity of the object, the same way as the default operator == implementation only considers objects equal if they are identical (see identityHashCode).
If operator == is overridden to use the object state instead, the hash code must also be changed to represent that state, otherwise the object cannot be used in hash based data structures like the default Set and Map implementations.
Hash codes must be the same for objects that are equal to each other according to operator ==. The hash code of an object should only change if the object changes in a way that affects equality. There are no further requirements for the hash codes. They need not be consistent between executions of the same program and there are no distribution guarantees.
Objects that are not equal are allowed to have the same hash code. It is even technically allowed that all instances have the same hash code, but if clashes happen too often, it may reduce the efficiency of hash-based data structures like HashSet or HashMap.
If a subclass overrides hashCode, it should override the operator == operator as well to maintain consistency.
Inherited from Object.
Implementation
external int get hashCode;
id no setter inherited#
Gets the unique identifier of this model.
Inherited from IModel.
Implementation
//String getId();
String get id;
isIfc extension no setter#
Returns true if the model is a IFC model, false otherwise.
Available on IModel, provided by the IModelExtension extension
Implementation
bool get isIfc => isIfcSchema(schemaEnum);
isReference no setter inherited#
Returns true if this is a reference model (read-only)
Inherited from IModel.
Implementation
bool get isReference;
name no setter inherited#
Gets the human-readable name of this model.
Inherited from IModel.
Implementation
// String getName();
String get name;
projectId no setter inherited#
Gets the project ID that this model belongs to.
Inherited from IModel.
Implementation
//String getProjectId();
String get projectId;
runtimeType no setter inherited#
A representation of the runtime type of the object.
Inherited from Object.
Implementation
external Type get runtimeType;
schema no setter inherited#
Gets the schema definition used by this model.
Inherited from IModel.
Implementation
//ISchema getSchema();
ISchema get schema;
schemaEnum no setter inherited#
Gets the schema enumeration value for this model.
Inherited from IModel.
Implementation
SupportedSchema get schemaEnum;
Methods#
addInstanceRef() extension#
add instance reference and clean up the old reference. and return the old referenced instance
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance addInstanceRef(IInstance instance, IInstance ref,
{String? attName, int? attIndex, bool addInverse = false}) {
if (instance.isNull || ref.isNull) {
return createNullInstance();
}
final prevRef = instance.getInstance(attIndex: attIndex, attName: attName);
IInstance prev = createNullInstance();
if (!prevRef.isNull && prevRef.isInstanceReference) {
prev = getInstance(prevRef.instanceHandle);
}
if (!prev.isNull) {
prev.removeInverse(instance.instanceId);
}
instance.addInstanceRef(ref,
attName: attName, attIndex: attIndex, addInverse: addInverse);
return prev;
}
axis2Placement3dFromMatrix() extension#
Creates an Axis2Placement3D from a transformation matrix.
Extracts the location, axis, and reference direction from the matrix columns:
- Location: column 3 (translation component)
- Axis: column 2 (Z-axis direction)
- Reference direction: column 0 (X-axis direction)
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance axis2Placement3dFromMatrix(Matrix4 mat) {
final location = mat.getColumn(3);
final ref = mat.getColumn(0);
final axis = mat.getColumn(2);
return createAxis2Placement3D(
[location[0], location[1], location[2]],
[axis[0], axis[1], axis[2]],
[ref[0], ref[1], ref[2]],
);
}
canDelete() inherited#
Checks if an instance can be safely deleted from the model.
This method performs a dependency analysis to determine if the instance
can be deleted without causing referential integrity issues. It checks
if any other instances in the model reference the specified instance.
Returns false if the instance is referenced by other instances,
indicating that deletion would break relationships and cause database
integrity problems.
Returns true otherwise
Inherited from IModel.
Implementation
bool canDelete(IInstance instance);
clear() inherited#
Clears all instances from the model. This completely empties the model database.
This method performs a complete wipe of all instances and associated data from the model, effectively resetting it to an empty state.
Returns true if the clear operation was successful, false otherwise.
Inherited from IModel.
Implementation
bool clear();
copyInstance() inherited#
Copies an instance from another model into this model.
This method creates a copy of the specified instance from the fromModel
and adds it to the current model. If fromModel is null, the copy is
performed within the same model.
The copy operation performs the following transformations:
- Nullifies references: All entity reference attributes in the copied instance are set to null to avoid cross-model reference issues
- Removes inverse relations: Any inverse relationship attributes are cleared to maintain referential integrity
- Resolves IDs: The copied instance receives a new consistent instance ID that fits within this model's ID allocation scheme
- if
instanceis a IfcRoot instance (ifc model), it is assigned a new IfcGloballyUniqueId
This method is ideal for copying simple instances without complex dependency hierarchies. For copying instances with composed dependencies, use copyInstanceWithComposedDependency instead.
Parameters:
-
fromModel: The source model containing the instance to copy. Ifnull, the copy is performed within the current model. instance: The instance to copy from the source model.
Returns the copied IInstance in the current model, or null instance copy fails
Example usage:
// Copy a point from another model
final otherModel = getOtherModel();
final pt = otherModel.getInstancesByType(toTypeId('cartesian_point')).first;
final copiedPt = copyInstance(otherModel, pt);
if (!copiedPt.isNull) {
print('copiedPt copied successfully with new ID: ${copiedPt.instanceId}');
} else {
print('Failed to copy pt');
}
See also:
- copyInstanceWithComposedDependency: For copying with dependency hierarchies
- resolveIndex: To ensure ID consistency after manual instance manipulation
- IInstance.duplicate: Alternative instance-level duplication method
- For ifc model, IIfcModel.copyChildrenWithComposedDependency : For copying from one hierarchy to another.
Inherited from IModel.
Implementation
IInstance copyInstance(IModel fromModel, IInstance instance);
copyInstanceWithComposedDependency() inherited#
Copies an instance along with its composed dependency hierarchy from another model.
This method performs a deep copy of the specified instance from the fromModel,
including all its composed child instances and non-reference type dependencies.
Unlike copyInstance, this method preserves the complete composition hierarchy
by recursively copying dependent instances that are composed within the main instance.
The copy operation handles different attribute types differently:
- Reference types: Attributes marked as reference types (via isReferenceType) are not copied and remain as null references in the copied instance
- Non-reference types: Composed child instances and non-reference attributes are recursively copied to maintain the complete dependency hierarchy
- Inverses: Inverses are cleared
Parameters:
-
fromModel: The source model containing the instance and its dependencies to copy. Must not benullfor cross-model copying. -
instance: The root instance to copy from the source model, along with its composed dependency hierarchy.
Returns a list of IInstance objects where:
- The first element is the copy of the root
instance
Returns an empty list if failed.
Example usage:
// Copy a wall with all its composed properties and geometry
final otherModel = getOtherModel();
final wallToCopy = otherModel.getInstancesByType(toTypeId('IfcWall')).first;
final copied = copyInstanceWithComposedDependency(otherModel, wallToCopy);
if (copied.isNotEmpty) {
final copiedWall = copied[0];
print('New wall ID: ${copiedWall.instanceId}');
// Composition hierarchy is preserved, reference types are nullified
} else {
print('Failed to copy wall with dependencies');
}
⚠️ Important Considerations:
- Reference type attributes will be nullified in the copied hierarchy
- All copied instances receive new consistent IDs in the target model
See also:
- copyInstance: For copying single instances without dependencies
- isReferenceType: To check which types are treated as references
- resolveIndices: To ensure ID consistency after complex copy operations
- For ifc model, IIfcModel.copyChildrenWithComposedDependency : For copying from one hierarchy to another.
Inherited from IModel.
Implementation
List<IInstance> copyInstanceWithComposedDependency(
IModel fromModel, IInstance instance);
createAppContext() extension#
Creates an application context instance for the current schema.
The application context identifies the application protocol and area of use. This is a required entity in STEP files that specifies which schema and protocol the data conforms to.
Typically, only one application context is needed per STEP file.
Returns an IInstance of type "application_context", or null instance if the creation fails.
Example usage:
final appContext = createAppContext();
if (!appContext.isNull) {
print('Created application context for ${schemaName[schemaEnum]}');
}
Available on ISTPModel, provided by the PISTPModelExtension extension
Implementation
IInstance createAppContext() {
try {
final appContext = createInstance(typeName: "application_context");
appContext.setAttribute(
attName: "application", schemaContentsDesc[schemaEnum] ?? '');
final appProto =
createInstance(typeName: "application_protocol_definition");
appProto.setAttribute(attName: "status", 'design');
appProto.setAttribute(
attName: "application_interpreted_model_schema_name",
schemaName[schemaEnum] ?? '');
appProto.setAttribute(
attName: "application_protocol_year",
schemaPublicationYear[schemaEnum] ?? 0);
appProto.setInstanceRef(attName: "application", appContext);
saveInstance(appProto);
saveInstance(appContext);
return appContext;
} catch (e) {
return createNullInstance();
}
}
createAxis2Placement2D() extension#
Creates an Axis2Placement2D from location and reference direction.
The location parameter must contain 2 coordinates.
The ref parameter is optional but must contain 2 coordinates if provided.
Returns a null instance if any coordinate list has an invalid length.
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance createAxis2Placement2D(List<double> location, [List<double>? ref]) {
if (location.length != 2) {
return createNullInstance();
}
final placement = createInstance(
typeName: isIfc ? kIfcAxis2Placement2d : kAxis2Placement2d)
..setAttribute(createCartesianPoint(location), attName: 'location');
ref ??= [1.0, 0];
if (ref.length != 2) {
return createNullInstance();
}
final refDir = createDirection(ref);
placement.setAttribute(refDir,
attName: isIfc ? 'refdirection' : 'ref_direction');
return placement;
}
createAxis2Placement3D() extension#
Creates an Axis2Placement3D from location, axis, and reference direction.
The location parameter must contain 3 coordinates.
The axis and ref parameters are optional but must contain 3 coordinates if provided.
Returns a null instance if any coordinate list has an invalid length.
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance createAxis2Placement3D(List<double> location,
[List<double>? axis, List<double>? ref]) {
if (location.length != 3) {
return createNullInstance();
}
final placement = createInstance(
typeName: isIfc ? kIfcAxis2Placement3d : kAxis2Placement3d)
..setAttribute(createCartesianPoint(location), attName: 'location');
axis ??= [0, 0, 1.0];
if (axis.length != 3) {
return createNullInstance();
}
placement.setAttribute(createDirection(axis), attName: 'axis');
ref ??= [1.0, 0, 0];
if (ref.length != 3) {
return createNullInstance();
}
placement.setAttribute(createDirection(ref),
attName: isIfc ? 'RefDirection' : 'ref_direction');
return placement;
}
createCartesianPoint() extension#
Creates a Cartesian point from coordinates.
The coordinates list must contain either 2 or 3 values for 2D or 3D points respectively. Returns a null instance if the coordinate list length is invalid.
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance createCartesianPoint(List<double> coords) {
final length = coords.length;
if (length != 2 && length != 3) {
return createNullInstance();
}
final inst =
createInstance(typeName: isIfc ? kIfcCartesianPoint : kCartesianPoint)
..setAttribute(coords, attName: 'coordinates');
return inst;
}
createComplexInstance()#
Creates a complex EXPRESS ENTITY instance.
Parameters:
typeNames: Optional list of partail types.-
typeIds: Optional list of partial type ids. Alternative totypeNamesusing type IDs instead of names.
Returns the created IInstance
Example usage:
IInstance _createSteradianUnit() {
final angle =
createComplexInstance(typeNames: ["solid_angle_unit", "si_unit"]);
final name = angle.createEnum(attName: "name", value: "steradian");
angle.setEnum(attName: "name", name);
Note: Either typeNames or typeIds must be provided, but not both.
The method will prioritize typeNames if both parameters are provided.
Implementation
IInstance createComplexInstance(
{List<String>? typeNames, List<int>? typeIds});
createDirection() extension#
Creates a direction vector from direction ratios.
The direction ratios list must contain either 2 or 3 values for 2D or 3D directions respectively. Returns a null instance if the ratios list length is invalid.
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance createDirection(List<double> coords) {
final length = coords.length;
if (length != 2 && length != 3) {
return createNullInstance();
}
return createInstance(typeName: isIfc ? kIfcDirection : kDirection)
..setAttribute(coords,
attName: isIfc ? 'DirectionRatios' : 'direction_ratios');
}
createEnum() inherited#
Creates an EXPRESS enumeration instance.
typeId: Hash-based type identifier of the enumeration
typeName: EXPRESS type name of the enumeration
value: Integer value to initialize the enumeration
stringValue: String representation value to initialize the enumeration
Returns null enum if typeId or typeName does not correspond to
a valid EXPRESS enumeration type.
Inherited from IObjectFactory.
Implementation
PIEnum createEnum(
{int? typeId, String? typeName, int? value, String? stringValue});
createGeometryContext() extension#
Creates a geometric representation context with specified dimensions and uncertainty.
This method creates a geometric context that includes:
- Coordinate space dimensionality (2D, 3D, etc.)
- Unit assignments (length, angle, solid angle)
- Optional uncertainty values for geometric accuracy
Parameters:
dims: The coordinate space dimension (2 for 2D, 3 for 3D)-
lengthUncertainty: The maximum uncertainty value for geometric accuracy. If less than kEpsilon, uncertainty assignment is omitted.
Returns an IInstance representing the geometric context, or null instance if creation fails.
Example usage:
Create a 3D geometric context with 0.001mm uncertainty
final geomContext = createGeometryContext(3, 0.001);
if (!geomContext.isNull) {
print('Created 3D geometric context with uncertainty');
}
Available on ISTPModel, provided by the PISTPModelExtension extension
Implementation
IInstance createGeometryContext(int dims, double lengthUncertainty) {
try {
String id = PIComposerAPIFFI.getGuid();
IInstance lenUnit = _createMMUnit();
IInstance angUnit = _createRadianUnit();
IInstance solidAngUnit =
dims > 2 ? _createSteradianUnit() : createNullInstance();
if (lenUnit.isNull || angUnit.isNull || solidAngUnit.isNull) {
return createNullInstance();
}
IInstance? ctx;
bool hasUncertainty = false;
if (lengthUncertainty < kEpsilon) {
List<String> parts = [
"geometric_representation_context",
"global_unit_assigned_context"
];
ctx = createComplexInstance(typeNames: parts);
} else {
List<String> parts = [
"geometric_representation_context",
"global_uncertainty_assigned_context",
"global_unit_assigned_context"
];
ctx = createComplexInstance(typeNames: parts);
hasUncertainty = true;
}
// Set the general geometric part of the context
String ss = '${dims}D';
ctx.setAttribute(attName: "context_identifier", id);
ctx.setAttribute(attName: "context_type", ss);
ctx.setAttribute(attName: "coordinate_space_dimension", dims);
// Set the global units part of the context
List<ISelect> units = [];
final l = createSelect(typeName: "unit");
l.setSelectedType(typeName: "named_unit");
if (hasUncertainty) {
l.setInstanceRef(lenUnit);
} else {
l.setValue(lenUnit);
}
units.add(l);
final a = createSelect(typeName: "unit");
a.setSelectedType(typeName: "named_unit");
a.setValue(angUnit);
units.add(a);
final s = createSelect(typeName: "unit");
s.setSelectedType(typeName: "named_unit");
if (!solidAngUnit.isNull) {
s.setValue(solidAngUnit);
}
units.add(s);
ctx.setAttribute(attName: "units", units);
// Set the uncertainty value if given
if (hasUncertainty) {
IInstance umwu =
createInstance(typeName: "uncertainty_measure_with_unit");
final measureValue = createSelect(typeName: "measure_value");
measureValue.setSelectedType(typeName: "length_measure");
measureValue.setValue(lengthUncertainty);
umwu.setAttribute(attName: "value_component", measureValue);
final unit = umwu.createSelect(
attName: "unit_component", selectedType: "named_unit");
unit.setInstanceRef(lenUnit);
umwu.setAttribute(attName: "unit_component", unit);
umwu.setAttribute(attName: "name", "DISTANCE_ACCURACY_VALUE");
umwu.setAttribute(
attName: "description",
"Maximum model space distance between geometric "
"entities at asserted connectivities");
ctx.addAttribute(attName: "uncertainty", umwu);
saveInstance(lenUnit);
}
return ctx;
} catch (e) {
return createNullInstance();
}
}
createHeader() extension#
Creates the header instance from PIModelHeader structure. The header instance captures all information in the header section of the Part 21 CSV file: HEADER; header information. ENDSEC; The header instance has three instance attributes:
- file_description
- file_name
- file_schema
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance createHeader(PIModelHeader header) {
final fileDescription =
createInstance(typeName: 'file_description', setId: false)
..setAttribute(header.description, attName: 'description')
..setAttribute(
header.implementation_level.isEmpty
? kImplementationLevel
: header.implementation_level,
attName: 'implementation_level');
final fileName = createInstance(typeName: 'file_name', setId: false)
..setAttribute(header.name, attName: 'name')
..setAttribute(PIModelHeader.getTimeStamp(), attName: 'time_stamp')
..setAttribute(header.author.isEmpty ? [kAuthor] : header.author,
attName: 'author')
..setAttribute(header.organization, attName: 'organization')
..setAttribute(
header.preprocessor_version.isEmpty
? kProcessorVersion
: header.preprocessor_version,
attName: 'preprocessor_version')
..setAttribute(header.originating_system, attName: 'originating_system')
..setAttribute(header.authorization, attName: 'authorization');
final schemas = [header.schema_identifier.toUpperCase()];
final fileSchema = createInstance(typeName: 'file_schema', setId: false)
..setAttribute(schemas, attIndex: 0);
final headerInst = createInstance(typeName: 'file_header', setId: false)
..setAttribute(fileDescription, attIndex: 0)
..setAttribute(fileName, attIndex: 1)
..setAttribute(fileSchema, attIndex: 2);
headerInst.setAttribute(header.schemaEnum.index, attName: 'schema_enum');
return headerInst;
}
createInchUnit() extension#
Creates an inch length unit with conversion factor to millimeters.
Returns an IInstance representing an inch unit as a conversion-based unit with proper conversion factor to SI units (25.4 mm per inch), or a null instance on failure.
This is useful for working with imperial measurement systems while maintaining SI unit compatibility.
Available on ISTPModel, provided by the PISTPModelExtension extension
Implementation
IInstance createInchUnit() {
try {
// Create conversion factor
final conversionFactor =
createInstance(typeName: "length_measure_with_unit");
final measureValue = createSelect(typeName: "measure_value");
measureValue.setSelectedType(typeName: "length_measure");
measureValue.setValue(25.4);
final mm = _createMMUnit();
if (mm.isNull) {
return createNullInstance();
}
final unit = createSelect(typeName: "unit");
unit.setSelectedType(typeName: "si_unit");
unit.setValue(mm);
conversionFactor.setAttribute(attName: "unit_component", unit);
conversionFactor.setAttribute(attName: "value_component", measureValue);
final inch = createComplexInstance(
typeNames: ["conversion_based_unit", "length_unit"]);
inch.setAttribute(attName: "name", "inch");
inch.setAttribute(attName: "conversion_factor", conversionFactor);
return inch;
} catch (e) {
return createNullInstance();
}
}
createInstance() inherited#
Creates an ENTITY instance of the specified type.
typeName: EXPRESS entity type name to create
typeId: Hash-based type identifier to create
setId: If true, automatically assigns a new instance identifier.
Set to false for header instances or when manual ID assignment is needed.
Returns a new IInstance of the requested type.
Inherited from IObjectFactory.
Implementation
IInstance createInstance({String? typeName, int? typeId, bool setId = true});
createInstanceReference() inherited#
Creates an instance reference from an instance handle.
instHandle: The InstanceHandle
containing reference information
Returns a lightweight reference instance pointing to the specified target.
Inherited from IObjectFactory.
Implementation
IInstance createInstanceReference(InstanceHandle instHandle);
createNullInstance() inherited#
Creates a null instance representing an unset or missing value.
Returns a special IInstance that represents a null value.
Inherited from IObjectFactory.
Implementation
IInstance createNullInstance();
createProductContext() extension#
Creates a product context instance for the current schema.
A product context identifies the engineering discipline's point of view from which the data is being presented (mechanical, electrical, etc.).
Parameters:
appCtx: The application context instance handle to reference
Returns an IInstance of type "product_context", or null instance if the creation fails.
Typically, only one product context is needed per STEP file.
Available on ISTPModel, provided by the PISTPModelExtension extension
Implementation
IInstance createProductContext(IInstance appCtx) {
try {
final prodContext = createInstance(typeName: "product_context");
prodContext.setAttribute(
attName: "name", schemaContextName[schemaEnum] ?? '');
prodContext.setAttribute(
attName: "discipline_type", schemaDiscipline[schemaEnum] ?? '');
prodContext.setInstanceRef(attName: "frame_of_reference", appCtx);
return prodContext;
} catch (e) {
return createNullInstance();
}
}
createProductDefinitionContext() extension#
Creates a product definition context instance.
The product definition context identifies the life cycle stage or maturity of the data being presented (e.g., design, prototype, production).
Parameters:
appCtx: The application context instance handle to referencestage: The life cycle stage (defaults to 'design')
Returns an IInstance of type "product_definition_context", or a null instance if the creation fails.
Typically, only one product definition context is needed per STEP file.
Available on ISTPModel, provided by the PISTPModelExtension extension
Implementation
IInstance createProductDefinitionContext(IInstance appCtx,
{String stage = 'design'}) {
try {
final ctx = createInstance(typeName: "product_definition_context");
ctx.setAttribute(attName: "name", schemaContextName[schemaEnum] ?? '');
ctx.setAttribute(attName: "life_cycle_stage", stage);
ctx.setInstanceRef(attName: "frame_of_reference", appCtx);
return ctx;
} catch (e) {
return createNullInstance();
}
}
createSelect() inherited#
Creates an EXPRESS SELECT instance.
typeId: Hash-based type identifier of the SELECT type
typeName: EXPRESS type name of the SELECT type
selectedType: Optional initial selected type identifier
Returns a configured ISelect instance ready for use.
Inherited from IObjectFactory.
Implementation
ISelect createSelect(
{int? typeId,
String? typeName,
int? selectedType,
String? selectedTypeName});
deleteInstance() inherited#
Removes an instance from the model and database.
This method permanently deletes the instance specified by instance handle
from both the database storage.
For memory-only models, the instance is removed from the in-memory collection.
For database-backed models, the instance is permanently deleted from storage.
It is strongly recommended to call canDelete before using this method to ensure the instance can be safely removed without causing referential integrity issues. If an instance is referenced by other instances, deletion may orphan those references and cause database consistency problems.
Returns true if the instance was successfully deleted, or false
otherwise.
Inherited from IModel.
Implementation
bool deleteInstance(IInstance instance);
exportModel() inherited#
Exports the model to the specified file path in the given format.
This method serializes the entire model and writes it to the specified
filePath in the requested format. The export includes all instances,
relationships defined in the primary schema of the model.
Supported formats:
-
ExportFormat.csv: ISO 10303-21 standard (STEP Physical File format) for model exchange with other IFC/STEP-compliant applications. This is the industry standard format for data exchange.
-
ExportFormat.json: Experimental JSON encoding suitable for web-based applications and REST APIs.
-
ExportFormat.pib: PIComposer proprietary binary format for backup and internal model exchange within the PIComposer application ecosystem. Provides optimal performance and complete semantic preservation but is not compatible with external applications.
Parameters:
-
filePath: The complete path and filename where the model should be exported. The directory must exist and be writable. -
format: The export format to use. See ExportFormat enum for options.
Returns true if the export was successful, or false otherwise
Example usage:
// Export to ISO 10303-21 standard format for external exchange
final success1 = exportModel('/projects/buildingA.ifc', ExportFormat.csv);
if (success1) {
print('Model exported to ISO 10303-21 format successfully');
// File can now be shared with Revit, ArchiCAD, etc.
} else {
print('ISO 10303-21 export failed');
}
// Export to JSON for web application consumption
final success2 = exportModel('/projects/buildingA.json', ExportFormat.json);
if (success2) {
print('Model exported to JSON format successfully');
// File can be loaded by web applications or used for debugging
} else {
print('JSON export failed');
}
// Export to PIComposer binary for backup
final success3 = exportModel('/backups/buildingA.pib', ExportFormat.pib);
if (success3) {
print('Model backed up to PIComposer binary format');
// File can be quickly reloaded in PIComposer with full fidelity
} else {
print('PIB export failed');
}
Inherited from IModel.
Implementation
bool exportModel(String filePath, ExportFormat format);
getAttributeByPath() inherited#
Gets an attribute value using a path specification.
This method retrieves values from deep within complex instance hierarchies by specifying a navigation path to the target attribute. It returns both the value and its fundamental type, providing complete type information for proper handling of the retrieved data.
The path can traverse through multiple levels of:
- Instance attributes (by name)
- Select type selections (using the selected type name)
- Aggregate elements (using integer indices for LIST, SET, ARRAY)
Together with setAttributeByPath
and getAttributeContainer, this method
provides a comprehensive way to inspect and manipulate complex instance
structures without manual traversal.
Parameters:
-
path: An InstancePath object specifying the navigation path to the target attribute. The path consists of a starting instance handle and a list of path components (strings for attributes, integers for aggregates).
Returns a tuple (FundamentalType, dynamic) where:
-
FundamentalType: The fundamental type of the retrieved value, which determines how the value should be interpreted and handled -
dynamic: The actual value at the specified path, whose type corresponds to the fundamental type
Returns (FundamentalType.UNKNOWN, null) if:
- The path is invalid or cannot be resolved
- The target attribute does not exist
- Any intermediate object in the path is null or invalid
- The path index is out of bounds for aggregate attributes
Example usage:
// Get a nested attribute with type information
final path = InstancePath(
wallHandle,
['ObjectPlacement', 'RelativePlacement', 'IfcAxis2Placement3D', 'Location']
);
final (type, value) = getAttributeByPath(path);
if (type != FundamentalType.UNKNOWN) {
print('Found value of type: $type');
if (type == FundamentalType.ENTITY) {
final location = value as IInstance;
print('Location instance: ${location.typeName}');
}
} else {
print('Path not found or invalid');
}
Inherited from IModel.
Implementation
(FundamentalType, dynamic) getAttributeByPath(InstancePath path);
getAttributeByPathAsDynamic() inherited#
Gets an attribute value using a path specification as a dynamic value.
This method retrieves values from deep within complex instance hierarchies by specifying a navigation path to the target attribute. It returns only the value without the fundamental type information, making it simpler to use when type information is not required.
This is a convenience wrapper around getAttributeByPath that discards the type information for simpler use cases.
Parameters:
-
path: An InstancePath object specifying the navigation path to the target attribute. The path consists of a starting instance handle and a list of path components (strings for attributes, integers for aggregates).
Returns the value at the specified path as a dynamic value, or null if:
- The path is invalid or cannot be resolved
- The target attribute does not exist
- Any intermediate object in the path is null or invalid
- The path index is out of bounds for aggregate attributes
Example usage:
// Simple value retrieval when type is known
final path = InstancePath(
wallHandle,
['Name'] // Known to be a string
);
final name = getAttributeByPathAsDynamic(path) as Option<String>?;
if (name != null) {
print('Wall name: $name.getOrElse(() => '')');
}
Inherited from IModel.
Implementation
dynamic getAttributeByPathAsDynamic(InstancePath path);
getComplexInstances()#
Implementation
List<IInstance> getComplexInstances();
getComplexInstancesWithPart()#
Implementation
List<IInstance> getComplexInstancesWithPart({int? partId, String? partName});
getComplexInstanceWithIdPart()#
Implementation
IInstance getComplexInstanceWithIdPart(int id,
{int? partId, String? partName});
getHeader() inherited#
Gets the header instance containing model metadata.
This method retrieves the header instance that contains essential metadata about the model, including file description, naming information, and schema details. The header follows the ISO 10303-21 (STEP) file structure and is typically created during model initialization.
The header instance contains three main attributes:
- file_description - Implementation level and description
- file_name - Name, timestamp, author, organization, and system information
- file_schema - Schema identifiers and version information
See IModelExtension.createHeader for details on how the header structure is created and the specific information captured in each attribute.
Returns the header IInstance if it exists, or null instance.
Inherited from IModel.
Implementation
IInstance getHeader();
getHeaderClearTextRepresentation() inherited#
Gets the string representation of the header instance in the specified format.
This method serializes the model header information into a human-readable string format suitable for display, export, or debugging. The header contains essential metadata about the model including file description, naming information, and schema details.
Supported formats:
-
ExportFormat.csv: Generates the HEADER section of an ISO 10303-21 (STEP) Part 21 file. This includes the standardized header structure with FILE_DESCRIPTION, FILE_NAME, and FILE_SCHEMA sections in the exact format required by the ISO standard.
-
ExportFormat.json: Generates a JSON representation of the header information suitable for web applications, APIs, or debugging. Provides a structured hierarchical view of the header data.
Together with IInstance.getClearTextRepresentation, this method enables users to implement custom export logic by combining the header content with individual instance representations to create complete model exports.
Parameters:
-
type: The export format to use. Only ExportFormat.csv and ExportFormat.json are supported for header representation.
Returns a string containing the header representation in the requested format. Returns an empty string if:
- The header instance is missing or invalid
Inherited from IModel.
Implementation
String getHeaderClearTextRepresentation(ExportFormat type);
getInfo() inherited#
Gets generic information about the model as a ModelInfo object.
Inherited from IModel.
Implementation
ModelInfo getInfo();
getInstance() inherited#
Gets an instance from the database by its persistent handle.
This method retrieves the instance corresponding to the specified instance
handle from the database or in-memory storage.
For database-backed models, this may involve a database query to load the instance data. For memory-only models, this retrieves the instance from the in-memory collection.
If the handle is invalid, or refers to a non-existent instance, null instance is returned. You should always check IInstance.isNull on the returned object before using it.
Inherited from IModel.
Implementation
IInstance getInstance(InstanceHandle instance);
getInstances() inherited#
Gets all instance handles in the model.
This method retrieves handles for every instance currently in the model. The returned list can be used to access, process, or iterate over all instances in the model.
⚠️ Performance Warning: This method should not be used for large models as it may cause significant memory usage and performance degradation. For models containing more than a few thousand instances, use the paginated API getInstancesPaginated instead.
Returns an empty list if the model contains no instances or if the model is not properly initialized.
Inherited from IModel.
Implementation
List<InstanceHandle> getInstances();
getInstancesByFilter() inherited#
Gets instances filtered by ID lists and/or ID ranges for a specific type.
This method retrieves instances of the specified type that match either
the explicit ids list or fall within the specified range
intervals.
Parameters:
ids: A list of specific instance IDs to retrieve. Empty list means no ID filtering.-
range: A list of IdRange objects defining inclusive ID ranges to retrieve. Empty list means no range filtering. -
type: The type ID of instances to retrieve. Use toTypeId() to convert type names.
Returns a list of IInstance objects that match the filter criteria. Returns an empty list if no instances match the filters or if the type has no instances.
Inherited from IModel.
Implementation
List<IInstance> getInstancesByFilter(
List<int> ids, List<IdRange> range, int type);
getInstancesByHandle() inherited#
Gets instances from the database by their persistent handles.
Inherited from IModel.
Implementation
List<IInstance> getInstancesByHandle(List<InstanceHandle> handles);
getInstancesByTag() inherited#
Gets all instances with the given tag.
This method retrieves all instances that have been tagged with the specified
tag string using the tagInstance
method. Each instance can have only
one tag at a time - setting a new tag replaces any existing tag.
Tags are not case-sensitive. The search will match tags regardless of capitalization. The method returns actual IInstance objects rather than handles, making it convenient for immediate processing of tagged instances.
Parameters:
tag: The tag string to search for. Tag matching is case-insensitive.
Returns a list of IInstance objects that have been tagged with the specified tag (case-insensitive match). Returns an empty list if no instances have the tag.
Inherited from IModel.
Implementation
List<IInstance> getInstancesByTag(String tag);
getInstancesByType() inherited#
Gets all instances of a given type.
This method retrieves all instances that match the specified typeId.
When includeSubType is true, it also includes instances of all subtypes
that inherit from the specified type, providing a hierarchical query capability.
The returned instances are ordered according to the same sorting as
getInstancesPaginated: first by
typeId, then by instanceId.
Parameters:
-
typeId: The type identifier to filter instances by. Use toTypeId() to convert a type name to its corresponding ID. -
includeSubType: Whentrue, includes instances of all subtypes that inherit from the specified type. Whenfalse, returns only exact matches.
Returns a list of instance handles matching the type criteria. Returns an empty list if no instances of the specified type (and subtypes, if enabled) exist in the model.
⚠️ Performance Note: For types with many instances or deep inheritance hierarchies, this method may be expensive. Consider using paginated approaches for very large result sets by using InstanceHandle(typeId, 0) as startingHandle to call getInstancesByTypePaginated.
Inherited from IModel.
Implementation
List<IInstance> getInstancesByType(
{int? typeId, String? typeName, bool includeSubType = false});
getInstancesByTypePaginated() inherited#
Gets all instances of a given type.
This method retrieves all instances that match the specified typeId.
When includeSubType is true, it also includes instances of all subtypes
that inherit from the specified type, providing a hierarchical query capability.
The returned instances are ordered according to the same sorting as
getInstancesPaginated: first by
typeId, then by instanceId.
Parameters:
-
typeId: The type identifier to filter instances by. Use toTypeId() to convert a type name to its corresponding ID. -
includeSubType: Whentrue, includes instances of all subtypes that inherit from the specified type. Whenfalse, returns only exact matches. pageSize: The number of return value per page, the maximum size is 2000.
Returns a list of instance handles matching the type criteria. Returns an empty list if no instances of the specified type (and subtypes, if enabled) exist in the model.
⚠️ Performance Note: For types with many instances or deep inheritance hierarchies, this method may be expensive. Consider using paginated approaches for very large result sets by using InstanceHandle(typeId, 0) as startingHandle to call getInstancesByTypePaginated.
Inherited from IModel.
Implementation
List<IInstance> getInstancesByTypePaginated(
InstanceHandle startHandle, int pageSize,
{int? typeId, String? typeName, bool includeSubType = false});
getInstancesPaginated() inherited#
Gets instances paginated for efficient handling of large models.
This method retrieves instances in manageable chunks (pages) to avoid memory overload and performance issues when working with large models. It is the recommended alternative to getInstances for models containing more than a few thousand instances.
The paging order is determined by the InstanceHandle's comparison operator,
which sorts instances first by typeId and then by instanceId. This
ensures consistent ordering across pagination requests.
Parameters:
-
startingHandle: The handle to start pagination from. UseInstanceHandle.nullHandle()for the first page. For subsequent pages, use the last handle from the current page. -
pageSize: The number of instances to retrieve per page. Defaults to 2000, the maximum page size. Adjust based on available memory and performance requirements.
Returns a list of instance handles for the current page, sorted by typeId then instanceId. Returns an empty list when no more instances are available (end of model reached).
Example usage:
// Paginate through all instances sorted by typeId then instanceId
InstanceHandle currentHandle = InstanceHandle.nullHandle();
int totalProcessed = 0;
do {
final pageHandles = getInstancesPaginated(currentHandle, pageSize: 250);
if (pageHandles.isEmpty) break;
for (final handle in pageHandles) {
final instance = getInstance(handle);
// do something with instance
processInstance(instance);
totalProcessed++;
}
currentHandle = pageHandles.last;
} while (true);
Inherited from IModel.
Implementation
List<IInstance> getInstancesPaginated(InstanceHandle startingHandle,
{int pageSize = 2000});
getInstanceTypes() inherited#
Gets a list of all instance types that appear at least once in the model.
sorted: Whentrue, returns the type names in alphabetical order.
Inherited from IModel.
Implementation
List<String> getInstanceTypes({bool sorted = false});
getLocation() inherited#
Gets the database location/path of this model.
Inherited from IModel.
Implementation
String getLocation();
getModelLengthUnit() inherited#
Gets the length unit instance defined in this model's IfcUnitAssignment.
This method retrieves the length unit instance that represents the base measurement unit for all geometric data in the model. The length unit is typically defined in the model's IfcUnitAssignment and is essential for ensuring consistent interpretation of dimensional values throughout the model.
The returned instance is usually of type IfcSIUnit (e.g., METER, MILLIMETER)
or IfcConversionBasedUnit for custom unit definitions.
Returns the length unit IInstance if found in the model's unit assignment. Returns null instance if error See also:
- hasSameLengthUnit: Compares length units between models
Inherited from IModel.
Implementation
IInstance getModelLengthUnit();
getOneInstanceOfType() inherited#
get one instance of a given type.
Inherited from IModel.
Implementation
IInstance getOneInstanceOfType({int? typeId, String? typeName});
getReferencingInstances() inherited#
Gets all instances that reference the specified instance.
This method performs an inverse relationship query to find all instances in
the model that contain references to the specified inst.
The method is useful for:
- Dependency analysis before deleting instances
- Understanding how an instance is used throughout the model
- Identifying relationships that might be affected by instance modifications
- Debugging reference integrity issues
Parameters:
inst: The target instance to find references for.
Returns a list of InstanceHandle
objects representing all instances that
reference the specified inst.
Inherited from IModel.
Implementation
List<InstanceHandle> getReferencingInstances(IInstance inst);
getTypeCount() inherited#
Gets the approximate count of instances of the given type.
This method returns an approximate count of instances for the specified typeId.
The count is based on metadata that tracks type distributions and is optimized
for performance rather than absolute accuracy.
For absolutely accurate counts, use getInstancesByType.length, but note
this has significant performance implications for types with many instances.
Parameters:
-
typeId: The type identifier to count instances for. Use toTypeId() to convert type names to IDs. -
includeSubType: Whentrue, includes instances of all subtypes that inherit from the specified type. Whenfalse, counts only exact matches.
Returns an approximate count of instances for the specified type. Returns 0 if the type has no instances, the type doesn't exist, or the metadata hasn't been initialized.
Inherited from IModel.
Implementation
int getTypeCount(int typeId, {bool includeSubType = false});
hasSameLengthUnit() inherited#
Checks if another model uses the same length unit as this model.
This method compares the length unit definition of this model with another model to determine if they use compatible measurement units. This is essential when merging models, exchanging data, or performing cross-model geometric operations to ensure dimensional consistency.
The comparison is based on the actual unit definition and conversion factors, not just unit names, ensuring accurate compatibility checking even for different unit representations that measure the same quantity.
Parameters:
model: The other model to compare against. Must be a valid, initialized model.
Returns true if both models use the same length unit definition (equivalent
measurement units)
See also:
- getModelLengthUnit: Retrieves this model's length unit instance
Inherited from IModel.
Implementation
bool hasSameLengthUnit(IModel model);
incrementTypeCount() inherited#
Increments the type count for a specific type.
This method manually increases the metadata counter for the specified typeId.
It is automatically called internally by saveInstance
and saveInstances
when new instances are persisted to the database, ensuring type counts are
maintained for approximate counting via getTypeCount.
⚠️ Manual Use Warning: This method should generally not be called manually unless you are implementing custom instance creation logic that bypasses the standard saveInstance mechanism. Improper use can lead to inaccurate type counts and metadata inconsistencies.
Parameters:
-
typeId: The type identifier to increment. Use toTypeId() to convert type names to IDs.
Returns the new count after incrementing
Inherited from IModel.
Implementation
int incrementTypeCount(int typeId);
initialize() inherited#
Initializes the model with the given parameters. Currently not in use.
Inherited from IModel.
Implementation
FutureOr<void> initialize(dynamic parameter);
instanceFromJson() inherited#
Creates an instance declaratively from JSON data.
This method provides a convenient way to create IFC instances using a JSON-like structure that mirrors the object composition hierarchy. It handles the complete instantiation process including object creation, attribute setting, and relationship establishment.
The JSON structure uses special keys and conventions:
'@type': Specifies the IFC type name for the instance (required for root objects)- Nested objects: Represent composed child instances or complex attributes
- Arrays: Represent aggregate attributes (LIST, SET, ARRAY)
- Select types: Use the selected type name as key with object as value
Parameters:
-
json: A JSON-like map representing the instance structure and attributes. The map must contain at least an'@type'key for the root object.
Returns the created IInstance, or null instance if:
- The
'@type'key is missing or invalid - The JSON structure is malformed or inconsistent
- Attribute values are incompatible with the target types
Example usage:
// Create a simple Cartesian point
final point = instanceFromJson({
'@type': 'IfcCartesianPoint',
'Coordinates': [1.0, 2.0, 3.0]
});
// Create property sets with complex values
final pset = instanceFromJson({
'@type': 'IfcPropertySet',
'Name': 'Pset_WallCommon',
'HasProperties': [
{
'@type': 'IfcPropertySingleValue',
'Name': 'Reference',
'NominalValue': {
'IfcSimpleValue' : {
'IfcIdentifier': 'EXTERIOR_WALL_001'
}
}
},
{
'@type': 'IfcPropertySingleValue',
'Name': 'LoadBearing',
'NominalValue': {
'IfcSimpleValue' : {
'IfcBoolean': true
}
}
}
]
});
Inherited from IObjectFactory.
Implementation
IInstance instanceFromJson(Map<String, dynamic> json);
isReferenceType() inherited#
Checks if a type is a reference type (should not be composed in instance attributes).
In IFC, reference types include:
- IfcOwnerHistory, IfcPerson, IfcOrganization, IfcPersonAndOrganization
- IfcApplication, IfcProject, IfcShapeRepresentation, IfcUnitAssignment
- IfcGeometricRepresentationContext, IfcGeometricRepresentationSubContext
- IfcLocalPlacement, IfcGridPlacement, IfcTask, IfcWorkCalendar
- IfcGrid, IfcGridAxis, IfcStyledItem, IfcWorkPlan
- All subtypes of: IfcProduct, IfcObjectPlacement, IfcRelationship, IfcPresentationLayerAssignment, IfcGroup
Inherited from IModel.
Implementation
bool isReferenceType(int typeId);
nextInstanceId() inherited#
Gets the next available instance identifier.
incrementId: If true, advances the internal ID counter after retrieval.
If false, returns the next ID without changing the counter.
Returns the next available instance identifier that will be assigned.
Inherited from IObjectFactory.
Implementation
int nextInstanceId([bool incrementId = false]);
noSuchMethod() inherited#
Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dynamic object = 1;
object.add(42); // Statically allowed, run-time error
This invalid code will invoke the noSuchMethod method
of the integer 1 with an Invocation
representing the
.add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}
This code has no compile-time warnings or errors even though
the MockList class has no concrete implementation of
any of the List interface methods.
Calls to List methods are forwarded to noSuchMethod,
so this code will log an invocation similar to
Invocation.method(#add, [42]) and then throw.
If a value is returned from noSuchMethod,
it becomes the result of the original invocation.
If the value is not of a type that can be returned by the original
invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Object.
Implementation
@pragma("vm:entry-point")
@pragma("wasm:entry-point")
external dynamic noSuchMethod(Invocation invocation);
resolveIndex() inherited#
Makes the instance's ID consistent with other instance IDs in the model.
This method ensures that the specified instance has an ID that is unique
and consistent with the model's ID allocation scheme. The operation cascades
recursively through the entire composition structure of the instance, including:
- All composed child instances
- All composites
This is typically used when:
- manually copying instances between models
- instance create from IInstance.duplicate resolve id consistency
- Repairing models with ID conflicts or inconsistencies
The method performs a deep resolution, ensuring that all components of the instance hierarchy have consistent IDs that won't conflict with existing instances in the model.
Parameters:
instance: The instance to resolve. Must be a valid instance handle.
Returns true if the ID resolution was successful for the entire hierarchy,
otherwise false.
Inherited from IModel.
Implementation
bool resolveIndex(IInstance instance);
resolveIndices() inherited#
Makes instance IDs in the list consistent with other instance IDs in the model.
This method ensures that all instances in the provided instances list have
unique IDs that are consistent with the model's ID allocation scheme. The
operation processes each instance and its entire composition hierarchy,
similar to resolveIndex, but handles multiple instances in a single call.
Parameters:
instances: The list of instances to resolve.
Returns true if all instances and their hierarchies were successfully resolved,
or false otherwise.
Inherited from IModel.
Implementation
bool resolveIndices(List<IInstance> instances);
resolveIndicesWithIds() inherited#
Resolves instance IDs while mapping them using the provided ID map.
This method provides precise control over ID resolution by allowing explicit
mapping of original IDs to new IDs using the provided ids mapping dictionary.
For any instance ID not explicitly mapped in the ids dictionary, the method
will automatically assign a new consistent ID to maintain model integrity.
The operation performs the following:
- Reassigns instance IDs according to the provided mapping for specified IDs
- Automatically generates consistent IDs for any unmapped instances
- Updates all internal references within the instance hierarchies
- Ensures consistency across the entire composition structure
- Validates that new IDs don't conflict with existing instances in the model
Parameters:
-
instances: The list of instances to resolve. These instances will have their IDs remapped according to the provided mapping or auto-assigned. -
ids: A mapping dictionary where keys are original IDs and values are the new target IDs. Instances with IDs not in this map will receive automatically generated consistent IDs.
Returns true if all instances were successfully remapped and all references
updated consistently, or false otherwise.
Inherited from IModel.
Implementation
bool resolveIndicesWithIds(List<IInstance> instances, Map<int, int> ids);
saveHeader() inherited#
Saves the header instance to the database.
Inherited from IModel.
Implementation
void saveHeader();
saveInstance() inherited#
Saves an instance to the database.
This method persists the specified instance to the underlying database
storage. If this is a memory-only model, the method does nothing and
returns true (as memory models don't require persistence).
The optional tag parameter allows you to associate a custom tag with
the instance for later retrieval using getInstancesByTag. Tags are
useful for categorizing instances or marking them for specific processing.
Returns true if the instance was successfully saved (or if this is a
memory model), or false if:
- The instance handle is invalid
- The database operation fails
Example usage:
final wallInstance = createInstance(typeName: 'IfcWall');
wallInstance.setString('Exterior Wall', attName: 'Name');
// Save without tag
final success1 = saveInstance(wallInstance);
if (success1) {
print('Wall instance saved successfully');
}
// Save with tag for easy retrieval
final success2 = saveInstance(wallInstance, tag: 'exterior_walls');
if (success2) {
print('Wall instance saved and tagged');
}
// Later retrieve by tag
final exteriorWalls = getInstancesByTag('exterior_walls');
print('Found ${exteriorWalls.length} exterior walls');
Inherited from IModel.
Implementation
bool saveInstance(
IInstance instance, {
String? tag,
});
saveInstances() inherited#
Saves multiple instances to the database in a batch operation.
This method persists a list of instances to the underlying database
storage in a single transaction, which is significantly more efficient
than saving instances individually. If this is a memory-only model,
the method does nothing and returns true (as memory models don't require persistence).
The batch operation is atomic - either all instances are saved successfully or none are saved if an error occurs during the transaction.
Returns true if all instances were saved successfully (or if this is a
memory model), or false if:
- The entire batch operation fails
- The database transaction cannot be completed
Example usage:
// Create multiple instances
final wall1 = createInstance(typeName: 'IfcWall')..setString('Wall 1', attName: 'Name');
final wall2 = createInstance(typeName: 'IfcWall')..setString('Wall 2', attName: 'Name');
final wall3 = createInstance(typeName: 'IfcWall')..setString('Wall 3', attName: 'Name');
final instancesToSave = [wall1, wall2, wall3];
// Save in batch for better performance
final success = saveInstances(instancesToSave);
if (success) {
print('All ${instancesToSave.length} instances saved successfully in batch');
} else {
print('Batch save operation failed - no instances were saved');
// All instances remain unchanged and need to be handled individually
}
Inherited from IModel.
Implementation
bool saveInstances(List<IInstance> instances);
saveMetaData() inherited#
Saves metadata to the database.
This method persists model metadata to the database, including:
- Entity types present in the model
- Instance counts for each entity type
- Schema version information
- Model statistics and usage metrics
Metadata is used for efficient querying, reporting, and model analysis. It enables quick access to model composition without scanning all instances.
This method is called automatically in several scenarios:
- During saveInstances operations to keep metadata synchronized
- During database shutdown (Project.Uninitialize) to ensure final persistence
If this is a memory-only model, the method does nothing and returns true
(as memory models don't require persistence).
Returns true if the metadata was successfully saved (or if this is a
memory model), or else false.
While called automatically, you may want to call this method explicitly:
- After bulk operations that bypass normal save mechanisms
- Before generating reports that rely on accurate type counts
- When manually modifying instance counts or model composition
Inherited from IModel.
Implementation
bool saveMetaData();
setAttributeByPath() inherited#
Sets an attribute value using a path specification.
This method allows precise modification of nested attributes within complex instance hierarchies by specifying a path to the target attribute. The path can traverse through multiple levels of object composition, aggregate elements, select type selections and across instance boundaries.
The path follows the same structure as IInstance.setAttributeByPath, allowing you to navigate through:
- Instance attributes (by name)
- Select type selections (using the selected type name)
- Aggregate elements (using integer indices for LIST, SET, ARRAY)
Together with getAttributeByPath
and getAttributeContainer, this method
provides a powerful way to manipulate complex instance structures without
needing to manually traverse and extract intermediate objects.
Parameters:
-
path: An InstancePath object specifying the navigation path to the target attribute. The path consists of a starting instance handle and a list of path components (strings for attributes, integers for aggregates). -
value: The value to set. The type must be compatible with the target attribute's fundamental type. For instance attributes, this can be an IInstance, ISelect, or primitive value. For aggregate elements, it must match the aggregate's element type.
Returns true if the attribute was successfully set, or false if:
- The path is invalid or cannot be resolved
- The target attribute does not exist
- The value type is incompatible with the target attribute
- The path traverses through null or invalid intermediate instance
Example usage:
// Set a nested attribute in a complex hierarchy
final attPath = ['RelativePlacement', 'IfcAxis2Placement2D', 'RefDirection'];
final handle = getInstancesByType(toTypeId('IfcLocalPlacement')).first;
final path = InstancePath(handle, attPath);
final refDir = instanceFromJson({
'@type': 'IfcDirection',
'DirectionRatios': [1.0, 0.0]
});
final success = setAttributeByPath(path, refDir);
if (success) {
print('Reference direction set successfully');
} else {
print('Failed to set reference direction');
}
Inherited from IModel.
Implementation
bool setAttributeByPath(InstancePath path, dynamic value);
setAttributeByPathWithJson() inherited#
Sets an attribute value using both path specification and JSON data.
This method combines the functionality of setAttributeByPath
and JSON-based
instance creation to provide a powerful way to set complex nested attributes
using a declarative JSON structure. It navigates to the target attribute
using the specified path and sets its value using the provided
json data.
The method handles the complete process:
- Navigates through the instance hierarchy using the provided path
- Creates appropriate values from the JSON data (including nested instances)
- Sets the target attribute to the created value(s)
This is particularly useful for setting complex attributes that require creating nested object hierarchies or select type values.
Parameters:
-
path: An InstancePath object specifying the navigation path to the target attribute where the JSON value should be set. -
json: A JSON-like map representing the value to set. The structure follows the same conventions as instanceFromJson, including support for: -'@type'key for entity instances- Nested objects for complex attributes
- Arrays for aggregate values
- Select type specifications
Returns true if the attribute was successfully set using the JSON data,
or false if:
- The path is invalid or cannot be resolved
- The JSON structure is malformed or incompatible with the target attribute
- The target attribute cannot accept the created value type
- Any intermediate object in the path is null or invalid
Example usage:
// Set a complex placement attribute using JSON
final placementPath = InstancePath(wallHandle, ['ObjectPlacement', 'RelativePlacement',
'IfcAxis2Placement3D', 'Location']);
final success = setAttributeByPathWithJson(placementPath, {
'@type': 'IfcCartesianPoint',
'Coordinates': [10.0, 5.0, 3.0]
});
if (success) {
print('Complex placement hierarchy created and set successfully');
} else {
print('Failed to set placement from JSON');
}
See also:
- setAttributeByPath: Sets attribute using direct value assignment
- instanceFromJson: Creates complete instances from JSON data
- getAttributeByPath: Retrieves values using path specification
Inherited from IModel.
Implementation
bool setAttributeByPathWithJson(InstancePath path, Map<String, dynamic> json);
setInstanceRef() extension#
Available on IModel, provided by the IModelExtension extension
Implementation
IInstance setInstanceRef(IInstance instance, IInstance ref,
{String? attName, int? attIndex, bool addInverse = false}) {
if (instance.isNull || ref.isNull) {
return createNullInstance();
}
final prevRef = instance.getInstance(attIndex: attIndex, attName: attName);
IInstance prev = createNullInstance();
if (!prevRef.isNull && prevRef.isInstanceReference) {
prev = getInstance(prevRef.instanceHandle);
}
if (!prev.isNull) {
prev.removeInverse(instance.instanceId);
}
instance.setInstanceRef(ref,
attName: attName, attIndex: attIndex, addInverse: addInverse);
return prev;
}
setNextInstanceId() inherited#
Sets the next instance identifier to use.
nextId: The next instance identifier value to set.
Use with caution: Setting this value affects all subsequent instance creations and may cause identifier conflicts if not managed carefully.
Inherited from IObjectFactory.
Implementation
void setNextInstanceId(int nextId);
tagInstance() inherited#
Tags an instance with the specified tag string.
This method assigns a tag to the specified instance. Each instance can
have only one tag at a time - calling this method with a new tag will
replace any existing tag on the instance.
Tags are not case-sensitive. The tag string will be stored and matched in a case-insensitive manner. However, the exact case used when setting the tag may be preserved for display purposes.
To remove a tag from an instance, use an empty string ('') as the tag
parameter.
Parameters:
instance: The instance to be taggedtag: The tag string to assign. Use''to remove existing tags.
Returns true if the tag was successfully assigned, or false otherwise.
Inherited from IModel.
Implementation
bool tagInstance(IInstance instance, String tag);
toString() inherited#
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Inherited from Object.
Implementation
external String toString();
uninitialize() inherited#
Uninitializes the model, releasing resources. Currently not in use.
Inherited from IModel.
Implementation
FutureOr<void> uninitialize();
updateModelInfo() inherited#
update model info. ModelInfo is derived from model header, the mutable values are: name and tag.
Inherited from IModel.
Implementation
bool updateModelInfo(String name, String tag);
Operators#
operator ==() inherited#
The equality operator.
The default behavior for all Objects is to return true if and
only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.-
Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false. -
Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Object.
Implementation
external bool operator ==(Object other);
