예제 #1
0
 private void AddChildVisibilitiesExcludingNodeModules(ModuleTree moduleTree) {
     foreach (var childTree in moduleTree.GetChildrenExcludingNodeModules()) {
         Debug.Assert(childTree.Name != AnalysisConstants.NodeModulesFolder);
         if (childTree.ProjectEntry == null) {
             AddChildVisibilitiesExcludingNodeModules(childTree);
         } else {
             _table.AddVisibility(_tree, childTree.ProjectEntry);
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 生成多条SQL语句删除分段和作图数据,先删除数据后删除分段
        /// </summary>
        /// <param name="objModuleTree"></param>
        /// <returns></returns>
        public bool DeleteModuleAndData(ModuleTree objModuleTree)
        {
            //编写SQL语句
            List <string> sqlList     = new List <string>();
            Category      objCategory = objCategoryService.GetCategoryByCategoryId(objModuleTree.CategoryId.ToString());
            string        sqldata     = string.Format("delete from " + objCategory.CategoryName + " where ModuleTreeId={0}", objModuleTree.ModuleTreeId);

            sqlList.Add(sqldata);
            string sql = string.Format("delete from ModuleTree where ModuleTreeId={0}", objModuleTree.ModuleTreeId);

            sqlList.Add(sql);
            return(SQLHelper.UpdateByTransaction(sqlList));
        }
예제 #3
0
        public Generator()
        {
            for (int i = 0; i < 6; i++)
            {
                myElevationTex[i] = new Texture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.R32f);
                myElevationTex[i].setName(String.Format("Elevation Tex {0}", i));
                myBiomeTex[i] = new Texture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.Rgba32f);
                myBiomeTex[i].setName(String.Format("Biome Tex {0}", i));
            }

            myElevationMap = new CubemapTexture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.R32f);
            myElevationMap.setName("Elevation Cubemap");

            myBiomeMap = new CubemapTexture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.Rgba32f);
            myBiomeMap.setName("Biome Cubemap");

            List <ShaderDescriptor> shadersDesc = new List <ShaderDescriptor>();

            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyElevation-cs.glsl"));
            ShaderProgramDescriptor sd = new ShaderProgramDescriptor(shadersDesc);

            myApplyElevationShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyHeat-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myApplyHeatShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyMoisture-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myApplyMoistureShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyBiome-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myGenerateBiomeShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            //setup generators
            myElevationGenerator   = new ModuleTree(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize);
            myElevationFractals[0] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal0") as Fractal;
            myElevationFractals[1] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal") as Fractal;
            myElevationFractals[2] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal2") as Fractal;
            myElevationFractals[3] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal3") as Fractal;
            myElevationFractals[4] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal4") as Fractal;
            myElevationFractals[5] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal5") as Fractal;
            AutoCorrect Eac = myElevationGenerator.addModule(Module.Type.AutoCorect, "autocorrect") as AutoCorrect;

            myHeatGenerator     = createHeatGenerator();
            myMoistureGenerator = createMoistureGenerator();
        }
