//////////////////////////////////////////////////////////////////////////// // System Pre-define Functions // 95099372-ef3e-11ea-9c81-bf848405c62e //Callback of data preparation stage before UI is fully loaded. 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.stack_constraint.index = 1; // ui.stack_menu.index = 2; //control(true); //controls(true); //ui.stack_constraint.index = 2; //ui.stack_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); } ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 /* function OnGetFaceName(){ const str = unit.form.mainfrm.OnGetFaceName(); // 匹配type对应内容的正则表达式,以type:开头,后面跟着非冒号的内容直到遇到空格或者字符串结束 const typeRegex = /type:([^point]+)/; // 匹配center坐标对应内容的正则表达式 const centerRegex = /point:([\d. ]+)/; const typeMatch = str.match(typeRegex); const typeInfo = typeMatch? typeMatch[1] : null; const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; ui.type.value = typeInfo; ui.xc.value = centerCoords[0]; ui.yc.value = centerCoords[1]; ui.zc.value = centerCoords[2]; }*/ function OnGetFaceName(){ const str = unit.form.mainfrm.OnGetFaceName(); console.log(str); // 匹配type对应内容的正则表达式,以type:开头,后面跟着非冒号的内容直到遇到空格或者字符串结束 const typeRegex = /type:([^point]+)/; // 匹配center坐标对应内容的正则表达式 //const centerRegex = /point:([\d. ]+)/; const typeMatch = str.match(typeRegex); const typeInfo = typeMatch? typeMatch[1] : null; //const centerMatch = str.match(centerRegex); //const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; const match = str.match(/point:([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)/); const centerCoords = match.slice(1, 4); ui.type.value = typeInfo; ui.xc.value = centerCoords[0]; ui.yc.value = centerCoords[1]; ui.zc.value = centerCoords[2]; } function OnCPointAddEnd(){ const str = unit.form.mainfrm.OnGetName(); // 匹配center坐标对应内容的正则表达式 const centerRegex = /center:([\d. ]+)/; const typeInfo = str.split(' ').slice(1, 4).join(' '); const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; ui.ctpyee.value = typeInfo; ui.cxe.value = centerCoords[0]; ui.cye.value = centerCoords[1]; ui.cze.value = centerCoords[2]; } function OnCPointAddStart(){ const str = unit.form.mainfrm.OnGetName(); // 匹配center坐标对应内容的正则表达式 const centerRegex = /center:([\d. ]+)/; const typeInfo = str.split(' ').slice(1, 4).join(' '); const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; ui.ctypes.value = typeInfo; ui.cxs.value = centerCoords[0]; ui.cys.value = centerCoords[1]; ui.czs.value = centerCoords[2]; } function OnSPointAddEnd(){ const str = unit.form.mainfrm.OnGetName(); // 匹配center坐标对应内容的正则表达式 const centerRegex = /center:([\d. ]+)/; const typeInfo = str.split(' ').slice(1, 4).join(' '); const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; ui.stypee.value = typeInfo; ui.sxe.value = centerCoords[0]; ui.sye.value = centerCoords[1]; ui.sze.value = centerCoords[2]; } function OnSPointAddStart(){ const str = unit.form.mainfrm.OnGetName(); // 匹配center坐标对应内容的正则表达式 const centerRegex = /center:([\d. ]+)/; const typeInfo = str.split(' ').slice(1, 4).join(' '); const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; ui.stypes.value = typeInfo; ui.sxs.value = centerCoords[0]; ui.sys.value = centerCoords[1]; ui.szs.value = centerCoords[2]; } function OnGetName(){ const str = unit.form.mainfrm.OnGetName(); console.log(str); // 匹配center坐标对应内容的正则表达式 const centerRegex = /center:([\d. ]+)/; const typeInfo = str.split(' ').slice(1, 4).join(' '); const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; ui.type.value = typeInfo; ui.xc.value = centerCoords[0]; ui.yc.value = centerCoords[1]; ui.zc.value = centerCoords[2]; } //修改约束 function OnModify(){ if(ui.limit_constraint.index === 0 && ui.constraint_type.index === 0) { let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique; unit.form.mainfrm.OnModifyConstrains(ui.xc.value, ui.yc.value, ui.zc.value, name); let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color; let Load = { "constraint":"固定支撑", "约束类型":ui.constraint_type.value, "type":ui.type.value, "xc":ui.xc.value, "yc":ui.yc.value, "zc":ui.zc.value, "固定支撑属性xd":ui.con_xn.value, "固定支撑属性xr":ui.con_xr.value, "固定支撑属性yd":ui.con_yn.value, "固定支撑属性yr":ui.con_yr.value, "固定支撑属性zd":ui.con_zn.value, "固定支撑属性zr":ui.con_zr.value, "cons_type":"constraints", "color":color, "unique":name }; unit.form.tree.ModifyConstraint(Load); unit.form.mainfrm.OnCueline('修改成功', 'green'); } if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 0 ) { let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique; unit.form.mainfrm.OnModifyBeams(ui.pb_size.value, ui.pb_xDiration.value, ui.pb_yDiration.value, ui.pb_zDiration.value, ui.pb_xCoord.value, ui.pb_yCoord.value, ui.pb_zCoord.value, ui.R.value, ui.G.value, ui.B.value, ui.pb_node_size.value, name); let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color; let Load = { "constraint":"梁", "非约束类型":ui.misConstraints.value, "梁约束位置xDirection":ui.pb_xDiration.value, "梁约束位置yDirection":ui.pb_yDiration.value, "梁约束位置zDirection":ui.pb_zDiration.value, "梁约束位置xCoord":ui.pb_xCoord.value, "梁约束位置yCoord":ui.pb_yCoord.value, "梁约束位置zCoord":ui.pb_zCoord.value, "梁约束参数半径":ui.rad.value, "梁约束参数长度":ui.pb_length.value, "梁约束参数个数":ui.pb_size.value, "弹性模量":ui.m.value, "泊松比":ui.poi.value, "梁节点大小半径":ui.pb_node_size.value, "R":ui.R.value, "G":ui.G.value, "B":ui.B.value, "cons_type":"beams", "color":color, "unique":name }; unit.form.tree.ModifyConstraint(Load); unit.form.mainfrm.OnCueline('修改成功', 'green'); } if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 1 ) { let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique; unit.form.mainfrm.OnModifySpring(ui.sxs.value, ui.sys.value, ui.szs.value, ui.sxe.value, ui.sye.value, ui.sze.value, ui.sr.value, ui.sg.value, ui.sb.value, name); let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color; let Load = { "constraint":"弹簧", "非约束类型":ui.misConstraints.value, "弹簧坐标x":ui.sxs.value, "弹簧坐标y":ui.sys.value, "弹簧坐标z":ui.szs.value, "stypes":ui.stypes.value, "弹簧终点x":ui.sxe.value, "弹簧终点y":ui.sye.value, "弹簧终点z":ui.sze.value, "stypee":ui.stypee.value, "stiffness_x":ui.sstifx.value, "stiffness_y":ui.sstify.value, "stiffness_z":ui.sstifz.value, "R":ui.sr.value, "G":ui.sg.value, "B":ui.sb.value, "cons_type":"spring", "color":color, "unique":name }; unit.form.tree.ModifyConstraint(Load); unit.form.mainfrm.OnCueline('修改成功', 'green'); } if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 2 ) { let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique; unit.form.mainfrm.OnModifyConnects(ui.cxs.value, ui.cys.value, ui.czs.value, ui.cxe.value, ui.cye.value, ui.cze.value, ui.cr.value, ui.cg.value, ui.cb.value, name); let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color; let Load = { "constraint":"连接", "非约束类型":ui.misConstraints.value, "弹簧坐标x":ui.cxs.value, "弹簧坐标y":ui.cys.value, "弹簧坐标z":ui.czs.value, "ctypes":ui.ctypes.value, "弹簧终点x":ui.cxe.value, "弹簧终点y":ui.cye.value, "弹簧终点z":ui.cze.value, "ctpyee":ui.ctpyee.value, "弹簧材料xn":ui.cxn.value, "弹簧材料yn":ui.cyn.value, "弹簧材料zn":ui.czn.value, "弹簧材料xr":ui.cxr.value, "弹簧材料yr":ui.cyr.value, "弹簧材料zr":ui.czr.value, "R":ui.cr.value, "G":ui.cg.value, "B":ui.cb.value, "cons_type":"connect", "color":color, "unique":name }; unit.form.tree.ModifyConstraint(Load); unit.form.mainfrm.OnCueline('修改成功', 'green'); } } function OnChangeBeam(){ if(parseFloat(ui.pb_length.value) <= 0 || parseFloat(ui.rad.value) <= 0 || parseFloat(ui.m.value) <= 0 || parseFloat(ui.poi.value) <= 0 || parseFloat(ui.rad.value) <= 0){ unit.form.mainfrm.OnChangePicture(3, 3); //unit.form.mainfrm.OnCueline('

非常抱歉,您输入的数据不在参数范围内!

'); unit.form.mainfrm.OnCueline('您输入的数据不在参数范围内!', 'red'); }else{ unit.form.mainfrm.OnChangePicture(3, 2); //unit.form.mainfrm.OnCueline('

恭喜您,您输入了正确的数据!

'); unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'blue'); } } function OnFix(){ let temp = unit.form.tree.GetCurUniqueName(); let name = temp; let constrain_data = model.acax_app.model.constrain.Database(); //console.log(workcondition_data); let i = 0; let j = 0; let constrain_arr = Object.keys(constrain_data.db); //console.log(constrain_data.db); name = name + "fix0"; while(1){ for( i = 0;i < constrain_arr.length;++i) { if(constrain_data.db[constrain_arr[i]].unique === name) { ++j; name = temp + "fix" + j; break; } } if(i === constrain_arr.length) { break; } } let name1 = unit.form.mainfrm.OnConstrains(ui.xc.value, ui.yc.value, ui.zc.value, name); name1 = name1.replace(temp, ""); unit.form.mainfrm.OnChangePicture(3, 2); let color = unit.form.tree.getRandomHexColor(); let Load = { "constraint":"固定支撑", "约束类型":ui.constraint_type.value, "type":ui.type.value, "xc":ui.xc.value, "yc":ui.yc.value, "zc":ui.zc.value, "固定支撑属性xd":ui.con_xn.value, "固定支撑属性xr":ui.con_xr.value, "固定支撑属性yd":ui.con_yn.value, "固定支撑属性yr":ui.con_yr.value, "固定支撑属性zd":ui.con_zn.value, "固定支撑属性zr":ui.con_zr.value, "cons_type":"constraints", "color":color, "unique":name }; // console.log(name1); if(ui.type.value === '--') { unit.form.mainfrm.OnCueline('未添加中心坐标', 'green'); }else{ unit.form.tree.CreateBoundary(Load, name1); unit.form.mainfrm.OnCueline('您完成了固定支撑属性的添加,请用鼠标右键选中需要施加约束的物体并按快捷键T或者t进行添加!', 'green'); } } function OnBeam2(){ unit.form.mainfrm.OnSend('beamHightLight2 ' + ui.m_seg.value + ' ' + ui.m_len.value + ' ' + ui.m_radius.value + ' ' + ui.m_mat.value + ' ' + ui.m_poi.value + ' ' + ui.m_R.value + ' '+ ui.m_G.value + ' ' + ui.m_B.value + ' ' + ui.m_ras.value); model.clearStr(); unit.form.mainfrm.OnChangePicture(3, 2); unit.form.mainfrm.OnCueline('您成功做好了不均匀梁的添加!', 'green'); } function OnConnect(){ let temp = unit.form.tree.GetCurUniqueName(); let name = temp; let constrain_data = model.acax_app.model.constrain.Database(); let i = 0; let j = 0; let constrain_arr = Object.keys(constrain_data.db); name = name + "con0"; while(1){ for( i = 0;i < constrain_arr.length;++i) { if(constrain_data.db[constrain_arr[i]].unique === name) { ++j; name = temp + "con" + j; break; } } if(i === constrain_arr.length) { break; } } let name1 = unit.form.mainfrm.OnConnects(ui.cxs.value, ui.cys.value, ui.czs.value, ui.cxe.value, ui.cye.value, ui.cze.value, ui.cr.value, ui.cg.value, ui.cb.value, name); name1 = name1.replace(temp, ""); //console.log(name1); unit.form.mainfrm.OnChangePicture(3, 2); let color = unit.form.tree.getRandomHexColor(); let Load = { "constraint":"连接", "非约束类型":ui.misConstraints.value, "弹簧坐标x":ui.cxs.value, "弹簧坐标y":ui.cys.value, "弹簧坐标z":ui.czs.value, "ctypes":ui.ctypes.value, "弹簧终点x":ui.cxe.value, "弹簧终点y":ui.cye.value, "弹簧终点z":ui.cze.value, "ctpyee":ui.ctpyee.value, "弹簧材料xn":ui.cxn.value, "弹簧材料yn":ui.cyn.value, "弹簧材料zn":ui.czn.value, "弹簧材料xr":ui.cxr.value, "弹簧材料yr":ui.cyr.value, "弹簧材料zr":ui.czr.value, "R":ui.cr.value, "G":ui.cg.value, "B":ui.cb.value, "cons_type":"connect", "color":color, "unique":name }; //console.log(name1); if(ui.ctypes.value === '--' || ui.ctpyee.value === '--') { unit.form.mainfrm.OnCueline('未添加弹簧坐标', 'red'); }else{ unit.form.tree.CreateBoundary(Load, name1); unit.form.mainfrm.OnCueline('您成功地做好了连接!', 'green'); } } function onEndMessage(){ controls(false); } function onStartMessage(){ controls(true); } function controls(idx){ ui.pb_start_message.enable = !idx; ui.pb_start_mes.enable = !idx; ui.pb_start_x.enable = idx; ui.pb_start_y.enable = idx; ui.pb_start_z.enable = idx; ui.pb_end_message.enable = idx; ui.pb_end_mes.enable = idx; ui.pb_end_x.enable = !idx; ui.pb_end_y.enable = !idx; ui.pb_end_z.enable = !idx; if(idx === true){ model.setStartEnd(0); } if(idx === false){ model.setStartEnd(1); } } function OnChangeValue(){ ui.pb_pass.enable = false; } function OnReturn(){ unit.form.mainfrm.menu(4); } function OnFile(){ ui.pb_pass.enable = true; model.setCon(1); if(ui.stack_menu.index === 0){ let id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('beamSave ' + model.getCurrentDirectory()); } if(ui.stack_menu.index === 1){ let id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('springSave ' + model.getCurrentDirectory()); } } function OnSpring(){ let temp = unit.form.tree.GetCurUniqueName(); let name = temp; let constrain_data = model.acax_app.model.constrain.Database(); //console.log(workcondition_data); let i = 0; let j = 0; let constrain_arr = Object.keys(constrain_data.db); //console.log(constrain_data.db); name = name + "spring0"; while(1){ for( i = 0;i < constrain_arr.length;++i) { if(constrain_data.db[constrain_arr[i]].unique === name) { ++j; name = temp + "spring" + j; break; } } if(i === constrain_arr.length) { break; } } let name1 = unit.form.mainfrm.OnSpring(ui.sxs.value, ui.sys.value, ui.szs.value, ui.sxe.value, ui.sye.value, ui.sze.value, ui.sr.value, ui.sg.value, ui.sb.value, name); name1 = name1.replace(temp, ""); unit.form.mainfrm.OnChangePicture(3, 2); let color = unit.form.tree.getRandomHexColor(); let Load = { "constraint":"弹簧", "非约束类型":ui.misConstraints.value, "弹簧坐标x":ui.sxs.value, "弹簧坐标y":ui.sys.value, "弹簧坐标z":ui.szs.value, "stypes":ui.stypes.value, "弹簧终点x":ui.sxe.value, "弹簧终点y":ui.sye.value, "弹簧终点z":ui.sze.value, "stypee":ui.stypee.value, "stiffness_x":ui.sstifx.value, "stiffness_y":ui.sstify.value, "stiffness_z":ui.sstifz.value, "R":ui.sr.value, "G":ui.sg.value, "B":ui.sb.value, "cons_type":"spring", "color":color, "unique":name }; //console.log(name1); if(ui.stypes.value === '--' || ui.stypee.value === '--') { unit.form.mainfrm.OnCueline('未添加弹簧坐标', 'green'); }else{ unit.form.tree.CreateBoundary(Load, name1); unit.form.mainfrm.OnCueline('您完成了弹簧约束的添加!', 'green'); } } function OnBeam(){ let temp = unit.form.tree.GetCurUniqueName(); let name = temp; let constrain_data = model.acax_app.model.constrain.Database(); //console.log(workcondition_data); let i = 0; let j = 0; let constrain_arr = Object.keys(constrain_data.db); //console.log(constrain_data.db); name = name + "beam0"; while(1){ for( i = 0;i < constrain_arr.length;++i) { if(constrain_data.db[constrain_arr[i]].unique.split(" ")[0] === name) { ++j; name = temp + "beam" + j; break; } } if(i === constrain_arr.length) { break; } } name = name + " B 0"; const str =unit.form.mainfrm.OnBeams(ui.pb_size.value, ui.pb_xDiration.value, ui.pb_yDiration.value, ui.pb_zDiration.value, ui.pb_xCoord.value, ui.pb_yCoord.value, ui.pb_zCoord.value, ui.R.value, ui.G.value, ui.B.value, ui.pb_node_size.value, name); let name1 = str.split(' ')[0].split(':')[1]; name1 = name1.replace(temp, ""); const centerRegex = /centers:([\d. ]+)/; const centerMatch = str.match(centerRegex); const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null; let color = unit.form.tree.getRandomHexColor(); unit.form.mainfrm.OnChangePicture(3, 2); let Load = { "constraint":"梁", "非约束类型":ui.misConstraints.value, "梁约束位置xDirection":ui.pb_xDiration.value, "梁约束位置yDirection":ui.pb_yDiration.value, "梁约束位置zDirection":ui.pb_zDiration.value, "梁约束位置xCoord":ui.pb_xCoord.value, "梁约束位置yCoord":ui.pb_yCoord.value, "梁约束位置zCoord":ui.pb_zCoord.value, "梁约束参数半径":ui.rad.value, "梁约束参数长度":ui.pb_length.value, "梁约束参数个数":ui.pb_size.value, "弹性模量":ui.m.value, "泊松比":ui.poi.value, "梁节点大小半径":ui.pb_node_size.value, "R":ui.R.value, "G":ui.G.value, "B":ui.B.value, "point":centerCoords, "cons_type":"beams", "color":color, "unique":name }; //console.log(name1); unit.form.tree.CreateBoundary(Load, name1); unit.form.mainfrm.OnCueline('您完成了梁约束的添加!', 'green'); } function control(idx){ ui.pb_start.enable = !idx; ui.pb_x.enable = idx; ui.pb_y.enable = idx; ui.pb_z.enable = idx; ui.pb_end.enable = idx; ui.pb_X.enable = !idx; ui.pb_Y.enable = !idx; ui.pb_Z.enable = !idx; if(idx === true){ model.setStartEnd(0); } if(idx === false){ model.setStartEnd(1); } } function OnEed(){ control(false); } function OnStart(){ control(true); } function OnChangeMenu(){ ui.stack_menu.index = parseFloat(ui.misConstraints.index); // console.log(ui.no_limit_constraint.index === 1); //console.log(ui.limit_constraint.index); if(ui.stack_menu.index === 3){ model.setBeam(true); }else{ model.setBeam(false); } } function OnChangeConstraint(){ ui.stack_constraint.index = ui.limit_constraint.index; if(parseFloat(idx) === 1){ unit.form.mainfrm.OnChangePicture(3, 1); unit.form.mainfrm.OnCueline('注意事项:弹簧单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第3个按钮)添加即可将坐标导入!', 'blue'); }else if(parseFloat(idx) === 2){ unit.form.mainfrm.OnChangePicture(3, 1); unit.form.mainfrm.OnCueline('注意事项:连接单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第3个按钮)添加即可将坐标导入!', 'blue'); }else if(parseFloat(idx) === 3){ unit.form.mainfrm.OnChangePicture(3, 1); unit.form.mainfrm.OnCueline('注意事项:非均匀梁的各个节点需要用鼠标右键拾取后点击H或h进行保存,梁上的各个点需要在一条直线上!', 'blue'); } } function ChangeRadiobutton(idx) { ui.limit_constraint.index = parseInt(idx); } //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 CW_DeclareVariable("idx", val => { ui.limit_constraint.index = val; }, () => {}); CW_DeclareVariable("pb_x", val => { ui.pb_x.value = val; ui.pb_start_x.value = val; }, () => {}); CW_DeclareVariable("pb_y", val => { ui.pb_y.value = val; ui.pb_start_y.value = val; }, () => {}); CW_DeclareVariable("pb_z", val => { ui.pb_z.value = val; ui.pb_start_z.value = val; }, () => {}); CW_DeclareVariable("pb_X", val => { ui.pb_X.value = val; ui.pb_end_x.value = val; }, () => {}); CW_DeclareVariable("pb_Y", val => { ui.pb_Y.value = val; ui.pb_end_y.value = val; }, () => {}); CW_DeclareVariable("pb_Z", val => { ui.pb_Z.value = val; ui.pb_end_z.value = val; }, () => {}); CW_DeclareVariable("listbox", val => { ui.listbox.list = [ val ]; }, () => {}); CW_DeclareVariable("start_mes", val => { ui.pb_type1.value = val; ui.pb_start_mes.value = val; }, () => {}); CW_DeclareVariable("end_mes", val => { ui.pb_type2.value = val; ui.pb_end_mes.value = val; }, () => {}); CW_DeclareVariable("change1", val => { ui.stack_constraint.index = val; }, () => {}); CW_DeclareVariable("change2", val => { ui.stack_menu.index = val; ui.misConstraints.index = val; }, () => {}); //固定支撑 CW_DeclareVariable("setConstraint0", val => { ui.type.value = val.type; ui.xc.value=val.xc; ui.yc.value=val.yc; ui.zc.value=val.zc; ui.con_xn.value = val["固定支撑属性xd"]; ui.con_xr.value = val["固定支撑属性xr"]; ui.con_yn.value = val["固定支撑属性yd"]; ui.con_yr.value = val["固定支撑属性yr"]; ui.con_zn.value = val["固定支撑属性zd"]; ui.con_zr.value = val["固定支撑属性zr"]; }, () => {}); //梁 CW_DeclareVariable("setConstraint1", val => { ui.pb_xDiration.value = val["梁约束位置xDirection"]; ui.pb_yDiration.value = val["梁约束位置yDirection"]; ui.pb_zDiration.value = val["梁约束位置zDirection"]; ui.pb_xCoord.value = val["梁约束位置xCoord"]; ui.pb_yCoord.value = val["梁约束位置yCoord"]; ui.pb_zCoord.value = val["梁约束位置zCoord"]; ui.rad.value = val["梁约束参数半径"]; ui.pb_length.value = val["梁约束参数长度"]; ui.pb_size.value = val["梁约束参数个数"]; ui.m.value = val["弹性模量"]; ui.poi.value = val["泊松比"]; ui.pb_node_size.value = val["梁节点大小半径"]; ui.R.value = val.R; ui.G.value = val.G; ui.B.value = val.B; }, () => {}); //弹簧 CW_DeclareVariable("setConstraint2", val => { ui.sxs.value = val["弹簧坐标x"]; ui.sys.value = val["弹簧坐标y"]; ui.szs.value = val["弹簧坐标z"]; ui.stypes.value = val.stypes; ui.sxe.value = val["弹簧终点x"]; ui.sye.value = val["弹簧终点y"]; ui.sze.value = val["弹簧终点z"]; ui.stypee.value = val.stypee; ui.sstifx.value = val.stiffness_x; ui.sstify.value = val.stiffness_y; ui.sstifz.value = val.stiffness_z; ui.sr.value = val.R; ui.sg.value = val.G; ui.sb.value = val.B; }, () => {}); //连接 CW_DeclareVariable("setConstraint3", val => { ui.cxs.value = val["弹簧坐标x"]; ui.cys.value= val["弹簧坐标y"]; ui.czs.value= val["弹簧坐标z"]; ui.ctypes.value= val.ctypes; ui.cxe.value= val["弹簧终点x"]; ui.cye.value= val["弹簧终点y"]; ui.cze.value= val["弹簧终点z"]; ui.ctpyee.value= val.ctpyee; ui.cxn.value = val["弹簧材料xn"]; ui.cyn.value= val["弹簧材料yn"]; ui.czn.value= val["弹簧材料zn"]; ui.cxr.value= val["弹簧材料xr"]; ui.cyr.value= val["弹簧材料yr"]; ui.czr.value= val["弹簧材料zr"]; ui.cr.value = val.R; ui.cg.value = val.G; ui.cb.value = val.B; }, () => {}); 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); } }