Custom Kernel#

The customKernel module augments the mdb, odb, and session objects with an object called customData. The customData object can contain custom data that you created using standard Python objects; for example, dictionaries, strings, numbers, and classes. In addition, the customData object can contain objects that you created using the classes described in this section.

All objects that you create under the mdb.customData and odb[odbName].customData object will be stored in the Abaqus/CAE model and output database, respectively, when you save the database; all objects that you create under the session.customData object will be lost when you exit Abaqus/CAE.

The customData object is an instance of the RepositorySupport class; for more information, see RepositorySupport. The classes described in this section register with the GUI infrastructure when you create the class. As a result, if you write a custom GUI script, you can query these objects from the GUI, and you can also be notified when the contents of these objects change so you can update the GUI accordingly. For more information, see Extending the Abaqus Scripting Interface and Accessing kernel data from the GUI.

Object features#

CommandRegister#

class CommandRegister[source]#

This class allows you to derive a general class that can be queried from the GUI and is capable of notifying the GUI when the contents of the class change.

Note

This object can be accessed by:

import customKernel

Public Methods:

__init__()

This class allows you to derive a general class that can be queried from the GUI and is capable of notifying the GUI when the contents of the class change.


RegisteredDictionary#

class RegisteredDictionary[source]#

This class allows you to create a dictionary that can be queried from the GUI and is capable of notifying the GUI when the contents of the dictionary change. The keys to a RegisteredDictionary must be either strings or integers. The RegisteredDictionary object is derived from the CommandRegister object.

Note

This object can be accessed by:

import customKernel

Public Methods:

__init__()

This method creates a RegisteredDictionary object.

Methods()

The RegisteredDictionary object supports the same methods as a Python dictionary.

changeKey(fromName, toName)

This method changes the name of a key in the dictionary.

Inherited from CommandRegister

__init__()

This method creates a RegisteredDictionary object.

Inherited from dict

__repr__()

Return repr(self).

__getattribute__(name, /)

Return getattr(self, name).

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.

__iter__()

Implement iter(self).

__init__()

This method creates a RegisteredDictionary object.

__or__(value, /)

Return self|value.

__ror__(value, /)

Return value|self.

__ior__(value, /)

Return self|=value.

__len__()

Return len(self).

__getitem__

x.__getitem__(y) <==> x[y]

__setitem__(key, value, /)

Set self[key] to value.

__delitem__(key, /)

Delete self[key].

__contains__(key, /)

True if the dictionary has the specified key, else False.

__sizeof__()

get(key[, default])

Return the value for key if key is in the dictionary, else default.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

keys()

items()

values()

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

clear()

copy()

__reversed__()

Return a reverse iterator over the dict keys.

__class_getitem__

See PEP 585


Methods()[source]#

The RegisteredDictionary object supports the same methods as a Python dictionary. In addition, the RegisteredDictionary object supports the changeKey method.

changeKey(fromName, toName)[source]#

This method changes the name of a key in the dictionary.

Parameters:
  • fromName (str) – A String or an integer specifying the name of the key to be changed.

  • toName (str) – A String or an integer specifying the new name for the key.

RegisteredList#

class RegisteredList[source]#

This class allows you to create a list that can be queried from the GUI and is capable of notifying the GUI when the contents of the list change. The RegisteredList object is derived from the CommandRegister object.

Note

This object can be accessed by:

import customKernel

Public Methods:

__init__()

This method creates a RegisteredList object.

Methods()

The RegisteredList object supports the same methods as a standard Python list object.

Inherited from CommandRegister

__init__()

This method creates a RegisteredList object.

Inherited from list

__repr__()

Return repr(self).

__getattribute__(name, /)

Return getattr(self, name).

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.

__iter__()

Implement iter(self).

__init__()

This method creates a RegisteredList object.

__len__()

Return len(self).

__getitem__

x.__getitem__(y) <==> x[y]

__setitem__(key, value, /)

Set self[key] to value.

__delitem__(key, /)

Delete self[key].

__add__(value, /)

Return self+value.

__mul__(value, /)

Return self*value.

__rmul__(value, /)

Return value*self.

__contains__(key, /)

Return key in self.

__iadd__(value, /)

Implement self+=value.

__imul__(value, /)

Implement self*=value.

__reversed__()

Return a reverse iterator over the list.

__sizeof__()

Return the size of the list in memory, in bytes.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

append(object, /)

Append object to the end of the list.

insert(index, object, /)

Insert object before index.

extend(iterable, /)

Extend list by appending elements from the iterable.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

__class_getitem__

See PEP 585


Methods()[source]#

The RegisteredList object supports the same methods as a standard Python list object.

RegisteredTuple#

class RegisteredTuple(tuple)[source]#

This class allows you to create a tuple that can be queried from the GUI and is capable of notifying the GUI when the contents of any of the tuple’s members change. The RegisteredTuple object is derived from the CommandRegister object.

Note

This object can be accessed by:

import customKernel

Public Methods:

__init__(tuple)

This method creates a RegisteredTuple object.

Methods()

The RegisteredTuple object supports the same methods as a standard Python list object.

Inherited from CommandRegister

__init__(tuple)

This method creates a RegisteredTuple object.

Inherited from tuple

__repr__()

Return repr(self).

__hash__()

Return hash(self).

__getattribute__(name, /)

Return getattr(self, name).

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.

__iter__()

Implement iter(self).

__len__()

Return len(self).

__getitem__(key, /)

Return self[key].

__add__(value, /)

Return self+value.

__mul__(value, /)

Return self*value.

__rmul__(value, /)

Return value*self.

__contains__(key, /)

Return key in self.

__getnewargs__()

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

__class_getitem__

See PEP 585


Methods()[source]#

The RegisteredTuple object supports the same methods as a standard Python list object.

RepositorySupport#

class RepositorySupport[source]#

The class from which you can derive your own classes that are designed to contain custom repositories. Instances of this class can be queried from the GUI and are capable of notifying the GUI when the contents of the instance change. The RepositorySupport object is derived from the CommandRegister object.

Note

This object can be accessed by:

import customKernel
mdb.customData
session.customData
session.odbs[name].customData
Repository(name, constructors)[source]#

This method installs a repository on the class. The repository is an instance of a RegisteredDictionary class. Refer to RegisteredDictionary for details on its methods. The objects stored in the repository are assumed to have an attribute called name that stores the key used to access the object in the repository. The name attribute will be modified by the changeKey method.

Parameters:
  • name (str) – A String specifying the name of the repository.

  • constructors (Union[Callable, List[Callable]]) – A constructor or sequence of constructors specifying which classes will store their instances in the repository.