예제 #4
0
 /// <summary>
 /// 以异步的方式打印JobCard
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 private Task PrintJobCardAsync(ModuleTree item)
 {
     return(Task.Run(() =>
     {
         try
         {
             new PrintReports().ExecPrintHoodJobCard(item);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }));
 }
예제 #5
0
 /// <summary>
 /// 异步方式开始导出dxf图纸
 /// </summary>
 /// <param name="item"></param>
 /// <param name="dxfPath"></param>
 /// <returns></returns>
 private Task exportDxfAsync(ModuleTree item, string dxfPath, int userId)
 {
     return(Task.Run(() =>
     {
         try
         {
             new ExprotDxf().HoodAssyToDxf(swApp, item, dxfPath, userId);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }));
 }
예제 #6
0
        public FrmUCWUVR4SDXF(Drawing drawing, ModuleTree tree) : this()
        {
            objUCWUVR4SDXF = (UCWUVR4SDXF)objUCWUVR4SDXFService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            if (objUCWUVR4SDXF == 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();
        }
예제 #7
0
 private void AddChildVisibilitiesExcludingNodeModules(ModuleTree moduleTree)
 {
     foreach (var childTree in moduleTree.GetChildrenExcludingNodeModules())
     {
         Debug.Assert(childTree.Name != AnalysisConstants.NodeModulesFolder);
         if (childTree.ProjectEntry == null)
         {
             AddChildVisibilitiesExcludingNodeModules(childTree);
         }
         else
         {
             _table.AddVisibility(_tree, childTree.ProjectEntry);
         }
     }
 }
예제 #8
0
 /// <summary>
 /// 异步方式执行作图程序
 /// </summary>
 /// <param name="item"></param>
 /// <param name="projectPath"></param>
 /// <returns></returns>
 private Task AutoDrawingAsync(ModuleTree item, string projectPath)
 {
     return(Task.Run(() =>
     {
         try
         {
             IAutoDrawing objAutoDrawing = AutoDrawingFactory.ChooseDrawingType(item);
             objAutoDrawing.AutoDrawing(swApp, item, projectPath);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }));
 }
예제 #9
0
        /// <summary>
        /// 生成多条SQL语句添加分段和作图数据,先添加分段再添加数据
        /// </summary>
        /// <param name="objModuleTree"></param>
        /// <returns></returns>
        public bool AddModuleAndData(ModuleTree objModuleTree)
        {
            //编写SQL语句
            string sql = "insert into ModuleTree(DrawingPlanId,CategoryId,Module)";

            sql += " values({0},{1},'{2}'); select @@identity";
            sql  = string.Format(sql, objModuleTree.DrawingPlanId, objModuleTree.CategoryId, objModuleTree.Module);
            List <string> sqlList = new List <string>();

            sqlList.Add(sql);
            Category objCategory = objCategoryService.GetCategoryByCategoryId(objModuleTree.CategoryId.ToString());
            string   sqldata     = "insert into " + objCategory.CategoryName + " (ModuleTreeId) values(@@IDENTITY)";

            sqlList.Add(sqldata);
            //将sql语句提交到数据库
            return(SQLHelper.UpdateByTransaction(sqlList));
        }
예제 #10
0
        ModuleTree createMoistureGenerator()
        {
            ModuleTree generated = new ModuleTree(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize);
            Fractal    f         = generated.addModule(Module.Type.Fractal, "fractal") as Fractal;

            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theMoistureOctaves;
            f.frequency = WorldParameters.theMoistureFrequency;

            AutoCorrect ac = generated.addModule(Module.Type.AutoCorect, "autocorrect") as AutoCorrect;

            ac.output.setName("Moisture Autocorrect");
            ac.source = f;

            generated.final.source = ac;

            return(generated);
        }
예제 #11
0
        ModuleTree defaultMoistureGenerator()
        {
            ModuleTree generated = new ModuleTree(WorldParameters.theWorldSize, WorldParameters.theWorldSize);
            Fractal2d  f         = generated.createModule(Module.Type.Fractal2d, "Moisture Fractal") as Fractal2d;

            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theMoistureOctaves;
            f.frequency = WorldParameters.theMoistureFrequency;

            AutoCorrect ac = generated.createModule(Module.Type.AutoCorrect, "Moisture AutoCorrect") as AutoCorrect;

            ac.output.setName("Moisture AutoCorrect");
            ac.source = f;

            generated.output = ac;

            return(generated);
        }
예제 #12
0
        /// <summary>
        /// 打印Cutlist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPrintCutList_Click(object sender, EventArgs e)
        {
            if (dgvCutList.RowCount == 0)
            {
                return;
            }
            btnPrintCutList.Enabled = false;
            btnPrintCutList.Text    = "打印中...";
            ModuleTree tree =
                objModuleTreeService.GetModuleTreeById(dgvCutList.Rows[0].Cells["ModuleTreeId"].Value.ToString());

            if (new PrintReports().ExecPrintHoodCutList(objDrawing, tree, dgvCutList))
            {
                MessageBox.Show("CutList打印完成", "打印完成");
            }
            btnPrintCutList.Enabled = true;
            btnPrintCutList.Text    = "打印CustList";
        }
예제 #13
0
        /// <summary>
        /// 修改分段
        /// </summary>
        /// <param name="objModuleTree"></param>
        /// <returns></returns>
        public int EditModuleTree(ModuleTree objModuleTree)
        {
            string sql = "update ModuleTree set Module='{0}' where ModuleTreeId={1}";

            sql = string.Format(sql, objModuleTree.Module, objModuleTree.ModuleTreeId);
            try
            {
                return(SQLHelper.Update(sql));
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库操作出现异常:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        ModuleTree defaultElevationGenerator()
        {
            ModuleTree generator = new ModuleTree(WorldParameters.theWorldSize, WorldParameters.theWorldSize);
            Fractal2d  f         = generator.createModule(Module.Type.Fractal2d, "Elevation Fractal") as Fractal2d;

            f.output.setName("fractal");
            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theTerrainOctaves;
            f.frequency = WorldParameters.theTerrainFrequency;

            AutoCorrect ac = generator.createModule(Module.Type.AutoCorrect, "Elevation AutoCorrect") as AutoCorrect;

            ac.output.setName("Elevation AutoCorrect");
            ac.source = f;

            generator.output = ac;

            return(generator);
        }
예제 #15
0
        ModuleTree createHeatGenerator()
        {
            ModuleTree generator = new ModuleTree(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize);
            Fractal    f         = generator.addModule(Module.Type.Fractal, "fractal") as Fractal;

            f.output.setName("Heat Fractal");
            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theHeatOctaves;
            f.frequency = WorldParameters.theHeatFrequency;

            AutoCorrect ac = generator.addModule(Module.Type.AutoCorect, "autocorrect") as AutoCorrect;

            ac.output.setName("Heat Autocorrect");
            ac.source = f;

            Gradient sg = generator.addModule(Module.Type.Gradient, "south gradient") as Gradient;

            sg.output.setName("Heat South gradient");
            sg.x0 = 0; sg.x1 = 1; sg.y0 = 0; sg.y1 = 1;

            Gradient ng = generator.addModule(Module.Type.Gradient, "north gradient") as Gradient;

            ng.output.setName("Heat North gradient");
            ng.x0 = 0; ng.x1 = 1; ng.y0 = 1; ng.y1 = 0;

            //          ScaleDomain s = generator.addModule(Module.Type.ScaleDomain, "scaleDomain") as ScaleDomain;
            //          s.x = 1.0f;
            //          s.y = 0.1f;
            //          s.input = g;

            Combiner comb = generator.addModule(Module.Type.Combiner, "combiner") as Combiner;

            comb.output.setName("Heat Combiner");
            comb.inputs[0] = ac;
            comb.inputs[1] = sg;
            comb.inputs[2] = ng;
            comb.action    = Combiner.CombinerType.Multiply;

            generator.final.source = comb;

            return(generator);
        }
        public IList <ModuleTree> GetRootMoudleTreeNodes()
        {
            IList <GTP.Services.Common.Entities.ModuleTree> list = new List <ModuleTree>();
            var svc = ServiceFactory.GetService <IModuleTreeService>();

            list = svc.GetNodesFromRoot(1, null);
            var svcAnalysis = ServiceFactory.GetService <IAnalysisModuleTreeService>();

            foreach (var item in svcAnalysis.GetNodesFromRoot(1, null))
            {
                ModuleTree info = new ModuleTree();
                info.ID       = item.ID;
                info.Name     = item.Name;
                info.PID      = item.PID;
                info.FullCode = item.FullCode;
                info.IsLeaf   = item.IsLeaf;
                info.Tag      = "Analy";
                list.Add(info);
            }
            return(FilterModuleList(list));
        }
        public IList <ModuleTree> GetGridByNoduleName(string name)
        {
            IList <GTP.Services.Common.Entities.ModuleTree> list = new List <ModuleTree>();
            var svc = ServiceFactory.GetService <IModuleTreeService>();

            list = svc.GetNodesByFilter(Filter.Like(GTP.Services.Common.Entities.ModuleTree.P_Name, name, null, MatchMode.Like));
            var svcAnalysis = ServiceFactory.GetService <IAnalysisModuleTreeService>();

            foreach (var item in svcAnalysis.GetNodesByFilter(Filter.Like(AnalysisModuleTree.P_Name, name, null, MatchMode.Like)))
            {
                ModuleTree info = new ModuleTree();
                info.ID       = item.ID;
                info.Name     = item.Name;
                info.PID      = item.PID;
                info.FullCode = item.FullCode;
                info.IsLeaf   = item.IsLeaf;
                info.Tag      = "Analy";
                list.Add(info);
            }
            return(FilterModuleList(list));
        }
예제 #18
0
        /// <summary>
        /// Consumes a token accounting for trivia tokens.
        /// </summary>
        /// <returns></returns>
        protected override Token <TTokenType> GetNextToken()
        {
            var reader      = Reader;
            var diagnostics = Diagnostics;
            var start       = reader.Position;

            try
            {
                if (EndOfFile)
                {
                    return(new Token <TTokenType>("EOF", EndOfFileTokenType, new Range <int>(reader.Position)));
                }

                foreach (var module in ModuleTree.GetSortedCandidates(reader))
                {
                    var tokenOpt = module.TryConsume(reader, diagnostics);
                    if (tokenOpt.IsSome)
                    {
                        return(tokenOpt.Value);
                    }

                    reader.Restore(start);
                }

                var fallback = ModuleTree.FallbackModule;
                if (fallback is not null)
                {
                    var tokenOpt = fallback.TryConsume(reader, Diagnostics);
                    if (tokenOpt.IsSome)
                    {
                        return(tokenOpt.Value);
                    }
                }

                throw new FatalParsingException(reader.Position, "No registered modules can consume the rest of the input.");
            }
            catch when(restore(reader, start))
            {
                throw;
            }
예제 #19
0
 /// <summary>
 /// 修改分段菜单
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsmiEditModule_Click(object sender, EventArgs e)
 {
     if (tvModule.SelectedNode == null)
     {
         return;
     }
     if (tvModule.SelectedNode.Level == 2)
     {
         string drawingPlanId = tvModule.SelectedNode.Parent.Tag.ToString();
         drawingPlanId = drawingPlanId.Substring(4);//除去item
         Drawing         objDrawing         = objDrawingService.GetDrawingById(drawingPlanId);
         string          moduleTreeId       = tvModule.SelectedNode.Tag.ToString();
         ModuleTree      objModuleTree      = objModuleTreeService.GetModuleTreeById(moduleTreeId);
         FrmCategoryTree objFrmCategoryTree = new FrmCategoryTree(objDrawing, objModuleTree);
         DialogResult    result             = objFrmCategoryTree.ShowDialog();
         if (result == DialogResult.OK)
         {
             //更新模型树
             RefreshTree();
         }
     }
 }
예제 #20
0
        public void load(String s)
        {
            LuaState state = new LuaState();

            state.doFile(s);

            LuaObject config      = state.findObject("terrain");
            LuaObject worldConfig = config["world"];

            myWorld.mySeed   = worldConfig["seed"];
            myWorld.myWidth  = worldConfig.get <int>("size[1]");
            myWorld.myHeight = worldConfig.get <int>("size[2]");

            LuaObject genConfig = config["generator"];

            myElevationGenerator = ModuleFactory.create(genConfig["elevation"]);
            myHeatGenerator      = ModuleFactory.create(genConfig["heat"]);
            myMoistureGenerator  = ModuleFactory.create(genConfig["moisture"]);

            myElevationMap = myElevationGenerator.output.output;
            myHeatMap      = myHeatGenerator.output.output;
            myMoistureMap  = myMoistureGenerator.output.output;
        }
예제 #21
0
        /// <summary>
        /// 根据Id返回单条moduleTree记录
        /// </summary>
        /// <param name="moduleTreeId"></param>
        /// <returns></returns>
        public ModuleTree GetModuleTreeById(string moduleTreeId)
        {
            string sql = "select ModuleTreeId,Module,ModuleTree.CategoryId,CategoryName,Model from ModuleTree";

            sql += " inner join Categories on Categories.CategoryId=ModuleTree.CategoryId";
            sql += string.Format(" where ModuleTreeId={0}", moduleTreeId);
            SqlDataReader objReader     = SQLHelper.GetReader(sql);
            ModuleTree    objModuleTree = null;

            while (objReader.Read())
            {
                objModuleTree = new ModuleTree()
                {
                    ModuleTreeId = Convert.ToInt32(objReader["ModuleTreeId"]),
                    CategoryId   = Convert.ToInt32(objReader["CategoryId"]),
                    CategoryName = objReader["CategoryName"].ToString(),
                    Module       = objReader["Module"].ToString(),
                    Model        = objReader["Model"].ToString()
                };
            }
            objReader.Close();
            return(objModuleTree);
        }
예제 #22
0
 public FrmQuickBrowse(Drawing drawing, ModuleTree tree) : this()
 {
     objDrawing = drawing;
     if (drawing == null)
     {
         return;
     }
     if (tree == null)
     {
         return;
     }
     RefreshData(drawing, tree);
     RefreshCutlist(drawing, tree);
     //天花烟罩不显示Cutlist
     if (drawing.HoodType == "Ceiling")
     {
         lblModule.Visible       = false;
         btnPrintCutList.Visible = false;
         dgvCutList.Visible      = false;
         dgvQuickBrowse.Height   = this.Height - 40;
         dgvQuickBrowse.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
     }
 }
        public IList <ModuleTree> GetMoudleTreeChildNodes(long pid, string tag)
        {
            IList <GTP.Services.Common.Entities.ModuleTree> list = new List <ModuleTree>();
            var svcAnalysis = ServiceFactory.GetService <IAnalysisModuleTreeService>();

            if (tag == "Analy")
            {
                foreach (var item in svcAnalysis.GetNodesByPid(pid))
                {
                    ModuleTree info = new ModuleTree();
                    info.ID       = item.ID;
                    info.Name     = item.Name;
                    info.PID      = item.PID;
                    info.FullCode = item.FullCode;
                    info.IsLeaf   = item.IsLeaf;
                    info.Tag      = "Analy";
                    list.Add(info);
                }
            }
            else
            {
                var svc = ServiceFactory.GetService <IModuleTreeService>();
                list = svc.GetNodesByPid(pid);
                foreach (var item in svcAnalysis.GetNodesByPid(pid))
                {
                    ModuleTree info = new ModuleTree();
                    info.ID       = item.ID;
                    info.Name     = item.Name;
                    info.PID      = item.PID;
                    info.FullCode = item.FullCode;
                    info.IsLeaf   = item.IsLeaf;
                    info.Tag      = "Analy";
                    list.Add(info);
                }
            }
            return(FilterModuleList(list));
        }
예제 #24
0
 /// <summary>
 /// 单击选择Node时,分三层显示不同的内容
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tvModule_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (tvModule.SelectedNode == null)
     {
         return;
     }
     if (e.Node.Level == 0)
     {
         pbLabelImage.Visible = false;
         ShowProjectInfoDeg(tvModule.SelectedNode.Text);
     }
     else if (e.Node.Level == 1)
     {
         string drawingPlanId = e.Node.Tag.ToString();
         drawingPlanId = drawingPlanId.Substring(4);//除去item
         Drawing objDrawing = objDrawingService.GetDrawingById(drawingPlanId);
         if (objDrawing == null)
         {
             return;
         }
         pbLabelImage.Visible = true;
         pbLabelImage.Image   = objDrawing.LabelImage.Length == 0
             ? Image.FromFile("NoPic.png")
             : (Image) new SerializeObjectToString().DeserializeObject(objDrawing.LabelImage);
     }
     else if (e.Node.Level == 2)
     {
         pbLabelImage.Visible = false;
         string drawingPlanId = tvModule.SelectedNode.Parent.Tag.ToString();
         drawingPlanId = drawingPlanId.Substring(4);//除去item
         Drawing    objDrawing    = objDrawingService.GetDrawingById(drawingPlanId);
         string     moduleTreeId  = tvModule.SelectedNode.Tag.ToString();
         ModuleTree objModuleTree = objModuleTreeService.GetModuleTreeById(moduleTreeId);
         //【5】调用委托
         QuickBrowseDeg(objDrawing, objModuleTree);
     }
 }
예제 #25
0
        public void init(LuaObject config)
        {
            myBiome = new Texture((int)WorldParameters.theRegionSize, (int)WorldParameters.theRegionSize, PixelInternalFormat.Rgba32f);
            myBiome.setName("Biome Map");
            mySampler = new Sampler2D(myBiome);

            LuaObject genConfig = config["generator"];

            myElevationGenerator = ModuleFactory.create(genConfig["elevation"]);
            myHeatGenerator      = ModuleFactory.create(genConfig["heat"]);
            myMoistureGenerator  = ModuleFactory.create(genConfig["moisture"]);

            //setup shaders
            List <ShaderDescriptor> shadersDesc = new List <ShaderDescriptor>();

            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "Terrain.shaders.applyElevation-cs.glsl"));
            ShaderProgramDescriptor sd = new ShaderProgramDescriptor(shadersDesc);

            myApplyElevationShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "Terrain.shaders.applyHeat-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myApplyHeatShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "Terrain.shaders.applyMoisture-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myApplyMoistureShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "Terrain.shaders.applyBiome-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myGenerateBiomeShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            update();
        }
예제 #26
0
 /// <summary>
 /// 删除分段菜单
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsmiDeleteModule_Click(object sender, EventArgs e)
 {
     if (tvModule.SelectedNode == null)
     {
         return;
     }
     if (tvModule.SelectedNode.Level == 2)
     {
         string drawingPlanId = tvModule.SelectedNode.Parent.Tag.ToString();
         drawingPlanId = drawingPlanId.Substring(4);//除去item
         Drawing      objDrawing    = objDrawingService.GetDrawingById(drawingPlanId);
         string       moduleTreeId  = tvModule.SelectedNode.Tag.ToString();
         ModuleTree   objModuleTree = objModuleTreeService.GetModuleTreeById(moduleTreeId);
         DialogResult result        = MessageBox.Show("确定要删除 Item为 " + objDrawing.Item + " 中的 " + objModuleTree.Module + " 分段吗?", "删除询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.No)
         {
             return;
         }
         //执行删除
         try
         {
             //if(objModuleTreeService.DeleteModuleTree(moduleTreeId)==1) RefreshTree();
             if (objModuleTreeService.DeleteModuleAndData(objModuleTree))
             {
                 RefreshTree();
             }
             else
             {
                 MessageBox.Show("删除分段出错,请联系管理员查看后台数据。");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
예제 #27
0
        public JobCard GetJobCard(ModuleTree tree)
        {
            string sql = "select ODPNo,BPONo,ProjectName,CustomerName,Item,Module,Categories.Model,ShippingTime,Length,Deepth,Height,SidePanel,LabelImage,HoodType from ModuleTree"
                         + " inner join DrawingPlan on DrawingPlan.DrawingPlanId=ModuleTree.DrawingPlanId"
                         + " inner join Projects on DrawingPlan.ProjectId=Projects.ProjectId"
                         + " inner join Customers on Projects.CustomerId=Customers.CustomerId"
                         + " inner join Categories on Categories.CategoryId=ModuleTree.CategoryId"
                         + " inner Join " + tree.CategoryName + " on " + tree.CategoryName + ".ModuleTreeId=ModuleTree.ModuleTreeId";

            sql += string.Format(" where ModuleTree.ModuleTreeId={0}", tree.ModuleTreeId);
            SqlDataReader objReader  = SQLHelper.GetReader(sql);
            JobCard       objJobCard = null;

            while (objReader.Read())
            {
                objJobCard = new JobCard()
                {
                    ODPNo        = objReader["ODPNo"].ToString(),
                    BPONo        = objReader["BPONo"].ToString(),
                    ProjectName  = objReader["ProjectName"].ToString(),
                    CustomerName = objReader["CustomerName"].ToString(),
                    Item         = objReader["Item"].ToString(),
                    Module       = objReader["Module"].ToString(),
                    Model        = objReader["Model"].ToString(),
                    ShippingTime = Convert.ToDateTime(objReader["ShippingTime"]),
                    Deepth       = objReader["Deepth"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["Deepth"]),
                    SidePanel    = objReader["SidePanel"].ToString(),
                    LabelImage   = objReader["LabelImage"].ToString(),
                    Length       = objReader["Length"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["Length"]),
                    HoodType     = objReader["HoodType"].ToString(),
                    Height       = objReader["Height"].ToString()
                };
            }
            objReader.Close();
            return(objJobCard);
        }
예제 #28
0
 private void GetChildModules(List<MemberResult> res, ModuleTree moduleTree, string projectRelative) {
     foreach (var child in moduleTree.GetChildrenExcludingNodeModules()) {
         Debug.Assert(child.Name != AnalysisConstants.NodeModulesFolder);
         if (child.ProjectEntry == null) {
             GetChildModules(res, child, projectRelative + child.Name + "/");
         } else {
             res.Add(MakeProjectMemberResult(projectRelative + child.Name));
         }
     }
 }
예제 #29
0
        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);
            }

            //查询参数
            UCJDB800 item = (UCJDB800)objUCJDB800Service.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会四舍五入
             */
            //-----------计算中间值,----------
            int fcNo = (int)((item.Length - item.FCSideLeft - item.FCSideRight) / 499m) - item.FCBlindNo;

            try
            {
                //----------Top Level----------
                //判断FC数量,FC侧板长度
                if (item.FCBlindNo > 0)
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0107[BP-500]{500}-1"));
                    swComp.SetSuppression2(2);                                           //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0107[BP-500]{500}-5"));
                    swComp.SetSuppression2(2);                                           //2解压缩,0压缩
                    swFeat = swAssy.FeatureByName("LocalLPattern4");
                    swFeat.SetSuppression2(1, 2, configNames);                           //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern4").SystemValue = item.FCBlindNo; //D1阵列数量,D3阵列距离
                    swModel.Parameter("D1@Distance29").SystemValue     = item.FCSideLeft / 1000m;
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0107[BP-500]{500}-1"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0107[BP-500]{500}-5"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩
                    swFeat = swAssy.FeatureByName("LocalLPattern4");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }

                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "UCJ FC COMBI-12"));
                swComp.SetSuppression2(2);                                 //2解压缩,0压缩.
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "UCJ FC COMBI-15"));
                swComp.SetSuppression2(2);                                 //2解压缩,0压缩.
                swFeat = swAssy.FeatureByName("LocalLPattern3");
                swFeat.SetSuppression2(1, 2, configNames);                 //参数1:1解压,0压缩
                swModel.Parameter("D1@LocalLPattern3").SystemValue = fcNo; //D1阵列数量,D3阵列距离
                swModel.Parameter("D1@Distance35").SystemValue     = (item.FCSideLeft + 500m * item.FCBlindNo) / 1000m;

                //----------HCL----------
                if (item.LightType == "HCL")
                {
                    //灯腔
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0054-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D1@Linear austragen1").SystemValue = item.Length / 1000m;
                    swFeat = swComp.FeatureByName("LIGHT T8");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("FC SUPPORT");
                    swFeat.SetSuppression2(2, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("FC SUPPORT B");
                    swFeat.SetSuppression2(2, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("JAP LED M8");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    if (item.LightCable == "LEFT")
                    {
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                    else if (item.LightCable == "RIGHT")
                    {
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    }
                    else
                    {
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0066-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0066-2"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0069-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 5m) / 1000m;
                    swPart.Parameter("D1@LPattern1").SystemValue    = fcNo + item.FCBlindNo;
                    swPart.Parameter("D3@Sketch6").SystemValue      = (item.FCSideLeft + 250m) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0071-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 5m) / 1000m;
                    swPart.Parameter("D1@LPattern1").SystemValue    = fcNo + item.FCBlindNo;
                    swPart.Parameter("D3@Sketch6").SystemValue      = (item.FCSideLeft + 250m) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0116-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0114-3"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0114-4"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0145-2"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0161-2"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                }
                else
                {
                    //灯腔
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0054-1"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0066-1"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0066-2"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0069-1"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0071-1"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0116-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D1@Linear austragen1").SystemValue = item.Length / 1000m;
                    swFeat = swComp.FeatureByName("LIGHT T8");
                    if (item.LightType == "T8")
                    {
                        swFeat.SetSuppression2(2, 2, configNames);                         //参数1:1解压,0压缩
                    }
                    else
                    {
                        swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                    }
                    swFeat = swComp.FeatureByName("FC SUPPORT");
                    swFeat.SetSuppression2(2, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("FC SUPPORT B");
                    swFeat.SetSuppression2(2, 2, configNames); //参数1:1解压,0压缩
                    swFeat = swComp.FeatureByName("JAP LED M8");
                    if (item.Japan == "YES")
                    {
                        swFeat.SetSuppression2(2, 2, configNames);                      //参数1:1解压,0压缩
                    }
                    else
                    {
                        swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                    }
                    if (item.LightCable == "LEFT")
                    {
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                    else if (item.LightCable == "RIGHT")
                    {
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    }
                    else
                    {
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    }
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0114-3"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0114-4"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0145-2"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 5m) / 1000m;
                    swPart.Parameter("D1@LPattern1").SystemValue    = fcNo + item.FCBlindNo;
                    swPart.Parameter("D3@Sketch6").SystemValue      = (item.FCSideLeft + 250m) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0161-2"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Base-Flange1").SystemValue = (item.Length - 5m) / 1000m;
                    swPart.Parameter("D1@LPattern1").SystemValue    = fcNo + item.FCBlindNo;
                    swPart.Parameter("D3@Sketch6").SystemValue      = (item.FCSideLeft + 250m) / 1000m;
                }
                //----------UV灯----------
                if (item.UVType == "LONG")
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "CEILING UVRACK SPECIAL 4S-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "CEILING UVRACK SPECIAL 4L-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩.
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "CEILING UVRACK SPECIAL 4S-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "CEILING UVRACK SPECIAL 4L-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                }
                //----------油网侧板----------
                switch (item.FCSide)
                {
                case "LEFT":
                    //重命名装配体内部
                    compReName = "FNCE0108[BP-" + tree.Module + ".1]{" + (int)(item.FCSideLeft - fcNo * 1m - 4m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft - fcNo * 1m - 4m) / 1000m;
                    }
                    //重命名装配体内部
                    compReName = "FNCE0136[BP-" + tree.Module + ".2]{" + (int)(item.FCSideLeft - fcNo * 1m - 4m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0136[BP-]{}-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft - fcNo * 1m - 4m) / 1000m;
                    }
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-3"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0162[BP-]{}-4"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    break;

                case "RIGHT":
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-2"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0136[BP-]{}-3"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    //重命名装配体内部
                    compReName = "FNCE0109[BP-" + tree.Module + ".1]{" + (int)(item.FCSideRight - fcNo * 1m - 4m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight - fcNo * 1m - 4m) / 1000m;
                    }
                    //重命名装配体内部
                    compReName = "FNCE0162[BP-" + tree.Module + ".2]{" + (int)(item.FCSideRight - fcNo * 1m - 4m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0162[BP-]{}-4") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-4" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-4");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight - fcNo * 1m - 4m) / 1000m;
                    }
                    break;

                case "BOTH":
                    //重命名装配体内部
                    compReName = "FNCE0108[BP-" + tree.Module + ".1]{" + (int)(item.FCSideLeft - fcNo * 1m - 2m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft - fcNo * 1m - 2m) / 1000m;
                    }
                    //重命名装配体内部
                    compReName = "FNCE0136[BP-" + tree.Module + ".2]{" + (int)(item.FCSideLeft - fcNo * 1m - 2m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0136[BP-]{}-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft - fcNo * 1m - 2m) / 1000m;
                    }
                    //重命名装配体内部
                    compReName = "FNCE0109[BP-" + tree.Module + ".3]{" + (int)(item.FCSideRight - fcNo * 1m - 2m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-3") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-3" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-3");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight - fcNo * 1m - 2m) / 1000m;
                    }
                    //重命名装配体内部
                    compReName = "FNCE0162[BP-" + tree.Module + ".4]{" + (int)(item.FCSideRight - fcNo * 1m - 2m) + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0162[BP-]{}-4") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-4" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-4");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight - fcNo * 1m - 2m) / 1000m;
                    }
                    break;

                default:
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-3"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0136[BP-]{}-3"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-3"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0162[BP-]{}-4"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    break;
                }
                //----------日本项目需要压缩零件----------
                if (item.Japan == "YES")
                {
                    //吊装垫片
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0070-10"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern22");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    //排风脖颈
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "EXSPIGOT-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    //排风腔
                    //重命名装配体内部
                    compReName = "FNCE0141[UCJDB800-" + tree.Module + "]{" + (int)item.Length + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0141-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("D1@Linear austragen1").SystemValue = item.Length / 1000m;
                        swFeat = swComp.FeatureByName("EX");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("Cut-Extrude4");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                        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压缩
                        swFeat = swComp.FeatureByName("MA-TAB");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        if (item.MARVEL == "YES")
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }
                    }
                }
                else
                {
                    //吊装垫片
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0070-10"));
                    swComp.SetSuppression2(2);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern2");
                    swFeat.SetSuppression2(2, 2, configNames); //参数1:1解压,0压缩
                    //排风脖颈
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "EXSPIGOT-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0019-1"));
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = (item.ExLength + 50m) / 1000m;
                    swPart.Parameter("D3@草图1").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, "FNCE0020-1"));
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = (item.ExLength + 50m) / 1000m;
                    swPart.Parameter("D3@草图1").SystemValue    = item.ExHeight / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0047-1"));
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = item.ExWidth / 1000m;
                    swPart.Parameter("D3@草图1").SystemValue    = item.ExHeight / 1000m;
                    swFeat = swComp.FeatureByName("ANDTEC");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0048-2"));
                    swPart = swComp.GetModelDoc2();            //打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = item.ExWidth / 1000m;
                    swPart.Parameter("D3@草图1").SystemValue    = item.ExHeight / 1000m;
                    swFeat = swComp.FeatureByName("ANDTEC");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    //排风腔
                    //重命名装配体内部
                    compReName = "FNCE0141[UCJDB800-" + tree.Module + "]{" + (int)item.Length + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0141-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("D1@Linear austragen1").SystemValue = item.Length / 1000m;
                        swFeat = swComp.FeatureByName("EX");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("Cut-Extrude4");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("MA-TAB");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swPart.Parameter("D3@Sketch3").SystemValue = item.ExRightDis / 1000m;
                        swPart.Parameter("D1@Sketch3").SystemValue = item.ExLength / 1000m;
                        swPart.Parameter("D2@Sketch3").SystemValue = item.ExWidth / 1000m;
                        if (item.ANSUL == "YES")
                        {
                            //侧喷
                            if (item.ANSide == "LEFT")
                            {
                                swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            }
                            else if (item.ANSide == "RIGHT")
                            {
                                swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            }
                            else
                            {
                                swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                                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.ANDetectorNo > 0)
                            {
                                swFeat = swComp.FeatureByName("ANDTEC1");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swPart.Parameter("D3@Sketch9").SystemValue = item.ANDetectorDis1 / 1000m;
                                if (item.ANDetectorEnd == "RIGHT" ||
                                    (item.ANDetectorEnd == "LEFT" && item.ANDetectorNo == 1))
                                {
                                    swPart.Parameter("D1@Sketch9").SystemValue = 195m / 1000m;
                                }
                                else
                                {
                                    swPart.Parameter("D1@Sketch9").SystemValue = 175m / 1000m;
                                }
                            }
                            if (item.ANDetectorNo > 1)
                            {
                                swFeat = swComp.FeatureByName("ANDTEC2");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swPart.Parameter("D1@Sketch15").SystemValue = item.ANDetectorDis2 / 1000m;
                                if (item.ANDetectorEnd == "LEFT" && item.ANDetectorNo == 2)
                                {
                                    swPart.Parameter("D2@Sketch15").SystemValue = 195m / 1000m;
                                }
                                else
                                {
                                    swPart.Parameter("D2@Sketch15").SystemValue = 175m / 1000m;
                                }
                            }
                            if (item.ANDetectorNo > 2)
                            {
                                swFeat = swComp.FeatureByName("ANDTEC3");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swPart.Parameter("D1@Sketch16").SystemValue = item.ANDetectorDis3 / 1000m;
                                if (item.ANDetectorEnd == "LEFT" && item.ANDetectorNo == 3)
                                {
                                    swPart.Parameter("D2@Sketch16").SystemValue = 195m / 1000m;
                                }
                                else
                                {
                                    swPart.Parameter("D2@Sketch16").SystemValue = 175m / 1000m;
                                }
                            }
                            if (item.ANDetectorNo > 3)
                            {
                                swFeat = swComp.FeatureByName("ANDTEC4");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swPart.Parameter("D1@Sketch17").SystemValue = item.ANDetectorDis4 / 1000m;
                                if (item.ANDetectorEnd == "LEFT" && item.ANDetectorNo == 4)
                                {
                                    swPart.Parameter("D2@Sketch17").SystemValue = 195m / 1000m;
                                }
                                else
                                {
                                    swPart.Parameter("D2@Sketch17").SystemValue = 175m / 1000m;
                                }
                            }
                            if (item.ANDetectorNo > 4)
                            {
                                swFeat = swComp.FeatureByName("ANDTEC5");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swPart.Parameter("D1@Sketch18").SystemValue = item.ANDetectorDis5 / 1000m;
                                if (item.ANDetectorEnd == "LEFT" && item.ANDetectorNo == 5)
                                {
                                    swPart.Parameter("D2@Sketch18").SystemValue = 195m / 1000m;
                                }
                                else
                                {
                                    swPart.Parameter("D2@Sketch18").SystemValue = 175m / 1000m;
                                }
                            }
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                            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.MARVEL == "YES")
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }
                        if (item.LightCable == "LEFT")
                        {
                            swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }
                        else if (item.LightCable == "RIGHT")
                        {
                            swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("LIGHT HOLE LEFT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("LIGHT HOLE RIGHT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }
                        //UV灯
                        if (item.UVType == "LONG")
                        {
                            swFeat = swComp.FeatureByName("UV L");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            swPart.Parameter("D5@Sketch4").SystemValue = (item.ExRightDis - 800m) / 1000m;
                            swPart.Parameter("D8@Sketch4").SystemValue = (item.ExRightDis - 600m) / 1000m;
                            swFeat = swComp.FeatureByName("UV S");
                            swFeat.SetSuppression2(0, 2, configNames);
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("UV S");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            swPart.Parameter("D3@Sketch11").SystemValue = (item.ExRightDis - 446.5m) / 1000m;
                            swPart.Parameter("D8@Sketch11").SystemValue = (item.ExRightDis - 300m) / 1000m;
                            swFeat = swComp.FeatureByName("UV L");
                            swFeat.SetSuppression2(0, 2, configNames);
                        }
                    }
                }
                swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0056-1"));
                swPart = swComp.GetModelDoc2();//打开零件
                swPart.Parameter("D1@Skizze1").SystemValue = item.Length / 1000m;

                //----------SSP灯板支撑条----------
                if (item.SSPType == "DOME")
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0036-4"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0036-5"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0035-6"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0035-5"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Sketch1").SystemValue = item.Length / 1000m;
                    if (item.Gutter == "YES")
                    {
                        swModel.Parameter("D1@Distance27").SystemValue = item.GutterWidth / 1000m;
                        swModel.Parameter("D1@Distance36").SystemValue = item.GutterWidth / 1000m;
                    }
                    else
                    {
                        swModel.Parameter("D1@Distance27").SystemValue = 0.5m / 1000m;
                        swModel.Parameter("D1@Distance36").SystemValue = 0.5m / 1000m;
                    }
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0036-4"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0036-5"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Sketch1").SystemValue = item.Length / 1000m;
                    if (item.Gutter == "YES")
                    {
                        swModel.Parameter("D1@Distance28").SystemValue = item.GutterWidth / 1000m;
                        swModel.Parameter("D1@Distance37").SystemValue = item.GutterWidth / 1000m;
                    }
                    else
                    {
                        swModel.Parameter("D1@Distance28").SystemValue = 0.5m / 1000m;
                        swModel.Parameter("D1@Distance37").SystemValue = 0.5m / 1000m;
                    }
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0035-6"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0035-5"));
                    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的使用
            }
        }
