Streamlined API Reference¶
The classes and functions that form the Streamlined API are grouped by database element, to help you find what you need:
Session level¶
Session¶
-
class
Session(service_layer_url: str, user_name: Optional[str] = None, password: Optional[str] = None, domain: Optional[str] = None, autologon: Optional[bool] = None, timeout: int = 300000, existing_session: Optional[GRANTA_MIScriptingToolkit.GRANTA_MISession.GRANTA_MISession] = None, oidc: bool = False, auth_token: Optional[str] = None, refresh_token: Optional[str] = None, use_stored_token: bool = False)¶ Represents a Granta MI Session. Allows the MI Scripting Toolkit to make calls to the Service Layer, and provides access to and search functions for available databases.
-
__init__(service_layer_url: str, user_name: Optional[str] = None, password: Optional[str] = None, domain: Optional[str] = None, autologon: Optional[bool] = None, timeout: int = 300000, existing_session: Optional[GRANTA_MIScriptingToolkit.GRANTA_MISession.GRANTA_MISession] = None, oidc: bool = False, auth_token: Optional[str] = None, refresh_token: Optional[str] = None, use_stored_token: bool = False) → None¶ - Parameters
service_layer_url – str
user_name – str
password – str
domain – str
autologon – bool
timeout – int (maximum time to wait for a response, in milliseconds)
existing_session – Foundation API
GRANTA_MIScriptingToolkit.GRANTA_MISessionclassoidc – bool (Contact Ansys Granta Technical Support for OIDC configuration and setup documentation)
auth_token – str
refresh_token – str
use_stored_token – bool
- Returns
None
-
update(records: List[Record], update_attributes: bool = True, update_links: bool = False, refresh_attributes: bool = True) → List[Record]¶ Pushes any changes in the specified records (including adding newly-created records) to the server. Returns a list of successfully imported
Recordobjects. If refresh_attributes set to True, the imported records’ attributes are exported after the update is complete.
-
update_links(records: List[Record]) → List[Record]¶ Pushes any changes in the links of the specified records (including newly-created records) to the server. Returns a list of successfully modified
Recordobjects. All source and target records must be exported to/from the server before being linked.
-
spawn_session() → Optional[GRANTA_MIScriptingToolkit.GRANTA_MISession.GRANTA_MISession]¶ Creates a new Foundation API
GRANTA_MIScriptingToolkit.GRANTA_MISessionobject using the credentials of the currentSession.- Returns
Foundation API
GRANTA_MIScriptingToolkit.GRANTA_MISessionclass
-
property
viewer_base_url¶ MI Viewer URL associated with the Service Layer.
- Returns
str
-
can_connect() → bool¶ Checks whether credentials have been provided to the server.
- Returns
bool
-
connect() → GRANTA_MIScriptingToolkit.GRANTA_MISession.GRANTA_MISession¶ Returns a Foundation API
GRANTA_MIScriptingToolkit.GRANTA_MISessionobject using the currentSession’s credentials.- Returns
Foundation API
GRANTA_MIScriptingToolkit.GRANTA_MISessionclass
-
persist_oidc_token() → None¶ Stores a refresh token in the credential manager for your system for unattended later use. The
keyringpackage uses system-managed storage, and supports the following credential managers:Windows Credential Manager
macOS Keychain
Freedesktop Secret Service
KDE4 and KDE5 KWallet
- Returns
None
-
refetch_dbs() → None¶ Fetches the list of databases from the server. Makes a Service Layer call.
- Returns
None
-
get_db(name: str = None, db_key: str = None) → Database¶ Returns the database with name
nameand/or database keydb_key.Raises a KeyError if multiple databases are found for the same criteria.
- Parameters
name – str
db_key – str
- Returns
Databaseobject
-
search_for_records_by_name(name: str) → List[Record]¶ Searches by record name over all databases (uses
Database.search_for_records_by_name()). Makes a Service Layer call for each table in each database.- Parameters
name – str
- Returns
List[
Record]
-
search_for_records_by_text(text: str) → List[Record]¶ Performs a simple text search over all databases (uses
Database.search_for_records_by_text()). Makes a Service Layer call for each table in each database.- Parameters
text – str
- Returns
List[
Record]
-
records_from_string(text: str) → List[Record]¶ Generates
Recordobjects from a string in MI clipboard format (version 12 or higher).Note
Required string format is .tsv with column headers RecordHistoryGuid, RecordGuid, Table, DatabaseKey and RecordFullName.
- Parameters
text – str
- Returns
List[
Record]
-
get_record_by_id(db_key: str, hguid: str = None, vguid: str = None, identity: int = None) → Record¶ Returns the record with the specified ID from the database specified by
db_key. If more than one ID is provided, the method looks foridentityfirst, thenvguidandhguid.- Parameters
db_key – str
hguid – str (Record History GUID, uniquely identifies record)
vguid – str (Record GUID, uniquely identifies record version)
identity – int (Record identifier)
- Returns
Recordobject
-
bulk_fetch_release_states(records: List[Record], batch_size: int = 100, parallelise: bool = False, max_num_threads: int = 6) → None¶ Fetches and populates the release states of the specified
Recordobjects.- Parameters
records – List[
Record]batch_size – int (default value of 100)
parallelise – bool
max_num_threads – int (default value of 6)
- Returns
None
-
bulk_delete_or_withdraw_records(records: List[Record], batch_size: int = 100, parallelise: bool = False, max_num_threads: int = 6, update_release_states: bool = False) → None¶ Deletes records from the server (or withdraws them, if in a version-controlled table). Record release states can also be updated using this method.
- Parameters
records – List[
Record]batch_size – int (default value of 100)
parallelise – bool
max_num_threads – int (default value of 6)
update_release_states – bool
- Returns
None
-
get_async_job_queue(queue_url: str = None, verify_ssl: bool = True, ssl_ca_bundle: Union[str, pathlib.Path] = None) → AsyncJobQueue¶ Creates an
AsyncJobQueueobject from thisSession.- Parameters
queue_url – str (URL of the Job Queue if not the same as the Service Layer, extracted from
mi_sessionotherwise)verify_ssl – bool (Whether to verify SSL connections to the remote server;
Trueby default)ssl_ca_bundle – Union[str, pathlib.Path] (optional) (Path to custom CA bundle (.crt or .pem); use if your MI installation has a self-signed certificate which is not trusted by the requests module)
- Returns
AsyncJobQueueobject
-
AttributeFetcher¶
-
class
AttributeFetcher(table: Table, batch_size: int = 100, attributes: List[Union[str, AttributeDefinition, PseudoAttributeDefinition]] = None, records: List[Record] = None, max_parallel_threads: int = 6)¶ Bulk exporter for record data. Fetches data values for all named
AttributeDefinitionandPseudoAttributeDefinitionobjects from the specifiedRecordobjects andTable.Set
attributestoNoneto export all record data.A class method executes the data export, allowing the
AttributeFetcherto be edited post-creation.-
__init__(table: Table, batch_size: int = 100, attributes: List[Union[str, AttributeDefinition, PseudoAttributeDefinition]] = None, records: List[Record] = None, max_parallel_threads: int = 6) → None¶ - Parameters
table –
Tableobjectbatch_size – int (default value of 100)
attributes – List[Union[
AttributeDefinition,PseudoAttributeDefinition, str]]records – List[
Record]
- Returns
None
-
property
attribute_list¶ List of attributes for which data will be fetched (exported).
- Returns
List[Union[
AttributeDefinition,PseudoAttributeDefinition]]
-
fetch_attribute_data(parallelise: bool = False) → None¶ Fetch the attribute data for the provided records and attributes, and populate the corresponding
AttributeValueobjects for each record.- Parameters
parallelise – bool
- Returns
None
-
AssociatedRecordFetcher¶
-
class
AssociatedRecordFetcher(table: Table, records: List[Record], target_table: Table, link_direction: str = 'Both', attribute_path: List[AttributeDefinition] = None, batch_size: int = 100)¶ Bulk fetcher for associated records. Fetches all
Recordobjects via association chains from the specifiedRecordobjects in the targetTable. Provides means to choose the direction that association chains are followed, and to specify a list of tabular attributes which are chained together.A class method executes the fetch, allowing the
AssociatedRecordFetcherto be edited post-creation.-
__init__(table: Table, records: List[Record], target_table: Table, link_direction: str = 'Both', attribute_path: List[AttributeDefinition] = None, batch_size: int = 100)¶ - Parameters
table –
Tablerecords – List[
Record]target_table –
Tablelink_direction – str (
Both,Forward,Reverse)attribute_path – List[
AttributeDefinition]batch_size – int (default value of 100)
- Returns
None
-
fetch_associated_records(parallelise: bool = False, max_parallel_threads: int = 6) → List[Dict[str, Union[Record, List[Record]]]]¶ Fetch the associated records in the specified
Tablefrom the specifiedRecordobjects.
-
LinkFetcher¶
-
class
LinkFetcher(table: Table, batch_size: int = 100, records: List[Record] = None, link_groups: List[str] = None)¶ Bulk record link fetcher (exporter). Fetches and populates record link groups for the specified
Recordobjects in the specifiedTable. Setlink_groupstoNoneto fetch all record link groups.-
__init__(table: Table, batch_size: int = 100, records: List[Record] = None, link_groups: List[str] = None) → None¶
-
property
link_groups¶ List of link groups to export.
- Returns
List[str]
-
fetch_linked_records(parallelise: bool = False, max_parallel_threads: int = 6) → None¶ Perform the bulk fetch (export). Batches Service Layer calls into efficient blocks, then populates
Recordobject pseudo-attributes.- Parameters
parallelise – bool
max_parallel_threads – int (default value of 6)
- Returns
None
-
ReleaseStateFetcher¶
-
class
ReleaseStateFetcher(session: GRANTA_MIScriptingToolkit.granta.mi.Session, records: List[Record], batch_size: int = 100, max_parallel_threads: int = 6)¶ Allows record release states to be fetched from the server in bulk.
The list of
Recordobjects, batch size, and number of threads in parallel can be edited post-creation.A class method fetches the release states and populates the relevant
Recordproperties.-
__init__(session: GRANTA_MIScriptingToolkit.granta.mi.Session, records: List[Record], batch_size: int = 100, max_parallel_threads: int = 6) → None¶ - Parameters
batch_size – int (default value of 100)
records – List[
Record]max_parallel_threads – int (default value of 6)
- Returns
None
-
BulkRecordDeleterWithdrawer¶
-
class
BulkRecordDeleterWithdrawer(session: GRANTA_MIScriptingToolkit.granta.mi.Session, records: List[Record], batch_size: int = 100, max_parallel_threads: int = 6)¶ Allows for bulk deletion or withdrawal or records from the server. Records are withdrawn from version-controlled tables, otherwise they are deleted.
The deletion/withdrawal is performed by a method on the class; as such, the list of
Recordobjects for deletion, batch size, and number of threads in parallel can be edited post-creation.-
__init__(session: GRANTA_MIScriptingToolkit.granta.mi.Session, records: List[Record], batch_size: int = 100, max_parallel_threads: int = 6) → None¶
-
delete_or_withdraw(parallelise: bool = False) → None¶ Performs the deletion (or withdrawal, if the records are in a version-controlled table).
- Parameters
parallelise – bool (splits operation into multiple threads if
True)- Returns
None
-
Database and Table level¶
Database¶
-
class
Database(_gdl_obj: GRANTA_MIScriptingToolkit.MIDatabase.MIDatabase, _mi: Session)¶ Represents an MI database, and provides access to its tables, unit systems, and record link groups.
-
__init__(_gdl_obj: GRANTA_MIScriptingToolkit.MIDatabase.MIDatabase, _mi: Session) → None¶ - Parameters
_gdl_obj – Foundation API
GRANTA_MIScriptingToolkit.MIDatabaseclass_mi –
Sessionobject
- Returns
None
-
property
parameters¶ Parameters associated with the database, indexed by name.
- Returns
Dict[str,
ParameterDefinition]
-
refetch_unit_systems() → None¶ Fetches the unit systems associated with the database. Makes a Service Layer call.
- Returns
None
-
dimensionally_equivalent_units(unit: str) → Dict[str, Dict[str, float]]¶ Returns all units which are dimensionally equivalent to the specified unit, with conversion factor and offset. Makes a single call to the Service Layer and caches the results.
- Example
db.dimensionally_equivalent_units(unit='kg')might return{'g': {'factor': 1000.0, 'offset': 0.0}}.- Parameters
unit – str
- Returns
Dict[str, Dict[str, float]]
-
property
unit_systems_available¶ Names of unit systems associated with the database.
- Returns
List[str]
-
set_unit_system(unit_system: str, absolute_temperatures: bool = False) → None¶ Sets the unit system for the
Databaseobject. The default unit system is the same as for the database itself.- Parameters
unit_system – str
absolute_temperatures – bool (Whether to use absolute temperature units or not)
- Returns
None
-
property
absolute_temperatures¶ Whether the
Databaseuses absolute temperature units (Kelvin/Rankine) or not (Celsius/Fahrenheit).- Returns
bool
-
property
unit_system¶ Currently selected unit system (default is ‘Database’).
- Returns
str
-
get_link_detail(name: str, table_name: Optional[str] = None) → GRANTA_MIScriptingToolkit.RecordLinkGroupDetail.RecordLinkGroupDetail¶ Returns the named Foundation API
GRANTA_MIScriptingToolkit.RecordLinkGroupDetailobject.- Parameters
name – str (Name of
GRANTA_MIScriptingToolkit.RecordLinkGroupDetailobject)table_name – str
- Returns
Foundation API
GRANTA_MIScriptingToolkit.RecordLinkGroupDetailclass
-
property
link_details¶ Foundation API
GRANTA_MIScriptingToolkit.RecordLinkGroupDetailobjects associated with the database.- Returns
-
property
record_link_groups¶ All record link groups in the database.
- Returns
List[
LinkGroupDetails]
-
property
db_key¶ Database key.
- Returns
str
-
property
name¶ Name of the database.
- Returns
str
-
refresh_tables() → None¶ Updates the list of tables associated with the database. Makes a Service Layer call.
- Returns
None
-
get_table(name: str, subsets: Optional[Set[str]] = None, unit_system: str = 'Database', absolute_temperatures: bool = False) → GRANTA_MIScriptingToolkit.granta.mi_tree_classes.Table¶ Returns the
Tableobject with the specified name. Case-insensitive.- Parameters
name – str
subsets – Set[str]
unit_system – str
absolute_temperatures – bool
- Returns
Tableobject
-
search_for_records_by_name(name: str) → List[Record]¶ Performs a search on record name across the database. Returns only the
Recordobjects whose short or long names are an exact match forname. Case-insensitive.Makes a separate Service Layer call for each table in the database.
Note: Use
Table.search_for_records_by_name()to narrow your search to a single table.- Parameters
name – str
- Returns
List[
Record]
-
search_for_records_by_text(text: str) → List[Record]¶ Performs a simple text search across the database for the string provided. Returns a list of matching
Recordobjects.Makes a separate Service Layer call for each table in the database.
Note: Use
Table.search_for_records_by_text()to narrow your search to a single table.- Parameters
text – str
- Returns
List[
Record]
-
search_for_records_where(list_of_criteria: List[SearchCriterion], **kwargs) → List[Record]¶ Performs a search against a single criterion or multiple criteria across the database. Returns a list of matching
Recordobjects.Note: Use
Table.search_for_records_where()to narrow your search to a single table.- Parameters
list_of_criteria – List[
SearchCriterion]kwargs – Set
silent=Trueto ignore errors due to attributes not existing (returns[]ifsilent==Trueand no attributes exist)
- Returns
List[
Record]
-
get_record_by_id(hguid: str = None, vguid: str = None, identity: int = None) → Record¶ Returns the
Recordobject with the specified identifier or GUID.- Parameters
hguid – str (Record History GUID - uniquely identifies record)
vguid – str (Record GUID - uniquely identifies record version)
identity – int (Record identifier)
- Returns
Recordobject
-
Table¶
-
class
Table(_gdl_obj: GRANTA_MIScriptingToolkit.TableDetail.TableDetail, _mi, unit_system: str = 'Database', absolute_temperatures: bool = False)¶ Represents an MI table, and provides access to records (particularly searching on record properties), exporters and attribute definitions.
Note
Do not create new instances of this class; it represents a pre-existing database structure.
-
__init__(_gdl_obj: GRANTA_MIScriptingToolkit.TableDetail.TableDetail, _mi, unit_system: str = 'Database', absolute_temperatures: bool = False) → None¶ - Parameters
_gdl_obj – Foundation API
GRANTA_MIScriptingToolkit.TableDetailclass_mi –
Sessionobjectunit_system – str (Unit system to use in this table, e.g. ‘UK Imperial’)
absolute_temperatures – bool (Whether to use absolute temperatures)
- Returns
None
-
property
unit_system¶ Unit system currently in use.
- Returns
str
-
set_display_unit(attribute: Union[str, AttributeDefinitionPoint, AttributeDefinitionRange], unit_symbol: str) → None¶ Sets the display unit for a
POINorRNGEattribute. This only affects display, not import or FEA exporters.- Parameters
attribute – Union[str, AttributeDefinitionPoint, AttributeDefinitionRange] (str must be the attribute name)
unit_symbol – str
- Returns
None
-
reset_display_unit(attribute: Union[str, AttributeDefinitionPoint, AttributeDefinitionRange]) → None¶ Resets the display unit for a
POINorRNGEattribute back to the unit system default.- Parameters
attribute – Union[str, AttributeDefinitionPoint, AttributeDefinitionRange] (str must be the attribute name)
- Returns
None
-
property
min_max_type¶ How table-wide minimum and maximum values of point (
POIN), integer (INPT), range (RNGE) and date-time (DTTM) attributes in the table are calculated:None: Does not calculate values (can improve performance when loading tables)Approximate(default): Uses a fast, approximate algorithmExact: Takes account of current subset and permissions (can be slow on large tables)
Setting this property refreshes all attributes in the table, and makes a Service Layer call.
- Returns
str
-
refresh_subsets() → None¶ Fetches the list of subsets which can be applied to this table. Makes a Service Layer call.
- Returns
None
-
property
subsets_available¶ Subsets which can be applied to this table.
- Returns
Set[str]
-
property
subsets¶ Subsets that are currently applied to the
Tableobject. Used for record creation and searching.- Returns
Set[str]
-
add_subsets(values: Union[Set[str], Tuple[str], List[str]]) → None¶ Adds single or multiple subsets to the list of subsets currently applied to the
Tableobject.- Parameters
values – Set[str], Tuple[str] or List[str]
- Returns
None
-
remove_subsets(values: Union[str, List[str], Tuple[str], Set[str]]) → None¶ Removes single or multiple subsets from the list of subsets currently associated with the
Tableobject.- Parameters
values – Set[str], Tuple[str] or List[str]
- Returns
None
-
all_records(include_folders: bool = False, include_generics: bool = True) → List[Record]¶ Returns a flattened list of all records in the table and populates the
childrenproperty of eachRecordobject. Makes a Service Layer call.- Parameters
include_folders – bool
include_generics – bool
- Returns
List[
Record]
-
search_for_records_by_text(text: str) → List[Record]¶ Performs a simple text search within the table for the specified string. Returns a list of matching
Recordobjects. Makes a Service Layer call.Note: Use
Database.search_for_records_by_text()to search across the whole database.- Parameters
text – str
- Returns
List[
Record]
-
search_for_records_where(list_of_criteria: List[SearchCriterion], **kwargs) → List[Record]¶ Performs a search against a single criterion or multiple criteria within the table. Returns a list of matching
Recordobjects.Note
Use
Database.search_for_records_where()to search across the whole database.- Parameters
list_of_criteria – List[
SearchCriterion]kwargs – Set
silent=Trueto ignore errors due to attributes not existing (returns[]ifsilent==Trueand no attributes exist)
- Returns
List[
Record]
-
property
name¶ Name of the table.
- Returns
str
-
property
db_key¶ Parent database key.
- Returns
str
-
refresh_attributes() → None¶ Performs a Foundation API
BrowseService.GetAttributeDetails()request and creates a new set of attributes for the table from the results. Makes a Service Layer call.- Returns
None
-
property
layouts¶ Fetch and view the layouts available in this table for Granta products.
- Returns
Dict[str,
TableLayout]
-
property
attributes¶ All attributes included in the table schema, indexed by name. Meta-attributes are accessible through the
meta_attributesproperty of their parent attribute.- Returns
Dict[str,
AttributeDefinition]
-
property
mi¶ MI Session that was used to create or access the
Tableobject. Used for any Service Layer calls made by theTable.- Returns
Sessionobject
-
get_attribute_definition(name: str = None, identity: int = None) → Union[Attribute, List[Attribute]]¶ Returns the
AttributeDefinitionobject specified bynameor the identifieridentity. Meta-attributes are also returned if the identifier is provided.- Parameters
name – str (Name of the
AttributeDefinitionobject)identity – int (Attribute identifier)
- Returns
AttributeDefinitionobject or List[AttributeDefinition]
-
get_record_by_id(identity: int = None, hguid: str = None, vguid: str = None) → Union[None, Record]¶ Returns a
Recordobject specified by identifier or GUID. Can be used to access records outside of the current subsets.- Parameters
identity – int (Record identifier)
hguid – str (Record History GUID - uniquely identifies record)
vguid – str (Record GUID - uniquely identifies record version)
- Returns
Recordobject or None
-
get_record_by_lookup_value(attribute_name: str, lookup_value: str) → Union[None, Record]¶ Returns a
Recordobject specified by attribute name and a exact match for a short text string (lookup value), provided that:The
lookup_valuematches exactly one record in the table.The record is in the default subset of the table.
- Parameters
attribute_name – str
lookup_value – str
- Returns
Recordobject or None
-
property
children¶ Return the children of the Table node. Analogous to
Record.children, this returns all the records one level from the Table root.- Returns
List[
Record]
-
search_for_records_by_name(name: str) → List[Record]¶ Performs a search on record name within the table. Returns only the
Recordobjects whose short or long names are an exact match forname. Case-insensitive.Note
Use
Database.search_for_records_by_name()to search across the whole database.- Parameters
name – str
- Returns
List[
Record]
-
create_empty_attribute_value(definition: AttributeDefinition) → AttributeValue¶ Create an empty
AttributeValueinstance for an attribute from itsAttributeDefinition. This can subsequently be assigned to a record for import.- Parameters
definition –
AttributeDefinitionobject- Returns
AttributeValueobject
-
create_record(name: str, parent: Union[Record, Table] = None, short_name: str = None, attributes: Dict[str, AttributeValue] = None, folder: bool = False, subsets: Set[str] = {}, release_record: bool = False, color: str = None) → Record¶ Creates a new
Recordobject in theTable. The record will not exist in MI, or be able to be assigned as a parent, until it is pushed to the server.- Parameters
name – str (Long name)
short_name – str
attributes – Dict[str,
AttributeValue]folder – bool (Whether the record will be Folder type)
release_record – bool (Whether the record will be released when it is next updated)
subsets – Set[str] (List of subsets the record will belong to)
color – str (Record color)
- Returns
Recordobject
-
paths_from(paths: List[Dict[str, Union[Record, Table, str, None, List[str]]]]) → List[Tuple[dict, Record]]¶ Create multiple paths between specified start and end nodes in the table tree.
Paths are specified as a list of dictionaries with the following structure:
{'starting_node': Union[Table, Record, None, str], 'tree_path': ['list', 'of', 'folders'], 'end_node': '<end node string>', 'color': 'color for all new nodes to be assigned'}
See description of
path_from()for further details.
-
path_from(starting_node: Union[Record, Table, None, str], tree_path: List[str], end_node: str = None, color: str = None) → Record¶ Create a path from a node in the table tree (a record or folder) down to a new or existing record.
The starting node of the path can be the table root or any record/folder in the tree.
Specify the names of the records/folders along the path as a list of strings, e.g.
['Polymers', 'Plastics', 'Thermoplastics' ...]. The last item in this path must be an existing record, but other nodes in the path will be created if they don’t already exist.To create a new record at the end of the path (i.e. to add a new end node), set
end_nodeto the new record name.You can also specify the color of the records in the path.
- Parameters
starting_node – A
Record, or ‘Root’/None. Identifies the node under which the new path will start. Set to'Root'orNoneto start the path below the root node of the table tree; set it to an existing record/folder to add the new path below that.tree_path – List[str] The names of the folders & records in the path, e.g. [‘name1’, ‘name2’, …].
end_node – string (Optional) The name of a new record that will be created below the last path node.
color – string (Optional) Sets the color of all folders & records in the path.
- Returns
The
Recordobject at the end of the path.
-
get_records_from_path(starting_node: Union[Record, Table, None, str], tree_path: List[Optional[str]], use_short_names: bool = False) → List[Record]¶ Return all records at the end of a path.
The starting node identifies the node immediately above the path. To start the path at the top of the tree, set
starting_nodeto ‘Root’ or to the Table object. To start the path under any other node in the tree, specify the record name as thestarting_node.Specify the path as a list of record names e.g.
['Polymers', 'Plastics', 'Thermoplastics' ...].You can include “wildcards” in the path by setting a node to ‘None’ e.g.
['Thermoplastics', 'None', 'Unfilled' ...].By default, the strings specified in the path list are assumed to be record full names; to specify the path using record short names instead, set
use_short_namesto True.
Example 1:
recs = table.get_records_from_path(table, ['Record 1', None, 'Record 2'])will return all records that are children of a record named Record 2, that also have Record 1 as a great-grandparent. The grandparent is set as a wildcard, and so any is allowed.
Example 2:
recs = table.get_records_from_path('Root', ['Record 1', 'Record 3', None])will return all records that are grandchildren of records named Record 3 that also have a great-grandparent called Record 1.
Both of these examples have assumed that Record 1 is a top-level record (and have a starting node as a table object to reflect this), but the method does not require this. The starting node can be any record object in the tree.
- Parameters
starting_node – any
Recordin the table tree. To start the path at the root node of the table tree, set this to'Root',None, or theTableobject.tree_path – a list of strings specifying the names of the records in the path. May include ‘None’ as a wildcard.
use_short_names – a boolean that specifies whether the strings in the path are the record short names
- Returns
returns a list of records
- Return type
List[
Record]
-
bulk_fetch(records: List[Record], attributes: List[Union[str, AttributeDefinition, PseudoAttributeDefinition]] = None, batch_size: int = 100, parallelise: bool = False, max_num_threads: int = 6) → None¶ Populates data values for all named
AttributeDefinitionandPseudoAttributeDefinitionobjects in the specifiedRecordobjects. SetattributestoNoneto export all record data.- Parameters
attributes – List[Union[
AttributeDefinition,PseudoAttributeDefinition, str]]records – List[
Record]batch_size – int (default value of 100)
parallelise – bool
max_num_threads – int (default value of 6)
- Returns
None
-
bulk_link_fetch(records: List[Record], link_groups: List[str] = None, batch_size: int = 100, parallelise: bool = False, max_num_threads: int = 6) → None¶ Fetches and populates record link groups for the specified
Recordobjects. Setlink_groupstoNoneto fetch all record link groups.- Parameters
records – List[
Record]link_groups – List[str]
batch_size – int (default value of 100)
parallelise – bool
max_num_threads – int (default value of 6)
- Returns
None
-
bulk_fetch_associated_records(records: List[Record], target_table: Table, link_direction: str = 'Both', attribute_path: List[AttributeDefinitionTabular] = None, batch_size: int = 100, parallelise: bool = False, max_num_threads: int = 6) → List[Dict[str, Union[Record, List[Record]]]]¶ Fetches records associated with the specified
Recordobjects from a targetTable. Returns a list of dictionaries containing the source record and associated records for eachRecordprovided.You may specify
link_directionto only follow tabular links in the specified direction, or provide a list ofAttributeDefinitionTabularobjects inattribute_pathto follow only those tabular links.- Parameters
records – List[
Record]target_table –
Tablelink_direction – str (
Both(default),Forward,Reverse)attribute_path – List[
AttributeDefinitionTabular]batch_size – int (default value of 100)
parallelise – bool
max_num_threads – int (default value of 6)
- Returns
-
get_available_exporters(package: str = None, model: str = None, applicability_tag: str = None) → List[Exporter]¶ Returns exporters available on the table filtered by package, model, and applicability tag value.
- Parameters
package – str The target FEA analysis package. For example: ‘NX 10.0’, ‘CATIA V5’.
model – str The material model type. For example, ‘Isotropic’, ‘Linear, temperature-independent, isotropic, thermal, plastic’.
applicability_tag – str A tag that identifies the applications for which an exporter is intended to be used. For example, ‘MIMaterialsGateway’, ‘MIViewer’.
- Returns
List[
Exporter]
-
LinkGroupDetails¶
-
class
LinkGroupDetails(link_detail: GRANTA_MIScriptingToolkit.RecordLinkGroupDetail.RecordLinkGroupDetail)¶ Provides access to the properties of a record link group.
-
__init__(link_detail: GRANTA_MIScriptingToolkit.RecordLinkGroupDetail.RecordLinkGroupDetail) → None¶ - Parameters
link_detail – Foundation API
GRANTA_MIScriptingToolkit.RecordLinkGroupDetailclass- Returns
None
-
property
name¶ Name of the record link group.
- Returns
str
-
property
table_to¶ Name of the table from which the link group originates.
- Returns
str
-
property
table_from¶ Name of the table the link group comes from.
- Returns
str
-
property
type¶ Whether the record link group is ‘static’, ‘cross-database’ or ‘dynamic’.
- Returns
str
-
property
reverse_name¶ Name of the record link group in the return direction.
- Returns
str
-
TableLayout¶
-
class
TableLayout(name: str, table: Table)¶ Provides a JSON-format display of a Granta layout. You can access this through the
layoutproperty.Note
Do not create new instances of this class manually.
-
property
name¶ Layout name.
- Returns
str
-
property
layout¶ JSON-formatted version of the layout.
- Returns
List[Dict[str, Union[str, List[str], Dict[str, Union[str, List[str]]]]]]
-
property
categories¶ List of all the categories (headings) in the layout.
- Returns
List[str]
-
property
attributes_by_category¶ Dictionary of attribute lists, indexed by the layout category they are in.
- Returns
Dict[str, List[str]]
-
property
link_groups_by_category¶ Dictionary of link group lists, indexed by the layout category they are in.
- Returns
Dict[str, List[str]]
-
property
meta_attributes_by_attribute¶ Dictionary of meta-attribute lists, indexed by parent attributes.
- Returns
Dict[str, List[str]]
-
meta_attributes_on(attribute_name: str) → List[str]¶ Returns the list of meta-attributes corresponding to a given attribute in this layout.
- Parameters
attribute_name – str
- Returns
List[str]
-
property
Exporter¶
-
class
Exporter(mi: GRANTA_MIScriptingToolkit.granta.mi.Session, exporter_key: str)¶ -
__init__(mi: GRANTA_MIScriptingToolkit.granta.mi.Session, exporter_key: str) → None¶ Represents a Granta MI FEA exporter. FEA exporters are used to export record data from Granta MI into formats supported by CAD and CAE packages.
- Parameters
mi – Current
Sessionobjectexporter_key – str (Unique identifier for this exporter)
- Returns
None
-
property
default_file_extension¶ Returns the default file extension as defined by the exporter configuration file.
- Returns
str
-
save(file_path: str, file_name: Optional[str] = None, file_extension: Optional[str] = None) → None¶ Saves the output of the last FEA export to the path provided using the default naming convention and file extension for the exporter; specify a file_name or file_extension to override the defaults.
- Parameters
file_path – str (File path of the form C:\Users\Username\)
file_name – str (Optional - Output file name. Does not require a file extension.)
file_extension – str (Optional - Output file extension.)
- Returns
None
-
property
default_file_name¶ Returns the default file name for the last performed export, as defined by the exporter configuration file.
- Returns
str
-
property
default_encoding¶ Returns the default file encoding scheme as defined by the exporter configuration file.
Note
This is returned as a Python-compatible string (e.g. “cp1252”) rather than the .NET codepage “1252”.
- Returns
str
-
property
default_bom¶ Returns the default byte-order mark as defined by the exporter configuration file. If no BOM is required by default, this property is
None.- Returns
Union[str, None]
-
get_parameters_required_for_export(records: List[Record]) → Dict[str, ParameterDefinition]¶ Returns a dictionary of all of the parameter definitions the Exporter requires to export the data from the specified list of records, indexed by parameter name.
- Parameters
records – List[
Record]- Returns
Dict[str,
ParameterDefinition]
-
run_exporter(records: List[Record], stop_before: Union[int, str] = None, parameter_defs: Dict[str, ParameterDefinition] = None, sig_figs: int = None) → str¶ Performs an FEA export on the specified list of records, returning the data representing the records as a string.
- Parameters
records – List[
Record]stop_before – Union[int, str] (Either refers to the index of the transform step (int) or its name (str))
parameter_defs – Dict[str,
ParameterDefinition]sig_figs – int
- Returns
str (Contains data output by the exporter)
-
export_list_is_valid(records: List[Record]) → bool¶ Verifies that a list of records is valid for export.
If the exporter was created from a table search, then this method verifies that all records come from this table. Otherwise, the first record is used to determine which table the exporter belongs to.
- Parameters
records – List[
Record]- Returns
bool (Whether the specified list of records can be exported with this exporter)
-
Record level¶
RecordDataStructure¶
-
class
RecordDataStructure(name: str, table: Table, short_name: Optional[str] = None, color: Optional[str] = None)¶ Provides access to all record properties and record-level methods that are not accessed via Foundation API
GRANTA_MIScriptingToolkit.RecordReferenceobjects.-
__init__(name: str, table: Table, short_name: Optional[str] = None, color: Optional[str] = None) → None¶ - Parameters
name – str (Long name of record)
table –
Tableobjectshort_name – str (Short name of record)
color – str (Color of the record)
- Returns
None
-
property
name¶ Long name of record.
- Returns
str
-
property
mi¶ MI Session that was used to create or access the record. Used for any Service Layer calls made by the
Recordobject.- Returns
Sessionobject
-
property
table_name¶ Name of parent table.
- Returns
str
-
property
db_key¶ Database key for the database the record belongs to.
- Returns
str
-
Record¶
-
class
Record(name: str, table: Table, parent: Union[Table, Record] = None, short_name: str = None, attributes: Dict[str, AttributeValue] = None, subsets: Set[str] = None, folder: bool = None, record_color: str = None, release_record: bool = True)¶ Extends the
RecordDataStructureclass. Stores and provides access to record attributes, pseudo-attributes, links and children. Provides methods for adding, editing and deleting records, and importing/exporting record data.New
Recordobjects may be created to represent records that do not currently exist in the database:A name, parent table and session must be specified.
namewill become the record’s long name; an optional argument can be used to specify the short (tree) name.Records created this way will not exist in the host database until the changes have been pushed to MI (see
Session.update()).
Note
Do not create new instances of
Recordobjects for records which are already in the database. Existing records will have Foundation API classes associated with them, from which the Streamlined API will automatically generate and returnRecordobjects as required.-
__init__(name: str, table: Table, parent: Union[Table, Record] = None, short_name: str = None, attributes: Dict[str, AttributeValue] = None, subsets: Set[str] = None, folder: bool = None, record_color: str = None, release_record: bool = True) → None¶ - Parameters
name – str (Long name for new records)
table –
Tableobjectshort_name – str (Short (tree) name for new records)
attributes – Dict[str,
AttributeValue]subsets – Set[str] (Subsets the record belongs to)
folder – bool (Whether the record is ‘Folder’ type)
record_color – str (see
color())release_record – bool (Release state of the record;
Trueto release next version)
- Returns
None
-
property
subsets¶ Subsets that the record belongs to.
- Returns
Set[str]
-
property
flag_for_release¶ Whether the record will be made available to users when it is next updated.
True(default): If changes were made to theRecord, a new version will be created, otherwise the unreleased version of the record will be released when the server is updated.False: If changes were made to theRecord, a new, unreleased version will be created when the server is updated.
Note
If you do not have the correct permissions to change release states, setting this property will not have the documented effect. Please see the Service Layer documentation for more details.
- Returns
bool or None
-
property
color¶ Color of the record when displayed in MI Viewer and other Granta MI applications.
The accepted record colors are: “Red”, “Maroon”, “Fuchsia”, “Yellow”, “Black”, “Gray”, “Aqua”, “Green” “Navy”, “Purple”, “Blue”, “Silver”, “Lime”, “Olive”, “Teal” and “White”.
- Returns
str
-
property
short_name¶ Short (tree) name of the record.
- Returns
str
-
find_parent() → None¶ Finds and sets the parent record or table.
If a
Recordhas been created from a Foundation APIGRANTA_MIScriptingToolkit.RecordReferenceobject (for example, an existing database record), its parent may not be defined. This function gets the Foundation APIGRANTA_MIScriptingToolkit.TreeRecordobject (if it does not already exist) and uses it to create and/or set a parentRecordobject. If the record is at the highest level, the parent is set as the hostTableobject instead.- Returns
None
-
property
history_guid¶ Record History GUID, if it exists. Records can be uniquely identified by their Record History GUID, which will return the latest version the user has access to.
- Returns
str or None
-
property
record_guid¶ Record GUID, if it exists. Each version of a record can be uniquely identified by its Record GUID.
- Returns
str or None
-
property
id¶ Record identifier, if it exists.
- Returns
int or None
-
set_attributes(attributes: Union[Iterable[AttributeValue]]) → None¶ Flags attributes to update on the server when
Session.update()is next called. Ifset_attributes()is not called on modified attributes, changes to those attributes will not be transferred to MI.- Parameters
attributes – Union[Iterable[AttributeValue]]
- Returns
None
-
clear_attributes(attributes: Union[Iterable[AttributeValue]]) → None¶ Flags attributes to have their data value on the server deleted when
Session.update()is next called. Does not delete the local value of flagged attributes, only the data on MI. Supercedes previousset_attributes()calls.- Parameters
attributes – Union[Iterable[AttributeValue]]
- Returns
None
-
property
viewer_url¶ The MI Viewer URL for the record.
- Returns
str
-
property
path¶ Browse tree path for the record as a list of folder short names.
- Returns
List[str]
-
property
pseudo_attributes¶ Pseudo-attributes associated with the record, indexed by name.
- Returns
Dict[str,
PseudoAttributeValue]
-
refresh_path() → None¶ Re-calculates the record path within the current table. Makes a Service Layer call.
- Returns
None
-
refresh_properties() → None¶ Refreshes the Foundation API
GRANTA_MIScriptingToolkit.TreeRecordobject associated with theRecord, if it has one. Makes a Service Layer call.- Returns
None
-
refetch_children() → None¶ Refreshes the list of children belonging to the record. Makes a Service Layer call.
- Returns
None
-
refresh_attributes() → None¶ Checks whether the record’s attributes have changed on the server, and updates the
Recordobject if required. Can also be used to populate attributes. Makes a Service Layer call.- Returns
None
-
refetch_pseudos() → None¶ Fetches pseudo-attribute data for this record, and updates subsets for the record if not set. Makes a Service Layer call.
- Returns
None
-
property
attributes¶ Attributes associated with the record, indexed by attribute name.
- Returns
Dict[str,
AttributeValue]
-
get_attributes(names: List[str] = None, types: List[str] = None, include_attributes: bool = True, include_metas: bool = False, include_pseudos: bool = False, empty: bool = None) → List[Union[PseudoAttributeValue, AttributeValue]]¶ Retrieve a list of attributes from the
record.attributesdictionary. 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.attributesdictionary is empty whenget_attributesis called, it will be populated before retrieving any attributes.- Example
r.get_attributes(names=['Density', 'Stress-Strain'], types=['POIN', 'SERI'], include_metas=True)will return all point or functional series attributes or meta-attributes named Density or Stress-Strain from the record.- Parameters
names – List[str]
types – List[str] (Attribute data types; allowed values are: DISC, DTTM, FILE, FUNC, HLNK, INPT, LOGI, LTXT, PICT, POIN, RNGE, STXT, TABL)
include_attributes – bool (whether to retrieve attributes that are not meta-attributes or pseudo-attributes;
Trueby default)include_metas – bool (whether to retrieve meta-attributes;
Falseby default)include_pseudos – bool (whether to retrieve pseudo-attributes;
Falseby default)empty – bool (whether to check if the returned attributes are populated)
- Returns
List[Union[
PseudoAttributeValue,AttributeValue]]
-
property
type¶ Record type, one of
Folder,Generic, orRecord. Record type can only be set toFolderorRecordthrough the MI Scripting Toolkit. If it is set on an existing record, it will have no effect.- Returns
str
-
all_children(include_folders=False, include_generics=True) → List[GRANTA_MIScriptingToolkit.granta.mi_record_classes.Record]¶ Returns a flattened list of all children of a record and populates the
childrenproperty of eachRecordobject. Makes a Service Layer call.- Parameters
include_folders – bool
include_generics – bool
- Returns
List[
Record]
-
property
links¶ Link groups for this
Recordobject, and the records they link to. Smart links may be viewed but not edited through thelinksproperty.- Returns
Dict[str, Set[
Record]]
-
get_associated_records(target_table: Table, link_direction: str = 'Both', attribute_path: List[AttributeDefinition] = None) → List[Record]¶ Gets all records in a target table that are linked to the current
Recordobject via tabular data association chains. This can be filtered by link direction and to a specific path.If
attribute_pathis 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.- Parameters
target_table –
Tableobjectlink_direction – str (Which direction to follow links in:
Both(default),Forward,Reverse)attribute_path – List[
AttributeDefinition] (Path of tabular attributes to follow - ifNone, all paths are followed)
- Returns
List[
Record]
-
set_links(link_name: str, records: Iterable[GRANTA_MIScriptingToolkit.granta.mi_record_classes.Record]) → None¶ 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
records – Iterable[
Record]
- Returns
None
-
decache_attributes() → None¶ Removes all attributes from the
Record, replacing theattributesproperty with an empty dictionary.- Returns
None
-
decache_links() → None¶ Removes all links from the
Record, setting thelinksproperty toNone.- Returns
None
-
property
is_folder¶ Whether the record is a ‘Folder’ type.
- Returns
bool
-
property
release_state¶ Release state of the record. Allowed values are ‘Released’, ‘Superseded’, ‘Withdrawn’, ‘Unreleased’, ‘Unversioned’ or ‘Unknown’.
- Returns
str
-
refetch_record_release_state() → None¶ Fetches the record’s release state from the server. Makes a Service Layer call.
- Returns
None
-
property
all_versions¶ Returns all versions or the record as dictionary of
Recordobjects indexed by version number, and the letter ‘v’, e.g. ‘v1’ or ‘v2’. In a version controlled table this can be many, and in a non-version-controlled table there will only ever be one, with the key ‘v0’.- Returns
Dict[str,
Record]
-
delete_or_withdraw_record_on_server() → None¶ Deletes the record from the server, or withdraws it from a version-controlled table. Makes a Service Layer call.
- Returns
None
-
get_available_exporters(package: str = None, model: str = None, applicability_tag: str = None) → List[Exporter]¶ Returns exporters available for this record filtered by package, model, and applicability tag value.
- Parameters
package – str (Name of target FEA analysis package, for example ‘NX 10.0’ or ‘CATIA V5’)
model – str (Material model type, for example ‘Isotropic’ or ‘Linear, temperature-independent, isotropic, thermal, plastic’)
applicability_tag – str (Tag that identifies the MI applications an exporter is intended to be used with, for example, ‘MIMaterialsGateway’ or ‘MIViewer’)
- Returns
List[
mi.Exporter]
Attribute level¶
There are two types of attribute object at the attribute level: Attribute Definitions and Attribute Values.
Attribute Definitions¶
These classes describe how an attribute appears in the schema of a given table. There are ten types.
AttributeDefinition - Base class, and parent of all AttributeDefinition classes; covers all attributes not covered by those below
AttributeDefinitionDiscrete - Child class covering discrete attributes
AttributeDefinitionMultiValue - Child class covering multi-valued attributes such as functional, or point
AttributeDefinitionPoint - Child class covering point attributes
AttributeDefinitionRange - Child class covering range attributes
AttributeDefinitionInteger - Child class covering integer attributes
AttributeDefinitionDatetime - Child class covering datetime attributes
AttributeDefinitionTabular - Child class covering tabular attributes
AttributeDefinitionUnsupported - Child class covering unsupported attribute types (maths functional and discrete functional)
PseudoAttributeDefinition - Class for pseudo-attributes. Operates like AttributeDefinition but is not a child of it.
AttributeDefinition¶
-
class
AttributeDefinition(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Base attribute definition class.
Note
Do not create new instances of this class; it represents a pre-existing database structure.
Stores basic information about an attribute, such as data type or possible values. Contains information about the attribute itself, and cannot be used to set attribute values.
AttributeDefinitionwraps all properties of the Foundation APIGRANTA_MIScriptingToolkit.AttributeDetailobject, including properties that may not be populated for a given attribute. For example,axis_namewill not always be populated, but it will always be included because it is a property ofGRANTA_MIScriptingToolkit.AttributeDetail.- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
id¶ Attribute identifier.
- Returns
int
-
property
axis_name¶ Y-axis name (for functional data attributes only).
- Returns
str
-
property
name¶ Attribute name.
- Returns
str
-
property
order¶ Display order in MI Viewer.
- Returns
int
-
property
is_meta¶ Whether the attribute is a meta-attribute or not.
- Returns
bool
-
property
is_meta_for¶ Name of the parent attribute, if the attribute is a meta-attribute. Returns
Noneif not a meta-attribute.- Returns
str or None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
property
unit¶ Unit symbol.
- Returns
str
-
property
meta_attributes¶ Meta-attributes associated with this attribute, indexed by name.
- Returns
Dict[str,
AttributeDefinition]
-
search_criterion(less_than: float = None, greater_than: float = None, contains: Union[str, bool] = None, contains_any: List[str] = None, contains_all: List[str] = None, does_not_contain: str = None, exists: bool = None, equal_to: int = None, between_dates: Tuple[Union[str, datetime.datetime], Union[str, datetime.datetime]] = None, in_column: str = None) → Optional[SearchCriterion]¶ Creates a search criterion for use with
Table.search_for_records_where()orDatabase.search_for_records_where(). Operator priority is the same as the order of the arguments.- Parameters
less_than – float
greater_than – float
contains – Union[str, bool]
contains_any – List[str]
contains_all – List[str]
does_not_contain – str
exists – bool
equal_to – int
between_dates – Union[str, datetime.datetime] (Two dates in chronological order, str must be in YYYY-MM-DD format)
in_column – str (Name of tabular column to search)
- Returns
SearchCriterionobject
-
AttributeDefinitionDiscrete¶
-
class
AttributeDefinitionDiscrete(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for discrete attributes.Provides a method to view the possible discrete values of an attribute.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
discrete_values¶ All possible discrete values of the attribute.
- Returns
List[str]
-
property
is_multivalued¶ Whether this attribute allows multiple values to be set.
- Returns
bool
-
AttributeDefinitionMultiValue¶
-
class
AttributeDefinitionMultiValue(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for functional and point data attributes.Provides access to functional data parameters.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
parameters¶ Parameters associated with the attribute, indexed by name.
- Returns
Dict[str,
ParameterDefinition]
-
AttributeDefinitionPoint¶
-
class
AttributeDefinitionPoint(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionMultiValueclass for point attributes.Provides access to point-specific information and methods.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
max¶ Maximum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
property
min¶ Minimum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
AttributeDefinitionRange¶
-
class
AttributeDefinitionRange(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for range attributes.Provides access to range-specific information and methods.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
max¶ Maximum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
property
min¶ Minimum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
AttributeDefinitionInteger¶
-
class
AttributeDefinitionInteger(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for integer attributes.Provides access to integer-specific information, such as minmax.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
max¶ Maximum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
property
min¶ Minimum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
AttributeDefinitionDatetime¶
-
class
AttributeDefinitionDatetime(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for date-time attributes.Provides access to type-specific information, such as minmax.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
max¶ Maximum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
property
min¶ Minimum value of the data attribute. Affected by user read permissions.
- Returns
Union[float, int, datetime.datetime]
-
AttributeDefinitionTabular¶
-
class
AttributeDefinitionTabular(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for tabular data attributes.Provides access to tabular-specific information and methods, such as columns, linking attribute and cross-table links.
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
property
linking_attribute¶ Linking attribute, a short text-type attribute used to link rows in the tabular data attribute to records. Returns
Nonefor purely local tabular data.- Returns
AttributeDefinitionobject or None
-
property
linking_table¶ Tableobject which the linking attribute belongs to. ReturnsNonefor purely local tabular data.- Returns
Tableobject or None
-
property
column_types¶ Data type in each column.
- Example
['STXT', 'POIN', 'DISC']- Returns
List[str]
-
property
column_histories¶ The revision histories of each column, as an ordered list of
ObjectHistoryobjects.- Returns
List[
ObjectHistory]
-
property
column_units¶ Unit symbols for each column.
- Returns
List[str]
-
property
discrete_values¶ All possible discrete values, for all columns with the discrete data type.
- Returns
List[List[str]]
-
property
column_targets¶ Column meta-types. Possible column targets are:
Local- Contains local dataTargetAttribute- Contains data from a linked attributeTargetRecord- Contains the records that the rows link toTargetTabularColumn- Contains data from a linked tabular columnUnavailable- Data cannot be viewed, usually due to version control or permissions- Returns
List[str]
-
property
columns¶ Column names (headers).
- Returns
List[str]
-
AttributeDefinitionUnsupported¶
-
class
AttributeDefinitionUnsupported(name: str, _mi: Session)¶ -
__init__(name: str, _mi: Session) → None¶ Extended
AttributeDefinitionclass for unsupported attribute types (maths functional (equations and logic), discrete functional).Provides access to the limited information available for unsupported attribute types (name, type and unit, if present).
- Parameters
name – str
_mi –
Sessionobject
- Returns
None
-
PseudoAttributeDefinition¶
-
class
PseudoAttributeDefinition(name: str)¶ -
__init__(name: str) → None¶ Stores basic information about a pseudo-attribute.
Note
namemust exist in thepseudo_attributes_definitiondictionary.- Parameters
name – str
- Returns
None
-
property
id¶ Attribute identifier (this is always 0 for pseudo-attributes).
- Returns
int
-
property
read_only¶ Whether the current user has the correct permissions to edit the attribute.
- Returns
bool
-
property
unit¶ Unit symbol for the pseudo-attribute.
- Returns
str
-
property
name¶ Name of the pseudo-attribute.
- Returns
str
-
property
type¶ Data type of the pseudo-attribute (four-character string).
- Returns
str
-
Attribute Values¶
These classes are attribute objects that contain data. There is (at least) one for each type.
AttributeValue - Base class for all attributes
AttributeBinary - Parent class for the binary attributes, AttributePicture and AttributeFile
AttributePicture - Attribute value class covering picture data
AttributeFile - Attribute value class covering file data
AttributeDate - Attribute value class covering datetime data
AttributeDiscrete - Attribute value class covering discrete data
AttributeFunctional - Attribute value class covering functional data. This is subclassed by FunctionalSeries and FunctionalGrid.
FunctionalSeries - Attribute value class covering float functional series data
FunctionalGrid - Attribute value class covering float functional gridded data
AttributeHyperlink - Attribute value class covering hyperlink data
AttributeInteger - Attribute value class covering integer data
AttributeLogical - Attribute value class covering logical data
AttributePoint - Attribute value class covering point with parameter data
AttributeRange - Attribute value class covering range data
AttributeTabular - Attribute value class covering tabular data
AttributeShortText - Attribute value class covering short text data
AttributeLongText - Attribute value class covering long text data
AttributeUnsupported - Attribute value class covering unsupported data
PseudoAttributeValue - Pseudo-attribute value class covering all pseudo-attribute types
AttributeValue¶
-
class
AttributeValue(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Stores and provides access to attribute data values.
Note
Do not create new instances of this class; it represents a pre-existing database structure, and empty instances are provided when needed.
The attributes in a
Recordare represented in the MI Scripting Toolkit byAttributeDefinitionobjects, with an associatedAttributeValueobject containing the attribute’s data.AttributeValueis the base class, and each attribute type has a specialised class that inherits from it.Note
The ‘Notes’ meta-attribute, common to all attributes, is not accessible through the MI Scripting Toolkit.
-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclasses for each meta-attribute of this attribute)
- Returns
None
-
property
value¶ Current value of the attribute. Can be modified for most attribute types to edit the attribute value. The exceptions are functional, point, tabular and binary (File or Picture) attributes. The
valueproperty of these classes always returns the current instance of the class and cannot be modified.- Returns
Union[List[str], str, Dict[str, float], int, bool, BinaryType, AttributeBinary, AttributeFunctional, AttributeTabular, AttributePoint]
-
is_empty() → bool¶ Checks whether the attribute value is populated.
- Returns
bool
-
property
definition¶ AttributeDefinitionassociated with thisAttributeValue.- Returns
AttributeDefinitionobject
-
property
id¶ Attribute identifier.
- Returns
int
-
property
is_meta¶ Whether the attribute is a meta-attribute.
- Returns
bool
-
property
is_meta_for¶ Name of the parent attribute, if a meta-attribute. Returns
Noneif not.- Returns
str or None
-
property
meta_attributes¶ Meta-attributes associated with this attribute. Does not make calls to the Service Layer.
- Returns
Dict[str,
AttributeValue]
-
property
name¶ Attribute name.
- Returns
str
-
abstract property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
property
unit¶ Unit symbol.
- Returns
str
-
property
is_applicable¶ Whether the attribute is applicable to the current record. Setting this to
Falsewill clear any data values on the attribute.- Returns
bool
-
AttributeBinary¶
-
class
AttributeBinary(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None, path: str = None, content_type: str = None)¶ Extended
AttributeValueclass to handleBinaryTypeobjects as attribute data values.Provides access to
BinaryTypeobject methods and properties.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None, path: str = None, content_type: str = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)path – str (Path to the file associated with the attribute)
content_type – str (MIME content/file type; see
BinaryType)
- Returns
None
-
property
url¶ Hosted URL of the file. Returns
Noneif not populated.- Returns
str or None
-
property
mime_file_type¶ MIME (Multipurpose Internet Mail Extensions) file type, if populated.
Some commonly-used extensions are:
image/png - .pngimage/gif - .gifimage/bmp - .bmpimage/tiff - .tif, .tifftext/plain - .txtapplication/zip - .zipapplication/pdf - .pdfapplication/vnd.ms-excel - .xlsapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet - .xlsxapplication/vnd.ms-powerpoint - .pptapplication/vnd.openxmlformats-officedocument.presentationml.presentation - .pptxapplication/msword - .docapplication/vnd.openxmlformats-officedocument.wordprocessingml.document - .docx- Returns
str
-
is_empty() → bool¶ Checks if the
BinaryTypeobject is populated by checking if it contains any binary data.- Returns
bool
-
property
binary_data¶ Returns the file as a bytes object, or None if unset.
- Returns
bytes or None.
-
AttributePicture¶
-
class
AttributePicture(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeBinaryclass for handlingPictureobjects.Provides access to
Picturesave/load methods.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
property
mime_file_type¶ MIME (Multipurpose Internet Mail Extensions) file type, if populated.
Some commonly-used extensions are:
image/png - .pngimage/gif - .gifimage/bmp - .bmpimage/tiff - .tif, .tifftext/plain - .txtapplication/zip - .zipapplication/pdf - .pdfapplication/vnd.ms-excel - .xlsapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet - .xlsxapplication/vnd.ms-powerpoint - .pptapplication/vnd.openxmlformats-officedocument.presentationml.presentation - .pptxapplication/msword - .docapplication/vnd.openxmlformats-officedocument.wordprocessingml.document - .docx- Returns
str
-
save(path: Union[str, pathlib.Path], file_name: Optional[str] = None) → None¶ Wraps the
Picture.save()method.- Parameters
path – Union[str, pathlib.Path] (Path where the image should be saved. Takes the form C:\Users\yourname\Pictures\image.jpg or /home/username/Pictures/image.jpg Deprecated: Path to the folder where the image should be saved. Requires separate file_name parameter. Takes the form C:\Users\yourname\Pictures\ or /home/username/Pictures/)
file_name – str (Name of new image file, with extension)
- Returns
None
-
load(path: Union[str, pathlib.Path], file_name: Optional[str] = None) → None¶ Wraps the
Picture.load()method (populates thePictureobject with the specified image file).- Parameters
path – Union[str, pathlib.Path] (Path to the image file to be imported. Takes the form C:\Users\yourname\Pictures\image.jpg or /home/username/Pictures/image.jpg Deprecated: Path to the folder containing the file to be imported. Takes the form C:\Users\yourname\Pictures\ or /home/username/Pictures/)
file_name – str (File name, with extension)
- Returns
None
-
AttributeFile¶
-
class
AttributeFile(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeBinaryclass to handleFileobjects.Provides access to
Fileobject save/load methods, file name, and description.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
save(path: Optional[Union[str, pathlib.Path]] = None, file_name: Optional[str] = None) → None¶ Wraps the
File.save()method.- Parameters
path – Union[str, pathlib.Path] (Path where the file should be saved. Takes the form C:\Users\yourname\Documents\file.pdf or /home/username/Documents/file.pdf Deprecated: Path to the folder where the file should be saved. Requires separate file_name parameter. Takes the form C:\Users\yourname\Documents\ or /home/username/Documents/)
file_name – str (Deprecated: New file name, with extension)
- Returns
None
-
load(path: Optional[Union[str, pathlib.Path]] = None, file_name: Optional[str] = None) → None¶ Wraps the
File.load()method (populates theFileobject with the specified file).- Parameters
path – Union[str, pathlib.Path] (Path to the file to be imported. Takes the form C:\Users\yourname\Documents\file.pdf or /home/username/Documents/file.pdf Deprecated: Path to the folder containing the file to be imported. Requires separate file_name parameter. Takes the form C:\Users\yourname\Documents\ or /home/username/Documents/)
file_name – str (File name, with extension)
- Returns
None
-
property
file_name¶ Name of the file associated with the
Fileobject. Displayed in MI applications.- Returns
str
-
property
description¶ Description of the file displayed in MI applications.
- Returns
str
-
AttributeDate¶
-
class
AttributeDate(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for date-time attributes.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
value_as_string¶ Return the value of the date attribute as a string.
- Returns
str
-
property
value¶ Return the value of the date attribute as a
datetime.datetimeobject.- Returns
datetime.datetimeobject
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeDiscrete¶
-
class
AttributeDiscrete(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for discrete attributes.Provides access to the list of strings that store the attribute’s data values, and their display order.
-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
order¶ Display order of the discrete data values (strings) in MI Viewer. Order cannot be edited using the MI Scripting Toolkit.
- Returns
List[int]
-
property
is_multivalued¶ Whether this attribute allows multiple values to be set.
- Returns
bool
-
property
possible_discrete_values¶ List of the attribute’s possible discrete data values.
- Returns
List[str]
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeFunctional¶
-
class
AttributeFunctional(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for functional data attributes.Stores and provides access to a data structure, parameters (constraints), specified x-axis, and individual columns and series within the functional data attribute. Series and Gridded data are stored identically in
AttributeFunctionalobjects. However, the two data types are imported into MI differently.The
AttributeFunctionalobject data structure is as follows:[[ 'y min', 'y max', 'constraint 1', 'constraint 2', 'Estimated point?'], [ 0.0, 0.0, 'Test', 0.5, , False, ], [ . , . , . , . , , . , ], [ . , . , . , . , , . , ], [ . , . , . , . , , . , ]]
The allowed data types are
floatfor x-y data,float,strorNonefor constraints, andboolfor flagging whether the data point is estimated or not.The functional data type is used to store graphical data in Granta MI. In MI Viewer there are two ways to view the data: Series and Gridded.
Series data is grouped according to constraints or parameters placed on x-y data. The x-axis is a constraint that is specified on import. Each group (‘Series’) can have a different linestyle.
Gridded data is similar to Series data, except that the x-axis is dynamically chosen within MI Viewer, and all data groups share one linestyle.
-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
value¶ Current value(s) of the attribute;
AttributeFunctional.valuealways returns the current instance of the class and cannot be modified. In this case, the values of the attribute can be accessed through theAttributeFunctional.dataproperty.- Returns
AttributeFunctionalobject
-
update_header_units() → None¶ Updates the unit symbols in the header with the currently selected units.
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
property
unit¶ Unit symbol for the y-axis.
- Returns
str
-
clear() → None¶ Deletes all data stored in the
AttributeFunctionalobject.- Returns
None
-
is_empty() → bool¶ Checks whether any of the data values in the attribute are populated.
- Returns
bool
-
add_point(columns: Dict[str, Union[str, float, int]]) → None¶ Adds a point value to the
AttributeFunctionalobject. Requires a dictionary with keys for the y-value, each constraint, and whether the value is estimated (optional):Dictionary keys for the y-value can be either ‘y’, ‘Y’, the attribute name, or the attribute name with units.
Constraint keys can be either the parameter name, or the parameter name with units.
Constraints are optional and can either be omitted entirely or set to None.
The key for whether the value is estimated must be ‘Estimated?’.
Note
The Estimated? flag can currently only be set for Gridded data, not Series.
- Parameters
columns – Dict[str, Union[str, float, bool, int]]
- Returns
None
-
add_range(columns: Dict[str, Union[str, float, int]]) → None¶ Adds a range value to the
AttributeFunctionalobject. Requires a dictionary with keys for the two y-values (ymin and ymax), each constraint, and whether the value is estimated (optional).Dictionary keys for the y-value can be either ‘ymin’, ‘ymax’, or the attribute name with units and ‘Y min’ or ‘Y max’ appended.
Constraint keys can either be the parameter name, or the parameter name with units.
Constraints are optional and can either be omitted entirely or set to None.
The key for whether the value is estimated must be ‘Estimated?’.
Note
The Estimated? flag can currently only be set for Gridded data, not Series.
- Parameters
columns – dict
- Returns
None
-
property
xaxis_parameter¶ ParameterDefinitionfor the current x-axis parameter of the functional data attribute.- Returns
ParameterDefinitionobject
-
property
column_headers¶ Column headers with units.
- Returns
List[str]
-
property
constraint_column_index¶ Mapping of columns to indices for functional data attributes.
- Returns
Dict[str, int]
-
data_by_column() → Dict[str, List[Any]]¶ Sorts data into columns (lists of values indexed by column name). Changing a dictionary generated using this method does not affect the underlying data, and data in the dictionary will not be refreshed automatically if the underlying data changes.
- Returns
Dict[str, List[Any]]
-
property
parameters¶ Parameters used by the functional data attribute, indexed by name.
- Returns
Dict[str,
ParameterDefinition]
FunctionalSeries¶
-
class
FunctionalSeries(attr_def: AttributeDefintion, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeFunctionalclass for Series functional data attributes.Provides access to Series numbers and linestyles, and a method of generating a
FunctionalGridobject from aFunctionalSeriesobject (generate_grid_version()).-
__init__(attr_def: AttributeDefintion, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
generate_grid_version() → GRANTA_MIScriptingToolkit.granta.mi_attribute_value_classes.FunctionalGrid¶ Creates a Gridded version of the
FunctionalSeriesobject and returns a copy of it.- Returns
FunctionalGridobject
-
property
data_with_series_number¶ Series number for all data points, returned as an additional column with the data values.
- Returns
List[List[Union[str, float, bool, int]]]
-
property
series_linestyles¶ Linestyles for each series (linestyle can be ‘Lines’, ‘Markers’, or ‘Both’).
- Returns
Dict[int, str]
-
FunctionalGrid¶
-
class
FunctionalGrid(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeFunctionalclass for Gridded functional data attributes.Provides access to linestyle and a method of generating a
FunctionalSeriesobject from aFunctionalGridobject (generate_series_version()).-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
generate_series_version() → GRANTA_MIScriptingToolkit.granta.mi_attribute_value_classes.FunctionalSeries¶ Creates a Series version of the
FunctionalGridobject and returns a copy of it.- Returns
FunctionalSeriesobject
-
property
linestyle¶ Linestyle for gridded functional data (gridded data can only have one linestyle: ‘Lines’, ‘Markers’, or ‘Both’).
- Returns
str
-
AttributeHyperlink¶
-
class
AttributeHyperlink(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for hyperlink attributes.Provides access to the
hyperlink_descriptionandhyperlink_displaytext properties.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
url¶ The URL for the hyperlink.
- Returns
str
-
property
hyperlink_display¶ Indicates how the hyperlink should be opened when clicked on in MI applications. Takes one of the following values:
New: Open in a new window or tab.Top: Open in the current window or tab.Content: Open within the current MI application (for example, in a frame or dialog).
- Returns
str
-
property
hyperlink_description¶ Text which displays instead of the URL in MI applications.
- Returns
str
-
is_empty() → bool¶ Checks whether the attribute value is populated.
- Returns
bool
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeInteger¶
-
class
AttributeInteger(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for integer attributes.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeLogical¶
-
class
AttributeLogical(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for logical attributes.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributePoint¶
-
class
AttributePoint(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for point data attributes.Provides access to lists of point values and their parameters. Points can be multi-valued and are represented in the Streamlined API as lists of floats. They can have multiple parameters.
-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
value¶ Current value of the attribute;
AttributePoint.valuealways returns the current instance of the class and cannot be modified. In this case, the values of the attribute can be accessed through theAttributePoint.pointsandAttributePoint.parametersproperties.- Returns
AttributePointobject
-
is_empty() → bool¶ Checks whether the attribute value is populated.
AttributePointobjects are empty if the length of the listAttributePoint.points== 0.- Returns
bool
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
property
parameter_definitions¶ Parameter definitions for the parameters associated with the point attribute, indexed by name.
- Returns
Dict[str,
ParameterDefinition]
-
property
parameters¶ Parameters associated with each point in the list
AttributePoint.points. Each point in the list has a dictionary, indexed by parameter name and containing the parameter value for that point.- Returns
List[Dict[str, Union[float, str]]]
-
property
points¶ Point values associated with this attribute.
- Returns
List[float]
-
AttributeRange¶
-
class
AttributeRange(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for range data attributes. Range attribute values are represented in the MI Scripting Toolkit by dictionaries of the form{'low': float, 'high': float}, and should be entered in this form when editing them.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeTabular¶
-
class
AttributeTabular(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for tabular data attributes.Provides access to tabular data and its properties, such as linking attribute and table, and methods for adding, deleting or swapping rows.
-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
property
columns¶ List of columns in the tabular data.
- Returns
List[str]
-
property
linked_columns¶ Whether each column is linked or not.
- Returns
List[bool]
-
property
value¶ Current value of the attribute;
AttributeTabular.valuealways returns the current instance of the class and cannot be modified. In this case, the values of the attribute can be accessed through theAttributeTabular.tabularproperty.- Returns
AttributeTabularobject
-
property
linking_table¶ Tableobject which the linking attribute belongs to. ReturnsNonefor purely local tabular data.- Returns
Tableobject or None
-
property
linking_attribute¶ Linking attribute, a short text-type attribute used to link rows in the tabular data attribute to records. Returns
Nonefor purely local tabular data.- Returns
AttributeDefinitionobject or None
-
property
data¶ Raw data for the attribute (list of data values per column).
-
property
units¶ TabularUnitsobject associated with thisAttributeTabularobject.- Returns
TabularUnitsobject
-
show() → None¶ Displays the data as an ascii-art style table.
- Returns
None
-
load() → None¶ Loads linked tabular data into the class.
- Returns
None
-
property
linked_records¶ The records linked to each row, indexed by the linking value of each row at loading.
These links are calculated in Granta MI, and therefore cannot be edited by the user. The dictionary is unaffected by local changes to the tabular data, and the data must be re-imported to reflect local changes.
- Returns
Dict[str, List[
Record]]
-
is_empty() → bool¶ Checks whether the attribute value is populated.
- Returns
bool
-
property
shape¶ Number of columns by number of rows.
- Returns
Tuple[int, int]
-
add_row(linking_value: str = '<linking value not chosen>') → None¶ Inserts a new unpopulated row, and sets the linking value for that row if one is provided.
- Parameters
linking_value – str
- Returns
None
-
delete_row(index: int) → None¶ Removes the row at the specified index.
- Example
delete_row(0)deletes the first row.- Parameters
index – int
- Returns
None
-
swap_rows(row1: int, row2: int) → None¶ Change the positions of two rows with indices
row1androw2.- Example
my_data.swap_rows(0, 4)swaps the first and fifth rows in the Tabular data structuremy_data.- Parameters
row1 – int
row2 – int
- Returns
None
-
AttributeShortText¶
-
class
AttributeShortText(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for short text attributes.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeLongText¶
-
class
AttributeLongText(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for long text attributes.-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
AttributeUnsupported¶
-
class
AttributeUnsupported(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None)¶ Extended
AttributeValueclass for attributes with unsupported data types.Note that unsupported attribute data will not yield any information regarding its value in that record. However, some meta-data is still available through this class (such as the attribute’s name and data type). An unsupported attribute value remains unpopulated, and these objects cannot be edited.
-
__init__(attr_def: AttributeDefinition, _gdl_av: GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue, _mi: Session, metas: List[GRANTA_MIScriptingToolkit.AttributeValue.AttributeValue] = None) → None¶ - Parameters
attr_def –
AttributeDefinitionobject_gdl_av – Foundation API
GRANTA_MIScriptingToolkit.AttributeValueclass for this attribute_mi –
Sessionobjectmetas – List[
GRANTA_MIScriptingToolkit.AttributeValue] (Foundation APIGRANTA_MIScriptingToolkit.AttributeValueclass for each meta-attribute of this attribute)
- Returns
None
-
property
is_applicable¶ Whether the attribute is applicable to the current record. Setting this to
Falsewill clear any data values on the attribute.- Returns
bool
-
is_empty() → bool¶ Checks whether the attribute value is populated.
- Returns
bool
-
property
type¶ Attribute data type, as a four-character string. Possible attribute types are:
POIN = point,RNGE = range,FUNC = float functional,INPT = integer,LOGI = logical,DISC = discrete,STXT = short text,LTXT = long text,DTTM = date time,HLNK = hyperlink,PICT = picture,FILE = file,DSFN = discrete functional,MAFN = maths functional (equations and logic),TABL = tabular.DSFN and MAFN are not supported by the MI Scripting Toolkit, and appear as UNSUPPORTED DATA TYPE.
- Returns
str
-
PseudoAttributeValue¶
-
class
PseudoAttributeValue(name: str)¶ Stores and provides access to pseudo-attribute data values.
-
__init__(name: str) → None¶ - Parameters
name – str
- Returns
None
-
property
value¶ Current value of the pseudo-attribute. Cannot be modified. Modification of pseudo-attributes must be done through the
Recordobject propertiescolor,short_nameandname.- Returns
Union[List[str], str, int, bool, Set[str],
datetime.datetime]
-
property
id¶ Attribute identifier (this is always 0 for pseudo-attributes).
- Returns
int
-
is_empty() → bool¶ Checks whether the pseudo-attribute value is populated or not.
- Returns
bool
-
property
name¶ Name of the pseudo-attribute.
- Returns
str
-
property
type¶ Data type of the pseudo-attribute value (four-character string).
- Returns
str
-
Sub-attribute level¶
Classes that are used by attribute objects but are not attributes themselves.
ParameterDefinition¶
-
class
ParameterDefinition(_gdl_param: GRANTA_MIScriptingToolkit.ParameterDetail.ParameterDetail, _mi: Session, unit_conversions: Dict[str, str] = None)¶ -
__init__(_gdl_param: GRANTA_MIScriptingToolkit.ParameterDetail.ParameterDetail, _mi: Session, unit_conversions: Dict[str, str] = None) → None¶ Streamlined API wrapper for the Foundation API
GRANTA_MIScriptingToolkit.ParameterDetailclass. Provides access to parameter properties such as revision history, default and possible values, and units.Note
Do not create new instances of this class; it represents a pre-existing database structure.
- Parameters
_gdl_param – Foundation API
GRANTA_MIScriptingToolkit.ParameterDetailclass_mi –
Sessionobjectunit_conversions – Dict[str, str] (maps database units to the current unit system’s units)
- Returns
None
-
property
value_for_exporters¶ Value on the
ParameterDefinitioninstance for use in any exporters the parameter is passed to. Can be set by the user.- Returns
Union[str, float]
-
property
name¶ Parameter name.
- Returns
str
-
property
parent_attribute¶ Name of the parent attribute.
- Returns
str
-
property
parent_record¶ Long name of the parent record.
- Returns
str
-
property
history¶ Revision history of the parameter, as an
ObjectHistoryobject.- Returns
ObjectHistoryobject
-
property
default_value¶ Default value of the parameter (all parameters must have a default value).
- Returns
str or float
-
property
history_of_default¶ Revision history of the parameter’s default value, as an
ObjectHistoryobject.- Returns
ObjectHistoryobject
-
property
interpolation_type¶ The interpolation type for the parameter (‘None’, ‘Linear’, or ‘Cubic Spline’).
- Returns
str
-
property
order¶ Order in which the parameter is stored in the attribute (column number). This is relevant for some interpolation methods, and determines the display order in MI Viewer.
- Returns
int
-
property
axis_scale_type¶ Axis scale type for the parameter (‘Linear’ or ‘Logarithmic’).
- Returns
str
-
property
unit¶ Unit symbol for the parameter.
- Returns
str
-
reset_unit() → None¶ Resets the unit back to its original value (the unit in use when the parameter was initially exported). Does not make a call to the Service Layer.
- Returns
None
-
property
values¶ List of all possible values the parameter can take.
- Returns
List[Union[str, float]]
-
property
values_histories¶ Revision histories of each possible value of a parameter, as a list of
ObjectHistoryobjects.- Returns
List[
ObjectHistory]
-
property
type¶ Parameter type (‘Unrestricted’ numeric, ‘Restricted’ numeric, or ‘Discrete’).
- Returns
str
-
property
id¶ Parameter identifier.
- Returns
int
-
ObjectHistory¶
-
class
ObjectHistory(_gdl_revision_info: GRANTA_MIScriptingToolkit.RevisionInfo.RevisionInfo)¶ Provides access to the revision history of an MI database element. Most structures, values and items have recorded histories in MI, for example tabular columns and functional data parameter values.
Note
Do not create new instances of this class; it represents a pre-existing database structure.
-
__init__(_gdl_revision_info: GRANTA_MIScriptingToolkit.RevisionInfo.RevisionInfo) → None¶ - Parameters
_gdl_revision_info – Foundation API
GRANTA_MIScriptingToolkit.RevisionInfoclass- Returns
None
-
property
last_modified_date¶ Date the database element was last modified.
- Returns
str
-
property
date_created¶ Date the database element was created.
- Returns
str
-
property
last_modified_by¶ The username of the last user to modify the database element.
- Returns
str
-
property
created_by¶ The username of the user who created the database element.
- Returns
str
-
SearchCriterion¶
-
class
SearchCriterion(attribute: Union[AttributeDefinition], operator: str, value: Union[float, int, str, List[str], Tuple[Union[str, datetime.datetime], Union[str, datetime.datetime]], List[float]] = None, column_name: str = None)¶ Defines a single criterion for use in a search. The criterion can be as simple as the presence of the specified attribute, or as complex as the data in a specified column of the tabular attribute being greater than a specifed value. The search will use the same units as the
AttributeDefinition.-
__init__(attribute: Union[AttributeDefinition], operator: str, value: Union[float, int, str, List[str], Tuple[Union[str, datetime.datetime], Union[str, datetime.datetime]], List[float]] = None, column_name: str = None) → None¶ - Parameters
attribute –
AttributeDefinitionobjectoperator – str
value – Input type corresponding to your
AttributeDefinitioncolumn_name – str
- Returns
None
-
property
attribute¶ AttributeDefinitionfor the attribute used in this search criterion.- Returns
AttributeDefinitionobject
-
property
operation¶ Operator used in this criterion, if provided.
- Example
‘EXISTS’ or ‘CONTAINS’
- Returns
str
-
Hyperlink¶
-
class
Hyperlink(url: Optional[str] = None, hyperlink_display: str = 'New', hyperlink_description: str = '')¶ Represents hyperlinks in MI. Can be used directly in tabular data, or within
AttributeHyperlinkobjects for standalone hyperlink attributes.-
__init__(url: Optional[str] = None, hyperlink_display: str = 'New', hyperlink_description: str = '') → None¶ - Parameters
url – str
hyperlink_display – str (Hyperlink display mode:
New,Content,Top)hyperlink_description – str (Hyperlink description, displayed in MI applications)
- Returns
None
-
property
hyperlink_display¶ Indicates how the hyperlink should be opened when clicked on in MI applications. Takes one of the following values:
New: Open in a new window or tab.Top: Open in the current window or tab.Content: Open within the current MI application (for example, in a frame or dialog).
- Returns
str
-
BinaryType¶
-
class
BinaryType¶ Stores and provides access to Pictures and Files, and associated metadata. Pictures and files can appear in Granta MI as data (for example, in a tabular data column), or as an attribute value.
The
BinaryTypeobject wraps files and images for inclusion in the corresponding MI Scripting Toolkit classes.-
__init__() → None¶ - Returns
None
-
property
value¶ Current value of the attribute;
BinaryType.valuealways returns the current instance of the class and cannot be modified. In this case, the values are the file or picture, which can be accessed through theloadandsavemethods of theFileorPictureclasses.- Returns
BinaryTypeobject
-
property
url¶ URL used to access the file. Returns
Noneif the URL is unpopulated, or the file has not been imported yet.- Returns
str or None
-
property
mime_file_type¶ MIME (Multipurpose Internet Mail Extensions) file type, if populated.
Some commonly-used extensions are:
image/png - .pngimage/gif - .gifimage/bmp - .bmpimage/tiff - .tif, .tifftext/plain - .txtapplication/zip - .zipapplication/pdf - .pdfapplication/vnd.ms-excel - .xlsapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet - .xlsxapplication/vnd.ms-powerpoint - .pptapplication/vnd.openxmlformats-officedocument.presentationml.presentation - .pptxapplication/msword - .docapplication/vnd.openxmlformats-officedocument.wordprocessingml.document - .docx- Returns
str
-
is_empty() → bool¶ Checks whether the
BinaryTypeobject is populated by checking whether there is binary data in the object.- Returns
bool
-
Picture¶
-
class
Picture(name: Optional[str] = None, path: Optional[Union[str, pathlib.Path]] = None, load: bool = True)¶ Extended
BinaryTypeclass for Pictures in MI.Provides access to image data through save/load methods. When the
pathto the image file is specified andloadisTrue, the Picture object is populated automatically.In Granta MI, Pictures do not have file names, and are instead stored as binary data that can be accessed by viewing the image in an MI application.
-
__init__(name: Optional[str] = None, path: Optional[Union[str, pathlib.Path]] = None, load: bool = True) → None¶ - Parameters
name – str (Picture name, used for locally saving and loading)
path –
Union[str, pathlib.Path] (Path to the image file to be imported. Takes the form C:\Users\yourname\Pictures\image.jpg or /home/username/Pictures/image.jpg
Deprecated: Path to the folder containing the file to be imported. Takes the form C:\Users\yourname\Pictures\ or /home/username/Pictures/)
load – bool
- Returns
None
-
load(path: Union[str, pathlib.Path], file_name: Optional[str] = None) → None¶ Populates the Picture object with the image
file_namelocated onpath. Relative paths accepted.- Parameters
path –
Union[str, pathlib.Path] (Path to the image file to be imported. Takes the form C:\Users\yourname\Pictures\image.jpg or /home/username/Pictures/image.jpg
Deprecated: Path to the folder containing the file to be imported. Takes the form C:\Users\yourname\Pictures\ or /home/username/Pictures/)
file_name – str (Image file name, with file extension)
- Returns
None
-
save(path: Union[str, pathlib.Path], file_name: Optional[str] = None) → None¶ Saves a Picture object to file location
path. Relative paths accepted.Deprecated: Saves a Picture object to folder location
pathwith namefile_name. Iffile_nameis not specified, the extension will be inferred from the mime_type and the image filename will be<attribute name>.extension.- Parameters
path –
Union[str, pathlib.Path] (Path where the image should be saved. Takes the form C:\Users\yourname\Pictures\image.jpg or /home/username/Pictures/image.jpg
Deprecated: Path to the folder where the image should be saved. Requires separate
file_nameparameter. Takes the form C:\Users\yourname\Pictures\ or /home/username/Pictures/)file_name – str (Image file name, with file extension)
- Returns
None
-
property
binary_data¶ The binary data for the image. Binary data can be set with a bytes object or file buffer.
- Returns
bytes or None.
-
File¶
-
class
File(file_name: Optional[str] = None, path: Optional[Union[str, pathlib.Path]] = None, load: bool = True)¶ Extended
BinaryTypeclass for Files in MI.Stores and provides access to file names and descriptions displayed in MI applications.
file_namemust be defined on creation of the File objectdescriptiondefaults to thefile_nameon creation, but can be edited afterwards
When
pathis specified andloadisTrue, the file is loaded automatically into the File object. IfloadisFalse, no path will be stored even if one is specified.-
__init__(file_name: Optional[str] = None, path: Optional[Union[str, pathlib.Path]] = None, load: bool = True) → None¶ - Parameters
file_name – str
path –
Union[str, pathlib.Path] (Path to the file to be imported. Takes the form C:\Users\yourname\Documents\file.pdf or /home/username/Documents/file.pdf
Deprecated: Path to the folder containing the file to be imported. Takes the form C:\Users\yourname\Documents\ or /home/username/Documents/)
load – bool
- Returns
None
-
save(path: Optional[Union[str, pathlib.Path]] = None, file_name: Optional[str] = None) → None¶ Saves a File object to file location
path. Relative paths accepted.Deprecated: Saves a File object to folder location
pathwith namefile_name. Iffile_nameis not specified, the file will be saved as<attribute name>, without an extension.- Parameters
path –
Union[str, pathlib.Path] (Path where the file should be saved. Takes the form C:\Users\yourname\Documents\file.pdf or /home/username/Documents/file.pdf
Deprecated: Path to the folder where the file should be saved. Requires separate
file_nameparameter. Takes the form C:\Users\yourname\Documents\ or /home/username/Documents/)file_name – str (Deprecated: File name, with extension)
- Returns
None
-
load(path: Optional[Union[str, pathlib.Path]] = None, file_name: Optional[str] = None) → None¶ Populates the File object with the file located by
path. Relative paths accepted.Deprecated: Populates the File object with the file named
file_nameat locationpath.- Parameters
path –
Union[str, pathlib.Path] (Path to the file to be imported. Takes the form C:\Users\yourname\Documents\file.pdf or /home/username/Documents/file.pdf
Deprecated: Path to the folder containing the file to be imported. Takes the form C:\Users\yourname\Documents\ or /home/username/Documents/)
file_name – str (File name, with extension)
- Returns
None
-
property
file_name¶ Name of the file.
- Returns
str
-
property
binary_data¶ The binary data for the file. Binary data can be set with a bytes object or file buffer.
- Returns
bytes or None.
TabularUnits¶
-
class
TabularUnits(units: List[List[str]], default_units: List[str])¶ Stores and provides access to the units for a parent
AttributeTabularobject, in the same tabular format as the data.Units can be set on a cell-by-cell basis.
TabularUnitsis populated when the parentAttributeTabularobject is loaded.Any changes made to the underlying
AttributeTabular.data()property must also be made to the correspondingTabularUnits.data()and vice versa, or your changes will not import successfully and may be lost (AttributeTabular.add_row()andAttributeTabular.delete_row()make the necessary changes to both objects, but you must duplicate other changes todatayourself).-
__init__(units: List[List[str]], default_units: List[str]) → None¶ - Parameters
units – List[List[str]]
default_units – List[str]
- Returns
None
-
property
database_units¶ The default units, as a list corresponding to each column.
- Returns
List[str]
-
property
data¶ Data values (unit symbol strings) stored in the
TabularUnitsobject.- Returns
List[List[str]]
-
Asynchronous Job Queue¶
These classes allow users to interact with the MI Asynchronous Job Queue, submitting Excel and Text importer jobs and monitoring their progress. This functionality relies on the external library requests.
AsyncJobQueue¶
-
class
AsyncJobQueue(mi_session: Session, queue_url: str = None, verify_ssl: bool = True, ssl_ca_bundle: Union[str, pathlib.Path] = None)¶ -
__init__(mi_session: Session, queue_url: str = None, verify_ssl: bool = True, ssl_ca_bundle: Union[str, pathlib.Path] = None) → None¶ Represents an instance of the Async Job Queue manager. Allows management of the job queue and submission of jobs.
- Parameters
mi_session –
Sessionobjectqueue_url – str (Job queue URL, if different from Service Layer URL; extracted from
mi_sessionif not specified)verify_ssl – bool (Whether to verify SSL connections to remote server,
Trueby default)ssl_ca_bundle – Union[str, pathlib.Path] (optional) (Path to custom CA bundle (.crt or .pem); use if your MI installation has a self-signed certificate which is not trusted by the requests module)
-
property
processing_configuration¶ Gets the current job queue configuration information from the server.
- Returns
dict
-
property
is_admin_user¶ - Checks whether the current user is a Job Queue admin (returns
Trueif the user is an admin). Admin users can promote jobs to the top of the queue and interact with other users’ jobs.
- Returns
bool
- Checks whether the current user is a Job Queue admin (returns
-
property
can_write_job¶ Checks whether the current user can create new jobs (returns
Trueif they can).- Returns
bool
-
property
num_jobs¶ Returns the number of jobs in the Job Queue, including completed and failed jobs.
- Returns
int
-
property
jobs¶ Returns a list of all jobs visible on the server. Running or pending jobs are sorted according to their position in the queue, completed or failed jobs are returned last.
- Returns
List[
AsyncJob]
-
jobs_where(name: Optional[str] = None, type_: Optional[str] = None, description: Optional[str] = None, submitter_name: Optional[str] = None, status: Optional[str] = None) → List[GRANTA_MIScriptingToolkit.granta.mi_async_jobs.AsyncJob]¶ Returns a list of jobs on the server matching a query. Running or queued jobs are sorted according to their position in the queue, completed or failed jobs are returned last.
- Parameters
name – str (Job name must contain)
type – str (
DataImportJob,TextImportJob,ExcelImportJob,ExcelExportJob)description – str (Job description must contain)
submitter_name – str (Name of user who submitted the job must equal)
status – str (
Pending,Running,Succeeded,Failed,Cancelled,Corrupted)
- Returns
List[
AsyncJob]
-
get_job_by_id(job_id: str) → GRANTA_MIScriptingToolkit.granta.mi_async_jobs.AsyncJob¶ Gets the job with unique identifier
job_idfrom the server.- Parameters
job_id – str
- Returns
AsyncJobobject
-
delete_jobs(jobs: List[GRANTA_MIScriptingToolkit.granta.mi_async_jobs.AsyncJob]) → None¶ Deletes jobs from the server.
- Parameters
jobs – List[
AsyncJob]- Returns
None
-
create_import_job_and_wait(job_request: GRANTA_MIScriptingToolkit.granta.mi_async_jobs.ImportJobRequest) → GRANTA_MIScriptingToolkit.granta.mi_async_jobs.AsyncJob¶ Creates an import job from an
ImportJobRequestobject. Uploads files and submits a job request to the Job Queue. Blocks execution until the job has either completed or failed, then returns the finishedAsyncJobobject.- Parameters
job_request –
ImportJobRequestobject- Returns
AsyncJobobject
-
create_import_job(job_request: GRANTA_MIScriptingToolkit.granta.mi_async_jobs.ImportJobRequest) → GRANTA_MIScriptingToolkit.granta.mi_async_jobs.AsyncJob¶ Creates an import job from an
ImportJobRequestobject. Uploads files and submits a job request to the Job Queue, then returns an in-progressAsyncJobobject for later use.- Parameters
job_request –
ImportJobRequestobject- Returns
AsyncJobobject
-
ImportJobRequest¶
-
class
ImportJobRequest(name: str, description: str, scheduled_execution_date: Optional[datetime.datetime] = None)¶ Abstract base class representing an import job request. Each subclass represents a specific import type and may override some steps of the import process. They also add additional file types and properties as required.
-
abstract
__init__(name: str, description: str, scheduled_execution_date: Optional[datetime.datetime] = None) → None¶ - Parameters
name – str (Display name of the job)
description – str
scheduled_execution_date – datetime.datetime (Earliest date and time job should be executed)
- Returns
None
-
get_job_for_import() → GRANTA_MIScriptingToolkit.granta.AsyncJobs.models.job_request.JobRequest¶ Creates a
JobRequestobject ready for import. Should be called after uploading files to the service.- Returns
JobRequestobject
-
abstract
check_valid_for_import() → None¶ Verifies that the import job can run. Raises a
ValueErrorwith a specific error message if not enough files have been provided for the import to successfully complete.- Returns
None
-
abstract
ExcelImportJobRequest¶
-
class
ExcelImportJobRequest(name: str, description: str, scheduled_execution_date: Optional[datetime.datetime] = None, data_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, template_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, combined_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, attachment_files: Optional[List[Union[str, pathlib.Path, IO]]] = None)¶ Represents an Excel import job request. Supports either combined imports (with template and data in the same file), or separate data and template imports.
-
__init__(name: str, description: str, scheduled_execution_date: Optional[datetime.datetime] = None, data_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, template_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, combined_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, attachment_files: Optional[List[Union[str, pathlib.Path, IO]]] = None)¶ - Parameters
name – str (Display name of the job)
description – str
scheduled_execution_date – datetime.datetime (Earliest date and time job should be executed)
data_files – List[Union[str, pathlib.Path, IO]] (Excel files containing data)
template_files – List[Union[str, pathlib.Path, IO]] (Excel template files)
combined_files – List[Union[str, pathlib.Path, IO]] (Excel files containing both template and data)
attachment_files – List[Union[str, pathlib.Path, IO]] (Any other files referenced in data or combined Excel files)
-
check_valid_for_import()¶ Verifies that the import job can run. Raises a
ValueErrorwith a specific error message if not enough files have been provided for the import to successfully complete.- Returns
None
-
TextImportJobRequest¶
-
class
TextImportJobRequest(name: str, description: str, scheduled_execution_date: Optional[datetime.datetime] = None, data_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, template_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, attachment_files: Optional[List[Union[str, pathlib.Path, IO]]] = None)¶ Represents a Text import job request. Requires a template file and one or more data files.
-
__init__(name: str, description: str, scheduled_execution_date: Optional[datetime.datetime] = None, data_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, template_files: Optional[List[Union[str, pathlib.Path, IO]]] = None, attachment_files: Optional[List[Union[str, pathlib.Path, IO]]] = None)¶ - Parameters
name – str (Display name of the job)
description – str
scheduled_execution_date – datetime.datetime (Earliest date and time job should be executed)
data_files – List[Union[str, pathlib.Path, IO]] (Text files containing data)
template_files – List[Union[str, pathlib.Path, IO]] (Text importer template file)
attachment_files – List[Union[str, pathlib.Path, IO]] (Any other files referenced in data files)
-
check_valid_for_import()¶ Verifies that the import job can run. Raises a
ValueErrorwith a specific error message if not enough files have been provided for the import to successfully complete.- Returns
None
-
AsyncJob¶
-
class
AsyncJob¶ -
property
id¶ Unique job identifier in GUID form. Recommended way to refer to individual jobs.
- Returns
str
-
property
name¶ Display name of the job (not unique).
- Returns
str
-
update_name(value: str) → None¶ Updates the display name of the job on the server.
- Parameters
value – str
- Returns
None
-
property
description¶ Description of the job (displayed in MI).
- Returns
str
-
update_description(value: str) → None¶ Updates the job description on the server.
- Parameters
value – str
- Returns
None
-
property
status¶ Job status on the server:
Pending: Job is in the queueRunning: Job is currently executingSucceeded: Job has completed (does not guarantee that no errors occurred)Failed: Job could not completeCancelled: Job was cancelled by the userCorrupted: Something went wrong on the server
If the job associated with the
AsyncJobobject was deleted, returnsDeleted.- Returns
str
-
property
type¶ Job type, as known to the server.
- Returns
str
-
property
position¶ Position in the Job Queue. Returns an
intif the job is pending, otherwise returnsNone.- Returns
int or None
-
move_to_top() → None¶ Promotes the job to the top of the Job Queue. User must have MI_ADMIN permission.
- Returns
None
-
property
submitter_information¶ Information about the job submission. Returns the
usernameof the submitter,date_timeof submission, and therolesto which the submitter belongs as a dictionary indexed by name.- Returns
dict
-
property
completion_date_time¶ Date and time of job completion. Returns
Noneif job is pending.- Returns
datetime.datetime or None
-
property
execution_date_time¶ Date and time of job execution. Returns
Noneif job is pending.- Returns
datetime.datetime or None
-
property
scheduled_execution_date_time¶ Date and time of job execution, if scheduled.
- Returns
datetime.datetime or None
-
update_scheduled_execution_date_time(value: datetime.datetime) → None¶ Updates the scheduled execution time on the server.
- Parameters
value – datetime.datetime
- Returns
None
-
property
output_information¶ Provides additional information such as record placement or verbose logging, if the job type supports it.
- Returns
Any job-specific outputs
-
property
output_file_names¶ List of file names produced by the job, for example log files.
- Returns
List[str]
-
download_file(remote_file_name: str, file_path: Union[str, pathlib.Path]) → None¶ Downloads an output file from the server by name and saves it to a specified location.
- Parameters
remote_file_name – str (File name provided by
output_file_names())file_path –
pathlib.Pathor str (Path where the file should be saved; if a file name isn’t specified, the name provided byoutput_file_names()is used)
- Returns
None
-
get_file_content(remote_file_name: str) → Union[bytes, str, dict]¶ Downloads an output file from the server by name, and returns the file contents.
- Parameters
remote_file_name – str (File name provided by
output_file_names())- Returns
Union[bytes, str, dict]
-
update() → None¶ Updates the job from the server.
- Returns
None
-
property
Helper Functions¶
connect¶
-
connect(service_layer_url: str, user_name: str = None, password: str = None, domain: str = None, autologon: bool = None, timeout: int = 300000, existing_session: GRANTA_MIScriptingToolkit.GRANTA_MISession.GRANTA_MISession = None, oidc: bool = False, auth_token: str = None, refresh_token: str = None, use_stored_token: bool = False) → Session¶ Establishes a connection to the Granta MI server and returns a
Sessionobject.An existing session may be specified.
- Parameters
service_layer_url – str
user_name – str
password – str
domain – str
autologon – bool
timeout – int (maximum time to wait for a response, in milliseconds)
existing_session – Foundation API
GRANTA_MIScriptingToolkit.GRANTA_MISessionclassoidc – bool
auth_token – str
refresh_token – str
use_stored_token – bool
- Returns
Sessionobject
extract_parameter_value¶
-
extract_parameter_value(param_value: GRANTA_MIScriptingToolkit.ParameterValue.ParameterValue) → Union[float, str]¶ Returns the data value stored in a Foundation API
GRANTA_MIScriptingToolkit.ParameterValueobject.- Parameters
param_value – Foundation API
GRANTA_MIScriptingToolkit.ParameterValueclass- Returns
str or float
get_foundation_logger¶
-
get_foundation_logger() → logging.Logger¶ Return the logger used by the Foundation API (has the name “GDL”).
- Returns
Loggerclass
log_to_file_in_local_app_data¶
-
log_to_file_in_local_app_data(path='Granta Design\\MIScriptingToolkit\\Python') → None¶ Set up the built-in Granta logger to log to a file in the user’s local app data directory (%LOCALAPPDATA% on Windows, ‘~/.appdata/’ on Linux). The log file name is MIScriptingToolkitForPython_YYYY.MM.DD.log and you can specify the filepath. The default filepath is Granta Design/MIScriptingToolkit/Python.
- Parameters
path – str
- Returns
None