//////////////////////////////////////////////////////////////////////////// // System Pre-define Functions // 95099372-ef3e-11ea-9c81-bf848405c62e //Callback of data preparation stage before UI is fully loaded. //dcip节点和模型树节点对应值 var g_cur_id2index_cache = {}; var g_cur_index2id_cache = {}; function OnInitializeData(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); ui.tree_menu.index = 2; } //Callback after UI is fully loaded and displayed. function OnReady(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } function OnCloseForm() { } function OnException(err) { //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok); } var options = true; let myArray = []; ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 //修改约束属性的名字 function ModifyConstraintName(new_name) { let cur_name = model.acax_app.model.constrain.Current(); let flag = model.acax_app.control.constrain.Rename(cur_name, new_name); let cur_index = model.acax_app.view.GetCurrentWorkConditionIndex(); let cur_id; if(flag === true) { unit.form.mainfrm.OnCueline('修改成功', 'green'); }else{ unit.form.mainfrm.OnCueline('修改失败', 'red'); } model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((new_name === info.name) && (model.acax_app.path.Parent(info.index, 3) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //从工程中获取保存的model数据 if(model.acax_app.model.project.GetModel().pro_model){ //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } ui.tree_Model.position = cur_id; } //修改材料属性的名字 function ModifyMaterialName(new_name) { let cur_name = model.acax_app.model.materialProp.Current(); let flag = model.acax_app.control.materialProp.Rename(cur_name, new_name); let cur_index = model.acax_app.view.GetCurrentWorkConditionIndex(); let cur_id; if(flag === true) { unit.form.mainfrm.OnCueline('修改成功', 'green'); }else{ unit.form.mainfrm.OnCueline('修改失败', 'red'); } model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((new_name === info.name) && (model.acax_app.path.Parent(info.index, 3) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //从工程中获取保存的model数据 if(model.acax_app.model.project.GetModel().pro_model){ //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } ui.tree_Model.position = cur_id; } //修改的工程名 function ModifyProName(new_name) { let cur_name = model.acax_app.path.Name(model.acax_app.view.GetCurrentProjectIndex()); model.acax_app.model.project.Rename(cur_name, new_name); let cur_index = model.acax_app.view.GetCurrentWorkAreaIndex(); let cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((new_name === info.name) && (model.acax_app.path.Parent(info.index, 0) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //从工程中获取保存的model数据 if(model.acax_app.model.project.GetModel().pro_model){ //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } ui.tree_Model.position = cur_id; } //处理字符串截掉后五位 function removeLastFiveCharacters(str) { str = String(str); if (str.length <= 5) { return ''; // 如果字符串长度小于等于 5,则返回空字符串 } return str.substring(0, str.length - 5); // 提取从 0 到倒数第 5 位的子字符串 } //点击弹出菜单 function OnContentClick(){ //获取一级子节点 let str = removeLastFiveCharacters(ui.tree_Model.content_menu); let model_id = g_cur_id2index_cache[str]; //let cur_name = model.acax_app.path.Name(model_id); switch (model.acax_app.path.Type(model_id)){ case 2: unit.form.Rename.Show(); break; case 3: break; case 4: unit.form.RenameConstraint.Show(); break; case 5: unit.form.RenameMaterial.Show(); break; default: break; } } //右键单击树效果 function OnRightClick(){ //console.log(ui.tree_Model.position); let model_id = g_cur_id2index_cache[ui.tree_Model.position]; switch (model.acax_app.path.Type(model_id)){ case 2: ui.tree_Model.content_menu =[{ "name":"重命名", "icon":"", "id":ui.tree_Model.position + "13579" }]; break; case 3: break; case 4: ui.tree_Model.content_menu =[{ "name":"重命名", "icon":"", "id":ui.tree_Model.position + "13579" }]; break; case 5: ui.tree_Model.content_menu =[{ "name":"重命名", "icon":"", "id":ui.tree_Model.position + "13579" }]; break; default: break; } } //点击树 function OnClickTree(){ //获取模型树的对应节点 console.log(ui.tree_Model.position); let model_id = g_cur_id2index_cache[ui.tree_Model.position]; let cur_workarea = model.acax_app.view.GetCurrentWorkAreaIndex(); let cur_proj = model.acax_app.view.GetCurrentProjectIndex(); let cur_workcondition = model.acax_app.view.GetCurrentWorkConditionIndex(); model.acax_app.view.RenderNode(model_id, info => { console.log(info); }); switch (model.acax_app.path.Type(model_id)) { //切换工作区 case 0: //不是当前工作区,切换工作区 if(model_id !== cur_workarea){ model.acax_app.view.RenderNode(model_id, info => { OpenWorkArea(info.prop); //切换到当前工作区 ui.tree_Model.position = g_cur_index2id_cache[model_id]; }); } break; //选中材料库 case 1: break; //切换工程 case 2: //不是当前工程,切换工程 if(model_id !== cur_proj){ model.acax_app.view.RenderNode(model_id, info => { ChangePro(model.acax_app.path.Name(model_id)); //切换到当前工程 ui.tree_Model.position = g_cur_index2id_cache[model_id]; }); } break; //切换工况 case 3: //不是当前工况,切换工况 if(model_id !== cur_workcondition){ model.acax_app.view.RenderNode(model_id, info => { console.log(model.acax_app.path.Name(model_id)) ; ChangeWorkCondition(model.acax_app.path.Name(model_id)); //切换到当前工况 ui.tree_Model.position = g_cur_index2id_cache[model_id]; }); } break; //选中约束 case 4: model.acax_app.view.RenderNode(model_id, info => { //切换到当前约束 model.acax_app.model.constrain.SwitchTo(model.acax_app.path.Name(model_id)); //将约束属性设置到对应面板 ChangeConstraint(Object.values(info.prop)[0], info.prop); //切换点击约束 ui.tree_Model.position = g_cur_index2id_cache[model_id]; }); break; //选中材料属性 case 5: model.acax_app.view.RenderNode(model_id, info => { //切换当前材料 model.acax_app.model.materialProp.SwitchTo(model.acax_app.path.Name(model_id)); unit.form.mainfrm.menu(3); unit.form.mainfrm.OnChangePicture(2, 1); unit.form.mainfrm.OnCueline('结构静力学材料设置', 'blue'); //将材料属性设置到面板 unit.form.mainfrm.setMaterial(info.prop); //切换到点击材料 ui.tree_Model.position = g_cur_index2id_cache[model_id]; }); break; default: break; } } //切换约束面板 function ChangeConstraint(constraint_name, prop) { let constraint = { "固定支撑":function(){ unit.form.mainfrm.menu(18); unit.form.mainfrm.changeConstrain(1, 0); unit.form.mainfrm.setConstraint(prop); }, "梁":function(){ unit.form.mainfrm.menu(18); unit.form.mainfrm.changeConstrain(1, 1); unit.form.mainfrm.changeConstrain(2, 0); unit.form.mainfrm.setConstraint(prop); }, "弹簧":function(){ unit.form.mainfrm.menu(18); unit.form.mainfrm.changeConstrain(1, 1); unit.form.mainfrm.changeConstrain(2, 1); unit.form.mainfrm.setConstraint(prop); }, "连接":function(){ unit.form.mainfrm.menu(18); unit.form.mainfrm.changeConstrain(1, 1); unit.form.mainfrm.changeConstrain(2, 2); unit.form.mainfrm.setConstraint(prop); }, "梁(非均匀)":function(){ }, "集中载荷压力":function(){ unit.form.mainfrm.menu(17); unit.form.mainfrm.changeConstrain(3, 0); unit.form.mainfrm.setConstraint(prop); }, "分布载荷压力":function(){ unit.form.mainfrm.menu(17); unit.form.mainfrm.changeConstrain(3, 1); unit.form.mainfrm.setConstraint(prop); } }; constraint[constraint_name](); } //测试函数 function OnTest(){ // console.log(model.acax_app.path.Name(g_cur_id2index_cache["131"])); //console.log(g_cur_id2index_cache); // console.log(g_cur_index2id_cache); } //切换工作区 function OpenWorkArea(fname) { fname = fname.replace(/\/+/g, "\\"); var work_path = model.acax_app.model.workArea.List(); //渲染模型树 for(var i = 0;i < work_path.length;++i) { work_path[i] = work_path[i].replace(/\/+/g, "\\"); if(fname === work_path[i]){ model.acax_app.control.workArea.SwitchTo(i); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //从工程中获取保存的model数据 if(model.acax_app.model.project.GetModel().pro_model){ //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); } } //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } } //切换工程 function ChangePro(pro_name) { model.acax_app.control.project.SwitchTo(pro_name); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //从工程中获取保存的model数据 if(model.acax_app.model.project.GetModel().pro_model){ //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } } //切换工况 function ChangeWorkCondition(wor_name) { model.acax_app.control.workCondition.SwitchTo(wor_name); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //从工程中获取保存的model数据 if(model.acax_app.model.project.GetModel().pro_model){ //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } } //创建工作区 function CreateWorkArea(name) { model.acax_app.control.workArea.Append(name); let cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if("workArea" === info.name) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree=>{ ui.tree_Model.tree = tree; }); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } ui.tree_Model.position = cur_id; } //创建工程 function CreateProject(name) { model.acax_app.control.project.Create(name); let cur_name = model.acax_app.model.project.Current(); let cur_index = model.acax_app.view.GetCurrentWorkAreaIndex(); let cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((cur_name === info.name) && (model.acax_app.path.Parent(info.index, 0) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree=>{ ui.tree_Model.tree = tree; }); //渲染3d模型 if(model.acax_app.model.project.GetModel().step === "unimported") { unit.form.mainfrm.ClearCanvas(); }else{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); } ui.tree_Model.position = cur_id; } //导入模型 function OnOpenStepFile() { var model_file = myArray[parseFloat(ui.listbox.index)]; model.acax_app.control.ImportStep(model_file, (model_file, model_plyfile)=>{ model.acax_app.view.Render3D(info=>{ unit.form.mainfrm.OnloadModel(info.model3d.step); }); // unit.form.mainfrm.OnSend('openSTLFile ' + model.getCurrentDirectory() + ' ' + myArray[parseFloat(ui.listbox.index)]); //unit.form.mainfrm.OnCueline(`Loading ${myArray[parseFloat(ui.listbox.index)]} ...`, 'Blue'); //model.setStepPath(model_file); //console.log(model_file); } ); } //插入新子节点 function findAndAppendByName(json, targetName, newChild) { if (json.name === targetName) { // 拼接新的 JSON 数据 if (!json.children) { json.children = []; } json.children.unshift(newChild); return true; // 找到后返回 true } // 遍历子节点递归查找 if (json.children) { for (const child of json.children) { if (findAndAppendByName(child, targetName, newChild)) { return true; // 如果找到目标节点,结束递归 } } } return false; // 没找到返回 false } //将模型的id值加密与模型树一一对应 function printIds(node) { if (node.id !== undefined) { id2index[id] = model.acax_app.path.Path; } if (Array.isArray(node.children)) { node.children.forEach(child => printIds(child)); } } //给面节点改名字并添加check_state属性 function updateJsonNodes(jsonData) { let count = 1; // 用于计数生成 Face1, Face2... function traverse(node) { // 为每个节点添加 check_state: 2 属性 node.check_state = 2; node.icon = ''; // 如果存在 children 属性,则递归处理 if (node.children && Array.isArray(node.children)) { for (let child of node.children) { traverse(child); // 递归遍历子节点 } } else if (node.name && node.name.startsWith("Face_")) { // 修改 name 值为 Face1, Face2... node.name = `Face${count}`; count++; } } traverse(jsonData); return jsonData; } //查找模型的第一个节点值获取id function getFirstId(obj) { // 检查是否有 children 并提取第一个节点的 id if (obj.children && obj.children.length > 0) { return obj.children[0].id; } return null; // 如果没有子节点,返回 null } //导入模型树节点 function OnTree(Idx){ updateJsonNodes(Idx); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //插入模型树节点与工程节点进行拼接 let pro_Index= model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); findAndAppendByName(tree, pro_name, Idx); //将模型树节点与工程节点拼接后保存到model中 let pro_model = model.acax_app.model.project.GetModel(); pro_model.pro_model = Idx; model.acax_app.model.project.SetModel(pro_model); ui.tree_Model.tree = tree; } ); ui.tree_Model.position = getFirstId(Idx); } //创建工况 function CreateWorkCondition(name){ let condition_index = model.acax_app.control.workCondition.Create(name); let cur_name = model.acax_app.model.workCondition.Current(); let cur_index = model.acax_app.view.GetCurrentProjectIndex(); let cur_id; console.log(model.acax_app.path.Parent(cur_index, 2) === model.acax_app.view.GetCurrentProjectIndex()); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((cur_name === info.name) && (model.acax_app.path.Parent(info.index, 2) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); //模型存在在加载 if(model.acax_app.model.project.GetModel().pro_model) { let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); ui.tree_Model.position = cur_id; } //创建材料属性 function CreateMaterial(mat) { model.acax_app.control.materialProp.Create(mat); let cur_name = model.acax_app.model.materialProp.Current(); let cur_index = model.acax_app.view.GetCurrentWorkConditionIndex(); let cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((cur_name === info.name) && (model.acax_app.path.Parent(info.index, 3) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); if(model.acax_app.model.project.GetModel().pro_model) { let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); ui.tree_Model.position = cur_id; } //修改材料面板属性属性 function ModifyMaterial(material) { //获取当前材料的名字 let material_name = model.acax_app.model.materialProp.Current(); model.acax_app.control.materialProp.Set(material, material_name); unit.form.mainfrm.OnCueline('修改成功', 'green'); } //创建载荷 function CreateBoundary(Load, name) { let load = model.acax_app.control.constrain.Create(Load, name); let cur_name = model.acax_app.model.constrain.Current(); let cur_index = model.acax_app.view.GetCurrentWorkConditionIndex(); let cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(index) { id2index[id] = index; index2id[index] = id; } if((cur_name === info.name) && (model.acax_app.path.Parent(info.index, 3) === cur_index)) { cur_id = info.id; } return { name : info.name, icon : info.icon, id : info.id, check_state : 0 }; }, tree => { //获取当前工程的名字 let pro_Index = model.acax_app.view.GetCurrentProjectIndex(); let pro_name = model.acax_app.path.Name(pro_Index); if(model.acax_app.model.project.GetModel().pro_model) { let cur_model = model.acax_app.model.project.GetModel().pro_model; findAndAppendByName(tree, pro_name, cur_model); } //赋值给dcip的树结构 ui.tree_Model.tree = tree; } ); ui.tree_Model.position = cur_id; } //修改载荷面板属性 function ModifyConstraint(constrain) { let constrain_name = model.acax_app.model.constrain.Current(); model.acax_app.control.constrain.Set(constrain, constrain_name); unit.form.mainfrm.OnCueline('修改成功', 'green'); } function OnMessage(idx){ ui.cueline.value += idx + '\n'; ui.cueline.row = -1; } function OnChangeMenu(Idx){ ui.tree_menu.index = parseInt(Idx); } function OnDeleteFile() { myArray.splice(parseFloat(ui.listbox.index), 1); ui.listbox.list = [ myArray ]; } function OnOpenFile(){ var fname = ui.OpenFileDialog("Import File", unit.dir + 'data/', "Step Files(*.step *.stp);;Iges Files(*.iges *.igs);;Nastran Files(*.nas)"); model.write(fname, model.getCurrentDirectory() + '/data/address.txt'); myArray.push(fname); ui.listbox.list = [ myArray ]; } function OnChangeOptions(){ options = !options; ui.stack_options.visible = options; } function OnTopMenu(idx) { ui.stack_import.visible = true; ui.stack_import.index = parseInt(idx) - 1; ui.pb_import01.valid = ui.pb_import02.valid = ui.pb_import03.valid = ui.pb_import04.valid = ui.pb_import05.valid = false; //model.ide_info(idx); if (parseInt(idx) === 1) { ui.pb_import01.valid = true; } if (parseInt(idx) === 2) { ui.pb_import02.valid = true; } if (parseInt(idx) === 3) { ui.pb_import03.valid = true; } if (parseInt(idx) === 4) { ui.pb_import04.valid = true; } if (parseInt(idx) === 5) { ui.pb_import05.valid = true; } } //The message corresponding callback executed by the docker pane. // when calling [side_pane].fireEvent(type,para) in the main form. function OnParentDockerMessage(type, para) { } ////////////////////////////////////////////////////////////////////////// // Utils Functions. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe function onDragFile(filepath) { } function PUI(cb) { if(pui){cb();} } /*Usage of BLOCK_EVENT BLOCK_EVENT(()=>{ ui.[name].[var] = ...; }); */ function BLOCK_EVENT(cb) { ui.block_event = true; cb(); ui.block_event = false; } ////////////////////////////////////////////////////////////////////////// // template codes for cw callback js. function CW_DeclareVariable(name, setter, getter) { if(typeof(__DeclareVariable) === 'function') { __DeclareVariable(name, setter, getter); } } function CW_DeclareOuterVariable(name) { if(typeof(__DeclareOuterVariable) === 'function') { __DeclareOuterVariable(name); } }