コード例 #1
0
        //生成block预览
        //插入block
        public void Insertblock(string s, out bool status)
        {
            status = false;
            DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
            Database db = HostApplicationServices.WorkingDatabase;
            ObjectId spaceId = db.CurrentSpaceId;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            String promptText = s.Contains("锅炉") ? "\n 选择插入热源的位置" : "\n 选择插入热力站的位置";
            PromptPointOptions getPointOptions = new PromptPointOptions(promptText);
            getPointOptions.AppendKeywordsToMessage = true;
            PromptPointResult getPointResult = ed.GetPoint(getPointOptions);

            if(getPointResult.Status == PromptStatus.Cancel)
            {
                status = true;
                return;
            }
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                ObjectId layerid = HeatSourceLayoutApp.currentSolution.BaseObjectId;
                LayerTableRecord layer = trans.GetObject(layerid, OpenMode.ForWrite) as LayerTableRecord;
                ObjectId blockid = spaceId.InsertBlockReference(layer.Name, s, getPointResult.Value, new Scale3d(HeatSourceLayoutApp.globalProperty.BlockScale), 0);
                trans.Commit();
                //将新建的热力站/热源存入解决方案的对象中
                if (s.CompareTo("锅炉5吨") == 0)
                {
                    HeatProducer producer = new HeatProducer(HeatSourceLayoutApp.currentSolution, true);
                    producer.BaseObjectId = blockid;
                    producer.Save();
                    HeatSourceLayoutApp.currentSolution.HeatProducers.Add(blockid, producer);
                }
                else if (s.CompareTo("换热机组") == 0)
                {
                        SubStation station = new SubStation(HeatSource.HeatSourceLayoutApp.currentSolution, true);
                        station.BaseObjectId = blockid;
                        station.Save();
                        HeatSourceLayoutApp.currentSolution.SubStations.Add(blockid, station);
                 }
            }
        }
コード例 #2
0
 public SubstationInfo(string name, SubStation substation)
     : base(name)
 {
     _substation = substation;
 }