Exemplo n.º 1
0
        /// <summary>
        /// 修改KVS的制图参数
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int EditModel(IModel model)
        {
            KVS objModel = (KVS)model;
            //编写带参数的SQL语句
            StringBuilder sqlBuilder = new StringBuilder();

            sqlBuilder.Append("Update KVS set Length=@Length,Deepth=@Deepth,ExNo=@ExNo,EXDis=@EXDis,ExLength=@ExLength,");
            sqlBuilder.Append("ExWidth=@ExWidth,ExHeight=@ExHeight,LightType=@LightType where KVSId=@KVSId");
            //定义参数数组
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@Length", objModel.Length),
                new SqlParameter("@Deepth", objModel.Deepth),
                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("@LightType", objModel.LightType),
                new SqlParameter("@KVSId", objModel.KVSId)
            };
            try
            {
                return(SQLHelper.Update(sqlBuilder.ToString(), param));
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库操作出现异常:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据条件查找KVS
        /// </summary>
        /// <param name="whereSql"></param>
        /// <returns></returns>
        public IModel GetModelByWhereSql(string whereSql)
        {
            string sql =
                "select KVSId,ModuleTreeId,Length,Deepth,ExNo,EXDis,ExLength,ExWidth,ExHeight,LightType,SidePanel from KVS";

            sql += whereSql;
            SqlDataReader objReader = SQLHelper.GetReader(sql);
            KVS           objModel  = null;

            if (objReader.Read())
            {
                objModel = new KVS()
                {
                    KVSId        = Convert.ToInt32(objReader["KVSId"]),
                    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"]),
                    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"]),
                    LightType = objReader["LightType"].ToString().Length == 0 ? "" : objReader["LightType"].ToString(),
                    SidePanel = objReader["SidePanel"].ToString().Length == 0 ? "" : objReader["SidePanel"].ToString(),
                };
            }
            objReader.Close();
            return(objModel);
        }
Exemplo n.º 3
0
        public TreeStateStore(string prefix)
        {
            treeStateKey = prefix + ".TreeStateV1";
            tokenKey     = prefix + ".Token";

            kvs = new KVS();
        }
Exemplo n.º 4
0
        private void Run()
        {
            KVS database = new KVS(@"/src/database");

            foreach (Tuple <string, string> record in database.GetAllRecords())
            {
                Console.WriteLine(record.Item1 + ": " + record.Item2);
            }
        }
Exemplo n.º 5
0
        private void Run()
        {
            KVS database = new KVS(@"/src/database");

            database.SetData("ananas", "3");
            database.SetData("banana", "23");
            database.SetData("cranberry", "5809");
            database.SetData("ananas", "42");
            database.SetData("date", "78");

            Console.WriteLine("Done");
        }
Exemplo n.º 6
0
        public FrmKVS(Drawing drawing, ModuleTree tree) : this()
        {
            objKVS = (KVS)objKVSService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            if (objKVS == 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 void ExportCoordinates()
        {
            if (m_pixelPoints.Count <= 0)
            {
                this.textBox.AppendText("导出坐标失败:未设置像控点。" + Environment.NewLine);
                return;
            }
            if (m_referencePoints.Count <= 0)
            {
                this.textBox.AppendText("导出坐标失败:未设置参考点。" + Environment.NewLine);
                return;
            }
            if (m_referencePoints.Count != m_pixelPoints.Count)
            {
                this.textBox.AppendText("导出坐标失败:像控点和参考点的数量不一致。" + Environment.NewLine);
                return;
            }

            var dialog = new SaveFileDialog();

            dialog.Filter       = "控制点坐标(*.xml)|*.xml";
            dialog.AddExtension = true;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var sourceCoordinates = new List <GeocentricCoordinate>();
                var targetCoordinates = new List <GeocentricCoordinate>();

                for (int i = 0; i < m_pixelPoints.Count; i++)
                {
                    sourceCoordinates.Add(new GeocentricCoordinate(m_pixelPoints[i].Lat, m_pixelPoints[i].Lng));
                    targetCoordinates.Add(new GeocentricCoordinate(m_referencePoints[i].Lat, m_referencePoints[i].Lng));
                }

                KVS.Create(dialog.FileName, sourceCoordinates, targetCoordinates);
            }
        }
Exemplo n.º 8
0
        /// <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 (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;
            }


            #endregion
            //封装对象
            KVS objKVS = new KVS()
            {
                KVSId     = Convert.ToInt32(pbModelImage.Tag),
                ExNo      = Convert.ToInt32(cobExNo.Text),
                LightType = cobLightType.Text,

                Length   = Convert.ToDecimal(txtLength.Text.Trim()),
                Deepth   = Convert.ToDecimal(txtDeepth.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())
            };
            //提交修改
            try
            {
                if (objKVSService.EditModel(objKVS) == 1)
                {
                    MessageBox.Show("制图数据修改成功", "提示信息");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void menuItemExportTransformedSketch_Click(object sender, EventArgs e)
        {
            var dialog = new SaveFileDialog();

            dialog.Filter       = "Shp文件(*.shp)|*.shp";
            dialog.AddExtension = true;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var xmlDialog = new OpenFileDialog();
                xmlDialog.Filter = "控制点坐标(*.xml)|*.xml";
                if (xmlDialog.ShowDialog() == DialogResult.OK)
                {
                    List <HorizontalCoordinate> sourceCoordinates, targetCoordinates;
                    KVS.Open(dialog.FileName, out targetCoordinates, out sourceCoordinates);
                    var param4 = LinearTransformation.GetTransformationParameter(sourceCoordinates, targetCoordinates);

                    var pathName = Path.GetDirectoryName(dialog.FileName);
                    var fileName = Path.GetFileNameWithoutExtension(dialog.FileName);

                    var      nVertices = m_mapDocument.GetSketchPointCount();
                    double[] adfX      = new double[1];
                    double[] adfY      = new double[1];
                    double[] adfZ      = new double[1];

                    var shpFileName = string.Format(@"{0}\{1}_point.shp", pathName, fileName);
                    var hSHP        = Shapelib.SHPCreate(shpFileName, Shapelib.ShapeType.Point);

                    for (int i = 0; i < nVertices; i++)
                    {
                        m_mapDocument.GetSketchPointInfo(i, ref adfX, ref adfY, ref adfZ, param4);
                        var psObject = Shapelib.SHPCreateSimpleObject(Shapelib.ShapeType.Point, nVertices, adfX, adfY, adfZ);
                        Shapelib.SHPWriteObject(hSHP, -1, psObject);
                    }
                    Shapelib.SHPClose(hSHP);
                    m_outputWindow.OutputText("点文件已存为:" + shpFileName);

                    nVertices   = m_mapDocument.GetSketchPolylineCount();
                    shpFileName = string.Format(@"{0}\{1}_polyline.shp", pathName, fileName);
                    hSHP        = Shapelib.SHPCreate(shpFileName, Shapelib.ShapeType.PolyLine);

                    for (int i = 0; i < nVertices; i++)
                    {
                        var count = m_mapDocument.GetSketchPolylinePointCount(i);
                        adfX = new double[count];
                        adfY = new double[count];
                        adfZ = new double[count];

                        m_mapDocument.GetSketchPolylineInfo(i, ref adfX, ref adfY, ref adfZ, param4);

                        var psObject = Shapelib.SHPCreateSimpleObject(Shapelib.ShapeType.PolyLine, count, adfX, adfY, adfZ);
                        var iLine    = Shapelib.SHPWriteObject(hSHP, -1, psObject);
                    }
                    Shapelib.SHPClose(hSHP);
                    m_outputWindow.OutputText("线文件已存为:" + shpFileName);

                    nVertices   = m_mapDocument.GetSketchPolygonCount();
                    shpFileName = string.Format(@"{0}\{1}_polygon.shp", pathName, fileName);
                    hSHP        = Shapelib.SHPCreate(shpFileName, Shapelib.ShapeType.Polygon);

                    for (int i = 0; i < nVertices; i++)
                    {
                        var count = m_mapDocument.GetSketchPolygonPointCount(i);
                        adfX = new double[count];
                        adfY = new double[count];
                        adfZ = new double[count];

                        m_mapDocument.GetSketchPolygonInfo(i, ref adfX, ref adfY, ref adfZ, param4);

                        var psObject = Shapelib.SHPCreateSimpleObject(Shapelib.ShapeType.Polygon, count, adfX, adfY, adfZ);
                        var iPolygon = Shapelib.SHPWriteObject(hSHP, -1, psObject);
                    }
                    Shapelib.SHPClose(hSHP);
                    m_outputWindow.OutputText("面文件已存为:" + shpFileName);
                }
            }
        }
        private void OpenLayer(string shpFileName, string xmlFileName = "")
        {
            var pathName = Path.GetDirectoryName(shpFileName);
            var fileName = Path.GetFileNameWithoutExtension(shpFileName);

            var shp  = string.Format(@"{0}\{1}.shp", pathName, fileName);
            var hSHP = Shapelib.SHPOpen(shp, "rb");
            var dbf  = string.Format(@"{0}\{1}.dbf", pathName, fileName);
            var hDBF = Shapelib.DBFOpen(dbf, "rb");

            // 实体数
            int pnEntities = 0;

            // 形状类型
            Shapelib.ShapeType pshpType = Shapelib.ShapeType.NullShape;
            // 界限坐标数组
            double[] adfMinBound = new double[4], adfMaxBound = new double[4];

            // 获取实体数、形状类型、界限坐标等信息
            Shapelib.SHPGetInfo(hSHP, ref pnEntities, ref pshpType, adfMinBound, adfMaxBound);

            var sourceCoordinates = new List <HorizontalCoordinate>();
            var targetCoordinates = new List <HorizontalCoordinate>();

            if (!string.IsNullOrEmpty(xmlFileName))
            {
                KVS.Open(xmlFileName, out sourceCoordinates, out targetCoordinates);
            }

            var param4 = string.IsNullOrEmpty(xmlFileName) ? null : LinearTransformation.GetTransformationParameter(sourceCoordinates, targetCoordinates);
            var rect   = string.IsNullOrEmpty(xmlFileName) ? GetShapeRect(adfMinBound, adfMaxBound) : GetShapeRect(adfMinBound, adfMaxBound, param4);

            var node = new TreeNode(shp);

            node.Tag     = rect;
            node.Checked = true;
            node.ExpandAll();

            GMapOverlay overlay = new GMapOverlay(shp);

            for (int iShape = 0; iShape < pnEntities; iShape++)
            {
                // SHPObject对象
                Shapelib.SHPObject shpObject = new Shapelib.SHPObject();
                // 读取SHPObject对象指针
                var shpObjectPtr = Shapelib.SHPReadObject(hSHP, iShape);
                // 忽略可能存在问题的实体
                if (shpObjectPtr == IntPtr.Zero)
                {
                    continue;
                }
                // 指针转换为SHPObject对象
                Marshal.PtrToStructure(shpObjectPtr, shpObject);

                // 顶点数
                int nVertices = shpObject.nVertices;

                // 顶点的X坐标数组
                var padfX = new double[nVertices];
                // 将顶点的X坐标数组指针转换为数组
                Marshal.Copy(shpObject.padfX, padfX, 0, nVertices);
                // 顶点的Y坐标数组
                var padfY = new double[nVertices];
                // 将顶点的Y坐标数组指针转换为数组
                Marshal.Copy(shpObject.padfY, padfY, 0, nVertices);

                int    iField     = Shapelib.DBFGetFieldIndex(hDBF, "名称");
                string entityName = Shapelib.DBFReadStringAttribute(hDBF, iShape, iField);
                // var entityName = Enum.GetName(pshpType.GetType(), pshpType) + iShape;
                var points     = new List <PointLatLng>();
                var entityNode = new TreeNode();
                entityNode.Text = entityName;
                switch (pshpType)
                {
                case Shapelib.ShapeType.Point:
                    var pointMarker = string.IsNullOrEmpty(xmlFileName) ? GetPoint(padfX[0], padfY[0]) : GetTransformedPoint(padfX[0], padfY[0], param4);
                    points.Add(pointMarker);
                    UpdateOverlay(ref overlay, pshpType, points, entityName);
                    entityNode.Tag = overlay.Id;
                    break;

                default:
                    var minPoint = new PointLatLng();
                    var maxPoint = new PointLatLng();
                    for (int i = 0; i < nVertices; i++)
                    {
                        var point = string.IsNullOrEmpty(xmlFileName) ? GetPoint(padfX[i], padfY[i]) : GetTransformedPoint(padfX[i], padfY[i], param4);
                        points.Add(point);

                        if (i == 0)
                        {
                            minPoint.Lat = maxPoint.Lat = point.Lat;
                            minPoint.Lng = maxPoint.Lng = point.Lng;
                        }
                        else
                        {
                            if (point.Lng > maxPoint.Lng)
                            {
                                maxPoint.Lng = point.Lng;
                            }
                            if (point.Lat > maxPoint.Lat)
                            {
                                maxPoint.Lat = point.Lat;
                            }
                            if (point.Lng < minPoint.Lng)
                            {
                                minPoint.Lng = point.Lng;
                            }
                            if (point.Lat < minPoint.Lat)
                            {
                                minPoint.Lat = point.Lat;
                            }
                        }
                    }

                    UpdateOverlay(ref overlay, pshpType, points, entityName);
                    var entityRect = new RectLatLng(maxPoint.Lat, minPoint.Lng, maxPoint.Lng - minPoint.Lng, maxPoint.Lat - minPoint.Lat);
                    entityNode.Tag = entityRect;
                    break;
                }
                node.Nodes.Add(entityNode);
            }
            Shapelib.DBFClose(hDBF);
            Shapelib.SHPClose(hSHP);

            m_layerWindow.AddNode(node);

            m_mapDocument.AddOverlayer(overlay);
            if (pshpType == Shapelib.ShapeType.Point)
            {
                m_mapDocument.Zoom(overlay.Id);
            }
            else
            {
                m_mapDocument.Zoom(rect);
            }
        }
Exemplo n.º 11
0
        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);
            }

            //查询参数
            KVS item = (KVS)objKVSService.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会四舍五入
             */
            //-----------计算中间值,----------
            //新风CJ孔数量和新风CJ孔第一个CJ距离边缘距离
            int     frontCjNo       = (int)((item.Length - 3m - 30m) / 32m) + 1;
            decimal frontCjFirstDis = (item.Length - 3m - (frontCjNo - 1) * 32m) / 2m;
            //铆钉数量
            int     rivetNo  = (int)((item.Length - 200m) / 300m);
            decimal rivetDis = (item.Length - 200m) / rivetNo;
            //为了适应肯德基脖颈缺口
            decimal midRoofSecondHoleDis = 0m;

            if (item.ExNo == 2)
            {
                midRoofSecondHoleDis = (item.Length - 300m - item.ExDis - item.ExLength) / 4m;
            }
            else if (item.ExNo == 1)
            {
                midRoofSecondHoleDis = (item.Length - 300m) / 2m;
            }
            //KSA数量,KSA侧板长度(以全长计算)
            int     ksaNo         = (int)((item.Length - 7m) / 498m);
            decimal ksaSideLength = (item.Length - 8m - ksaNo * 498m) / 2m;


            try
            {
                //----------Top Level----------
                ////判断KSA数量,KSA侧板长度,如果太小,则使用特殊小侧板侧边
                //swFeat = swAssy.FeatureByName("LocalLPattern1");
                //if (ksaNo == 1) swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                //else
                //{
                //    swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                //    swModel.Parameter("D1@LocalLPattern1").SystemValue = ksaNo; //D1阵列数量,D3阵列距离
                //}
                ////KSA距离左边缘
                //if (ksaSideLength < 12m / 1000m) swModel.Parameter("D1@Distance15").SystemValue = 0.5m / 1000m;
                //else swModel.Parameter("D1@Distance15").SystemValue = ksaSideLength;

                //排风脖颈数量和距离
                if (item.ExNo == 1)
                {
                    swModel.Parameter("D1@Distance52").SystemValue = (item.Length - item.ExLength) / 2000m;
                    swFeat = swAssy.FeatureByName("LocalLPattern1");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }
                else if (item.ExNo == 2)
                {
                    swModel.Parameter("D1@Distance52").SystemValue = ((item.Length - item.ExDis) / 2m - item.ExLength) / 1000m;
                    swFeat = swAssy.FeatureByName("LocalLPattern1");
                    swFeat.SetSuppression2(1, 2, configNames);                                                 //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern1").SystemValue = item.ExNo;                            //D1阵列数量,D3阵列距离
                    swModel.Parameter("D3@LocalLPattern1").SystemValue = (item.ExDis + item.ExLength) / 1000m; //D1阵列数量,D3阵列距离
                }
                //日光灯
                if (item.LightType == "FSSHORT")
                {
                    //SHORT
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0003-3"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0004-2"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0005-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0005-2"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020404-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020406-S-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-3"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-4"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300026-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300026-3"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    //LONG
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0002-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0002-2"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0003-4"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0004-3"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020405-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020407-S-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-5"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-6"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300023-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300023-2"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                }
                else
                {
                    //SHORT
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0003-3"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0004-2"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0005-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0005-2"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020404-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020406-S-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-3"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-4"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300026-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300026-3"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩
                    //LONG
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0002-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0002-2"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0003-4"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0004-3"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020405-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020407-S-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-5"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020424-6"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300023-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200300023-2"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩
                }
                //----------排风腔----------
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0110-1"));
                swPart = swComp.GetModelDoc2();//打开零件3
                swPart.Parameter("D1@Sketch1").SystemValue  = (item.Length - 7m) / 1000m;
                swPart.Parameter("D5@Sketch62").SystemValue = (item.ExDis + item.ExLength) / 1000m;
                //排风口
                if (item.ExNo == 1)
                {
                    swFeat = swComp.FeatureByName("EXCOONE");
                    swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("EXCOTWO");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swPart.Parameter("D1@Sketch115").SystemValue = item.ExLength / 1000m;
                    swPart.Parameter("D2@Sketch115").SystemValue = item.ExWidth / 1000m;
                    swPart.Parameter("D5@Sketch62").SystemValue  = midRoofSecondHoleDis / 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("D4@Sketch114").SystemValue = item.ExDis / 1000m;
                    swPart.Parameter("D2@Sketch114").SystemValue = item.ExLength / 1000m;
                    swPart.Parameter("D1@Sketch114").SystemValue = item.ExWidth / 1000m;
                    swPart.Parameter("D5@Sketch62").SystemValue  = (item.ExDis + item.ExLength) / 1000m;
                    if (midRoofSecondHoleDis > 300m)
                    {
                        swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swPart.Parameter("D3@Sketch116").SystemValue = midRoofSecondHoleDis / 1000m;
                    }
                    else
                    {
                        swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                }
                //----------其他零件----------
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0111-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = (item.Length - 6m) / 1000m;

                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0112-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch3").SystemValue = ksaSideLength / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0113-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch3").SystemValue = ksaSideLength / 1000m;

                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0114-2"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D1@Sketch1").SystemValue = (item.ExLength + 50m) / 1000m;
                swPart.Parameter("D2@Sketch1").SystemValue = (item.ExHeight + 54.8m) / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0115-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D1@Sketch1").SystemValue = (item.ExLength + 50m) / 1000m;
                swPart.Parameter("D2@Sketch1").SystemValue = (item.ExHeight + 54.8m) / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0117-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D1@Sketch1").SystemValue = item.ExLength / 2000m;
                swPart.Parameter("D2@Sketch1").SystemValue = (item.ExWidth + 20m) / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHE0118-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = (item.ExLength * 2m) / 1000m;

                //----------MiddleRoof灯板----------
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHM0023-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = (item.Length - 3m) / 1000m;
                swPart.Parameter("D1@Sketch1").SystemValue = (item.Deepth - 788.5m) / 1000m;
                if (item.ExNo == 1)
                {
                    swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swPart.Parameter("D2@Sketch20").SystemValue = midRoofSecondHoleDis / 1000m;
                }
                else
                {
                    swPart.Parameter("D2@Sketch20").SystemValue = (item.ExDis + item.ExLength) / 1000m;
                    if (midRoofSecondHoleDis > 300m)
                    {
                        swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swPart.Parameter("D1@Sketch26").SystemValue = midRoofSecondHoleDis / 1000m;
                    }
                    else
                    {
                        swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                }
                //灯具
                if (item.LightType == "FSSHORT")
                {
                    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("FSLONG");
                    swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("FSSHORT");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5201020401-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Deepth - 793m) / 1000m;
                //----------大侧板----------
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0036-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = item.Deepth / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0037-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = item.Deepth / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0038-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = item.Deepth / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHS0039-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Sketch1").SystemValue = item.Deepth / 1000m;

                //------------新风腔----------
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0052-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 7m) / 1000m;
                if (item.ExNo == 1)
                {
                    swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swPart.Parameter("D3@Sketch50").SystemValue = midRoofSecondHoleDis / 1000m;
                }
                else
                {
                    swPart.Parameter("D3@Sketch50").SystemValue = (item.ExDis + item.ExLength) / 1000m;
                    if (midRoofSecondHoleDis > 300m)
                    {
                        swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swPart.Parameter("D3@Sketch127").SystemValue = midRoofSecondHoleDis / 1000m;
                    }
                    else
                    {
                        swFeat = swComp.FeatureByName("MIDROOFINSDIS2");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                }
                swPart.Parameter("D1@LPattern2").SystemValue = rivetNo + 1;
                swPart.Parameter("D3@LPattern2").SystemValue = rivetDis / 1000m;

                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0053-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 103m) / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0054-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 3m) / 1000m;
                swPart.Parameter("D1@LPattern1").SystemValue    = frontCjNo;
                swPart.Parameter("D10@Sketch8").SystemValue     = frontCjFirstDis / 1000m;
                swPart.Parameter("D1@LPattern2").SystemValue    = rivetNo + 1;
                swPart.Parameter("D3@LPattern2").SystemValue    = rivetDis / 1000m;
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNHA0055-1"));
                swPart = swComp.GetModelDoc2();
                swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 7m) / 1000m;

                swModel.ForceRebuild3(true);    //设置成true,直接更新顶层,速度很快,设置成false,每个零件都会更新,很慢
                swModel.Save();                 //保存,很耗时间
                swApp.CloseDoc(packedAssyPath); //关闭,很快
            }
            catch (Exception ex)
            {
                throw new Exception(packedAssyPath + "作图过程发生异常,详细:" + ex.Message);
            }
            finally
            {
                swApp.CommandInProgress = false; //及时关闭外部命令调用,否则影响SolidWorks的使用
            }
        }