HyperWorks二次开发API-孔的识别

HyperWorks二次开发API-孔的识别

前段时间学习了HyperWorks的二次开发方法,HyperWorks的二次开发语言为TCL,参考资料较少,主要通过某站的官方教学视频、《Tcl_Tk入门经典(第2版)》、帮助文档进行学习。

发文的目的一是记笔记,二是学习分享,欢迎大家交流。写得简单,后续有空再补充


以下是TCL语言编写的代码,仅能识别带壳单元washer的孔,并生成rigid。实际通过自带Blot建rigid连接更加便捷

*createmarkpanel nodes 1 "select nodes to creat rigidlink";#通过面板标记点   
set node_in_elems [hm_getmark nodes 1];#将选择的点ID提取出来
*findmark nodes 1 1 1 components 1 2;#标记节点对应的component
*findmark components 2 257 1 elements 0 1;#标记component包含单元
hm_holedetectioninit;#初始化孔识别程序
hm_holedetectionsetentities elems 1;#设置检测的实体类型
hm_holedetectionsetholeparams hole_shape=31;#设置需要识别孔的参数
hm_holedetectionfindholes 1;#找到实体包含的孔          
foreach every_node $node_in_elems {
	set hole_info  [hm_holedetectionidentifyhole $every_node ];#获取含该节点的孔编号
    set washer  [ hm_holedetectiongetwasherelementslist $hole_info ];#得到孔的washer
    set washer [split $washer \{\}];#得到孔washer的单元编号
    append rigidelems   [lindex $washer 2];#收集每个孔washer的单元
    }
hm_createmark elements 1 $rigidelems  ;#标记孔的washer单元
*findmark elements 1 1 1 nodes 0 2;#标记孔washer节点
*rigidlinkinodecalandcreate 2 0 0 123456;#生成rigid
*clearmarkall 1
*clearmarkall 2
hm_holedetectionend;#结束孔识别

​参考:

HyperWorks Desktop Reference Guides-HyperMesh - Scripts - Commands and Functions - Tcl Query Commands

HyperWorks关系孔的API命令如下:

hm_holedetectioninit

——初始化孔检测模块

——调用其他hm_holedetection* api之前必须使用,并且必须在调用hm_holedetectionend

hm_holedetectionend

——清除内存,结束孔检测模块

——在此之前必须有对hm_holedetectioninit和其他hm_holedetection* api的调用

hm_holedetectionsetentities

——定义检测孔的实体

——可以多次调用,每次调用结果进行叠加

——在调用hm_holedetectioninit/hm_holedetectionend时,选择的实体被清除

——在此之前必须调用hm_holedetectioninit

——hm_holedetectionsetentities entity_type mark_id

——entity_type用于寻找孔的实体类型。有效值是comps、surfs、solid和elems。如果指定了comps,几何和FE都要考虑

——mark_id包含实体标记的ID。有效值为1和2

hm_holedetectionsetholeparams

——在几何和有限元中定义二维孔的参数

——可以多次调用此命令来覆盖或重新定义每个孔形状的参数

——在调用hm_holedetectioninit/hm_holedetectionend时,设置被清除。

——在此之前必须调用hm_holedetectioninit

——hole_shape是强制性的。所有其他参数都是可选的并具有默认值

——参数可以按任意顺序指定。

——hm_holedetectionsetholeparams hole_shape=<> ?parameter1=<>? ?parameter2=<>?

——hole_shape= (Bit0 + 2*Bit1 + 4*Bit2 + 8*Bit3 + 16*Bit4)

Bit1

0 – 不考虑圆孔

1 – 考虑圆孔

Bit2

0 - Do not consider rounded holes.

1 - Consider rounded holes.

Bit3

0 – 不考虑方孔.

1 – 考虑方孔.

Bit4

0 – 不考虑矩形孔.

1 - 考虑矩形孔.

——hole_type= (Bit0 + 2*Bit1 + 4*Bit2 + 8*Bit3)

Bit0

0 – 不考虑表面孔.

1 - 考虑表面孔.

Bit1

0 – 不考虑法兰面孔

1 - 考虑法兰面孔

Bit2

0 – 不考虑圆柱孔.

1 - 考虑圆柱孔.

Bit3

0 – 不考虑锥形孔.

1 - 考虑锥形孔.

——其他用于定义孔类型的参数:如角度、容差等

hm_holedetectionsettubeparams

——定义在几何和FE中管的参数

hm_holedetectionfindholes

——执行孔检测工具

——根据输入实体和参数寻找孔。调先用hm_holedetectioninit、hm_holedetectionsetenties、hm_holedetectionsetholparams或hm_holedetectionsettubeparams

——hm_holedetectionfindholes find

——find:(Bit0 + 2*Bit1 + 4*Bit2):

Bit0

0 – 不查找孔

1 - 查找孔

Bit1

0 – 不查找 2D 管

1 - 查找 2D 管

Bit2

0 – 不查找 3D 管

