public FrmDP330(Drawing drawing, ModuleTree tree) : this() { objDP330 = (DP330)objDP330Service.GetModelByModuleTreeId(tree.ModuleTreeId.ToString()); if (objDP330 == 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(); }
public int EditModel(IModel model) { DP330 objModel = (DP330)model; //编写带参数的SQL语句 StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.Append("Update DP330 set Length=@Length,SidePanel=@SidePanel,Outlet=@Outlet,"); sqlBuilder.Append("BackCJSide=@BackCJSide,DPSide=@DPSide,LeftDis=@LeftDis,RightDis=@RightDis,"); sqlBuilder.Append("LeftBeamType=@LeftBeamType,LeftBeamDis=@LeftBeamDis,RightBeamType=@RightBeamType,RightBeamDis=@RightBeamDis,"); sqlBuilder.Append("LKSide=@LKSide,GutterSide=@GutterSide,GutterWidth=@GutterWidth where DP330Id=@DP330Id"); //定义参数数组 SqlParameter[] param = new SqlParameter[] { new SqlParameter("@Length", objModel.Length), new SqlParameter("@SidePanel", objModel.SidePanel), new SqlParameter("@Outlet", objModel.Outlet), new SqlParameter("@BackCJSide", objModel.BackCJSide), new SqlParameter("@DPSide", objModel.DPSide), new SqlParameter("@LeftDis", objModel.LeftDis), new SqlParameter("@RightDis", objModel.RightDis), new SqlParameter("@LeftBeamType", objModel.LeftBeamType), new SqlParameter("@LeftBeamDis", objModel.LeftBeamDis), new SqlParameter("@RightBeamType", objModel.RightBeamType), new SqlParameter("@RightBeamDis", objModel.RightBeamDis), new SqlParameter("@LKSide", objModel.LKSide), new SqlParameter("@GutterSide", objModel.GutterSide), new SqlParameter("@GutterWidth", objModel.GutterWidth), new SqlParameter("@DP330Id", objModel.DP330Id) }; try { return(SQLHelper.Update(sqlBuilder.ToString(), param)); } catch (SqlException ex) { throw new Exception("数据库操作出现异常:" + ex.Message); } catch (Exception ex) { throw ex; } }
public IModel GetModelByWhereSql(string whereSql) { string sql = "select DP330Id,ModuleTreeId,Length,SidePanel,Outlet,BackCJSide,DPSide,LeftDis,RightDis," + "LeftBeamType,LeftBeamDis,RightBeamType,RightBeamDis,LKSide,GutterSide,GutterWidth from DP330"; sql += whereSql; SqlDataReader objReader = SQLHelper.GetReader(sql); DP330 objModel = null; if (objReader.Read()) { objModel = new DP330() { DP330Id = Convert.ToInt32(objReader["DP330Id"]), ModuleTreeId = Convert.ToInt32(objReader["ModuleTreeId"]), //最好不要用=null去判断,提示类型转换错误 Length = objReader["Length"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["Length"]), LeftDis = objReader["LeftDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["LeftDis"]), RightDis = objReader["RightDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["RightDis"]), LeftBeamDis = objReader["LeftBeamDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["LeftBeamDis"]), RightBeamDis = objReader["RightBeamDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["RightBeamDis"]), GutterWidth = objReader["GutterWidth"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["GutterWidth"]), SidePanel = objReader["SidePanel"].ToString().Length == 0 ? "" : objReader["SidePanel"].ToString(), Outlet = objReader["Outlet"].ToString().Length == 0 ? "" : objReader["Outlet"].ToString(), BackCJSide = objReader["BackCJSide"].ToString().Length == 0 ? "" : objReader["BackCJSide"].ToString(), DPSide = objReader["DPSide"].ToString().Length == 0 ? "" : objReader["DPSide"].ToString(), LeftBeamType = objReader["LeftBeamType"].ToString().Length == 0 ? "" : objReader["LeftBeamType"].ToString(), RightBeamType = objReader["RightBeamType"].ToString().Length == 0 ? "" : objReader["RightBeamType"].ToString(), LKSide = objReader["LKSide"].ToString().Length == 0 ? "" : objReader["LKSide"].ToString(), GutterSide = objReader["GutterSide"].ToString().Length == 0 ? "" : objReader["GutterSide"].ToString(), }; } objReader.Close(); return(objModel); }
public void AutoDrawing(SldWorks swApp, ModuleTree tree, string projectPath) { //创建项目模型存放地址 string itemPath = projectPath + @"\" + 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.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); } //查询参数 DP330 item = (DP330)objDP330Service.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; ModelDocExtension swModelDocExt = default(ModelDocExtension); bool status = false; string compReName = string.Empty; //打开Pack后的模型 swModel = swApp.OpenDoc6(packedAssyPath, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings) as ModelDoc2; swAssy = swModel as AssemblyDoc; //装配体 string assyName = swModel.GetTitle().Substring(0, swModel.GetTitle().Length - 7); //获取装配体名称 swModelDocExt = (ModelDocExtension)swModel.Extension; //打开装配体后必须重建,使Pack后的零件名都更新到带后缀的状态,否则程序出错 swModel.ForceRebuild3(true); //TopOnly参数设置成true,只重建顶层,不重建零件内部 /*注意SolidWorks单位是m,计算是应当/1000m * 整形与整形运算得出的结果仍然时整形,1640 / 1000m结果为0,因此必须将其中一个转化成decimal型,使用后缀m就可以了 * (int)不进行四舍五入,Convert.ToInt32会四舍五入 */ //-----------计算中间值,---------- decimal leftSBDis = item.LeftDis; decimal rightSBDis = item.RightDis; try { //----------Top Level---------- if (item.Length < 1000m) { swModel.Parameter("D1@LocalLPattern2").SystemValue = 2; swModel.Parameter("D3@LocalLPattern2").SystemValue = (item.Length - 400m) / 1000m; } else if (item.Length >= 1000m && item.Length < 2000m) { swModel.Parameter("D1@LocalLPattern2").SystemValue = 3; swModel.Parameter("D3@LocalLPattern2").SystemValue = (item.Length - 400m) / 2000m; } else { swModel.Parameter("D1@LocalLPattern2").SystemValue = 4; swModel.Parameter("D3@LocalLPattern2").SystemValue = (item.Length - 400m) / 3000m; } //----------侧板---------- switch (item.SidePanel) { case "LEFT": case "DPBACKL": swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0003-2")); swComp.SetSuppression2(2); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-10")); swComp.SetSuppression2(0); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0004-2")); swComp.SetSuppression2(0); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-11")); swComp.SetSuppression2(2); //2解压缩,0压缩. break; case "RIGHT": case "DPBACKR": swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0003-2")); swComp.SetSuppression2(0); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-10")); swComp.SetSuppression2(2); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0004-2")); swComp.SetSuppression2(2); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-11")); swComp.SetSuppression2(0); //2解压缩,0压缩. break; case "MIDDLE": swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0003-2")); swComp.SetSuppression2(0); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-10")); swComp.SetSuppression2(2); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0004-2")); swComp.SetSuppression2(0); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-11")); swComp.SetSuppression2(2); //2解压缩,0压缩. break; default: swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0003-2")); swComp.SetSuppression2(2); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-10")); swComp.SetSuppression2(0); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0004-2")); swComp.SetSuppression2(2); //2解压缩,0压缩. swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0005-11")); swComp.SetSuppression2(0); //2解压缩,0压缩. break; } //----------背板---------- swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCS0002-2")); swPart = swComp.GetModelDoc2();//打开零件 swPart.Parameter("D3@Skizze1").SystemValue = item.Length / 1000m; swFeat = swComp.FeatureByName("DPB-LEFT"); if (item.SidePanel == "DPBACKL" || item.SidePanel == "DPBACKB") { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } swFeat = swComp.FeatureByName("DPB-RIGHT"); if (item.SidePanel == "DPBACKR" || item.SidePanel == "DPBACKB") { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //----------NOCJ腔主体---------- //重命名装配体内部 compReName = "FNCS0001[DP330-" + tree.Module + "]{" + (int)item.Length + "}"; status = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCS0001-1") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0); if (status) { swModelDocExt.RenameDocument(compReName); } swModel.ClearSelection2(true); status = swModelDocExt.SelectByID2(compReName + "-1" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0); swModel.ClearSelection2(true); if (status) { swComp = swAssy.GetComponentByName(compReName + "-1"); swPart = swComp.GetModelDoc2(); //打开零件 swPart.Parameter("D2@Skizze1").SystemValue = item.Length / 1000m; if (item.Outlet == "LEFT") { swFeat = swComp.FeatureByName("OUTLET-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("OUTLET-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } else if (item.Outlet == "RIGHT") { swFeat = swComp.FeatureByName("OUTLET-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("OUTLET-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat = swComp.FeatureByName("OUTLET-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("OUTLET-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } swFeat = swComp.FeatureByName("DPB-LEFT"); if (item.SidePanel == "DPBACKL" || item.SidePanel == "DPBACKB") { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } swFeat = swComp.FeatureByName("DPB-RIGHT"); if (item.SidePanel == "DPBACKR" || item.SidePanel == "DPBACKB") { swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 } else { swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //DP if (item.DPSide == "LEFT" || item.DPSide == "BOTH") { swFeat = swComp.FeatureByName("DP-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D14@Sketch42").SystemValue = (item.LeftDis + 1m) / 1000m; leftSBDis = leftSBDis + 90m; swFeat = swComp.FeatureByName("CUT-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch56").SystemValue = 105m / 1000m; } else { swFeat = swComp.FeatureByName("DP-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("CUT-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } if (item.DPSide == "RIGHT" || item.DPSide == "BOTH") { swFeat = swComp.FeatureByName("DP-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D14@Sketch43").SystemValue = (item.RightDis + 1m) / 1000m; rightSBDis = rightSBDis + 90m; swFeat = swComp.FeatureByName("CUT-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch58").SystemValue = 105m / 1000m; } else { swFeat = swComp.FeatureByName("DP-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("CUT-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //BCJ if (item.BackCJSide == "LEFT" || item.BackCJSide == "BOTH") { swFeat = swComp.FeatureByName("BCJ-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D8@Sketch19").SystemValue = (item.LeftDis + 11m) / 1000m; leftSBDis = leftSBDis + 90m; } else { swFeat = swComp.FeatureByName("BCJ-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } if (item.BackCJSide == "RIGHT" || item.BackCJSide == "BOTH") { swFeat = swComp.FeatureByName("BCJ-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D1@Sketch20").SystemValue = (item.RightDis + 11m) / 1000m; rightSBDis = rightSBDis + 90m; } else { swFeat = swComp.FeatureByName("BCJ-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //----------左---------- ////左类型排风腔KCJDB800 //if (item.LeftBeamType == "KCJDB800" || item.LeftBeamType == "UCJDB800") //{ // swFeat = swComp.FeatureByName("BCJ-LEFT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 // swFeat = swComp.FeatureByName("KCJDB800-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D59@Sketch46").SystemValue = (item.LeftBeamDis + 1m) / 1000m; // if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch48").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch48").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D6@Sketch48").SystemValue = (item.Length - item.LeftBeamDis + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("KCJDB800-LEFT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} //左类型排风腔KCWDB800 if (item.LeftBeamType == "KCWDB800" || item.LeftBeamType == "UCWDB800") { swFeat = swComp.FeatureByName("BCJ-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DP-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("KCWDB800-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D30@Sketch50").SystemValue = (item.LeftBeamDis + 1m) / 1000m; if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch53").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch53").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch53").SystemValue = (item.Length - item.LeftBeamDis + 1m) / 1000m; } } else { swFeat = swComp.FeatureByName("KCWDB800-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } ////左类型排风腔KCJSB535 //if (item.LeftBeamType == "KCJSB535" || item.LeftBeamType == "UCJSB535") //{ // swFeat = swComp.FeatureByName("KCJSB535-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D46@Sketch35").SystemValue = (leftSBDis + 1m) / 1000m; // if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch48").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch48").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D6@Sketch48").SystemValue = (leftSBDis + 535m + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("KCJSB535-LEFT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} //左类型排风腔KCWSB535 if (item.LeftBeamType == "KCWSB535" || item.LeftBeamType == "UCWSB535") { swFeat = swComp.FeatureByName("KCWSB535-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D25@Sketch48").SystemValue = (leftSBDis + 1m) / 1000m; if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch53").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch53").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch53").SystemValue = (leftSBDis + 535m + 1m) / 1000m; } } else { swFeat = swComp.FeatureByName("KCWSB535-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } ////左类型排风腔UCJSB385 //if (item.LeftBeamType == "UCJSB385") //{ // swFeat = swComp.FeatureByName("UCJSB385-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D16@Sketch43").SystemValue = (leftSBDis + 1m) / 1000m; // if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch48").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch48").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D6@Sketch48").SystemValue = (leftSBDis + 385m + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("UCJSB385-LEFT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} ////左类型排风腔KCJSB290 //if (item.LeftBeamType == "KCJSB290") //{ // swFeat = swComp.FeatureByName("KCJSB290-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D14@Sketch41").SystemValue = (leftSBDis + 1m) / 1000m; // if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch48").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch48").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D6@Sketch48").SystemValue = (leftSBDis + 290m + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("KCJSB290-LEFT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} ////左类型排风腔KCJSB265 //if (item.LeftBeamType == "KCJSB265") //{ // swFeat = swComp.FeatureByName("KCJSB265-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D23@Sketch28").SystemValue = (leftSBDis + 1m) / 1000m; // if (item.LKSide == "LEFT" || item.LKSide == "BOTH") // { // swFeat = swComp.FeatureByName("LKS270-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D24@Sketch51").SystemValue = (leftSBDis + 265m + 1m) / 1000m; // if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch48").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch48").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D6@Sketch48").SystemValue = (leftSBDis + 270m + 265m + 1m) / 1000m; // } // } // else // { // if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-LEFT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch48").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch48").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D6@Sketch48").SystemValue = (leftSBDis + 265m + 1m) / 1000m; // } // } //} //else //{ // swFeat = swComp.FeatureByName("KCJSB265-LEFT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} //左类型排风腔KCWSB265 if (item.LeftBeamType == "KCWSB265") { swFeat = swComp.FeatureByName("KCWSB265-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D15@Sketch46").SystemValue = (leftSBDis + 1m) / 1000m; if (item.LKSide == "LEFT" || item.LKSide == "BOTH") { swFeat = swComp.FeatureByName("LKS270-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D24@Sketch52").SystemValue = (leftSBDis + 265m + 1m) / 1000m; if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch53").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch53").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch53").SystemValue = (leftSBDis + 270m + 265m + 1m) / 1000m; } } else { if (item.GutterSide == "LEFT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-LEFT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch53").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch53").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch53").SystemValue = (leftSBDis + 265m + 1m) / 1000m; } } } else { swFeat = swComp.FeatureByName("KCWSB265-LEFT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } //----------右---------- ////右类型排风腔KCJDB800 //if (item.RightBeamType == "KCJDB800" || item.RightBeamType == "UCJDB800") //{ // swFeat = swComp.FeatureByName("BCJ-RIGHT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 // swFeat = swComp.FeatureByName("KCJDB800-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D59@Sketch47").SystemValue = (item.RightBeamDis + 1m) / 1000m; // if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch50").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch50").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D7@Sketch50").SystemValue = (item.Length - item.RightBeamDis + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("KCJDB800-RIGHT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} //右类型排风腔KCWDB800 if (item.RightBeamType == "KCWDB800" || item.RightBeamType == "UCWDB800") { swFeat = swComp.FeatureByName("BCJ-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("DP-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 swFeat = swComp.FeatureByName("KCWDB800-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D31@Sketch51").SystemValue = (item.RightBeamDis + 1m) / 1000m; if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch55").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch55").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch55").SystemValue = (item.Length - item.RightBeamDis + 1m) / 1000m; } } else { swFeat = swComp.FeatureByName("KCWDB800-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } ////右类型排风腔KCJSB535 //if (item.RightBeamType == "KCJSB535" || item.RightBeamType == "UCJSB535") //{ // swFeat = swComp.FeatureByName("KCJSB535-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D46@Sketch37").SystemValue = (rightSBDis + 1m) / 1000m; // if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch50").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch50").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D7@Sketch50").SystemValue = (rightSBDis + 535m + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("KCJSB535-RIGHT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} //右类型排风腔KCWSB535 if (item.RightBeamType == "KCWSB535" || item.RightBeamType == "UCWSB535") { swFeat = swComp.FeatureByName("KCWSB535-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D24@Sketch49").SystemValue = (rightSBDis + 1m) / 1000m; if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch55").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch55").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch55").SystemValue = (rightSBDis + 535m + 1m) / 1000m; } } else { swFeat = swComp.FeatureByName("KCWSB535-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 } ////右类型排风腔UCJSB385 //if (item.RightBeamType == "UCJSB385") //{ // swFeat = swComp.FeatureByName("UCJSB385-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D16@Sketch44").SystemValue = (rightSBDis + 1m) / 1000m; // if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch50").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch50").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D7@Sketch50").SystemValue = (rightSBDis + 385m + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("UCJSB385-RIGHT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} ////右类型排风腔KCJSB290 //if (item.RightBeamType == "KCJSB290") //{ // swFeat = swComp.FeatureByName("KCJSB290-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D14@Sketch42").SystemValue = (rightSBDis + 1m) / 1000m; // if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch50").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch50").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D7@Sketch50").SystemValue = (rightSBDis + 290m + 1m) / 1000m; // } //} //else //{ // swFeat = swComp.FeatureByName("KCJSB290-RIGHT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} ////右类型排风腔KCJSB265 //if (item.RightBeamType == "KCJSB265") //{ // swFeat = swComp.FeatureByName("KCJSB265-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D1@Sketch55").SystemValue = (rightSBDis + 1m) / 1000m; // if (item.LKSide == "RIGHT" || item.LKSide == "BOTH") // { // swFeat = swComp.FeatureByName("LKS270-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D24@Sketch53").SystemValue = (rightSBDis + 265m + 1m) / 1000m; // if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch50").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch50").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D7@Sketch50").SystemValue = (rightSBDis + 270m + 265m + 1m) / 1000m; // } // } // else // { // if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") // { // swFeat = swComp.FeatureByName("GUTTER-RIGHT"); // swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 // swPart.Parameter("D4@Sketch50").SystemValue = (item.GutterWidth - 2m) / 1000m; // swPart.Parameter("D5@Sketch50").SystemValue = (item.GutterWidth - 62m) / 1000m; // swPart.Parameter("D7@Sketch50").SystemValue = (rightSBDis + 265m + 1m) / 1000m; // } // } //} //else //{ // swFeat = swComp.FeatureByName("KCJSB265-RIGHT"); // swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩 //} //右类型排风腔KCWSB265 if (item.RightBeamType == "KCWSB265") { swFeat = swComp.FeatureByName("KCWSB265-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D15@Sketch47").SystemValue = (rightSBDis + 1m) / 1000m; if (item.LKSide == "RIGHT" || item.LKSide == "BOTH") { swFeat = swComp.FeatureByName("LKS270-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D24@Sketch54").SystemValue = (rightSBDis + 265m + 1m) / 1000m; if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch55").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch55").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch55").SystemValue = (rightSBDis + 270m + 265m + 1m) / 1000m; } } else { if (item.GutterSide == "RIGHT" || item.GutterSide == "BOTH") { swFeat = swComp.FeatureByName("GUTTER-RIGHT"); swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩 swPart.Parameter("D4@Sketch55").SystemValue = (item.GutterWidth - 2m) / 1000m; swPart.Parameter("D5@Sketch55").SystemValue = (item.GutterWidth - 62m) / 1000m; swPart.Parameter("D7@Sketch55").SystemValue = (rightSBDis + 265m + 1m) / 1000m; } } } else { swFeat = swComp.FeatureByName("KCWSB265-RIGHT"); swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,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的使用 } }
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()) < 90m) { MessageBox.Show("请认真检查DP腔长度", "提示信息"); txtLength.Focus(); txtLength.SelectAll(); return; } if (cobSidePanel.SelectedIndex == -1) { MessageBox.Show("请选择DP腔侧板", "提示信息"); cobSidePanel.Focus(); return; } if (cobOutlet.SelectedIndex == -1) { MessageBox.Show("请选择排水口位置,没有请选择NO", "提示信息"); cobOutlet.Focus(); return; } if (cobBackCJSide.SelectedIndex == -1) { MessageBox.Show("请选择BCJ位置,如果没有请选择NO", "提示信息"); cobBackCJSide.Focus(); return; } if (cobDPSide.SelectedIndex == -1) { MessageBox.Show("请选择DP位置,如果没有请选择NO", "提示信息"); cobDPSide.Focus(); return; } if (cobLeftBeamType.SelectedIndex == -1) { MessageBox.Show("请选择左排风腔类型,如果没有请选择NO", "提示信息"); cobBackCJSide.Focus(); return; } if (cobRightBeamType.SelectedIndex == -1) { MessageBox.Show("请选择右排风腔类型,如果没有请选择NO", "提示信息"); cobBackCJSide.Focus(); return; } if (cobLKSide.SelectedIndex == -1) { MessageBox.Show("请选择LK270位置", "提示信息"); cobLKSide.Focus(); return; } if (cobGutterSide.SelectedIndex == -1) { MessageBox.Show("请选择ANSUL腔的位置", "提示信息"); cobGutterSide.Focus(); return; } if (cobGutterSide.SelectedIndex != 2) { if (!DataValidate.IsDecimal(txtGutterWidth.Text.Trim()) || Convert.ToDecimal(txtGutterWidth.Text.Trim()) < 30m) { MessageBox.Show("请认真检查ANSUL腔的宽度", "提示信息"); txtGutterWidth.Focus(); txtGutterWidth.SelectAll(); return; } } #endregion //封装对象 DP330 objDP330 = new DP330() { DP330Id = Convert.ToInt32(pbModelImage.Tag), SidePanel = cobSidePanel.Text, Outlet = cobOutlet.Text, BackCJSide = cobBackCJSide.Text, DPSide = cobDPSide.Text, LeftBeamType = cobLeftBeamType.Text, RightBeamType = cobRightBeamType.Text, LKSide = cobLKSide.Text, GutterSide = cobGutterSide.Text, Length = Convert.ToDecimal(txtLength.Text.Trim()), LeftDis = Convert.ToDecimal(txtLeftDis.Text.Trim()), RightDis = Convert.ToDecimal(txtRightDis.Text.Trim()), LeftBeamDis = Convert.ToDecimal(txtLeftBeamDis.Text.Trim()), RightBeamDis = Convert.ToDecimal(txtRightBeamDis.Text.Trim()), GutterWidth = Convert.ToDecimal(txtGutterWidth.Text.Trim()) }; //提交修改 try { if (objDP330Service.EditModel(objDP330) == 1) { MessageBox.Show("制图数据修改成功", "提示信息"); this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }