在ansa2021版本中这段代码有什么错误import ansa from ansa import base from ansa import constants deck = constants.LSDYNA set_nodes = base.CollectEntities(deck, None, "SET") undefined_sets = [] for set1 in set_nodes: if set1._name == "NODE_ABS: NODE referenced but not defined": undefined_sets.append(set1) print(set1._id) print(undefined_sets) vals = undefined_sets.append_entity_values(deck, ('NODE'))
时间: 2024-02-19 07:57:17 浏览: 86
PartName_to_PropertyName.zip_python 二次开发 ansa
5星 · 资源好评率100%
在ansa2021版本中,这段代码存在以下错误:
1. 第一行的 `import ansa` 是错误的,应该改为 `import ansa.base`。
2. 在最后一行,`undefined_sets.append_entity_values(deck, ('NODE'))` 是错误的,因为 `undefined_sets` 是一个列表,它没有 `append_entity_values` 这个方法。应该将其替换为 `base.AppendEntityValues(deck, undefined_sets, ('NODE'))`。
修正后的代码如下:
```
import ansa.base
from ansa import constants
deck = constants.LSDYNA
set_nodes = ansa.base.CollectEntities(deck, None, "SET")
undefined_sets = []
for set1 in set_nodes:
if set1._name == "NODE_ABS: NODE referenced but not defined":
undefined_sets.append(set1)
print(set1._id)
print(undefined_sets)
ansa.base.AppendEntityValues(deck, undefined_sets, ('NODE'))
```
阅读全文