许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  HyperMesh二次开发注解(一):新版本说明与更新

HyperMesh二次开发注解(一):新版本说明与更新

阅读数 5
点赞 0
article_banner

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的时候需要特别注意。


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


相关文章
技术文档
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
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空