ansa_python学习贴
import osimport ansa
from ansa import base
from ansa import constants
def main():
# Need some documentation? Run this with F5
"""Docstrings for function help"""
#Collect the parts
search_type = ('ANSAPART',)
parts = base.CollectEntities(constants.NASTRAN, None, search_type, True)
#Use each part as a container in order to collect its faces
search_type = ('FACE',)
faces = list()
for part in parts:
container = #The container must be in a matrix form
faces.append(base.CollectEntities(constants.NASTRAN,container,search_type,False))
print(faces)
if __name__ == '__main__':
main()
print(len(faces))结果为1,这是为什么?
还有,帮助里面的错误也太多了,希腊的beta公司就这态度还能好? 原因找到了:
print(faces)
print(type(faces))
print((faces))
print(type(faces))
print(faces)
print(type(faces))
结果为:
[[<Entity: 0x00000000105E6350: type: 3908(3908,G_FACE) id:158>, <Entity: 0x00000000105E86F8: type: 3908(3908,G_FACE) id:160>]]
<class 'list'>
[<Entity: 0x00000000105E6350: type: 3908(3908,G_FACE) id:158>, <Entity: 0x00000000105E86F8: type: 3908(3908,G_FACE) id:160>]
<class 'list'>
<Entity: 0x00000000105E86F8: type: 3908(3908,G_FACE) id:160>
<class 'ansa.base.Entity'>
这里是列表包含列表,有没有办法生成只有一个列表的表示啊? container = #The container must be in a matrix form
faces.append(base.CollectEntities(constants.NASTRAN,container,search_type,False))
这两句你把上面一句去掉,下面一句改为faces.append(base.CollectEntities(constants.NASTRAN,part,search_type,False))
试试 yijianluo 发表于 2015-1-9 10:58
原因找到了:
print(faces)
print(type(faces))
帮助里错误确实太多,尤其是例子中,最好一个一个调试 个人意见,仅供参考:
ansa的版本好些,发展时间长, 但是帮助 和script的文件 是累加的 方式写的,所以老斑的,新版就有问题。
而且那个python是基于script改写的,帮助就改了一下,所以问题多得。
那个上面的 例子,有问题的,有些调出来的就是句柄,也就是地址,所以没有什么打印意义的,所以不需要输出的。 楼主 NASTRAN做频响分析时,输出的FREQ1改怎么写程序啊?研究过么? 419435663 发表于 2015-5-4 09:35
楼主 NASTRAN做频响分析时,输出的FREQ1改怎么写程序啊?研究过么? ...
没用过nastran yijianluo 发表于 2015-5-4 11:22
没用过nastran
其他软件做频响分析也得定义频率吧? 有做过么? 谢谢楼主的无私奉献! 419435663 发表于 2015-5-4 11:29
其他软件做频响分析也得定义频率吧? 有做过么?
我主要做结构疲劳方面的
页:
[1]