geometry_check_pane.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. //Callback of data preparation stage before UI is fully loaded.
  5. function OnInitializeData(reload, preview) {
  6. PUI(()=>{
  7. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  8. //The 'pui' variable is valid in all functions of this document.
  9. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  10. });
  11. //unit.form.mainfrm.OnCueline('模型检测,检测模型水密性!');
  12. }
  13. //Callback after UI is fully loaded and displayed.
  14. function OnReady(reload, preview) {
  15. PUI(()=>{
  16. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  17. //The 'pui' variable is valid in all functions of this document.
  18. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  19. });
  20. }
  21. function OnCloseForm() {
  22. }
  23. function OnException(err) {
  24. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  25. }
  26. let myArray = [];
  27. //////////////////////////////////////////////////////////////////////////
  28. // Callback Functions.
  29. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  30. function OnError(){
  31. myArray.forEach((item) => {
  32. console.log(item);
  33. unit.form.mainfrm.OnSend("BadFace " + item);
  34. });
  35. }
  36. function OnErrorFace(ids){
  37. let id = unit.form.mainfrm.findRIdById(model.acax_app.model.project.GetModel().pro_model, parseInt(ids) + 100003);
  38. const str = comx.occio.GetFacePoint(comx.occore.GetEntryEx(), id);
  39. const regex = /point:(\d+\.\d+) (\d+\.\d+) (\d+\.\d+)/;
  40. const match = str.match(regex);
  41. if (match) {
  42. const x = parseFloat(match[1]);
  43. const y = parseFloat(match[2]);
  44. const z = parseFloat(match[3]);
  45. unit.form.mainfrm.OnArrows(x, y, z, 1, 0, 0, "errorArrows");
  46. }
  47. }
  48. function OnReturnMeun(){
  49. unit.form.mainfrm.menu(0);
  50. }
  51. function OnTestModel(){
  52. var flag = true;
  53. unit.form.mainfrm.OnCueline('检测中...', 'Blue');
  54. model.spawn(model.getCurrentDirectory() + "src/check4/demo1.exe", model.acax_app.model.project.GetModel().step, cb =>{
  55. //model.spawn(model.getCurrentDirectory() + "src/check4/demo1.exe", "E:/dcip/comx_sdk.node/unit/hypermesh/data/FN_MK-17_CQC_Variant_STEP.step", cb =>{
  56. ui.cueline.value += "检测中..." + '\n';
  57. ui.cueline.row = -1;
  58. if (cb.indexOf("success!!!") !== -1 && flag) {
  59. ui.cueline.value += '成功!\n';
  60. ui.cueline.row = -1;
  61. unit.form.mainfrm.OnChangePicture(1, 2);
  62. unit.form.mainfrm.OnCueline('通过!', 'green');
  63. ui.pb_pass.enable = true;
  64. ui.pb_pass01.enable = true;
  65. }
  66. const numbers = cb.match(/FaceIndex: (\d+)/g).map(item => item.match(/\d+/)[0]);
  67. ui.cueline.value += '您需要修改错误面:' + numbers[0] + '\n';
  68. ui.cueline.row = -1;
  69. OnErrorFace(numbers[0]);
  70. flag = false;
  71. unit.form.mainfrm.OnChangePicture(1, 3);
  72. unit.form.mainfrm.OnCueline('您需要修改错误面:' + numbers[0], 'red');
  73. ui.pb_Error.enable = true;
  74. ui.pb_pass01.enable = false;
  75. });
  76. }
  77. //The message corresponding callback executed by the docker pane.
  78. // when calling [side_pane].fireEvent(type,para) in the main form.
  79. function OnParentDockerMessage(type, para) {
  80. }
  81. //////////////////////////////////////////////////////////////////////////
  82. // Utils Functions.
  83. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  84. function onDragFile(filepath) {
  85. }
  86. function PUI(cb) {
  87. if(pui){cb();}
  88. }
  89. CW_DeclareVariable("path",
  90. val => {
  91. ui.pb_value.value = val;
  92. }, () => {});
  93. /*Usage of BLOCK_EVENT
  94. BLOCK_EVENT(()=>{
  95. ui.[name].[var] = ...;
  96. });
  97. */
  98. function BLOCK_EVENT(cb) {
  99. ui.block_event = true;
  100. cb();
  101. ui.block_event = false;
  102. }
  103. //////////////////////////////////////////////////////////////////////////
  104. // template codes for cw callback js.
  105. function CW_DeclareVariable(name, setter, getter) {
  106. if(typeof(__DeclareVariable) === 'function') {
  107. __DeclareVariable(name, setter, getter);
  108. }
  109. }
  110. function CW_DeclareOuterVariable(name) {
  111. if(typeof(__DeclareOuterVariable) === 'function') {
  112. __DeclareOuterVariable(name);
  113. }
  114. }