许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  与ANSA交互:Edit, Create and Delete Entities操作

与ANSA交互:Edit, Create and Delete Entities操作

阅读数 10
点赞 0
article_banner

Edit, Create and Delete Entities

Once the entities have been collected, the next step is to edit, modify or delete some of them. The functions that are oftenly used for this   purpose are the following:


FunctionDescription
base.GetEntityCardValuesGets values from a card
base.SetEntityCardValuesSets values to a card
base.CreateEntityCreates a new entity
connections.CreateConnectionPointCreates a connection point
connections.CreateConnectionLineCreates a connection line
connections.CreateConnectionFaceCreates a connection face
connections.RealizeConnectionsRealizes connections
base.DeleteEntityDeletes an entity
base.NewPartCreates new parts
base.NewGroupCreates new groups

Get values from an entity using its Edit card

In order to acquire the values of an entity’s edit card the functions base.GetEntityCardValuesand Entity.get_entity_values are used. Both these functions work in a similar way, with the Entity.get_entity_values() method being a new addition and providing the ability to obtain any object that is referenced in an entity’s card.

Their call normally follows functions that have collected a number of entities in a prior step. Appart from the deck and the reference to the entity, a list containing all the labels of the values to be obtained, must be given as an argument. These labels are the keywords of the fields, exactly as they appear in the edit card. The following example demonstrates the process of getting the values of the name, property id, material id and thickness, of all the SECTION_SHELL cards of the LSDYNA deck, by using the function base.GetEntityCardValues():

在这里插入图片描述


import ansa
from ansa import base
from ansa import constants

def GetValues():
    props = base.CollectEntities(constants.LSDYNA, None, 'SECTION_SHELL')
    #Initialize lists
    names = []
    pids = []
    mids = []
    thickness = []

    for prop in props:
        vals = base.GetEntityCardValues(constants.LSDYNA, prop, ('Name', 'PID', 'MID', 'T1'))
        names.append(vals['Name'])
        pids.append(vals['PID'])
        mids.append(vals['MID'])
        thickness.append(vals['T1'])

It is crucial for the user to be familiar with the labels of each edit card, since they must be written exactly as they appear in the cards. The function returns a dictionary with keys the requested fields and values the corresponding values. If an error occurs the value of the particular field will be None.

If the user needs direct access to the entity object of a card field, it is reccomended to use the method Entity.get_entity_values(). The following example demonstrates its use, in contrast to the actions performed previously, in order to get the entity object:


import ansa
from ansa import base
from ansa import constants

def main():
    shell = base.GetEntity(constants.ABAQUS, 'SHELL', 1)

    #previous approach
    vals = base.GetEntityCardValues(constants.ABAQUS, shell, ('G1', 'G2', 'G3', 'G4'))
    g1_obj = base.GetEntity(constants.ABAQUS, 'NODE', vals['G1'])
    print(g1_obj.ansa_type(constants.ABAQUS))

    #new approach
    vals2 = shell.get_entity_values(constants.ABAQUS, ('G1', 'G2', 'G3', 'G4'))
    print(vals2['G1'].ansa_type(constants.ABAQUS))

To avoid opening and closing cards just   for seeing the names of the labels, three global label – keywords can be used. These keywords allow the extraction of the entity’s id, property and type, without knowing the names of their respective labels. Their syntax is the following:


LabelDescription
idThe entity’s ID
typeThe entity’s ANSA type
propThe entity’s property id

A plain usage of these keywords is shown in the following example:

status = base.GetEntityCardValues(constants.LSDYNA, ent, ('__id__', '__type__', '__prop__'))

In order to get the
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空