1 - 查找 3D 管

hm_holedetectionidentifyhole

——返回含给定节点或线的孔索引

——在此之前必须调用hm_holedetectionfindholes

——hm_holedetectionidentifyhole id

——id :需要查询的节点或线的ID

hm_holedetectiongetholedetails

——返回孔的详细信息

——在此之前必须调用hm_holedetectionfindholes

——hm_holedetectiongetholedetails index

——index:孔的索引号

General hole:

0 0 {center x/y/z} {axis x/y/z} {entities ordered lines/nodes} {0 - No washer elements, 1 - Washer elements; Always 0 for geometry holes}

Circular hole:

0 1 radius {center x/y/z} {axis x/y/z} {entities ordered lines/nodes} {0 - No washer elements, 1 - Washer elements; Always 0 for geometry holes}

Square hole:

0 3 length {center x/y/z} {axis x/y/z} {entities ordered lines/nodes} {0 - No washer elements, 1 - Washer elements; Always 0 for geometry holes}

……

hm_holedetectiongetnumberofholes

——返回孔的数量

——在此之前必须调用hm_holedetectionfindholes

hm_getholedetectionwasherelementslist

——返回Washer单元的ID

——在此之前必须调用hm_holedetectionfindholes

——输出格式为:

{Number of layers {layer 1 elem IDs…} {layer 2 elem IDs…} {layer 3 elem IDs…} etc...}

For example:

{2 { 430 429 428 427 426 425 424 423 }{ 418 417 416 415 414 413 412 411 }}

——hm_getholedetectionwasherelementslist index

——index:孔的编号

hm_holedetectionfindmates

——执行孔配合工具

——运行孔检测匹配功能,寻找孔匹配的'groups'

——在此之前必须调用hm_holedetectionfindholes

——所有其他参数都是可选的并具有默认值

——参数可以按任意顺序指定。

——hm_holedetectionfindmates ?parameter1=<>? ?parameter2=<>? Etc

max_angle:孔中心线之间的最大夹角,默认值1.0。

max_distance:孔中心之间的最大法向距离,默认值10.0。

max_lateral_distance:允许的最大横向距离,默认值1.0。

max_lateral_factor:允许的最大侧向距离系数,默认不使用

allow_hole_to_tube:0-不允许孔和管配合(默认);1-允许孔和管配合

allow_mismatched_shapes:0-不允许不同形状间配合(默认);1-允许不同形状间配合

allow_self:0-不允许同一组件间配合(默认);1-允许同一组件间配合

hm_holedetectiongetmatedetails

——返回指定孔/管配合'groups'的详细信息

——之前必须有一个hm_holedetectionfindmates调用

——hm_holedetectiongetmatedetails index

——index:配对索引号

——具体返回如下:

total_length {center_top x/y/z} {center x/y/z} {center_bottom x/y/z} number_of_indices {ordered_indices top-to-bottom}

其中total_length是配合孔的完整长度,从孔到孔测量,包括管深度;而center是连接孔中心线的中心。

hm_holedetectiongetnumberofmates

——返回匹配'groups'的孔/管的数量

——hm_holedetectiongetnumberofmates

——之前必须有一个对hm_holedetectionfindmates的调用

  • 2
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
HyperWorks是一款高级工程仿真平台,提供了多种工具和解决方案来支持各种各样的工程分析和设计任务。下面是几个HyperWorks的实例: 1. 结构分析:HyperWorks提供了一套强大的工具套件,可用于进行结构分析。工程师可以使用这些工具进行线性和非线性分析、模态分析、疲劳分析等,以评估结构的安全性和性能。例如,在汽车工业中,HyperWorks可以用于对车身结构进行有限元分析,以确保其在各种工况下的刚性和强度满足要求。 2. 流体动力学分析:HyperWorks还提供了CFD(计算流体力学)工具,用于分析气体和液体在流动环境中的行为。这些工具可以用来模拟和优化风阻、气动外形、涡流等。在航空航天领域,HyperWorks可以用于设计和改进飞机机身和机翼的气动外形,以降低空气阻力,提高飞机的性能。 3. 碰撞模拟:HyperWorks的碰撞模拟工具可用于评估汽车和其他交通工具在碰撞情况下的安全性。通过模拟碰撞过程,工程师可以预测车辆在事故中的表现,并进行结构优化,以提高乘员的安全性。 4. 振动和噪声分析:HyperWorks提供了用于分析和优化机械系统振动和噪声的工具。工程师可以使用这些工具来识别和减少机械系统中的振动和噪声源,以提高系统的性能和舒适性。在家电和工业机械领域,HyperWorks可以用于改善洗衣机、风扇、空调等产品的振动和噪声问题。 总之,HyperWorks是一个功能强大的工程仿真平台,可用于各种工程领域的分析和设计任务。通过使用HyperWorks,工程师可以更准确地评估和优化产品的性能和安全性,从而提高产品的质量和竞争力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值