예제 #30
0
        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);
            }

            //查询参数
            KCJSB265 item = (KCJSB265)objKCJSB265Service.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会四舍五入
             */
            //-----------计算中间值,----------
            int fcNo = (int)((item.Length - item.FCSideLeft - item.FCSideRight) / 499m) - item.FCBlindNo;

            try
            {
                //----------Top Level----------
                //判断FC数量,FC侧板长度
                if (item.FCBlindNo > 0)
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0107[BP-500]{500}-1"));
                    swComp.SetSuppression2(2);                                           //2解压缩,0压缩
                    swFeat = swAssy.FeatureByName("LocalLPattern3");
                    swFeat.SetSuppression2(1, 2, configNames);                           //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern3").SystemValue = item.FCBlindNo; //D1阵列数量,D3阵列距离
                    swModel.Parameter("D1@Distance11").SystemValue     = item.FCSideLeft / 1000m;
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0107[BP-500]{500}-1"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩
                    swFeat = swAssy.FeatureByName("LocalLPattern3");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }
                //判断FC/KSA
                if (item.FCType == "KSA")
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5202040401-1"));
                    swComp.SetSuppression2(2);                                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern4");
                    swFeat.SetSuppression2(1, 2, configNames);                 //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern4").SystemValue = fcNo; //D1阵列数量,D3阵列距离
                    swModel.Parameter("D1@Distance9").SystemValue      = (item.FCSideLeft + 500m * item.FCBlindNo) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "KCJ FC FILTER-1"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern2");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "KCJ FC FILTER-1"));
                    swComp.SetSuppression2(2);                                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern2");
                    swFeat.SetSuppression2(1, 2, configNames);                 //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern2").SystemValue = fcNo; //D1阵列数量,D3阵列距离
                    swModel.Parameter("D1@Distance10").SystemValue     = (item.FCSideLeft + 500m * item.FCBlindNo) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "5202040401-1"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern4");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                }
                //----------油网侧板----------
                switch (item.FCSide)
                {
                case "LEFT":
                    //重命名装配体内部
                    if (item.FCType == "KSA")
                    {
                        compReName = "FNCE0108[BP-" + tree.Module + "]{" + (int)(item.FCSideLeft + fcNo * 2.5m) + "}";
                    }
                    else
                    {
                        compReName = "FNCE0108[BP-" + tree.Module + "]{" + (int)(item.FCSideLeft - 4m) + "}";
                    }
                    status = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-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");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        if (item.FCType == "KSA")
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft + fcNo * 2.5m) / 1000m;
                        }
                        else
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft - 4m) / 1000m;
                        }
                    }
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-1"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    break;

                case "RIGHT":
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-1"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    //重命名装配体内部
                    if (item.FCType == "KSA")
                    {
                        compReName = "FNCE0109[BP-" + tree.Module + "]{" + (int)(item.FCSideRight + fcNo * 2.5m) + "}";
                    }
                    else
                    {
                        compReName = "FNCE0109[BP-" + tree.Module + "]{" + (int)(item.FCSideRight - 4m) + "}";
                    }
                    status = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-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");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        if (item.FCType == "KSA")
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight + fcNo * 2.5m) / 1000m;
                        }
                        else
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight - 4m) / 1000m;
                        }
                    }
                    break;

                case "BOTH":
                    //重命名装配体内部
                    if (item.FCType == "KSA")
                    {
                        compReName = "FNCE0108[BP-" + tree.Module + ".1]{" + (int)(item.FCSideLeft + fcNo * 1.25m) + "}";
                    }
                    else
                    {
                        compReName = "FNCE0108[BP-" + tree.Module + "]{" + (int)(item.FCSideLeft - 2m) + "}";
                    }
                    status = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-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");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        if (item.FCType == "KSA")
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft + fcNo * 1.25m) / 1000m;
                        }
                        else
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideLeft - 2m) / 1000m;
                        }
                    }
                    //重命名装配体内部
                    if (item.FCType == "KSA")
                    {
                        compReName = "FNCE0109[BP-" + tree.Module + ".2]{" + (int)(item.FCSideRight + fcNo * 1.25m) + "}";
                    }
                    else
                    {
                        compReName = "FNCE0109[BP-" + tree.Module + "]{" + (int)(item.FCSideRight - 2m) + "}";
                    }
                    status = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-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");
                        swComp.SetSuppression2(2);      //2解压缩,0压缩.
                        swPart = swComp.GetModelDoc2(); //打开零件
                        if (item.FCType == "KSA")
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight + fcNo * 1.25m) / 1000m;
                        }
                        else
                        {
                            swPart.Parameter("D2@草图1").SystemValue = (item.FCSideRight - 2m) / 1000m;
                        }
                    }
                    break;

                default:
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0108[BP-]{}-1"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0109[BP-]{}-1"));
                    swComp.SetSuppression2(0);     //2解压缩,0压缩.
                    break;
                }
                //----------日本项目需要压缩零件----------
                if (item.Japan == "YES")
                {
                    //吊装垫片
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0070-9"));
                    swComp.SetSuppression2(0);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern1");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    //排风脖颈
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "EXSPIGOT-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    //排风滑门
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "EXDOOR-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    //排风腔
                    //重命名装配体内部
                    compReName = "FNCE0125[KCJSB265-" + tree.Module + "]{" + (int)item.Length + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0125-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D1@Aufsatz-Linear austragen1").SystemValue = item.Length / 1000m;
                        swFeat = swComp.FeatureByName("EX");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("Cut-Extrude4");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("ANDTECSIDE RIGHT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("ANDTECSIDE LEFT");
                        swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        if (item.MARVEL == "YES")
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("MA-TAB");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("MA-TAB");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }
                    }
                }
                else
                {
                    //吊装垫片
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0070-9"));
                    swComp.SetSuppression2(2);                 //2解压缩,0压缩.
                    swFeat = swAssy.FeatureByName("LocalLPattern1");
                    swFeat.SetSuppression2(2, 2, configNames); //参数1:1解压,0压缩
                    //排风脖颈
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "EXSPIGOT-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0019-1"));
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = (item.ExLength + 50m) / 1000m;
                    swPart.Parameter("D3@草图1").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, "FNCE0020-1"));
                    swPart = swComp.GetModelDoc2();//打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = (item.ExLength + 50m) / 1000m;
                    swPart.Parameter("D3@草图1").SystemValue    = item.ExHeight / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0047-1"));
                    swPart = swComp.GetModelDoc2();//打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = item.ExWidth / 1000m;
                    swPart.Parameter("D3@草图1").SystemValue    = item.ExHeight / 1000m;
                    swFeat = swComp.FeatureByName("ANDTEC");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0048-2"));
                    swPart = swComp.GetModelDoc2();            //打开零件
                    swPart.Parameter("D2@基体-法兰1").SystemValue = item.ExWidth / 1000m;
                    swPart.Parameter("D3@草图1").SystemValue    = item.ExHeight / 1000m;
                    swFeat = swComp.FeatureByName("ANDTEC");
                    swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                    //排风滑门
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "EXDOOR-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D1@Distance3").SystemValue = (item.ExWidth + 20m) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0018-1"));
                    swPart = swComp.GetModelDoc2();//打开零件
                    swPart.Parameter("D2@Base-Flange1").SystemValue = (item.ExLength * 2m + 100m) / 1000m;
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0013-1"));
                    swPart = swComp.GetModelDoc2();//打开零件
                    swPart.Parameter("D1@Sketch1").SystemValue = (item.ExLength / 2m + 10m) / 1000m;
                    swPart.Parameter("D2@Sketch1").SystemValue = (item.ExWidth + 40m) / 1000m;
                    //排风腔
                    //重命名装配体内部
                    compReName = "FNCE0125[KCJSB265-" + tree.Module + "]{" + (int)item.Length + "}";
                    status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCE0125-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    if (status)
                    {
                        swModelDocExt.RenameDocument(compReName);
                    }
                    swModel.ClearSelection2(true);
                    status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    swModel.ClearSelection2(true);
                    if (status)
                    {
                        swComp = swAssy.GetComponentByName(compReName + "-2");
                        swPart = swComp.GetModelDoc2(); //打开零件
                        swPart.Parameter("D1@Aufsatz-Linear austragen1").SystemValue = item.Length / 1000m;
                        swFeat = swComp.FeatureByName("EX");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swFeat = swComp.FeatureByName("Cut-Extrude4");
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swPart.Parameter("D4@Sketch2").SystemValue = item.ExRightDis / 1000m;
                        swPart.Parameter("D1@Sketch2").SystemValue = item.ExLength / 1000m;
                        swPart.Parameter("D2@Sketch2").SystemValue = item.ExWidth / 1000m;
                        if (item.ANSUL == "YES")
                        {
                            //侧喷
                            if (item.ANSide == "LEFT")
                            {
                                swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            }
                            else if (item.ANSide == "RIGHT")
                            {
                                swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            }
                            else
                            {
                                swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            }
                            //探测器
                            if (item.ANDetector == "LEFT")
                            {
                                swFeat = swComp.FeatureByName("ANDTECSIDE RIGHT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANDTECSIDE LEFT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            }
                            else if (item.ANDetector == "RIGHT")
                            {
                                swFeat = swComp.FeatureByName("ANDTECSIDE RIGHT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANDTECSIDE LEFT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            }
                            else if (item.ANDetector == "BOTH")
                            {
                                swFeat = swComp.FeatureByName("ANDTECSIDE RIGHT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANDTECSIDE LEFT");
                                swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            }
                            else
                            {
                                swFeat = swComp.FeatureByName("ANDTECSIDE RIGHT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                                swFeat = swComp.FeatureByName("ANDTECSIDE LEFT");
                                swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            }
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("ANSULSIDE RIGHT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("ANSULSIDE LEFT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("ANDTECSIDE RIGHT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("ANDTECSIDE LEFT");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }

                        if (item.MARVEL == "YES")
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("MA-TAB");
                            swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        }
                        else
                        {
                            swFeat = swComp.FeatureByName("MA-NTC");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                            swFeat = swComp.FeatureByName("MA-TAB");
                            swFeat.SetSuppression2(0, 2, configNames); //参数1:1解压,0压缩
                        }
                    }
                }
                //----------SSP灯板支撑条----------
                if (item.SSPType == "DOME")
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0036-1"));
                    swComp.SetSuppression2(0);      //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0035-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Sketch1").SystemValue = item.Length / 1000m;
                    if (item.Gutter == "YES")
                    {
                        swModel.Parameter("D1@Distance12").SystemValue = item.GutterWidth / 1000m;
                    }
                    else
                    {
                        swModel.Parameter("D1@Distance12").SystemValue = 0.5m / 1000m;
                    }
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0036-1"));
                    swComp.SetSuppression2(2);      //2解压缩,0压缩.
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Sketch1").SystemValue = item.Length / 1000m;
                    if (item.Gutter == "YES")
                    {
                        swModel.Parameter("D1@Distance2").SystemValue = item.GutterWidth / 1000m;
                    }
                    else
                    {
                        swModel.Parameter("D1@Distance2").SystemValue = 0.5m / 1000m;
                    }
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCE0035-1"));
                    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的使用
            }
        }
예제 #31
0
        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);
            }

            //查询参数
            LLEDS item = (LLEDS)objLLEDSService.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会四舍五入
             */
            //-----------计算中间值,----------
            int     stdPanelNo = (int)((item.Length - 300.5m) / 1500m);//1500+300直接做成一块
            decimal sideLength = item.Length - stdPanelNo * 1500m;
            int     ledNo      = (int)((sideLength - 300m) / 500m);

            try
            {
                //----------Top Level----------
                swModel.Parameter("D1@Distance3").SystemValue = item.Length / 1000m;
                //----------边缘板----------
                //重命名装配体内部
                compReName = "FNCL0023[LLEDS-" + tree.Module + "]{" + (int)sideLength + "}";
                status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "FNCL0023[LLEDS-]{}-2") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                if (status)
                {
                    swModelDocExt.RenameDocument(compReName);
                }
                swModel.ClearSelection2(true);
                status = swModelDocExt.SelectByID2(compReName + "-2" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                swModel.ClearSelection2(true);
                if (status)
                {
                    swComp = swAssy.GetComponentByName(compReName + "-2");
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Skizze1").SystemValue = sideLength / 1000m;
                    swFeat = swComp.FeatureByName("LPattern1");
                    if (ledNo > 0)
                    {
                        swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                        swPart.Parameter("D1@LPattern1").SystemValue = ledNo + 1;
                    }
                    else
                    {
                        swFeat.SetSuppression2(0, 2, configNames);  //参数1:1解压,0压缩
                    }
                }

                //----------标准板----------
                if (stdPanelNo > 0)
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCL0022[LLEDS-STD]{1483}-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200600003-1"));
                    swComp.SetSuppression2(2); //2解压缩,0压缩.
                }
                else
                {
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "FNCL0022[LLEDS-STD]{1483}-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                    swComp = swAssy.GetComponentByName(CommonFunc.AddSuffix(suffix, "2200600003-1"));
                    swComp.SetSuppression2(0); //2解压缩,0压缩.
                }

                swFeat = swAssy.FeatureByName("LocalLPattern1");
                if (stdPanelNo > 1)
                {
                    swFeat.SetSuppression2(1, 2, configNames); //参数1:1解压,0压缩
                    swModel.Parameter("D1@LocalLPattern1").SystemValue = stdPanelNo;
                }
                else
                {
                    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的使用
            }
        }
예제 #32
0
 private IEnumerable<ModuleTree> GetChildrenExcludingNodeModules(ModuleTree moduleTree) {
     if (moduleTree == null) {
         return Enumerable.Empty<ModuleTree>();
     }
     //Children.Values returns an IEnumerable
     //  The process of resolving modules can lead us to add entries into the underlying array
     //  doing so results in exceptions b/c the array has changed under the enumerable
     //  To avoid this, we call .ToArray() to create a copy of the array locally which we then Enumerate
     return moduleTree.Children.Values.ToArray().Where(mod => !String.Equals(mod.Name, AnalysisConstants.NodeModulesFolder, StringComparison.OrdinalIgnoreCase));
 }
예제 #33
0
        public void AutoDrawing(SldWorks swApp, ModuleTree tree, string projectPath)
        {
            //创建下料图文件夹,默认在D盘MyProjects目录下(先判断文件夹是否存在)
            string dxfPath = projectPath + @"\DXF-CUTLIST";

            if (!Directory.Exists(dxfPath))
            {
                Directory.CreateDirectory(dxfPath);
            }
            //创建dxf图文件夹
            string newPath = dxfPath + @"\" + tree.Item + "-" + tree.Module + @"\";

            if (!Directory.Exists(newPath))
            {
                Directory.CreateDirectory(newPath);
            }
            //拷贝文件,调用通用函数
            if (!CommonFunc.CopyDxfFiles(tree.ModelPath, newPath))
            {
                return;
            }
            //查询参数
            UCJFCCOMBIDXF objUCJFCCOMBIDXF = (UCJFCCOMBIDXF)objUCJFCCOMBIDXFService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            //查询标准DxfCutlist,根据item.categoryId查询dxfCutList对象列表
            List <DXFCutList> oldList = objDxfCutListService.GetDXFCutListsByCategoryId(tree.CategoryId.ToString());

            Project objProject = objProjectService.GetProjectByProjectId(tree.ProjectId.ToString());

            #region HoodCutList
            if (objProject.HoodType == "Hood")
            {
                //乘以数量,赋值moduletreeid
                foreach (var item in oldList)
                {
                    hoodCutLists.Add(new HoodCutList()
                    {
                        ModuleTreeId    = objUCJFCCOMBIDXF.ModuleTreeId,
                        PartDescription = item.PartDescription,
                        Length          = item.Length,
                        Width           = item.Width,
                        Thickness       = item.Thickness,
                        Quantity        = item.Quantity * objUCJFCCOMBIDXF.Quantity,//多个UCP
                        Materials       = item.Materials,
                        PartNo          = item.PartNo,
                        UserId          = 1
                    });
                }
                //基于事务hoodCutLists提交SQLServer
                if (hoodCutLists.Count == 0)
                {
                    return;
                }
                try
                {
                    if (objHoodCutListService.ImportCutList(hoodCutLists))
                    {
                        hoodCutLists.Clear();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("UCJFCCOMBIDXF的HoodCutlist导入数据库失败" + ex.Message);
                }
            }
            #endregion


            #region CeilingCutList

            if (objProject.HoodType == "Ceiling")
            {
                //添加SubAssy,获得SubAssyId
                int subAssyId = objSubAssyService.AddSubAssy(new SubAssy()
                {
                    ProjectId   = objProject.ProjectId,
                    SubAssyName = tree.Module
                });
                //乘以数量,赋值moduletreeid
                foreach (var item in oldList)
                {
                    ceilingCutLists.Add(new CeilingCutList()
                    {
                        SubAssyId       = subAssyId,
                        PartDescription = item.PartDescription,
                        Length          = item.Length,
                        Width           = item.Width,
                        Thickness       = item.Thickness,
                        Quantity        = item.Quantity * objUCJFCCOMBIDXF.Quantity,//多个UCP
                        Materials       = item.Materials,
                        PartNo          = item.PartNo,
                        UserId          = 1
                    });
                }
                //基于事务CeilingCutLists提交SQLServer
                if (ceilingCutLists.Count == 0)
                {
                    return;
                }
                try
                {
                    if (objCeilingCutListService.ImportCutList(ceilingCutLists))
                    {
                        ceilingCutLists.Clear();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("UCJFCCOMBIDXF的CeilingCutlist导入数据库失败" + ex.Message);
                }
            }
            #endregion
        }
예제 #34
0
 internal RequireAnalysisUnit(ModuleTree tree, ModuleTable table, ProjectEntry entry, string dependency) : base (entry.Tree, entry.EnvironmentRecord) {
     _tree = tree;
     _table = table;
     _dependency = dependency;
 }