Download Abaqus Scripting User's Manual

Transcript
OBJECT-ORIENTED PROGRAMMING AND THE Abaqus SCRIPTING INTERFACE
relates to the Abaqus Scripting Interface and summarizes some of the terminology. The following topics
are covered:
•
•
•
“The Abaqus Scripting Interface and methods,” Section 5.4.1
“The Abaqus Scripting Interface and members,” Section 5.4.2
“Object-oriented programming and the Abaqus Scripting Interface—a summary,” Section 5.4.3
5.4.1
The Abaqus Scripting Interface and methods
Most Abaqus Scripting Interface commands are methods. For example,
session.viewports['Viewport-1'].setValues(width=50)
In this example setValues() is a method of the Viewport object.
A constructor is a method that creates an object. By convention, all constructor names and all
objects start with an uppercase character in the Abaqus Scripting Interface. The name of a constructor is
usually the same as the name of the type of object it creates. In the following example Viewport is a
constructor that creates a Viewport object called myViewport:
myViewport = session.Viewport(name='newViewport',
width=100,height=100)
Some objects do not have a constructor. The object is created as a member of another object when
the first object is created. For example, Abaqus creates the vertices of a part when you create a part’s
geometry, and the coordinates of the vertices are stored as Vertex objects. The Vertex objects are members
of the Part object. The following statement prints the coordinates of the first vertex of a part:
print
mdb.models['Model-1'].parts['Part-1'].vertices[0].pointOn
The standard Python statement object.__methods__ lists all the methods of an object. For
example, the following statement lists all the methods of a Viewport object:
session.viewports['myViewport'].__methods__
See the Abaqus Scripting Reference Manual for a description of each method of the Abaqus Scripting
Interface objects.
5.4.2
The Abaqus Scripting Interface and members
An object has members as well as methods. A member can be thought of as a property of an object. For
example, width is a member of the Viewport object. The following statements show how you access a
member of an object:
>>> myWidth = session.viewports['myViewport'].width
>>> print 'Viewport width =', myWidth Viewport width = 100.0
5–10
Abaqus ID:
Printed on: