//////////////////////////////////////////////////////////////////////////// // 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; ui.tree_Model; ui.tree_Model.title = ['Part Assemblies/Parts', '?Color', 'UID']; } //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 getRandomHexColor() { // 随机生成一个 0 到 16777215 之间的整数,并转换为十六进制字符串 let color = Math.floor(Math.random() * 16777216).toString(16); // 确保颜色代码始终为 6 位 return "#" + color.padStart(6, "0"); } //生成求解文件 function GenerateFile() { model.execs(model.getCurrentDirectory() + "/src/generateBrep/generateBrep.exe " + model.acax_app.model.project.GetModel().step.replace(/\\/g, "/") + " " + model.getCurrentDirectory(), cb => { console.log(cb); }); model.acax_app.control.Export(info=>{ console.log(JSON.stringify(info, null, 2)); let cut_workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex(); var File = ['结构静力学前处理文件', '\n$ address', info.model3d.step.replace(/\\/g, "/")]; //添加材料 File.push("\n$ materials"); let str = info.mat_prop_list[0]["密度(g/cm^3)"] + " " + info.mat_prop_list[0]["弹性模量(MPa)"] + " " + info.mat_prop_list[0]["泊松比"] + " " +info.mat_prop_list[0]["屈服强度"]; File.push(str); //添加BPP File.push("\n$ BPP"); File.push(model.acax_app.view.GetProperty(cut_workcondition_index).BPP.BPP); //brepFiles File.push("\n$ brepFiles"); //需要brepFiles文件 let brep_data = model.acax_app.view.GetProperty(cut_workcondition_index).brep; let brep_arr = Object.keys(brep_data); for(let i = 0;i < brep_arr.length;++i) { File.push(brep_data[brep_arr[i]].brep); } /* if(self_prop.brep) { old_brep_path = model.acax_app.view.GetProperty(cut_workcondition_index).brep; brep_path = old_brep_path.concat(brep_path); brep_path = [...new Set(brep_path)]; } let new_prop = model.acax_app.view.GetProperty(cut_workcondition_index); new_prop.brep = brep_path; model.acax_app.view.SetProperty(cut_workcondition_index, new_prop);*/ //forceFace未实现 File.push("\n$ forceFace id xn yn zn xr yr zr"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "分布载荷压力" && info.cons_list[i]["位置标记"][0] === 'F' ) { let str0 = info.cons_list[i]["位置标记"].split(" "); let str1 = str0[2] + " "+ info.cons_list[i]["压力方向fa_x"] + " " + info.cons_list[i]["压力方向fa_y"] + " " + info.cons_list[i]["压力方向fa_z"] + " "+info.cons_list[i]["压力大小fa_xr"] + " " + info.cons_list[i]["压力大小fa_yr"] +" " + info.cons_list[i]["压力大小fa_zr"]; File.push(str1); } } //fixFace未实现 File.push("\n$ fixFace id xn yn zn xr yr zr"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "固定支撑" && info.cons_list[i].type[0] === 'F' ) { let str0 = info.cons_list[i].type.split(" "); let str1 = str0[2] + " "+ info.cons_list[i]["固定支撑属性xd"] + " " + info.cons_list[i]["固定支撑属性yd"] + " " + info.cons_list[i]["固定支撑属性zd"] + " "+info.cons_list[i]["固定支撑属性xr"] + " " + info.cons_list[i]["固定支撑属性yr"] +" " + info.cons_list[i]["固定支撑属性zr"]; File.push(str1); } } //添加梁和梁节点 for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "梁") { File.push("\n$ mat poi radius len seg Beam"); let str1 = info.cons_list[i]["弹性模量"] + " " + info.cons_list[i]["泊松比"] + " " + info.cons_list[i]["梁约束参数半径"] + " " +info.cons_list[i]["梁约束参数长度"] + " " + info.cons_list[i]["梁约束参数个数"]; File.push(str1); let len = info.cons_list[i]["梁约束参数个数"]; File.push("\n$ x y z Beam"); for(let j = 0 ; j <= len ;++j){ let str = info.cons_list[i].point[j*3] + " " +info.cons_list[i].point[j*3 +1] + " " +info.cons_list[i].point[j*3 + 2]; File.push(str); } } } //添加固定支撑 File.push("\n$ con ids id xd yd zd xr yr zr Beam"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "固定支撑" && info.cons_list[i].type[0] === 'B') { let str0 = info.cons_list[i].type.split(" "); let str1 = str0[1] + " " + str0[2] + " "+ info.cons_list[i]["固定支撑属性xd"] + " " + info.cons_list[i]["固定支撑属性yd"] + " " + info.cons_list[i]["固定支撑属性zd"] + " "+info.cons_list[i]["固定支撑属性xr"] + " " + info.cons_list[i]["固定支撑属性yr"] +" " + info.cons_list[i]["固定支撑属性zr"]; File.push(str1); } } //添加arrow File.push("\n$ arrow ids id xn yn zn xr yr zr Beam"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "固定支撑" && info.cons_list[i].type[0] === 'B') { let str0 = info.cons_list[i].type.split(" "); let str1 = str0[1] + " " + str0[2] + " "+ info.cons_list[i]["固定支撑属性xd"] + " " + info.cons_list[i]["固定支撑属性yd"] + " " + info.cons_list[i]["固定支撑属性zd"] + " "+info.cons_list[i]["固定支撑属性xr"] + " " + info.cons_list[i]["固定支撑属性yr"] +" " + info.cons_list[i]["固定支撑属性zr"]; File.push(str1); } } //添加弹簧 File.push("\n$ x y z X Y Z stiffness_x stiffness_y stiffness_z type1 type2 Spring"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "弹簧" && (info.cons_list[i].stypes[0] === 'P' ||info.cons_list[i].stypes[0] === 'B') && (info.cons_list[i].stypee[0] === 'P' ||info.cons_list[i].stypee[0] === 'B')) { let str1 = info.cons_list[i]["弹簧坐标x"] + " " + info.cons_list[i]["弹簧坐标y"] + " " + info.cons_list[i]["弹簧坐标z"] + " "+info.cons_list[i]["弹簧终点x"] + " " + info.cons_list[i]["弹簧终点y"] +" " + info.cons_list[i]["弹簧终点z"] + " " + info.cons_list[i].stiffness_x +" " + info.cons_list[i].stiffness_y+ " " + info.cons_list[i].stiffness_z + " " + info.cons_list[i].stypes[0] + " " + info.cons_list[i].stypee[0]; File.push(str1); } } //添加连接 File.push("\n$ type id1 id x1 y1 z1 type id1 id x2 y2 z2 xn yn zn xr yr zr Connect"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "连接" && (info.cons_list[i].ctypes[0] === 'P' ||info.cons_list[i].ctypes[0] === 'B') && (info.cons_list[i].ctpyee[0] === 'P' ||info.cons_list[i].ctpyee[0] === 'B')) { let str1 = info.cons_list[i].ctypes + " " + info.cons_list[i]["弹簧坐标x"] + " " + info.cons_list[i]["弹簧坐标y"] + " " + info.cons_list[i]["弹簧坐标z"] + " " + info.cons_list[i].ctpyee + " " + info.cons_list[i]["弹簧终点x"] + " " + info.cons_list[i]["弹簧终点y"] +" " + info.cons_list[i]["弹簧终点z"] + " " + info.cons_list[i]["弹簧材料xn"] +" " + info.cons_list[i]["弹簧材料yn"]+ " " + info.cons_list[i]["弹簧材料zn"] + " " + info.cons_list[i]["弹簧材料xr"] + " " + info.cons_list[i]["弹簧材料yr"]+ " "+ info.cons_list[i]["弹簧材料zr"]; File.push(str1); } } //添加rb3 for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "rb3") { File.push("\n$ id RB3"); let str1 = info.cons_list[i]["编号"]; str1 = str1.split(" "); console.log(str1); for(let j = 0;j < str1.length;++j) { if(str1[j] !== '') { File.push(str1[j]); } } File.push("\n$ type id ids x y z RB3"); let str = info.cons_list[i].types + " " +info.cons_list[i].x + " " + info.cons_list[i].y + " " + info.cons_list[i].z; File.push(str); } } console.log("rb3"); //集中载荷rb3 File.push("\n$ arrow type id ids xn yn zn xr yr zr RB3"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "集中载荷压力" && info.cons_list[i]["位置标记"][0] === 'P' ) { let str1 = info.cons_list[i]["位置标记"] + " " + info.cons_list[i]["压力方向xn"] + " " + info.cons_list[i]["压力方向yn"] + " "+info.cons_list[i]["压力方向zn"] + " " + info.cons_list[i]["压力大小xr"] +" " + info.cons_list[i]["压力大小yr"]+ " " + info.cons_list[i]["压力大小zr"]; File.push(str1); } } //固定支撑rb3 File.push("\n$ con type id ids xn yn zn xr yr zr RB3"); for(let i = 0;i < info.cons_list.length;++i ) { if(info.cons_list[i].constraint === "固定支撑" && info.cons_list[i].type[0] === 'P') { let str1 = info.cons_list[i]["位置标记"] + " "+ info.cons_list[i]["固定支撑属性xd"] + " " + info.cons_list[i]["固定支撑属性yd"] + " " + info.cons_list[i]["固定支撑属性zd"] + " "+info.cons_list[i]["固定支撑属性xr"] + " " + info.cons_list[i]["固定支撑属性yr"] +" " + info.cons_list[i]["固定支撑属性zr"]; File.push(str1); } } model.writeFile(File); }); } function OnTest1(){ //console.log(model.acax_app.model.constrain.Database()); GenerateFile() ; //console.log(model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current())); } //创建约束显示 function CreateContrainShow() { if(model.acax_app.model.workArea.Current() !== false && model.acax_app.model.project.Current() !== "" &&model.acax_app.model.workCondition.Current() !== ""){ //获取工况数据库 var new_arr_key ; var constrain_data; if(model.acax_app.model.workCondition.Current() === "") { new_arr_key = []; }else{ constrain_data = model.acax_app.model.workCondition.Get(model.acax_app.model.workCondition.Current()); if(Object.keys(constrain_data.constrain.db).length !== 0) { new_arr_key = Object.keys(constrain_data.constrain.db); }else{ new_arr_key = []; } } //查看当前工程工况是否已加载 const path1 = model.acax_app.model.workArea.Database().list[0]; const workarea_name1 =path1.substring(path1.lastIndexOf('/') + 1); var cur_name = workarea_name1 + model.acax_app.model.project.Current() + model.acax_app.model.workCondition.Current(); var flag = 1; if(workcondition.includes(cur_name)) { for(let i = 0;i < new_arr_key.length;++i) { let type = constrain_data.constrain.db[new_arr_key[i]].cons_type; unit.form.mainfrm.HideAndShow(type, constrain_data.constrain.db[new_arr_key[i]].unique, false); if(type === "rb3" && flag) { unit.form.mainfrm.HideAndShow("pick", "rb3", false); flag = 0; } } ShowPoints(); }else{ for(let i = 0;i < new_arr_key.length;++i) { if(constrain_data.constrain.db[new_arr_key[i]].constraint === "集中载荷压力") { unit.form.mainfrm.OnArrows(constrain_data.constrain.db[new_arr_key[i]]["位置坐标x"], constrain_data.constrain.db[new_arr_key[i]]["位置坐标y"], constrain_data.constrain.db[new_arr_key[i]]["位置坐标z"], constrain_data.constrain.db[new_arr_key[i]]["压力方向xn"], constrain_data.constrain.db[new_arr_key[i]]["压力方向yn"], constrain_data.constrain.db[new_arr_key[i]]["压力方向zn"], constrain_data.constrain.db[new_arr_key[i]].unique); console.log("集中载荷压力"); } if(constrain_data.constrain.db[new_arr_key[i]].constraint === "固定支撑") { unit.form.mainfrm.OnConstrains(constrain_data.constrain.db[new_arr_key[i]].xc, constrain_data.constrain.db[new_arr_key[i]].yc, constrain_data.constrain.db[new_arr_key[i]].zc, constrain_data.constrain.db[new_arr_key[i]].unique); } if(constrain_data.constrain.db[new_arr_key[i]].constraint === "梁") { unit.form.mainfrm.OnBeams(constrain_data.constrain.db[new_arr_key[i]]["梁约束参数个数"], constrain_data.constrain.db[new_arr_key[i]]["梁约束位置xDirection"], constrain_data.constrain.db[new_arr_key[i]]["梁约束位置yDirection"], constrain_data.constrain.db[new_arr_key[i]]["梁约束位置zDirection"], constrain_data.constrain.db[new_arr_key[i]]["梁约束位置xCoord"], constrain_data.constrain.db[new_arr_key[i]]["梁约束位置yCoord"], constrain_data.constrain.db[new_arr_key[i]]["梁约束位置zCoord"], constrain_data.constrain.db[new_arr_key[i]].R, constrain_data.constrain.db[new_arr_key[i]].G, constrain_data.constrain.db[new_arr_key[i]].B, constrain_data.constrain.db[new_arr_key[i]]["梁节点大小半径"], constrain_data.constrain.db[new_arr_key[i]].unique); } if(constrain_data.constrain.db[new_arr_key[i]].constraint === "连接") { unit.form.mainfrm.OnConnects(constrain_data.constrain.db[new_arr_key[i]]["弹簧坐标x"], constrain_data.constrain.db[new_arr_key[i]]["弹簧坐标y"], constrain_data.constrain.db[new_arr_key[i]]["弹簧坐标z"], constrain_data.constrain.db[new_arr_key[i]]["弹簧终点x"], constrain_data.constrain.db[new_arr_key[i]]["弹簧终点y"], constrain_data.constrain.db[new_arr_key[i]]["弹簧终点z"], constrain_data.constrain.db[new_arr_key[i]].R, constrain_data.constrain.db[new_arr_key[i]].G, constrain_data.constrain.db[new_arr_key[i]].B, constrain_data.constrain.db[new_arr_key[i]].unique); } if(constrain_data.constrain.db[new_arr_key[i]].constraint === "弹簧") { unit.form.mainfrm.OnSpring(constrain_data.constrain.db[new_arr_key[i]]["弹簧坐标x"], constrain_data.constrain.db[new_arr_key[i]]["弹簧坐标y"], constrain_data.constrain.db[new_arr_key[i]]["弹簧坐标z"], constrain_data.constrain.db[new_arr_key[i]]["弹簧终点x"], constrain_data.constrain.db[new_arr_key[i]]["弹簧终点y"], constrain_data.constrain.db[new_arr_key[i]]["弹簧终点z"], constrain_data.constrain.db[new_arr_key[i]].R, constrain_data.constrain.db[new_arr_key[i]].G, constrain_data.constrain.db[new_arr_key[i]].B, constrain_data.constrain.db[new_arr_key[i]].unique); } if(constrain_data.constrain.db[new_arr_key[i]].constraint === "分布载荷压力") { unit.form.mainfrm.OnArrows(constrain_data.constrain.db[new_arr_key[i]]["位置坐标x"], constrain_data.constrain.db[new_arr_key[i]]["位置坐标y"], constrain_data.constrain.db[new_arr_key[i]]["位置坐标z"], constrain_data.constrain.db[new_arr_key[i]]["压力方向fa_x"], constrain_data.constrain.db[new_arr_key[i]]["压力方向fa_y"], constrain_data.constrain.db[new_arr_key[i]]["压力方向fa_z"], constrain_data.constrain.db[new_arr_key[i]].unique); } if(constrain_data.constrain.db[new_arr_key[i]].constraint === "rb3") { unit.form.mainfrm.OnSpheres(constrain_data.constrain.db[new_arr_key[i]].x, constrain_data.constrain.db[new_arr_key[i]].y, constrain_data.constrain.db[new_arr_key[i]].z, constrain_data.constrain.db[new_arr_key[i]].radius, constrain_data.constrain.db[new_arr_key[i]].unique); } } //加载点 OnLoadPoints(); workcondition.push(cur_name); } } } //已创建但被隐藏,显示点 function ShowPoints() { let work_condition = model.acax_app.view.GetCurrentWorkConditionIndex(); let point_model = model.acax_app.view.GetProperty(work_condition).point; let point_arr = Object.keys(point_model); for(let i = 0;i < point_arr.length;++i) { unit.form.mainfrm.HideAndShow("points", point_model[point_arr[i]].name, false); } } //加载点 function OnLoadPoints() { let work_condition = model.acax_app.view.GetCurrentWorkConditionIndex(); let point_model = model.acax_app.view.GetProperty(work_condition).point; let point_arr = Object.keys(point_model); for(let i = 0;i < point_arr.length;++i) { unit.form.mainfrm.OnSetPoints(point_model[point_arr[i]].x, point_model[point_arr[i]].y, point_model[point_arr[i]].z, point_model[point_arr[i]].radius, point_model[point_arr[i]].name); } } //隐藏旧的工况 function HideWorkcondition() { if(model.acax_app.model.workArea.Current() !== false && model.acax_app.model.project.Current() !== "" &&model.acax_app.model.workCondition.Current() !== ""){ let old_workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex(); var point_model; var point_arr; if( model.acax_app.view.GetProperty(old_workcondition_index) === undefined || model.acax_app.view.GetProperty(old_workcondition_index).point === undefined) { point_model = {}; }else{ point_model = model.acax_app.view.GetProperty(old_workcondition_index).point; } point_arr = Object.keys(point_model); let constrain_data = model.acax_app.model.workCondition.Get(model.acax_app.model.workCondition.Current()); var old_arr_key ; if(Object.keys(constrain_data.constrain.db).length !== 0) { old_arr_key = Object.keys(constrain_data.constrain.db); }else{ old_arr_key = []; } //旧的隐藏 //紫色包围盒开关 var flag = 1; for(let i = 0;i { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } 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 : cur_check_state }; }, 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } 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 : cur_check_state }; }, 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } 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 : cur_check_state }; }, 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(){ 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; } } var workcondition = []; //点击树 function OnClickTree(){ //获取模型树的对应节点 //ui.tree_Model. 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 => { HideWorkcondition(); OpenWorkArea(info.prop); //切换到当前工作区 ui.tree_Model.position = g_cur_index2id_cache[model_id]; }); } break; //选中材料库 case 1: break; //切换工程 case 2: //不是当前工程,切换工程 if(model_id !== cur_proj){ //隐藏掉旧的工况 HideWorkcondition(); 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]; //在canvas显示新的约束 CreateContrainShow(); }); } break; //切换工况 case 3: //不是当前工况,切换工况 if(model_id !== cur_workcondition){ model.acax_app.view.RenderNode(model_id, info => { //隐藏工况 HideWorkcondition(); //切换工况,旧的隐藏 let old_data = ChangeWorkCondition(model.acax_app.path.Name(model_id)); ui.tree_Model.position = g_cur_index2id_cache[model_id]; //显示工况 CreateContrainShow(); }); } 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]; //渲染到3D模型 if(ui.tree_Model.node.check_state === 2) { unit.form.mainfrm.HideAndShow(info.prop.cons_type, info.prop.unique, false); console.log("show"); }else if(ui.tree_Model.node.check_state === 0) { unit.form.mainfrm.HideAndShow(info.prop.cons_type, info.prop.unique, true); console.log("hide"); } }); 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); }, "rb3":function(){ unit.form.mainfrm.menu(23); unit.form.mainfrm.setConstraint(prop); } }; constraint[constraint_name](); } //测试函数 function OnTest(){ //GenerateFile(); // 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; }else if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } 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 : cur_check_state }; }, 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); CreateContrainShow(); }); } } //切换工程 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; }else if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } 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 : cur_check_state }; }, 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) { var old_data = model.acax_app.model.workCondition.Get(model.acax_app.model.workCondition.Current()); model.acax_app.control.workCondition.SwitchTo(wor_name); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; }else if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } 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 : cur_check_state }; }, 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); }); }*/ return old_data; } //创建工作区 function CreateWorkArea(name) { let tree_color = []; HideWorkcondition(); model.acax_app.control.workArea.Append(name); let cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } if(cur_type === 0 || cur_type === 2 ||cur_type === 3) { tree_color.push(""); } 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 : cur_check_state }; }, tree=>{ ui.tree_Model.tree = tree; }); ui.tree_Model.position = cur_id; //渲染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.column = [1, tree_color]; } //创建工程 function CreateProject(name) { let tree_color = []; //隐藏掉旧的工况 HideWorkcondition(); 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } if(cur_type === 0 || cur_type === 2 ||cur_type === 3) { tree_color.push(""); } 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 : cur_check_state }; }, tree=>{ ui.tree_Model.tree = tree; }); ui.tree_Model.position = cur_id; //渲染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.column = [1, tree_color]; } //导入模型 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); }); } ); } //插入新子节点 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 } //给面节点改名字并添加check_state属性 function updateJsonNodes(jsonData) { let count = 1; // 用于计数生成 Face1, Face2... let count_id = 100000; function traverse(node) { // 为每个节点添加 check_state: 2 属性 node.check_state = 3; node.icon = ''; node.r_id = node.id; node.id = ++count_id; node.color = getRandomHexColor(); // 如果存在 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 dfsSetColor(node) { // 如果节点有 color 属性,加入数组 if (node.color) { tree_color.push(node.color); } // 遍历子节点 if (node.children && node.children.length > 0) { node.children.forEach(child => dfs(child)); } } //导入模型树节点 function OnTree(Idx){ let tree_color = []; updateJsonNodes(Idx); model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ //设置id let color = ""; let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } let id2index = g_cur_id2index_cache; let index2id = g_cur_index2id_cache; let index = info.index; let id = info.id; if(cur_type === 0 || cur_type === 2 ||cur_type === 3) { color = ""; } if(cur_type === 4 && model.acax_app.view.GetCurrentWorkConditionIndex() === model.acax_app.path.Parent(info.index, 3)) { console.log(JSON.stringify(model.acax_app.model.constrain.Get(info.name), null, 2)); color = model.acax_app.model.constrain.Get(info.name).color; } if(index) { id2index[id] = index; index2id[index] = id; } return { name : info.name, icon : info.icon, id : info.id, check_state : cur_check_state, color : color }; }, 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); console.log(JSON.stringify(tree, null, 2)); dfsSetColor(tree); ui.tree_Model.tree = tree; } ); ui.tree_Model.column = [1, tree_color]; ui.tree_Model.position = getFirstId(Idx); } //创建工况 function CreateWorkCondition(name){ //隐藏掉旧的工况 HideWorkcondition(); 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; } if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } 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 : cur_check_state }; }, 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; tree_color.push(""); ui.tree_Model.column = [1, tree_color]; } //创建材料属性 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=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; }else if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } 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 : cur_check_state }; }, 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; //将材料属性添加到模型信息中 model.acax_app.view.Render3D(info=>{ info.model3d.materialProps.push(mat); }); tree_color.push(getRandomHexColor()); ui.tree_Model.column = [1, tree_color]; } //修改材料面板属性属性 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(); var cur_id; model.acax_app.view.RenderTree(() => { g_cur_id2index_cache = {}; g_cur_index2id_cache = {}; }, info=>{ //设置id let cur_check_state = 0; let cur_type = model.acax_app.path.Type(info.index); if( cur_type === 0 || cur_type === 2 || cur_type === 5) { cur_check_state = 3; }else if((cur_type === 4 && model.acax_app.path.Parent(info.index, 3) === model.acax_app.view.GetCurrentWorkConditionIndex()) ||(info.index === model.acax_app.view.GetCurrentWorkConditionIndex())) { cur_check_state = 2; } 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; cur_check_state = 2; } return { name : info.name, icon : info.icon, id : info.id, check_state : cur_check_state }; }, 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; } ); //将载荷属性添加到模型信息中 console.log(cur_id); ui.tree_Model.position = cur_id; model.acax_app.view.Render3D(info=>{ info.model3d.constrains.push(Load); }); tree_color.push(getRandomHexColor()); ui.tree_Model.column = [1, tree_color]; } //修改载荷面板属性 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); } }