Skip to main content

class Record

Represents a Granta MI record. May represent an existing Granta MI record, or a record which is staged for import. Stores and provides access to record attributes, pseudo-attributes, links and children. Provides methods for adding, editing and deleting records, and importing and exporting record data.
  • Parameters:
    • name (str) – Long name for new records.
    • table (Table) – Table object.
    • parent (Record or Table, optional) – Parent record or table object.
    • short_name (str , optional) – Short (tree) name for new records.
    • attributes (dict[str, AttributeValue], optional) – Dictionary of attribute values.
    • subsets (set [str ] , optional) – Subsets the record belongs to.
    • folder (bool , optional) – Whether the record is ‘Folder’ type.
    • record_color (RecordColor, optional) – Color of the record.
    • release_record (bool, default: True) – Release state of the record; True to release next version.

WARNING

Do not create Record instances for records which are already in the database. Use the appropriate Session, Database, Table, or Record methods and properties to access existing records.

Notes

Record objects may be created to represent records that do not currently exist in the database. A name and parent table must be specified. name will become the record’s long name. The record short name (or tree name) can be set via the argument short_name, or via the Record.short_name property following object creation. If a record is pushed to Granta MI without a specifying short name, the short name will default to the record name. Records created this way will not exist in the specified database until the changes have been pushed to Granta MI (see Session.update()).

clear_attributes(attributes)

Flags attribute values to be deleted when Session.update() is next called. Does not delete the local value of flagged attributes, only the data on Granta MI. Supersedes previous set_attributes() calls.
  • Parameters: attributes (Iterable [AttributeValue ]) – Attributes to clear on the record.

copy_to(destination, record_name=None, release=False)

Creates a copy of the record at the provided location. Returns a record object that represents the newly created record. The resulting record is added to the same subsets as the original record, and contains identical attribute values.
  • Parameters:
    • destination (Record or Table) – Location in the tree where to create the copy.
    • record_name (str , optional) – Record name for the created record. By default, the copied record is created with the same name as the original record. If the destination already contains a record with an identical name, use this parameter to override the name.
    • release (bool, default: False) – Whether to release the created record. The argument has no effect for records in tables that are not version-controlled.
  • Return type: Record
  • Raises: InvalidRecordStateError – If the record has not been pushed to the server.

WARNING

Data validation rules, such as attribute value uniqueness, might prevent record copying.

Notes

Makes a Service Layer call.

decache_attributes()

Removes all attribute values from the Record. Removes all links from the Record.

delete_or_withdraw_record_on_server(withdrawal_notes=None)

Deletes the record from the server, or withdraws it from a version-controlled table.
  • Parameters: withdrawal_notes (str , optional) – Withdrawal revision notes.
  • Raises: InvalidRecordStateError – If the record has not been pushed to the server.

Notes

Makes a Service Layer call.

find_parent()

Finds and sets the parent record or table.

Notes

Makes a Service Layer call if the parent has not already been fetched. This operation performs no subset filtering because, by definition, the parent record must belong to all subsets that this record belongs to.

get_associated_records(target_table, link_direction=‘Both’, attribute_path=None)

Gets records target_table linked to the current Record object via tabular data association chains. This can be filtered by link direction and to a specific path. If attribute_path is provided, then only records from that exact path will be returned. Note that the specified tabular attributes will be the ‘source’ of the tabular link, and there may be tables in the chain with no attributes. This operation performs no subset filtering.
  • Parameters:
    • target_table (Table) – The table from which to retrieve associated records.
    • link_direction (str , default: “Both”) – Which direction to follow links in: Both (default), Forward, Reverse.
    • attribute_path (list[AttributeDefinition], optional) – Path of tabular attributes to follow. If None, all paths are followed.
  • Return type: list[Record]
  • Raises: InvalidRecordStateError – If the record has not been pushed to the server.

Notes

Makes a Service Layer call.

get_attributes(names=None, types=None, include_attributes=True, include_meta_attributes=False, include_pseudo_attributes=False, empty=None)

Retrieve a list of attributes from the record.attributes dictionary. You can narrow the results by specifying the attribute names or data types, or the required attribute categories (attribute, meta-attribute, or pseudo-attribute). If the record.attributes dictionary is empty when get_attributes is called, it will be populated before retrieving any attributes. This operation performs no subset filtering, so all tabular rows will be included in the response regardless of the subset membership of the linked records.

