HyperMesh二次开发注解【一】---新版本说明

HyperMesh12.0中API的变化

模型ID管理变化

新的模型ID管理与以前版本不同(官方发布在12.0.110升级包中),模型ID信息范围将按照子模型(或者Include模型)区分范围。例如:HM中包含连个include文件,include1文件与include2文件的ID范围分别是1001-2000和3001-4000,如果include1被设置为当前文件,则新的或者被导入的模型ID信息将在ID范围1001-2000内设置,并不是按照全部HM数据ID的进行更改。

于此更改相关的API命令为hm_entitymaxid。以前版本中中的ID将范围这个歌HM数据中对应类型的最大的ID,而更新后的命令将返回当前使用模型的最大的ID。

当前,hm_entitymaxid主要有两种用途:

(1)获取创建类型最大的ID,如下:

procCreateGRNOD { args } {
  set d_nodesList [lindex $args 0];
  if { [llength $d_nodesList] } {
      set str_setName [::hwat::utils::GetUniqueName sets [lindex$args 1]];
      eval *createmark nodes 1 $d_nodesList;
      *entitysetcreate "$str_setName" nodes 1;
      *createmark sets 1 -1;
      *dictionaryload sets 1 $::str_templatePath"GRNOD";
      return [hm_entitymaxidsets];
  } else {
      return 0;
  }
}
 


(2)获取唯一的ID赋给指定的名称的对象,如下:

procHandleNewInDefineMaterialProperties { args } {
  # First find out the maximum material ID used.
  set max_mat_col_id [hm_entitymaxid mats];
 
  # The new material ID will be one more than the existing maximum mat ID.
  set ::material_id [ expr { $max_mat_col_id + 1 }];
 
  # Set the default mu value.
  set ::material_mu 0.2;
 
  # Set the Material collector default name by adding name and ID.
  # This is to make sure that it is a unique name.
  set ::material_name "";
  append ::material_name "TARGET_CONTACT" "_MAT_"$::material_id;
}


为了避免新的数据结构对hm_entitymaxid命令带来的影响,引入了新的命令函数hm_latestentityid,直接替换程序中的和hm_entitymaxid,如下:

procCreateGRNOD { args } {
  set d_nodesList [lindex $args 0];
  if { [llength $d_nodesList] } {
      set str_setName [::hwat::utils::GetUniqueName sets [lindex$args 1]];
      eval *createmark nodes 1 $d_nodesList;
      *entitysetcreate "$str_setName" nodes 1;
      *createmark sets 1 -1;
      *dictionaryload sets 1 $::str_templatePath"GRNOD";
      return [hm_latestentityidsets];
  } else {
      return 0;
  }
}
 


解决上述问题,还可以使用其他的函数,比如hm_entityinfo maxid。如下:

procHandleNewInDefineMaterialProperties { args } {
  # First find out the maximum material ID used.
  set max_mat_col_id [hm_entityinfo maxidmats];
 
  # The new material ID will be one more than the existing maximum mat ID.
  set ::material_id [ expr { $max_mat_col_id + 1 }];
 
  # Set the default mu value.
  set ::material_mu 0.2;
 
  # Set the Material collector default name by adding name and ID.
  # This is to make sure that it is a unique name.
  set ::material_name "";
  append ::material_name "TARGET_CONTACT" "_MAT_"$::material_id;
}


对于方便模型中产生唯一的对象名称,可以使用命令hm_getincrementalname。命令格式如下:

hm_getincrementalname entity_type_list base_name ?start_num? ?num_digits?

上述命令可以在已经有的名称后面自动添加索引,以区别已经有的数据名称,参考帮助手册。

另外,对于数据选择方面的,在12.0版本中也有加强,以前使用带有负参数的命令*createmark或者hm_createmark来选择当前创建的数据ID。新版本中同样可以使用,并且,获取的数据与使用hm_latestentityid获取的ID相同。

换句话说,在新的数据结构中,HM数据中最新的ID并不一定是最大ID,而以前版本中获取最新的ID基本就是获取最大的ID,但是,随着模型数据变得复杂,新的ID并非就是最大ID,为了与新的数据ID管理结构对应,在使用有关数据ID的时候需要特别注意。

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HyperMesh二次开发是指在HyperMesh软件中进行自定义功能开发的过程。在学习HyperMesh二次开发时,可能会遇到一些困难,因为在最初学习时,可能找不到完整的学习资料。一些人可能只能通过软件帮助和自己摸索来学习,这个过程可能会很痛苦,有时候为了实现一个简单的功能,需要翻遍帮助文档和查询网络,但仍然找不到合适的处理方法,这可能会让人怀疑自己的能力。然而,只要坚持下来,通过不断的学习和实践,就能掌握绝大多数的HyperMesh开发项目。\[1\] 有些人为了分享自己在HyperMesh二次开发学习中的经验总结,帮助有兴趣学习HyperMesh二次开发的同学快速掌握开发知识,以及提供一个技术交流的平台,开设了一些教程专栏。这些教程专栏可以让大家在此交流学习心得、分享技术、共同进步。\[2\] 如果你对HyperMesh二次开发感兴趣,可以寻找这些教程专栏来获取更多的学习资源和指导。虽然这些教程可能存在一些没有覆盖到的内容和错误的地方,但是通过与他人的交流和探讨,可以更好地理解和应用HyperMesh二次开发技术。\[3\] #### 引用[.reference_title] - *1* *2* *3* [HyperMesh二次开发教程 - 前言](https://blog.csdn.net/buleskyline/article/details/122004956)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值