public FrmCMODI555(Drawing drawing, ModuleTree tree) : this() { objCMODI555 = (CMODI555)objCMODI555Service.GetModelByModuleTreeId(tree.ModuleTreeId.ToString()); if (objCMODI555 == null) { return; } this.Text = drawing.ODPNo + " / Item: " + drawing.Item + " / Module: " + tree.Module + " - " + tree.CategoryName; Category objCategory = objCategoryService.GetCategoryByCategoryId(tree.CategoryId.ToString()); pbModelImage.Image = objCategory.ModelImage.Length == 0 ? Image.FromFile("NoPic.png") : (Image) new SerializeObjectToString().DeserializeObject(objCategory.ModelImage); FillData(); }
/// <summary> /// 根据条件查找CMODI555 /// </summary> /// <param name="whereSql"></param> /// <returns></returns> public IModel GetModelByWhereSql(string whereSql) { string sql = "select CMODI555Id,ModuleTreeId,Length,Deepth,ExRightDis,ExNo,EXDis,ExLength,ExWidth,ExHeight,SidePanel," + "Outlet,Inlet,LEDlogo,BackToBack,LEDSpotNo,LEDSpotDis,LightType," + "ANSUL,ANSide,ANDetectorEnd,ANYDis,ANDropNo,ANDropDis1,ANDropDis2,ANDropDis3,ANDropDis4,ANDropDis5," + "ANDetectorNo,ANDetectorDis1,ANDetectorDis2,ANDetectorDis3,ANDetectorDis4,ANDetectorDis5," + "MARVEL,IRNo,IRDis1,IRDis2,IRDis3 from CMODI555"; sql += whereSql; SqlDataReader objReader = SQLHelper.GetReader(sql); CMODI555 objModel = null; if (objReader.Read()) { objModel = new CMODI555() { CMODI555Id = Convert.ToInt32(objReader["CMODI555Id"]), ModuleTreeId = Convert.ToInt32(objReader["ModuleTreeId"]), //最好不要用=null去判断,提示类型转换错误 Length = objReader["Length"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["Length"]), Deepth = objReader["Deepth"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["Deepth"]), ExRightDis = objReader["ExRightDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExRightDis"]), ExNo = objReader["ExNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["ExNo"]), ExDis = objReader["ExDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExDis"]), ExLength = objReader["ExLength"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExLength"]), ExWidth = objReader["ExWidth"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExWidth"]), ExHeight = objReader["ExHeight"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExHeight"]), SidePanel = objReader["SidePanel"].ToString().Length == 0 ? "" : objReader["SidePanel"].ToString(), Outlet = objReader["Outlet"].ToString().Length == 0 ? "" : objReader["Outlet"].ToString(), Inlet = objReader["Inlet"].ToString().Length == 0 ? "" : objReader["Inlet"].ToString(), LEDlogo = objReader["LEDlogo"].ToString().Length == 0 ? "" : objReader["LEDlogo"].ToString(), BackToBack = objReader["BackToBack"].ToString().Length == 0 ? "" : objReader["BackToBack"].ToString(), LEDSpotNo = objReader["LEDSpotNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["LEDSpotNo"]), LEDSpotDis = objReader["LEDSpotDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["LEDSpotDis"]), LightType = objReader["LightType"].ToString().Length == 0 ? "" : objReader["LightType"].ToString(), ANSUL = objReader["ANSUL"].ToString().Length == 0 ? "" : objReader["ANSUL"].ToString(), ANSide = objReader["ANSide"].ToString().Length == 0 ? "" : objReader["ANSide"].ToString(), ANDetectorEnd = objReader["ANDetectorEnd"].ToString().Length == 0 ? "" : objReader["ANDetectorEnd"].ToString(), ANYDis = objReader["ANYDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANYDis"]), ANDropNo = objReader["ANDropNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["ANDropNo"]), ANDropDis1 = objReader["ANDropDis1"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDropDis1"]), ANDropDis2 = objReader["ANDropDis2"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDropDis2"]), ANDropDis3 = objReader["ANDropDis3"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDropDis3"]), ANDropDis4 = objReader["ANDropDis4"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDropDis4"]), ANDropDis5 = objReader["ANDropDis5"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDropDis5"]), ANDetectorNo = objReader["ANDetectorNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["ANDetectorNo"]), ANDetectorDis1 = objReader["ANDetectorDis1"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDetectorDis1"]), ANDetectorDis2 = objReader["ANDetectorDis2"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDetectorDis2"]), ANDetectorDis3 = objReader["ANDetectorDis3"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDetectorDis3"]), ANDetectorDis4 = objReader["ANDetectorDis4"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDetectorDis4"]), ANDetectorDis5 = objReader["ANDetectorDis5"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ANDetectorDis5"]), MARVEL = objReader["MARVEL"].ToString().Length == 0 ? "" : objReader["MARVEL"].ToString(), IRNo = objReader["IRNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["IRNo"]), IRDis1 = objReader["IRDis1"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["IRDis1"]), IRDis2 = objReader["IRDis2"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["IRDis2"]), IRDis3 = objReader["IRDis3"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["IRDis3"]) }; } objReader.Close(); return(objModel); }
/// <summary> /// 修改CMODI555的制图参数 /// </summary> /// <param name="models"></param> /// <returns></returns> public int EditModel(IModel models) { CMODI555 objModel = (CMODI555)models; //编写带参数的SQL语句 StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.Append("Update CMODI555 set Length=@Length,Deepth=@Deepth,ExRightDis=@ExRightDis,ExNo=@ExNo,ExDis=@ExDis,ExLength=@ExLength,ExWidth=@ExWidth,ExHeight=@ExHeight,SidePanel=@SidePanel,"); sqlBuilder.Append("Outlet=@Outlet,Inlet=@Inlet,LEDlogo=@LEDlogo,BackToBack=@BackToBack,LEDSpotNo=@LEDSpotNo,LEDSpotDis=@LEDSpotDis,LightType=@LightType,"); sqlBuilder.Append("ANSUL=@ANSUL,ANSide=@ANSide,ANDetectorEnd=@ANDetectorEnd,ANYDis=@ANYDis,ANDropNo=@ANDropNo,ANDropDis1=@ANDropDis1,ANDropDis2=@ANDropDis2,ANDropDis3=@ANDropDis3,ANDropDis4=@ANDropDis4,ANDropDis5=@ANDropDis5,"); sqlBuilder.Append("ANDetectorNo=@ANDetectorNo,ANDetectorDis1=@ANDetectorDis1,ANDetectorDis2=@ANDetectorDis2,ANDetectorDis3=@ANDetectorDis3,ANDetectorDis4=@ANDetectorDis4,ANDetectorDis5=@ANDetectorDis5,"); sqlBuilder.Append("MARVEL=@MARVEL,IRNo=@IRNo,IRDis1=@IRDis1,IRDis2=@IRDis2,IRDis3=@IRDis3 where CMODI555Id=@CMODI555Id"); //定义参数数组 SqlParameter[] param = new SqlParameter[] { new SqlParameter("@Length", objModel.Length), new SqlParameter("@Deepth", objModel.Deepth), new SqlParameter("@ExRightDis", objModel.ExRightDis), new SqlParameter("@ExNo", objModel.ExNo), new SqlParameter("@ExDis", objModel.ExDis), new SqlParameter("@ExLength", objModel.ExLength), new SqlParameter("@ExWidth", objModel.ExWidth), new SqlParameter("@ExHeight", objModel.ExHeight), new SqlParameter("@SidePanel", objModel.SidePanel), new SqlParameter("@Outlet", objModel.Outlet), new SqlParameter("@Inlet", objModel.Inlet), new SqlParameter("@LEDlogo", objModel.LEDlogo), new SqlParameter("@BackToBack", objModel.BackToBack), new SqlParameter("@LEDSpotNo", objModel.LEDSpotNo), new SqlParameter("@LEDSpotDis", objModel.LEDSpotDis), new SqlParameter("@LightType", objModel.LightType), new SqlParameter("@ANSUL", objModel.ANSUL), new SqlParameter("@ANSide", objModel.ANSide), new SqlParameter("@ANDetectorEnd", objModel.ANDetectorEnd), new SqlParameter("@ANYDis", objModel.ANYDis), new SqlParameter("@ANDropNo", objModel.ANDropNo), new SqlParameter("@ANDropDis1", objModel.ANDropDis1), new SqlParameter("@ANDropDis2", objModel.ANDropDis2), new SqlParameter("@ANDropDis3", objModel.ANDropDis3), new SqlParameter("@ANDropDis4", objModel.ANDropDis4), new SqlParameter("@ANDropDis5", objModel.ANDropDis5), new SqlParameter("@ANDetectorNo", objModel.ANDetectorNo), new SqlParameter("@ANDetectorDis1", objModel.ANDetectorDis1), new SqlParameter("@ANDetectorDis2", objModel.ANDetectorDis2), new SqlParameter("@ANDetectorDis3", objModel.ANDetectorDis3), new SqlParameter("@ANDetectorDis4", objModel.ANDetectorDis4), new SqlParameter("@ANDetectorDis5", objModel.ANDetectorDis5), new SqlParameter("@MARVEL", objModel.MARVEL), new SqlParameter("@IRNo", objModel.IRNo), new SqlParameter("@IRDis1", objModel.IRDis1), new SqlParameter("@IRDis2", objModel.IRDis2), new SqlParameter("@IRDis3", objModel.IRDis3), new SqlParameter("@CMODI555Id", objModel.CMODI555Id) }; try { return(SQLHelper.Update(sqlBuilder.ToString(), param)); } catch (SqlException ex) { throw new Exception("数据库操作出现异常:" + ex.Message); } catch (Exception ex) { throw ex; } }
/// <summary> /// 修改参数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEditData_Click(object sender, EventArgs e) { #region 数据验证 //必填项目 if (pbModelImage.Tag.ToString().Length == 0) { return; } if (!DataValidate.IsDecimal(txtLength.Text.Trim()) || Convert.ToDecimal(txtLength.Text.Trim()) < 500m) { MessageBox.Show("请认真检查烟罩长度", "提示信息"); txtLength.Focus(); txtLength.SelectAll(); return; } if (!DataValidate.IsDecimal(txtDeepth.Text.Trim()) || Convert.ToDecimal(txtDeepth.Text.Trim()) < 500m) { MessageBox.Show("请认真检查烟罩深度", "提示信息"); txtDeepth.Focus(); txtDeepth.SelectAll(); return; } if (cobSidePanel.SelectedIndex == -1) { MessageBox.Show("请选择烟罩大侧板", "提示信息"); cobSidePanel.Focus(); return; } if (cobExNo.SelectedIndex == -1) { MessageBox.Show("请选择排风脖颈数量", "提示信息"); cobExNo.Focus(); return; } else if (cobExNo.SelectedIndex > 0 && (!DataValidate.IsDecimal(txtExDis.Text.Trim()) || Convert.ToDecimal(txtExDis.Text.Trim()) < 40m)) { MessageBox.Show("请认真检查排风脖颈间距", "提示信息");//当脖颈大于2时需要填写脖颈间距 txtExDis.Focus(); txtExDis.SelectAll(); return; } if (!DataValidate.IsDecimal(txtExLength.Text.Trim()) || Convert.ToDecimal(txtExLength.Text.Trim()) < 50m) { MessageBox.Show("请填写脖颈长度", "提示信息"); txtExLength.Focus(); txtExLength.SelectAll(); return; } if (!DataValidate.IsDecimal(txtExWidth.Text.Trim()) || Convert.ToDecimal(txtExWidth.Text.Trim()) < 50m) { MessageBox.Show("请填写脖颈宽度", "提示信息"); txtExWidth.Focus(); txtExWidth.SelectAll(); return; } if (!DataValidate.IsDecimal(txtExHeight.Text.Trim()) || Convert.ToDecimal(txtExHeight.Text.Trim()) < 20m) { MessageBox.Show("请填写脖颈高度", "提示信息"); txtExHeight.Focus(); txtExHeight.SelectAll(); return; } if (cobLightType.SelectedIndex == -1) { MessageBox.Show("请选择灯具类型", "提示信息"); cobLightType.Focus(); return; } if (cobANSUL.SelectedIndex == -1) { MessageBox.Show("是否带ANSUL", "提示信息"); cobANSUL.Focus(); return; } if (cobMARVEL.SelectedIndex == -1) { MessageBox.Show("是否带MARVEL", "提示信息"); cobMARVEL.Focus(); return; } if (cobLightType.SelectedIndex == 2 || cobLightType.SelectedIndex == 3) { if (cobLEDSpotNo.SelectedIndex == -1) { MessageBox.Show("请检查筒灯数量", "提示信息"); cobLEDSpotNo.Focus(); return; } if (!DataValidate.IsDecimal(txtLEDSpotDis.Text.Trim()) || Convert.ToDecimal(txtLEDSpotDis.Text.Trim()) < 60m) { MessageBox.Show("请填写筒灯间距", "提示信息"); txtLEDSpotDis.Focus(); txtLEDSpotDis.SelectAll(); return; } } if (cobANSUL.SelectedIndex == 0) { if (cobANSide.SelectedIndex == -1) { MessageBox.Show("请选择ANSUL侧喷位置", "提示信息"); cobANSide.Focus(); return; } if (cobANDetectorEnd.SelectedIndex == -1) { MessageBox.Show("请选择ANSUL末端探测器位置", "提示信息"); cobANDetectorEnd.Focus(); return; } if (cobANDropNo.SelectedIndex == -1) { MessageBox.Show("请检查下喷数量", "提示信息"); cobANDropNo.Focus(); return; } if (cobANDropNo.SelectedIndex > 0) { if (!DataValidate.IsDecimal(txtANYDis.Text.Trim()) || Convert.ToDecimal(txtANYDis.Text.Trim()) < 200m) { MessageBox.Show("请检查ANSUL下喷距离烟罩前端距离", "提示信息"); txtANYDis.Focus(); txtANYDis.SelectAll(); return; } if (!DataValidate.IsDecimal(txtANDropDis1.Text.Trim()) || Convert.ToDecimal(txtANDropDis1.Text.Trim()) < 30m) { MessageBox.Show("请检查下喷间距1", "提示信息"); txtANDropDis1.Focus(); txtANDropDis1.SelectAll(); return; } } if (cobANDropNo.SelectedIndex > 1) { if (!DataValidate.IsDecimal(txtANDropDis2.Text.Trim()) || Convert.ToDecimal(txtANDropDis2.Text.Trim()) < 30m) { MessageBox.Show("请检查下喷间距2", "提示信息"); txtANDropDis2.Focus(); txtANDropDis2.SelectAll(); return; } } if (cobANDropNo.SelectedIndex > 2) { if (!DataValidate.IsDecimal(txtANDropDis3.Text.Trim()) || Convert.ToDecimal(txtANDropDis3.Text.Trim()) < 30m) { MessageBox.Show("请检查下喷间距3", "提示信息"); txtANDropDis3.Focus(); txtANDropDis3.SelectAll(); return; } } if (cobANDropNo.SelectedIndex > 3) { if (!DataValidate.IsDecimal(txtANDropDis4.Text.Trim()) || Convert.ToDecimal(txtANDropDis4.Text.Trim()) < 30m) { MessageBox.Show("请检查下喷间距4", "提示信息"); txtANDropDis4.Focus(); txtANDropDis4.SelectAll(); return; } } if (cobANDropNo.SelectedIndex > 4) { if (!DataValidate.IsDecimal(txtANDropDis5.Text.Trim()) || Convert.ToDecimal(txtANDropDis5.Text.Trim()) < 30m) { MessageBox.Show("请检查下喷间距5", "提示信息"); txtANDropDis5.Focus(); txtANDropDis5.SelectAll(); return; } } } if (cobANDetectorNo.SelectedIndex == -1) { MessageBox.Show("请检查探测器数量", "提示信息"); cobANDetectorNo.Focus(); return; } if (cobANDetectorNo.SelectedIndex > 0) { if (!DataValidate.IsDecimal(txtANDetectorDis1.Text.Trim()) || Convert.ToDecimal(txtANDetectorDis1.Text.Trim()) < 30m) { MessageBox.Show("请检查探测器间距1", "提示信息"); txtANDetectorDis1.Focus(); txtANDetectorDis1.SelectAll(); return; } } if (cobANDetectorNo.SelectedIndex > 1) { if (!DataValidate.IsDecimal(txtANDetectorDis2.Text.Trim()) || Convert.ToDecimal(txtANDetectorDis2.Text.Trim()) < 30m) { MessageBox.Show("请检查探测器间距2", "提示信息"); txtANDetectorDis2.Focus(); txtANDetectorDis2.SelectAll(); return; } } if (cobANDetectorNo.SelectedIndex > 2) { if (!DataValidate.IsDecimal(txtANDetectorDis3.Text.Trim()) || Convert.ToDecimal(txtANDetectorDis3.Text.Trim()) < 30m) { MessageBox.Show("请检查探测器间距3", "提示信息"); txtANDetectorDis3.Focus(); txtANDetectorDis3.SelectAll(); return; } } if (cobANDetectorNo.SelectedIndex > 3) { if (!DataValidate.IsDecimal(txtANDetectorDis4.Text.Trim()) || Convert.ToDecimal(txtANDetectorDis4.Text.Trim()) < 30m) { MessageBox.Show("请检查探测器间距4", "提示信息"); txtANDetectorDis4.Focus(); txtANDetectorDis4.SelectAll(); return; } } if (cobANDetectorNo.SelectedIndex > 4) { if (!DataValidate.IsDecimal(txtANDetectorDis5.Text.Trim()) || Convert.ToDecimal(txtANDetectorDis5.Text.Trim()) < 30m) { MessageBox.Show("请检查探测器间距5", "提示信息"); txtANDetectorDis5.Focus(); txtANDetectorDis5.SelectAll(); return; } } if (cobMARVEL.SelectedIndex == 0) { if (cobIRNo.SelectedIndex == -1) { MessageBox.Show("请检查IR数量", "提示信息"); cobIRNo.Focus(); return; } if (cobIRNo.SelectedIndex > 0) { if (!DataValidate.IsDecimal(txtIRDis1.Text.Trim()) || Convert.ToDecimal(txtIRDis1.Text.Trim()) < 30m) { MessageBox.Show("请检查IR间距1", "提示信息"); txtIRDis1.Focus(); txtIRDis1.SelectAll(); return; } } if (cobIRNo.SelectedIndex > 1) { if (!DataValidate.IsDecimal(txtIRDis2.Text.Trim()) || Convert.ToDecimal(txtIRDis2.Text.Trim()) < 30m) { MessageBox.Show("请检查IR间距2", "提示信息"); txtIRDis2.Focus(); txtIRDis2.SelectAll(); return; } } if (cobIRNo.SelectedIndex > 2) { if (!DataValidate.IsDecimal(txtIRDis3.Text.Trim()) || Convert.ToDecimal(txtIRDis3.Text.Trim()) < 30m) { MessageBox.Show("请检查IR间距3", "提示信息"); txtIRDis3.Focus(); txtIRDis3.SelectAll(); return; } } } if (cobLEDLogo.SelectedIndex == -1) { MessageBox.Show("请检查是否带LOGO", "提示信息"); cobLEDLogo.Focus(); return; } if (cobOutlet.SelectedIndex == -1) { MessageBox.Show("请检查排水口位置", "提示信息"); cobOutlet.Focus(); return; } if (cobInlet.SelectedIndex == -1) { MessageBox.Show("请检查入水口位置", "提示信息"); cobInlet.Focus(); return; } if (cobBackToBack.SelectedIndex == -1) { MessageBox.Show("请检查是否背靠背", "提示信息"); cobBackToBack.Focus(); return; } #endregion //封装对象 CMODI555 objCMODI555 = new CMODI555() { CMODI555Id = Convert.ToInt32(pbModelImage.Tag), SidePanel = cobSidePanel.Text, ExNo = Convert.ToInt32(cobExNo.Text), LightType = cobLightType.Text, LEDSpotNo = cobLEDSpotNo.Text.Trim().Length == 0 ? 0 : Convert.ToInt32(cobLEDSpotNo.Text), ANSUL = cobANSUL.Text, ANSide = cobANSide.Text.Trim().Length == 0 ? "NO" : cobANSide.Text, ANDetectorEnd = cobANDetectorEnd.Text.Trim().Length == 0 ? "NO" : cobANDetectorEnd.Text, ANDropNo = cobANDropNo.Text.Trim().Length == 0 ? 0 : Convert.ToInt32(cobANDropNo.Text), ANDetectorNo = cobANDetectorNo.Text.Trim().Length == 0 ? 0 : Convert.ToInt32(cobANDetectorNo.Text), MARVEL = cobMARVEL.Text, IRNo = cobIRNo.Text.Trim().Length == 0 ? 0 : Convert.ToInt32(cobIRNo.Text), LEDlogo = cobLEDLogo.Text, Outlet = cobOutlet.Text, Inlet = cobInlet.Text, BackToBack = cobBackToBack.Text, Length = Convert.ToDecimal(txtLength.Text.Trim()), Deepth = Convert.ToDecimal(txtDeepth.Text.Trim()), ExRightDis = Convert.ToDecimal(txtExRightDis.Text.Trim()), ExDis = Convert.ToDecimal(txtExDis.Text.Trim()), ExLength = Convert.ToDecimal(txtExLength.Text.Trim()), ExWidth = Convert.ToDecimal(txtExWidth.Text.Trim()), ExHeight = Convert.ToDecimal(txtExHeight.Text.Trim()), LEDSpotDis = Convert.ToDecimal(txtLEDSpotDis.Text.Trim()), ANYDis = Convert.ToDecimal(txtANYDis.Text.Trim()), ANDropDis1 = Convert.ToDecimal(txtANDropDis1.Text.Trim()), ANDropDis2 = Convert.ToDecimal(txtANDropDis2.Text.Trim()), ANDropDis3 = Convert.ToDecimal(txtANDropDis3.Text.Trim()), ANDropDis4 = Convert.ToDecimal(txtANDropDis4.Text.Trim()), ANDropDis5 = Convert.ToDecimal(txtANDropDis5.Text.Trim()), ANDetectorDis1 = Convert.ToDecimal(txtANDetectorDis1.Text.Trim()), ANDetectorDis2 = Convert.ToDecimal(txtANDetectorDis2.Text.Trim()), ANDetectorDis3 = Convert.ToDecimal(txtANDetectorDis3.Text.Trim()), ANDetectorDis4 = Convert.ToDecimal(txtANDetectorDis4.Text.Trim()), ANDetectorDis5 = Convert.ToDecimal(txtANDetectorDis5.Text.Trim()), IRDis1 = Convert.ToDecimal(txtIRDis1.Text.Trim()), IRDis2 = Convert.ToDecimal(txtIRDis2.Text.Trim()), IRDis3 = Convert.ToDecimal(txtIRDis3.Text.Trim()) }; //提交修改 try { if (objCMODI555Service.EditModel(objCMODI555) == 1) { MessageBox.Show("制图数据修改成功", "提示信息"); this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AutoDrawing(SldWorks swApp, ModuleTree tree, string projectPath) { //创建项目模型存放地址 string itemPath = projectPath + @"\" + tree.Item + "-" + tree.Module + "-" + tree.CategoryName; if (!Directory.Exists(itemPath)) { Directory.CreateDirectory(itemPath); } else { DialogResult result = MessageBox.Show("模型文件夹" + itemPath + "存在,如果之前pack已经执行过,将不执行pack过程而是直接修改模型,如果要继续请点击YES,否请点击No中断作图", "提示信息", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } //Pack的后缀 string suffix = tree.Item + "-" + tree.Module + "-" + tree.ODPNo.Substring(tree.ODPNo.Length - 6); //判断文件是否存在,如果存在将不执行pack,如果不存在则执行pack //packango后需要接收打包完成的地址,参数为后缀 string packedAssyPath = itemPath + @"\" + tree.CategoryName.ToLower() + "_" + suffix + ".sldasm"; if (!File.Exists(packedAssyPath)) { packedAssyPath = CommonFunc.PackAndGoFunc(suffix, swApp, tree.ModelPath, itemPath); } //查询参数 CMODI555 item = (CMODI555)objCMODI555Service.GetModelByModuleTreeId(tree.ModuleTreeId.ToString()); swApp.CommandInProgress = true; //告诉SolidWorks,现在是用外部程序调用命令 int warnings = 0; int errors = 0; suffix = "_" + suffix;//后缀 ModelDoc2 swModel = default(ModelDoc2); ModelDoc2 swPart = default(ModelDoc2); AssemblyDoc swAssy = default(AssemblyDoc); Component2 swComp; Feature swFeat = default(Feature); object configNames = null; //打开Pack后的模型 swModel = swApp.OpenDoc6(packedAssyPath, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings) as ModelDoc2; swAssy = swModel as AssemblyDoc; //装配体 //打开装配体后必须重建,使Pack后的零件名都更新到带后缀的状态,否则程序出错 swModel.ForceRebuild3(true); //TopOnly参数设置成true,只重建顶层,不重建零件内部 /*注意SolidWorks单位是m,计算是应当/1000m * 整形与整形运算得出的结果仍然时整形,1640 / 1000m结果为0,因此必须将其中一个转化成decimal型,使用后缀m就可以了 * (int)不进行四舍五入,Convert.ToInt32会四舍五入 */ //-----------计算中间值,---------- //新风面板卡扣数量及间距 int frontPanelKaKouNo = (int)((item.Length - 300m) / 450m) + 2; decimal frontPanelKaKouDis = Convert.ToDecimal((item.Length - 300m) / (frontPanelKaKouNo - 1)) / 1000m; //新风面板螺丝孔数量及间距 int frontPanelHoleNo = (int)((item.Length - 300m) / 900m) + 2; decimal frontPanelHoleDis = Convert.ToDecimal((item.Length - 300) / (frontPanelHoleNo - 1)) / 1000m; //新风CJ孔数量和新风CJ孔第一个CJ距离边缘距离 int frontCjNo = (int)((item.Length - 30m) / 32m) + 1; decimal frontCjFirstDis = Convert.ToDecimal((item.Length - (frontCjNo - 1) * 32m) / 2) / 1000m; //Midroof灯板螺丝孔数量及第二个孔距离边缘距离,灯板顶面吊装槽钢螺丝孔位距离 int midRoofHoleNo = (int)((item.Length - 300m) / 400m); decimal midRoofSecondHoleDis = Convert.ToDecimal((item.Length - (midRoofHoleNo - 1) * 400m) / 2) / 1000m; decimal midRoofTopHoleDis = Convert.ToDecimal(item.Deepth - 535m - 360m - 90m - (int)((item.Deepth - 535m - 360m - 90m - 100m) / 50m) * 50m) / 1000m; //KSA数量,KSA侧板长度(以全长计算)水洗烟罩KSA在三角板内侧,减去3mm int ksaNo = (int)((item.Length - 2m) / 498m); decimal ksaSideLength = Convert.ToDecimal((item.Length - 3m - ksaNo * 498m) / 2) / 1000m; //MESH侧板长度(除去排风三角板3mm计算) decimal meshSideLength = Convert.ToDecimal((item.Length - 3m - (int)((item.Length - 2m) / 498m) * 498m) / 2) / 1000m; //侧板CJ孔整列到烟罩底部 int sidePanelDownCjNo = (int)((item.Deepth - 95m) / 32m); //非水洗烟罩KV/UV //int sidePanelSideCjNo = (int)((item.Deepth - 305m) / 32m); //水洗烟罩KW/UW int sidePanelSideCjNo = (int)((item.Deepth - 380m) / 32m); try { //----------Top Level---------- //烟罩深度 swModel.Parameter("D1@Distance77").SystemValue = item.Deepth / 1000m; //灯板加强筋 if (item.Deepth > 1649m && ((item.LightType == "FSLONG" && item.Length > 1900m) || (item.LightType == "FSSHORT" && item.Length > 1500m) || (item.Length > 2000m))) { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0006-3")); swComp.SetSuppression2(2); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0006-2")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); //打开零件 swPart.Parameter("D2@Base-Flange1").SystemValue = item.Deepth / 1000m - 898m / 1000m; } else { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0006-3")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0006-2")); swComp.SetSuppression2(0); //2解压缩,0压缩 } //----------排风腔---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0070-1")); swPart = swComp.GetModelDoc2();//打开零件3 swPart.Parameter("D2@Base-Flange1").SystemValue = item.Length / 1000m; swPart.Parameter("D2@Sketch9").SystemValue = midRoofSecondHoleDis; if (midRoofHoleNo == 1) { swFeat = swComp.FeatureByName("LPattern1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("LPattern1"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@LPattern1").SystemValue = midRoofHoleNo; } //排风口 //if (item.ExNo == 1) //{ swFeat = swComp.FeatureByName("EXCOONE"); swFeat.SetSuppression2(1, 2, configNames); //swFeat = swComp.FeatureByName("EXCOTWO"); //swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //swPart.Parameter("D4@Sketch11").SystemValue = item.ExRightDis / 1000m; swPart.Parameter("D2@Sketch4").SystemValue = item.ExLength / 1000m; swPart.Parameter("D3@Sketch4").SystemValue = item.ExWidth / 1000m; //} //else //{ // swFeat = swComp.FeatureByName("EXCOONE"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 // swFeat = swComp.FeatureByName("EXCOTWO"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D5@Sketch12").SystemValue = item.ExRightDis / 1000m; // swPart.Parameter("D4@Sketch12").SystemValue = item.ExDis / 1000m; // swPart.Parameter("D1@Sketch12").SystemValue = item.ExLength / 1000m; // swPart.Parameter("D2@Sketch12").SystemValue = item.ExWidth / 1000m; //} //下水口/上排水 if (item.Outlet == "LEFT") { swFeat = swComp.FeatureByName("DRAINPIPE-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRAINPIPE-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else if (item.Outlet == "RIGHT") { swFeat = swComp.FeatureByName("DRAINPIPE-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRAINPIPE-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else if (item.Outlet == "UPLEFT") { swFeat = swComp.FeatureByName("DRAINPIPE-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRAINPIPE-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else if (item.Outlet == "UPRIGHT") { swFeat = swComp.FeatureByName("DRAINPIPE-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRAINPIPE-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("DRAINPIPE-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRAINPIPE-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AUTODRAIN RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //背靠背 if (item.BackToBack == "YES") { swFeat = swComp.FeatureByName("BACKTOBACK"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("BACKTOBACK"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //进水口 if (item.Inlet == "LEFT") { swFeat = swComp.FeatureByName("DRWATER INLET-L"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRWATER INLET-R"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else if (item.Inlet == "RIGHT") { swFeat = swComp.FeatureByName("DRWATER INLET-L"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRWATER INLET-R"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("DRWATER INLET-L"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRWATER INLET-R"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //ANSUL if (item.ANSUL == "YES") { //侧喷 if (item.ANSide == "LEFT") { swFeat = swComp.FeatureByName("ANSUL-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else if (item.ANSide == "RIGHT") { swFeat = swComp.FeatureByName("ANSUL-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("ANSUL-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANSUL-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } } //----------排风腔前面板---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0071-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = item.Length / 1000m; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0074-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 7.5m) / 1000m; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0088-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 7.5m) / 1000m; //----------排风滑门/导轨---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0013-2")); if (item.ExWidth == 300m) { swComp.SetSuppression2(0); //2解压缩,0压缩 } else { swComp.SetSuppression2(2); //2解压缩,0压缩 } swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0013-1")); if (item.ExWidth == 300m) { swComp.SetSuppression2(0); //2解压缩,0压缩 } else { swComp.SetSuppression2(2);//2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@Sketch1").SystemValue = (item.ExLength / 2 + 10m) / 1000m; swPart.Parameter("D2@Sketch1").SystemValue = (item.ExWidth + 40m) / 1000m; } swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0018-2")); swComp.SetSuppression2(2); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0018-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); if (item.ExNo == 1) { swPart.Parameter("D2@Base-Flange1").SystemValue = (item.ExLength * 2 + 100m) / 1000m; } else { swPart.Parameter("D2@Base-Flange1").SystemValue = (item.ExLength * 3 + item.ExDis + 100m) / 1000m; } //----------排风脖颈---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0089-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = item.ExLength / 1000m; swPart.Parameter("D2@Sketch1").SystemValue = item.ExHeight / 1000m; //swFeat = swComp.FeatureByName("ANSUL"); //if (item.ANSUL == "YES") swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 //else swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0090-1")); swComp.SetSuppression2(2);//2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@Sketch1").SystemValue = (item.ExWidth - 2.5m) / 1000m; swPart.Parameter("D2@Sketch1").SystemValue = item.ExHeight / 1000m; //----------排风腔内部零件---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0075-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 113m) / 2000m; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0078-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 170m) / 2000m; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0079-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 200m) / 2000m; //----------灯具---------- //日光灯 if (item.LightType == "FSLONG") { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020410-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020409-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 } else if (item.LightType == "FSSHORT") { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020410-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020409-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 } else { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020410-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020409-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 } //----------MiddleRoof灯板---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0001-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = (item.Length - 4m) / 1000m; swPart.Parameter("D2@草图1").SystemValue = (item.Deepth - 424m) / 1000m; swPart.Parameter("D1@草图6").SystemValue = (item.Deepth - 651m) / 1000m; swPart.Parameter("D3@草图25").SystemValue = midRoofTopHoleDis; swPart.Parameter("D2@草图26").SystemValue = (item.Deepth - 595m) / 3000; swPart.Parameter("D1@Sketch3").SystemValue = midRoofSecondHoleDis - 2m / 1000m; swFeat = swComp.FeatureByName("NAMEPLATE"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern1"); if (midRoofHoleNo == 1) { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@LPattern1").SystemValue = midRoofHoleNo; } //灯具 if (item.LightType == "LED60") { swFeat = swComp.FeatureByName("LED140"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSLONG"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSSHORT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LED60"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 if (item.LEDSpotNo == 1) { swPart.Parameter("D2@Sketch1").SystemValue = 0; } else { swPart.Parameter("D2@Sketch1").SystemValue = (item.LEDSpotDis * (item.LEDSpotNo / 2m - 1) + item.LEDSpotDis / 2m) / 1000m; swFeat = swComp.FeatureByName("LPattern2"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@LPattern2").SystemValue = item.LEDSpotNo; swPart.Parameter("D3@LPattern2").SystemValue = item.LEDSpotDis / 1000m; } } else if (item.LightType == "LED60") { swFeat = swComp.FeatureByName("LED60"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSLONG"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSSHORT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LED140"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 if (item.LEDSpotNo == 1) { swPart.Parameter("D5@Sketch7").SystemValue = 0; } else { swPart.Parameter("D5@Sketch7").SystemValue = (item.LEDSpotDis * (item.LEDSpotNo / 2m - 1) + item.LEDSpotDis / 2m) / 1000m; swFeat = swComp.FeatureByName("LPattern3"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@LPattern3").SystemValue = item.LEDSpotNo; swPart.Parameter("D3@LPattern3").SystemValue = item.LEDSpotDis / 1000m; } } else if (item.LightType == "FSLONG") { swFeat = swComp.FeatureByName("LED60"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LED140"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSLONG"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSSHORT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else if (item.LightType == "FSSHORT") { swFeat = swComp.FeatureByName("LED60"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LED140"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSLONG"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSSHORT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("LED60"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LED140"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LPattern3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSLONG"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("FSSHORT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //ANSUL if (item.ANSUL == "YES") { swFeat = swComp.FeatureByName("AN1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN4"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN5"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC4"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC5"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //下喷 if (item.ANDropNo > 0) { swFeat = swComp.FeatureByName("AN1"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch11").SystemValue = item.ANDropDis1 / 1000m; swPart.Parameter("D3@Sketch11").SystemValue = (item.ANYDis - 360m) / 1000m; } if (item.ANDropNo > 1) { swFeat = swComp.FeatureByName("AN2"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch12").SystemValue = item.ANDropDis2 / 1000m; } if (item.ANDropNo > 2) { swFeat = swComp.FeatureByName("AN3"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch13").SystemValue = item.ANDropDis3 / 1000m; } if (item.ANDropNo > 3) { swFeat = swComp.FeatureByName("AN4"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch14").SystemValue = item.ANDropDis4 / 1000m; } if (item.ANDropNo > 4) { swFeat = swComp.FeatureByName("AN5"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch15").SystemValue = item.ANDropDis5 / 1000m; } //探测器 if (item.ANDetectorNo > 0) { swFeat = swComp.FeatureByName("ANDTEC1"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch31").SystemValue = item.ANDetectorDis1 / 1000m; if (item.ANDetectorEnd == "LEFT" || (item.ANDetectorEnd == "RIGHT" && item.ANDetectorNo == 1)) { swPart.Parameter("D2@Sketch31").SystemValue = 195m / 1000m; } else { swPart.Parameter("D2@Sketch31").SystemValue = 175m / 1000m; } } if (item.ANDetectorNo > 1) { swFeat = swComp.FeatureByName("ANDTEC2"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch32").SystemValue = item.ANDetectorDis2 / 1000m; if (item.ANDetectorEnd == "RIGHT" && item.ANDetectorNo == 2) { swPart.Parameter("D2@Sketch32").SystemValue = 195m / 1000m; } else { swPart.Parameter("D2@Sketch32").SystemValue = 175m / 1000m; } } if (item.ANDetectorNo > 2) { swFeat = swComp.FeatureByName("ANDTEC3"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch33").SystemValue = item.ANDetectorDis3 / 1000m; if (item.ANDetectorEnd == "RIGHT" && item.ANDetectorNo == 3) { swPart.Parameter("D2@Sketch33").SystemValue = 195m / 1000m; } else { swPart.Parameter("D2@Sketch33").SystemValue = 175m / 1000m; } } if (item.ANDetectorNo > 3) { swFeat = swComp.FeatureByName("ANDTEC4"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch34").SystemValue = item.ANDetectorDis4 / 1000m; if (item.ANDetectorEnd == "RIGHT" && item.ANDetectorNo == 4) { swPart.Parameter("D2@Sketch34").SystemValue = 195m / 1000m; } else { swPart.Parameter("D2@Sketch34").SystemValue = 175m / 1000m; } } if (item.ANDetectorNo > 4) { swFeat = swComp.FeatureByName("ANDTEC5"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch35").SystemValue = item.ANDetectorDis5 / 1000m; if (item.ANDetectorEnd == "RIGHT" && item.ANDetectorNo == 5) { swPart.Parameter("D2@Sketch35").SystemValue = 195m / 1000m; } else { swPart.Parameter("D2@Sketch35").SystemValue = 175m / 1000m; } } } else { swFeat = swComp.FeatureByName("AN1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN4"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("AN5"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //UW/KW HOOD 水洗烟罩探测器在midRoof上,非水洗烟罩压缩 swFeat = swComp.FeatureByName("ANDTEC1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC4"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("ANDTEC5"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //开方孔,UV或待MARVEL时解压 swFeat = swComp.FeatureByName("CUT-BACK-LEFT"); if (item.MARVEL == "YES") { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } swFeat = swComp.FeatureByName("CUT-BACK-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("CUT-FRONT-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //UV灯线缆穿孔 swFeat = swComp.FeatureByName("UVCABLE"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //CMOD NTC Sensor swFeat = swComp.FeatureByName("NTC Sensor"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 //----------吊装槽钢---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2900100001-1")); swPart = swComp.GetModelDoc2(); if (item.ANSUL == "YES") { swPart.Parameter("D2@基体-法兰1").SystemValue = (item.Deepth - 250) / 1000m; } else { swPart.Parameter("D2@基体-法兰1").SystemValue = (item.Deepth - 100m) / 1000m; } //----------大侧板---------- if (item.SidePanel == "BOTH") { //LEFT swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0001-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = item.Deepth / 1000m; swPart.Parameter("D1@阵列(线性)1").SystemValue = sidePanelSideCjNo; swPart.Parameter("D1@阵列(线性)2").SystemValue = sidePanelDownCjNo; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0002-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = (item.Deepth - 79m) / 1000m; //RIGHT swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0003-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = item.Deepth / 1000m; swPart.Parameter("D1@阵列(线性)1").SystemValue = sidePanelSideCjNo; swPart.Parameter("D1@阵列(线性)2").SystemValue = sidePanelDownCjNo; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0004-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = (item.Deepth - 79m) / 1000m; } else if (item.SidePanel == "LEFT") { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0003-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0004-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0001-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = item.Deepth / 1000m; swPart.Parameter("D1@阵列(线性)1").SystemValue = sidePanelSideCjNo; swPart.Parameter("D1@阵列(线性)2").SystemValue = sidePanelDownCjNo; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0002-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = (item.Deepth - 79m) / 1000m; } else if (item.SidePanel == "RIGHT") { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0001-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0002-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0003-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = item.Deepth / 1000m; swPart.Parameter("D1@阵列(线性)1").SystemValue = sidePanelSideCjNo; swPart.Parameter("D1@阵列(线性)2").SystemValue = sidePanelDownCjNo; swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0004-1")); swComp.SetSuppression2(2); //2解压缩,0压缩 swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = (item.Deepth - 79m) / 1000m; } else { swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0001-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0002-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0003-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0004-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0005-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0006-1")); swComp.SetSuppression2(0); //2解压缩,0压缩 } //------------I型新风腔主体---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0001-2")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@基体-法兰1").SystemValue = item.Length / 1000m; swPart.Parameter("D1@阵列(线性)1").SystemValue = frontPanelKaKouNo; swPart.Parameter("D3@阵列(线性)1").SystemValue = frontPanelKaKouDis; swPart.Parameter("D3@Sketch3").SystemValue = midRoofSecondHoleDis; swPart.Parameter("D9@草图7").SystemValue = 200m / 1000m - midRoofTopHoleDis; swFeat = swComp.FeatureByName("LPattern1"); if (midRoofHoleNo == 1) { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@LPattern1").SystemValue = midRoofHoleNo; } //MARVEL if (item.MARVEL == "YES") { if (item.IRNo > 0) { swFeat = swComp.FeatureByName("MA1"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D3@Sketch14").SystemValue = item.IRDis1 / 1000m; swFeat = swComp.FeatureByName("MACABLE1"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch17").SystemValue = item.IRDis1 / 1000m; } if (item.IRNo > 1) { swFeat = swComp.FeatureByName("MA2"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D3@Sketch15").SystemValue = item.IRDis2 / 1000m; swFeat = swComp.FeatureByName("MACABLE2"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch18").SystemValue = item.IRDis2 / 1000m; } if (item.IRNo > 2) { swFeat = swComp.FeatureByName("MA3"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D3@Sketch16").SystemValue = item.IRDis3 / 1000m; swFeat = swComp.FeatureByName("MACABLE3"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch19").SystemValue = item.IRDis3 / 1000m; } } else { swFeat = swComp.FeatureByName("MA1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("MA2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("MA3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("MACABLE1"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("MACABLE2"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("MACABLE3"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //UV HOOD swFeat = swComp.FeatureByName("SUCABLE-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("JUNCTION BOX-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //----------新风前面板---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0003-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D1@草图1").SystemValue = (item.Length - 3m) / 1000m; swPart.Parameter("D1@阵列(线性)7").SystemValue = frontPanelKaKouNo; swPart.Parameter("D3@阵列(线性)7").SystemValue = frontPanelKaKouDis; swPart.Parameter("D1@LPattern1").SystemValue = frontPanelHoleNo; swPart.Parameter("D3@LPattern1").SystemValue = frontPanelHoleDis; //----------新风底部CJ孔板---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0002-1")); swPart = swComp.GetModelDoc2(); swPart.Parameter("D2@基体-法兰1").SystemValue = item.Length / 1000m; swPart.Parameter("D1@CJHOLES").SystemValue = frontCjNo; swPart.Parameter("D10@草图8").SystemValue = frontCjFirstDis; swPart.Parameter("D1@LPattern1").SystemValue = frontPanelHoleNo; swPart.Parameter("D3@LPattern1").SystemValue = frontPanelHoleDis; swFeat = swComp.FeatureByName("BLUETOOTH"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("LOGO"); if (item.LEDlogo == "YES") { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //集水翻边 swFeat = swComp.FeatureByName("DRAINCHANNEL-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DRAINCHANNEL-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //----------LOGO---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2900300005-1")); if (item.LEDlogo == "YES") { swComp.SetSuppression2(2); //2解压缩,0压缩 } else { swComp.SetSuppression2(0); //2解压缩,0压缩 } swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201010401-1")); if (item.LEDlogo == "YES") { swComp.SetSuppression2(2); //2解压缩,0压缩 } else { swComp.SetSuppression2(0); //2解压缩,0压缩 } swModel.ForceRebuild3(true); //设置成true,直接更新顶层,速度很快,设置成false,每个零件都会更新,很慢 swModel.Save(); //保存,很耗时间 swApp.CloseDoc(packedAssyPath); //关闭,很快 } catch (Exception ex) { throw new Exception(packedAssyPath + "作图过程发生异常,详细:" + ex.Message); } finally { swApp.CommandInProgress = false; //及时关闭外部命令调用,否则影响SolidWorks的使用 } }