Versionchanged

Changed in version 4.2: Argument include_metas was renamed to include_meta_attributes.

Versionchanged

Changed in version 4.2: Argument include_pseudos was renamed to include_pseudo_attributes.
  • Parameters:
    • names (list [str ] , optional) – Attribute names.
    • types (list [str ] , optional) – Attribute data types; allowed values are: DISC, DTTM, FILE, FUNC, HLNK, INPT, LOGI, LTXT, PICT, POIN, RNGE, STXT, TABL.
    • include_attributes (bool, default: True) – Whether to retrieve attributes that are not meta-attributes or pseudo-attributes.
    • include_meta_attributes (bool, default: False) – Whether to retrieve meta-attributes.
    • include_pseudo_attributes (bool, default: False) – Whether to retrieve pseudo-attributes.
    • empty (bool , optional) – Whether to filter by whether an attribute is populated or not. If None, both populated and empty attributes are returned.
  • Return type: list[PseudoAttributeValue or AttributeValue]

Examples

The code below returns all point or functional series attributes or meta-attributes named Density or Stress-Strain:

get_available_exporters(package=None, model=None, applicability_tag=None)

Returns exporters available for this record filtered by package, model, and applicability tag value.
  • Parameters:
    • package (str , optional) – Name of target FEA analysis package, for example ‘NX 10.0’ or ‘CATIA V5’.
    • model (str , optional) – Material model type, for example ‘Isotropic’ or ‘Linear, temperature-independent, isotropic, thermal, plastic’.
    • applicability_tag (str , optional) – Tag that identifies the MI applications an exporter is intended to be used with, for example, ‘MIMaterialsGateway’ or ‘MIViewer’.
  • Return type: list[Exporter]

Notes

Makes a Service Layer call on first request for each applicability tag.

get_descendants(include_folders=False, include_generics=True, filter_by_subset=True, subset_name=None)

Returns a flattened list of all descendants of a record. Populates the children property of each Record object traversed in the process. If filter_by_subset is True then the operation will only return records that are in the subset given in subset_name, if no value is provided then the subset specified on the table will be used. If filter_by_subset is False then records will be returned from all subsets.
  • Parameters:
    • include_folders (bool, default: False) – Whether to include folders in the list of descendants.
    • include_generics (bool, default: True) – Whether to include generic records in the list of descendants.
    • filter_by_subset (bool, default: True) – Whether to filter by subset.
    • subset_name (str , optional) – Name of the subset to use for filtering.
  • Return type: list[Record]
  • Raises:
    • ValueError – If more than one subset is applied to the table when filter_by_subset is True and subset_name is not provided.
    • InvalidRecordStateError – If the record has not been pushed to the server.

Notes

Makes a Service Layer call.

move_to(new_parent)

Moves the record and all its descendants to a new parent. The provided new parent must be a Record of type RecordType.Folder or RecordType.Generic, or a Table to move the record at the root of the table.

Notes

Some cached properties are cleared after the record has been moved, as they would be out-of-date: They will be dynamically retrieved from the server on property access, or can be manually refreshed via the following methods: Record.children is not cleared, because children are moved with the parent. Their internal state might be outdated, and if necessary can be updated via the methods listed above. children properties of the source and target parent are not cleared or updated. This is by design, to prevent unnecessary updates in scripts performing a large number of record move operations. To update the list of children of a table (after moving a child record from it or to it), use the method Table.refetch_children(). To update the list of children of a record (after moving a child record from it or to it), use the method Record.refetch_children().

Notes

Makes a Service Layer call.

refetch_children(filter_by_subset=True, subset_name=None)

Refreshes the list of children belonging to the record. If filter_by_subset is True then the operation will only return records that are in the subset given in subset_name, if no value is provided then the subset specified on the table will be used. If filter_by_subset is False then records will be returned from all subsets.
  • Parameters:
    • filter_by_subset (bool, default: True) – Whether to filter by subset.
    • subset_name (str , optional) – Name of the subset to use for filtering.
  • Raises:
    • ValueError – If more than one subset is applied to the table when filter_by_subset is True and subset_name is not provided.
    • InvalidRecordStateError – If the record has not been pushed to the server.

Notes

Makes a Service Layer call.

refetch_pseudo_attributes()

Fetches pseudo-attribute data for this record, and updates subsets for the record if not set.

Notes

Makes a Service Layer call.

