Repositories

Repositories are containers that store a particular type of object; for example, the steps repository contains all the steps defined in the model. A repository maps to a set of information and is similar to a Python dictionary; for more information, see Using dictionaries. However, only a constructor can add an object to a repository. In addition, all the objects in a repository are of the same type. For example, the following repository contains all the models in the model database:

 mdb.models
In turn, the following repository contains all the parts in the model Model-1:
 mdb.models['Model-1'].parts

As with dictionaries, you can refer to an object in a repository using its key. The key is typically the name you provided in the constructor command when the object was created. For example, the Viewport constructor creates a new Viewport object in the viewports repository.

session.Viewport(name='Side view',
    origin = (10,10), width=50, height=50)

The key to this new Viewport object in the viewports repository is Side view. You use this key to access this particular Viewport object. For example,

session.viewports['Side view'].viewportAnnotationOptions.\
    setValues(legend=OFF, title=OFF)

You can make your scripts more readable by assigning a variable to an object in a repository. For example, you could rewrite the previous statement after assigning the Viewport object to the variable myViewport:

myViewport = session.viewports['Side view'] 
myViewport.viewportAnnotationOptions.setValues(
    legend=OFF, title=OFF)

In general, if the user can create the object, its repository key is a string. In some cases Abaqus/CAE creates an object, and the key can be a string, an integer, or a SymbolicConstant.

As with dictionaries, you can use the keys() method to access the repository keys.

>>> session.Viewport(name='Side view') 
>>> session.Viewport(name='Top view') 
>>> session.Viewport(name='Front view') 
>>> for key in session.viewports.keys(): 
        ...  
        print key 
Front view
Top view 
Side view

You can use the keys()[ i] method to access an individual key; however, most repositories are not ordered, and this is not recommended.

You can use the changeKey() method to change the name of a key in a repository. For example,

myPart = mdb.models['Model-1'].Part(name='housing',
     dimensionality=THREE_D, type=DEFORMABLE_BODY) 
mdb.models['Model-1'].parts.changeKey(fromName='housing',
    toName='form')