IReferenceModel
PIComposer APIPIComposer API

IReferenceModel abstract#

abstract class IReferenceModel

Interface for managing reference models with immutable core content and mutable overlays.

A reference model is built from a core Part 21 (STEP) model file where the original content remains immutable. This interface provides CRUD operations through a model merging mechanism that allows the model to evolve while preserving the original data.

Key Concepts:

  • Immutable Core: The original Part 21 file content cannot be modified
  • Mutable Overlay: Changes are stored separately as additions, updates, and deletions
  • Merge Mechanism: Runtime composition of original content with applied changes
  • Non-Destructive Editing: Original data remains intact for audit purposes

Reference models are created via IProject.importModel with asReference set to true or PIRocksFFIModel.createMemoryReferenceModel in the store_ffi package.

Limitations:

  • Reference models cannot be exported to binary format (PIB)
  • Export is limited to CSV (ISO 10303-21) and JSON formats
  • Performance may be impacted for large models with many changes

Constructors#

IReferenceModel()#

IReferenceModel()

Properties#

hashCode no setter inherited#

int get hashCode

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;

isReferenceLoaded no setter#

bool get isReferenceLoaded

is the referenced model loaded into memory return true if loaded, false otherwise

Implementation
bool get isReferenceLoaded;

runtimeType no setter inherited#

Type get runtimeType

A representation of the runtime type of the object.

Inherited from Object.

Implementation
external Type get runtimeType;

Methods#

getAddedInstances()#

List<InstanceHandle> getAddedInstances()

Gets all instances that have been added to the reference model.

Returns a list of InstanceHandle objects representing new instances that were not present in the original Part 21 file.

Added instances are stored separately and composed with the reference content during model operations.

Implementation
List<InstanceHandle> getAddedInstances();

getReferenceInstances()#

List<InstanceHandle> getReferenceInstances()

Gets all instances from the original reference model that have not been updated.

Returns a list of InstanceHandle objects representing the immutable content from the original Part 21 file that remains unchanged.

These instances are read-only and represent the baseline state of the model.

Implementation
List<InstanceHandle> getReferenceInstances();

getReferenceInstancesPaginated()#

List<InstanceHandle> getReferenceInstancesPaginated( int startingInstanceId, { int pageSize = 2000, });

Gets all instances from the original reference model that have not been updated by page. To start, let startingInstanceId = 0, subsequent pages use the last instanceId on the page.

Returns a list of InstanceHandle objects representing the immutable content from the original Part 21 file that remains unchanged.

These instances are read-only and represent the baseline state of the model.

Implementation
List<InstanceHandle> getReferenceInstancesPaginated(int startingInstanceId,
    {int pageSize = 2000});

getUpdatedInstances()#

List<InstanceHandle> getUpdatedInstances()

Gets all instances from the reference model that have been updated.

Returns a list of InstanceHandle objects representing instances from the original Part 21 file that have been modified.

Updated instances maintain their original ID but contain modified attribute values or relationships.

Implementation
List<InstanceHandle> getUpdatedInstances();

isAdded()#

bool isAdded(int id)

Checks if an instance ID represents an added instance.

Parameters:

  • id: The instance ID to check

Returns true if the instance was added to the model after import and does not exist in the original reference content.

Implementation
bool isAdded(int id);

isReferenceInstance()#

bool isReferenceInstance(int id)

Checks if an instance ID belongs to the original reference content.

Parameters:

  • id: The instance ID to check

Returns true if the instance exists in the original Part 21 file, regardless of whether it has been updated or deleted.

Implementation
bool isReferenceInstance(int id);

isUpdated()#

bool isUpdated(int id)

Checks if an instance ID has been updated from its original state.

Parameters:

  • id: The instance ID to check

Returns true if the instance exists in the original reference content and has been modified in the current model state.

Implementation
bool isUpdated(int id);

loadReferenceModel()#

bool loadReferenceModel()

load the referenced model into memory This function allow lazy loading of reference model content and must be call in order to access referenced part of the model.

return true if successful, false otherwise

Implementation
bool loadReferenceModel();

noSuchMethod() inherited#

dynamic noSuchMethod(Invocation invocation)

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);

toString() inherited#

String toString()

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();

undoUpdate()#

bool undoUpdate(int id)

Reverts updates made to a specific instance, restoring its original state. This function must be use with care. Caller must ensure model integraty is maintained.

Parameters:

  • handle: The instance handle to revert

Returns true if the update was successfully reverted, or false if:

  • The instance handle is invalid
  • The instance was not previously updated
  • The revert operation fails

After successful revert, the instance will match its original state from the reference Part 21 file.

Implementation
bool undoUpdate(int id);

unloadReferenceModel()#

bool unloadReferenceModel()

unload the referenced model from memory

return true if successful, false otherwise

Implementation
bool unloadReferenceModel();

writeReferenceDataSectionToStream()#

bool writeReferenceDataSectionToStream( IFileStream stream, bool bSkipUpdated, ExportFormat format, );

Writes the reference content to a file stream, optionally skipping updated instances.

This method exports the original Part 21 content, potentially excluding instances that have been updated in the current model state.

Parameters:

  • stream: The target file stream for writing
  • bSkipUpdated: When true, excludes instances that have been updated
  • format: The export format (only ExportFormat.csv and ExportFormat.json are supported)

Returns true if the export was successful, or false if:

  • The stream is invalid or not writable
  • The format is not supported for reference models
  • The export operation fails

The exported data represents the baseline reference content rather than the current composed model state.

Implementation
bool writeReferenceDataSectionToStream(
    IFileStream stream, bool bSkipUpdated, ExportFormat format);

writeReferenceInstancesOfTypeToStream()#

int writeReferenceInstancesOfTypeToStream(IFileStream stream, int typeId)

write the reference instances of a type to a file stream. only for part21 format only (ExportFormat.csv) return the number instance writen

Implementation
int writeReferenceInstancesOfTypeToStream(IFileStream stream, int typeId);

writeReferenceInstancesToStream()#

int writeReferenceInstancesToStream( IFileStream stream, List<int> instanceIds, );

write the reference instances to a file stream. only for part21 format only (ExportFormat.csv) return the number instance writen

Implementation
int writeReferenceInstancesToStream(
    IFileStream stream, List<int> instanceIds);

writeReferenceInstanceToStream()#

bool writeReferenceInstanceToStream(IFileStream stream, int instanceId)

write the reference instance to a file stream. only for part21 format only (ExportFormat.csv)

Implementation
bool writeReferenceInstanceToStream(IFileStream stream, int instanceId);

writeUpdatedDataSectionToStream()#

bool writeUpdatedDataSectionToStream(IFileStream stream, ExportFormat format)

Writes only the updated and newly added portions of the reference model to a file stream.

This method exports the delta changes (additions, updates) that have been applied to the reference model.

Parameters:

Returns true if the export was successful, or false if:

  • The stream is invalid or not writable
  • The format is not supported for reference models
  • The export operation fails

The exported data represents the change set rather than the complete model, useful for change tracking and delta exchanges.

Implementation
bool writeUpdatedDataSectionToStream(IFileStream stream, ExportFormat format);

Operators#

operator ==() inherited#

bool operator ==(Object other)

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 == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must 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);