refetch_record_release_state()

Fetches the record’s release state from the server.

Notes

Makes a Service Layer call.

refetch_record_versions()

Refetches version information and all visible versions of the record for this user.

Notes

Makes a Service Layer call.

refresh_attributes()

Updates the Record object if they have changed on the server. Can also be used to populate attributes. Always includes binary data in the response. Use the bulk_fetch() method if URL data representation is required.

Notes

Makes a Service Layer call.

refresh_path()

Re-calculates the record path within the current table.

Notes

This operation performs no subset filtering because, by definition, the parent record must belong to all subsets that this record belongs to. Makes a Service Layer call.

refresh_properties()

Refreshes the Foundation API ansys.grantami.backend.soap.TreeRecord object associated with the Record, if it has one.

Notes

Makes a Service Layer call.

set_attributes(attributes)

Flags attribute values to update on the server when Session.update() is next called. If attribute values are not supplied to this method, changes to those attributes will not be transferred to Granta MI.
  • Parameters: attributes (Iterable [AttributeValue ]) – Attributes to set on the record.

SEE ALSO

clear_attributes() : Flags attribute values to be deleted when Session.update() is next called. Adds the specified records to the named record link group and flags those links for update. Links that are not set through this method will not be updated on the server.
  • Parameters:
    • link_name (str) – Link group name to be updated.
    • records (Iterable[Record]) – Records to add to the link group.

property all_versions : Dict[str, Record]

Returns all versions or the record as dictionary of Record objects. The dictionary is indexed by the version number in the form ‘v#’, for example ‘v1’ or ‘v2’. In a version controlled table there is an entry for each version of the record in Granta MI. In a non-version controlled table there is a single entry with the key ‘v0’.

Notes

Makes a Service Layer call if the refetch_record_versions() method has not already been called on this record.

property attributes : Dict[str, AttributeValue]

Attributes associated with the record, indexed by attribute name.

SEE ALSO

Table.bulk_fetch() : Fetch attributes for multiple records in a single call.

Notes

Makes a Service Layer call if the record.attributes dictionary is empty when accessed.

property children : List[Record]

Records that are direct children of the current record. Records returned by this property may have been cached from previous calls to Record.get_descendants(), Record.refetch_children() or Table.all_records(), which all apply subset filtering. If the Table subset configuration has since been updated, refresh the list of children via one of the methods listed. If there is no cached list of children, children are dynamically fetched on property access via refetch_children(). The default subset filtering behavior is applied.
  • Return type: list[Record]
  • Raises:
    • ValueError – If more than one subset is applied to the table when dynamically retrieving children records.
    • InvalidRecordStateError – If the record has not been pushed to the server.

Notes

Makes a Service Layer call if there is no cached list of children.

property color : RecordColor

Color of the record when displayed in MI Viewer and other Granta MI applications. If the Record object represents an existing record:
  • The color property will initially return the exported color of the record. It will be fetched if it has not already been exported.
  • If color is modified, the Record color will be set to the specified value.
  • If color is set to None, the Record color will be reset to the exported value.
If the Record object represents a new record:
  • The color property will initially return the value specified in the Record constructor. If not set, it will default to the value InheritFromParent.
  • If color is modified, the Record color will be set to the specified value.
  • If color is set to None, the Record color will be set to the value InheritFromParent.
  • Return type: RecordColor

Notes

Makes a Service Layer call if the record exists on the server and the color has not already been fetched. If a Record is imported with color set to None, the record will inherit the color of the parent record.

property created_by : str

User who created the record. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property created_on : datetime

Datetime of the record creation. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property data_revision_history : Dict[str, DataRevisionHistory]

Data revision history for all attributes, indexed by attribute name.

Notes

Makes a Service Layer call if the data revision history has not already been fetched for this record.

property db_key : str

Database key for the database the record belongs to.
  • Return type: str

property exists_on_server : bool

Whether the record exists on the server (True) or has been created in memory (False).

property flag_for_release : bool | None

Whether the record will be made available to users when it is next updated.
  • True (default): If changes were made to the Record, a new version will be created and then immediately released. If changes were not made to the Record, the existing version will be released.
  • False: If changes were made to the Record, a new, unreleased version will be created. The record will not be released.
  • Return type: bool or None

Notes

If you do not have the correct permissions to change release states, setting this property will not have the documented effect. See the Service Layer documentation for more details.

