The following section describes how you copy and delete ABAQUS Scripting Interface objects. The following topics are covered:
Most ABAQUS objects have a method that creates a copy of the object. The same command provides the name of the new object. Methods that create a copy of an object are called copy constructors. Although copy constructors exist for most objects, in most cases they are not documented in the ABAQUS Scripting Reference Manual. The format of a copy constructor is
ObjectName(name='name', objectToCopy=objectToBeCopied)A copy constructor returns an object of the type of objectToBeCopied with the given name. For example, the following statements show you can create a Part object and then use a copy constructor to create a second Part object that is a copy of the first:
firstBolt = mdb.models['Metric'].Part( name='boltPattern', dimensionality=THREE_D, type=DEFORMABLE_BODY) secondBolt = mdb.models['Metric'].Part( name='newBoltPattern', objectToCopy=firstBolt)
You can also use the copy constructor to create a new object in a different model.
firstBolt = mdb.models['Metric'].Part( name='boltPattern', dimensionality=THREE_D, type=DEFORMABLE_BODY) secondBolt = mdb.models['SAE'].Part( name='boltPattern', objectToCopy=firstBolt)
To create a copy of an object, some objects use the base type described in Abstract base type, Section 6.1.5. For example, to copy a HomogeneousSolidSection object, you use the abstract base type Section constructor.
import material import section impactModel = mdb.Model(name='Model A') mySteel = impactModel.Material(name='Steel') # Create a section firstSection = impactModel.HomogeneousSolidSection( name='steelSection 1', material='Steel', thickness=1.0) # Copy the section secondSection = impactModel.Section( name='steelSection 2', section=firstSection)
In general, if you can create an object, you can delete the object. For example, the following statements create a Material object in the material repository:
myMaterial = mdb.models['Model-1'].Material(name='aluminum')You can use the Python del statement to delete an object, but you must provide the full path to the object.
del mdb.models['Model-1'].materials['aluminum']The variable myMaterial that referred to the object still exists; however, the variable no longer refers to the object. You can use the del statement to delete the variable.
del myMaterial
Conversely, if you create the object as before but delete the variable that referred to the object, only the variable is deleted; the object still exists. You can assign a new variable to the object.
myMaterial = mdb.models['Model-1'].Material(name='aluminum') del myMaterial myNewMaterial = mdb.models['Model-1'].materials['aluminum']
The previous explanation does not apply to the few ABAQUS/CAE objects that are not members of either an Mdb object or a Session object; for example, XYData and Leaf objects. These objects are sometimes referred to as “temporary,” and the delete semantics for these objects are the same as for standard Python objects. The object exists as long as there is a reference to it. If you delete the reference, the object is also deleted.