找回密码
 注册
Simdroid-非首页
查看: 223|回复: 2

[二次开发] Python及ASI对象使用心得 (二)

[复制链接]
发表于 2012-2-21 15:51:37 | 显示全部楼层 |阅读模式 来自 浙江杭州
本帖最后由 zbd 于 2012-2-21 15:51 编辑

——参考《Abaqus Scripting User's Manual》、《Abaqus ScriptingReference Manual》

Abaqus Scripting Reference Manual》中的Python commands列出了所有的AbaqusPython增加的ASI数据类型(又名对象)。使用这本手册之前需要理解一些基本的概念。

1、 什么是对象。一个对象就是封装了一些数据和可以操作这些数据的功能。被对象封装的数据被称作是members,操作这些数据的功能被称作methods。举个例子:比如我们把现实世界的所有轮胎封装为一个Class。那么,这个Class中挑出一个轮胎,这个轮胎就是一个member。这个轮胎包含很多数据,比如品牌、材料、使用年限、形状、重量、价格、齿形等等。而methods是对这些数据的一种操作,比如计算在给定荷载下该轮胎如何变形。Abaqus在支持Python的基本变量类型的基础上,增加了超过500对象类型,即Classes,本手册中主要介绍了这些对象类型是怎样定义的,含有什么数据,支持哪些操作。

2、 根据对象的用途不同,从Adaptivitycommands 到XY commands 之间共分成了51个commands。比如,对job的操作在job commands中,共有六个对象,分别是:Job object、JobFromInputFile object、Message object、ModelJobobject等。所以,如果我们要查询对Odb进行的操作,就从31 Odb中查找。

3、 对每一个对象介绍的内容。就以31.1中odb对象类型为例。
首先是Access:
import odbAccess
session.odbs[name]
第一行表示怎样导入该对象(我们可以只是用一句from abaqusConstants import *将所有的Abaqus对象一次性全部导入)
第二行是写获取这个数据的途径,很容易理解。

之后是:31.1.1 Odb(...)、31.1.2 close()、31.1.3 getFrame(...)、31.1.4 save()等。
这些都叫做“method“,都是可以对该对象可以执行的命令。
拿31.1.1 Odb(...)举例。首先解释了该method的作用是建立一个新的Odb;在Path中给出了到达该命令的途径;Required argument中列出了必须提供的参数(这里必须给出Odb的名字);Optional arguments中列出了可以选择的参数(比如description对该Odb的描述);Return value给出了该method的返回值(比如myodb=session.Odbs(‘myodb’)之后myodb这个变量就连接到了一个odb)。

最后在31.1.6  Members中列出了所有的members,即对象含有的参数(可以用.__members__来列出一个对象的所有members)。看一下odb对象都有什么参数:isReadOnly、interactions、interactionProperties、steps、materials、parts。我们可以用setValues() 这个命令来设定members值。


4、 总结(直接摘录的AbaqusScripting User's Manual中的)
An object encapsulates some data andfunctions that are used to manipulate those data.

The data encapsulated by an object arecalled the members of the object.

The functions that manipulate the data arecalled methods.

The Abaqus Scripting Interface uses theconvention that the name of a type of object begins with an uppercasecharacter; for example, a Viewport object.

A method that creates an object is called aconstructor. The Abaqus Scripting Interface uses the convention thatconstructors begin with an uppercase character. In contrast, methods thatoperate on an object begin with a lowercase character.

After you create an object, you then usemethods of the object to enter or to modify the data associated with theobject. For example, if you are creating an output database, you first createan Odb object. You then use the addNodes and addElements methods of the Partobject to add nodes and elements, respectively. Similarly, you use the addDatamethod of the FieldOutput object to add field output data to the outputdatabase.

You use the Access description providedwith each object in the Abaqus Scripting Reference Manual to determine how youaccess the object. You append a method or a member to this description when youare writing a script.

You use the Path description provided witheach constructor in the Abaqus Scripting Reference Manual to determine the pathto the constructor.

You use the setValues() method to modifythe members of an Abaqus Scripting Interface object.
session.viewports['Side view'].setValues(origin=(20,20))


评分

1

查看全部评分

发表于 2013-6-15 11:08:24 | 显示全部楼层 来自 北京
Simdroid开发平台
没太看懂
回复 不支持

使用道具 举报

发表于 2017-2-16 15:34:26 | 显示全部楼层 来自 广东东莞
楼主好人  楼主辛苦了
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-28 15:07 , Processed in 0.029621 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表