property history_guid : str | None

Record history GUID.
  • Returns: None for records that do not exist on the server.
  • Return type: str or None

Notes

Records in unversioned tables can be uniquely identified by their record history GUID. For records in versioned tables, the record history guid refers to the latest version of the record the user has access to.

property history_identity : int | None

Record history identity.
  • Returns: None for records that do not exist on the server.
  • Return type: int or None

Notes

Do not use, use history_guid instead.

property is_folder : bool

Whether the record is a RecordType.Folder type.

property is_writable : bool

Whether the current user has write permissions on the record. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property last_modified_by : str

User who last modified the record. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property last_modified_on : datetime

Datetime of the last modification. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record. Link groups for this Record object, and the records they link to. Smart links may be viewed but not edited through the links property. This operation performs no subset filtering.
  • Return type: dict[str, set[Record]]

property mi : Session

Session used to create or access the record. Used for any Service Layer calls made by the Record object.

property name : str

Long name of record. If the Record object represents an existing record:
  • The property will initially return the exported name of the record. It will be fetched if it has not already been exported.
  • If the property is modified, the Record name will be set to the specified value.
  • If the property is set to None, the Record name will be reset to the exported value.
If the Record object represents a new record:
  • The property will initially return the value specified in the Record constructor.
  • If the property is modified, the Record name will be set to the specified value.
  • If the property is set to None, the Record name will be set to None.
  • Return type: str

Notes

If a Record is imported with name set to None, a ValueError is raised.

property parent : Record | Table

Parent record or table of this record.

Notes

Makes a Service Layer call if the parent has not already been fetched.

property parent_record_history_identity : int

History identity of the parent record. If the record is at the root of the table, returns the history identity of the table root node. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property parent_record_name : str

Name of the parent record. If the record is at the root of the table, returns the name of the table. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property parent_record_short_name : str

Short name of the parent record. If the record is at the root of the table, returns the name of the table. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property path : List[str]

Browse tree path for the record as a list of folder short names.

Notes

Makes a Service Layer call if the path has not already been fetched.

property record_guid : str | None

Record version GUID.
  • Returns: None for records that do not exist on the server.
  • Return type: str or None

Notes

Records in unversioned and versioned tables can be uniquely identified by their record version GUID. For records in versioned tables, the record version guid refers to a specific version of a record.

property record_history : RecordVersionHistory

Details about the record history. Includes user, datetime, and notes associated with events of the record’s life cycle.

Notes

Makes a Service Layer call if the refetch_record_release_state() method has not already been called on this record.

property release_state : str

Release state of the record. Allowed values are Released, Superseded, Withdrawn, Unreleased, Unversioned or Unknown.

Notes

Makes a Service Layer call if the refetch_record_release_state() method has not already been called on this record.

property released_on : datetime

Datetime of the record release. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property short_name : str | None

Short (tree) name of the record. If the Record object represents an existing record:
  • The short_name property will initially return the exported short name of the record. It will be fetched if it has not already been exported.
  • If short_name is modified, the Record short name will be set to the specified value.
  • If short_name is set to None, the Record short name will be reset to the exported value.
If the Record object represents a new record:
  • The short_name property will initially return the value specified in the Record constructor.
  • If short_name is modified, the Record short name will be set to the specified value.
  • If short_name is set to None, the Record short name will be set to None.
  • Return type: str, optional

Notes

Makes a Service Layer call if the record exists on the server and the short name has not already been fetched. If a Record is imported with short_name set to None, the short name will default to the record name.

property subsets : Set[str]

Subsets that the record belongs to.

Notes

Makes a Service Layer call if the record exists on the server and the subsets have not already been fetched.

property table : Table

Parent table the record belongs to.

property table_name : str

Name of parent table.
  • Return type: str

property type : RecordType

Record type. On record creation via the MI Scripting Toolkit, the record type can only be set to RecordType.Folder or RecordType.Record. The type of an existing record cannot be set via this property. Adding children to a record, or populating attributes on a folder both result in the type updating to RecordType.Generic during the update.

property version_number : int | None

Record version number. This is set to None if the record is in a non version-controlled table. Read-only property. This property is populated from a pseudo-attribute value and can be refreshed via refetch_pseudo_attributes().

Notes

Makes a Service Layer call if the pseudo-attributes have not yet been fetched for this record.

property viewer_url : str

The MI Viewer URL for the record.