The basic concepts of object-oriented programming include:
1) Objects
2) Classes
3) Properties
4) Inheritance
5) Polymorphism
6) Methods
7) Members ( members)
This section introduces the methods and members of the Abaqus script interface
1. Methods in the Abaqus script interface
Most of the Abaqus script interface commands are methods. like:
session.viewports["Viewport-1"].setValue(width = 50)
The setValue method of this line of code is a method of the Viewport object
myViewport = session.Viewport(name = "newViewport", width = 100, height = 100)
This line of code uses the constructor Viewport to create a Viewport object and assigns it to the variable myViewport.
Some objects do not contain a constructor, and the first object created at this time will become a member of another object. For example: when creating the geometric shape of a part (Part), Abaqus will first create a vertex, and the coordinates of the vertex will be saved as a Vertex object, and the Vertex object is a member of the Part object. like:
print(mdb.models["Model-1"].parts["Part-1"].vertices[0].pointOn)
This line of code will output the coordinates of the first vertex of part Part-1
2. Members in the Abaqus script interface
Each object contains methods (method) and members (member).
Members can be considered as a certain property of the object, and the members of the object can be accessed by using the delimiter. like:
myWidth = session.viewports["myViewport"].width
Width is a member of the Viewport object.
Call the object.__members__ method in the Python language to list all members of the object.
sessoin.viewports["myViewport"].__members__
This line of code will list all the members of the Viewport object.
The member values of each instance object are generally different, such as the width member values of
different viewports . Direct assignment to member values is allowed, but member values can be changed with the setValues() method
import section
shellSection = mdb.models["Model-1"].HomogeneousShellSection(
name = "Steel Shell", thickness = 1.0, material = "Steel")
print("Original shell section thickness =", shellSection.thickness)
shellSection.setValues(thickness = 2.0)
print("Final shell section thickness =", shellSection.thickness)
The fourth line of code calls the setValues() method to modify the thickness of the
section
#创建Section对象
mySection = mdb.models["Model-1"].HomogeneousSolidSection(name = "solidSteel", material = "Steel", thickness = 1.0)
#使用type()函数显示对象的类型
print("Section type =", type(mySection))
#列出对象的所有成员
print("Section members are ", mySection.__members__)
#列出对象的所有方法
print("Section methods are ", mySection.__methods__)
#输出每个成员的值
for member in mySection.__members__:
print("mySection.{0} = {1}".format(member, getattr(mySection, member)))
After the object is created, you can also call some methods of the object to input or modify data.
For example: call the addNodes and addElements methods to add nodes and elements for the component;
call the addData method of the FieldOutput object to add field variable output data