protected override void GetAttributes() { attrs.Clear(); attrs.Add("area", this.Area.ToString()); attrs.Add("layercount", this.LayerCount.ToString()); attrs.Add("height", this.Height.ToString()); attrs.Add("heatload", this.HeatLoad.ToString()); attrs.Add("yearheat", this.YearHeat.ToString()); //OwnDistrict string str = ""; if (OwnDistrict.Count > 0) { foreach (var item in OwnDistrict) { str += ModelIdManager.toString(item.Key.BaseModelId) + ":" + ModelIdManager.toString(item.Value.BaseModelId) + " "; } //去除最后的空格 str = str.Substring(0, str.Length - 1); attrs.Add("district", str); } if (this.BuildingNum == 0) { this.RequireLock(); this.AddBuildingNumber(); this.ReleaseLock(); } attrs.Add("buildingnum", this.BuildingNum.ToString()); attrs.Add("buildingtype", this.buildingType.ToString()); attrs.Add("heatindex", this.heatIndex.ToString()); }
protected override void GetAttributes() { attrs.Clear(); attrs.Add("pumpnum", this.WaterPumpCount.ToString()); attrs.Add("heatstyle", this.HeatStyle.ToString()); attrs.Add("boilercount", this.BoilerCount.ToString()); //throw new NotImplementedException(); attrs.Add("boilerEfficiency", this.BoilerEfficiency.ToString()); attrs.Add("supplywatertemp", this.SupplyWaterTemp.ToString()); attrs.Add("returnwatertemp", this.ReturnWaterTemp.ToString()); attrs.Add("totalLoad", this.TotalLoad.ToString()); attrs.Add("solution", Utils.ModelIdManager.toString(this.OwnSolution.BaseModelId)); if (OwnMasterDistrict != null) { attrs.Add("masterdistrict", ModelIdManager.toString(OwnMasterDistrict.BaseModelId)); } if (OwnSlaveDistrict != null) { attrs.Add("slavedistrict", ModelIdManager.toString(OwnSlaveDistrict.BaseModelId)); } if (BoilerSolutionFile != null && BoilerSolutionFile.Length > 0) { attrs.Add("boilersolutionfile", BoilerSolutionFile); } }
protected override void _SetAttributes(Dictionary <string, string> _attrs) { Dictionary <string, string> attrs = new Dictionary <string, string>(); foreach (var item in _attrs) { attrs[item.Key] = item.Value; } //if (attrs.ContainsKey("WaterPumpCount")) //{ // this.WaterPumpCount = int.Parse(attrs["WaterPumpCount"]); //} if (attrs.ContainsKey("HeatStyle")) { this.HeatStyle = int.Parse(attrs["HeatStyle"]); } if (attrs.ContainsKey("HeatSwitcherCount")) { this.HeatSwitcherCount = int.Parse(attrs["HeatSwitcherCount"]); } if (attrs.ContainsKey("HeatSwitcherVolumn")) { this.HeatSwitcherVolumn = double.Parse(attrs["HeatSwitcherVolumn"]); } if (attrs.ContainsKey("WaterPumpPower")) { this.WaterPumpPower = double.Parse(attrs["WaterPumpPower"]); } if (attrs.ContainsKey("supplywatertemp")) { this.SupplyWaterTemp = double.Parse(attrs["supplywatertemp"]); } if (attrs.ContainsKey("returnwatertemp")) { this.ReturnWaterTemp = double.Parse(attrs["returnwatertemp"]); } if (attrs.ContainsKey("solution")) { this.OwnSolution = (Solution)BaseModel.GetModelById(Utils.ModelIdManager.Parse(attrs["solution"])); if (this.OwnSolution != null) { this.OwnSolution.SubStations.Add(this.BaseObjectId, this); } } if (attrs.ContainsKey("masterdistrict")) { this.OwnMasterDistrict = (District)BaseModel.GetModelById(ModelIdManager.Parse(attrs["masterdistrict"])); } if (attrs.ContainsKey("slavedistrict")) { this.OwnSlaveDistrict = (District)BaseModel.GetModelById(ModelIdManager.Parse(attrs["slavedistrict"])); } }
public void SaveEntities() { ObjectIdCollection col = new ObjectIdCollection(); Database db = HostApplicationServices.WorkingDatabase; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); this.CenterArc = btr.AppendEntity(arc); if (Style == Solution.PipeLineStyle.AnyConnectedBuilding) { arc.Color = Color.FromRgb(0, 0, 255); } else { arc.Color = Color.FromRgb(255, 255, 0); } tr.AddNewlyCreatedDBObject(arc, true); this.BoundPolygon = btr.AppendEntity(polyline); if (Style == Solution.PipeLineStyle.AnyConnectedBuilding) { polyline.Color = Color.FromRgb(0, 255, 255); } else { polyline.Color = Color.FromRgb(255, 0, 0); } tr.AddNewlyCreatedDBObject(polyline, true); this.SplitLines = new List <ObjectId>(); for (int i = 0; i < lines.Count; i++) { if (Style == Solution.PipeLineStyle.AnyConnectedBuilding) { lines[i].Color = Color.FromRgb(0, 0, 255); } else { lines[i].Color = Color.FromRgb(255, 255, 0); } this.SplitLines.Add(btr.AppendEntity(lines[i])); tr.AddNewlyCreatedDBObject(lines[i], true); } col.Add(this.BoundPolygon); col.Add(this.CenterArc); foreach (var item in this.SplitLines) { col.Add(item); } tr.Commit(); } this.BaseObjectId = Utils.Utility.createGroup(col, ModelIdManager.toString(this.BaseModelId)); OwnSolution.SimplePipeJoints.Add(this.BaseObjectId, this); this.Save(); }
protected override void _SetAttributes(Dictionary <string, string> _attrs) { Dictionary <string, string> attrs = new Dictionary <string, string>(); foreach (var item in _attrs) { attrs[item.Key] = item.Value; } if (attrs.ContainsKey("pumpnum")) { this.WaterPumpCount = int.Parse(attrs["pumpnum"]); } if (attrs.ContainsKey("heatstyle")) { this.HeatStyle = int.Parse(attrs["heatstyle"]); } if (attrs.ContainsKey("boilercount")) { this.BoilerCount = int.Parse(attrs["boilercount"]); } if (attrs.ContainsKey("boilerEfficiency")) { this.BoilerEfficiency = double.Parse(attrs["boilerEfficiency"]); } if (attrs.ContainsKey("solution")) { this.OwnSolution = (Solution)BaseModel.GetModelById(Utils.ModelIdManager.Parse(attrs["solution"])); if (this.OwnSolution != null) { this.OwnSolution.HeatProducers.Add(this.BaseObjectId, this); } } if (attrs.ContainsKey("masterdistrict")) { this.OwnMasterDistrict = (District)BaseModel.GetModelById(ModelIdManager.Parse(attrs["masterdistrict"])); } if (attrs.ContainsKey("slavedistrict")) { this.OwnSlaveDistrict = (District)BaseModel.GetModelById(ModelIdManager.Parse(attrs["slavedistrict"])); } if (attrs.ContainsKey("boilersolutionfile")) { this.BoilerSolutionFile = attrs["boilersolutionfile"]; } if (attrs.ContainsKey("supplywatertemp")) { this.SupplyWaterTemp = double.Parse(attrs["supplywatertemp"]); } if (attrs.ContainsKey("returnwatertemp")) { this.ReturnWaterTemp = double.Parse(attrs["returnwatertemp"]); } }
protected override void _SetAttributes(Dictionary <String, String> _attrs) { Dictionary <string, string> attrs = new Dictionary <string, string>(); foreach (var item in _attrs) { attrs[item.Key] = item.Value; } if (attrs.ContainsKey("area")) { Area = double.Parse(attrs["area"]); } if (attrs.ContainsKey("layercount")) { LayerCount = int.Parse(attrs["layercount"]); } if (attrs.ContainsKey("height")) { Height = double.Parse(attrs["height"]); } if (attrs.ContainsKey("district")) { OwnDistrict.Clear(); string str = attrs["district"]; string[] strs = str.Split(' '); foreach (var item in strs) { string[] kv = item.Split(':'); if (kv.Length == 2) { int id1 = ModelIdManager.Parse(kv[0]); int id2 = ModelIdManager.Parse(kv[1]); Solution s = (Solution)BaseModel.GetModelById(id1); District t = (District)BaseModel.GetModelById(id2); OwnDistrict[s] = t; } } } if (attrs.ContainsKey("buildingnum")) { this.BuildingNum = int.Parse(attrs["buildingnum"]); } if (attrs.ContainsKey("buildingtype")) { this.BuildingType = int.Parse(attrs["buildingtype"]); } if (attrs.ContainsKey("heatindex")) { this.heatIndex = double.Parse(attrs["heatindex"]); } }
protected override void _SetAttributes(Dictionary <string, string> _attrs) { Dictionary <string, string> attrs = new Dictionary <string, string>(); foreach (var item in _attrs) { attrs[item.Key] = item.Value; } Buildings.Clear(); HeatProducers.Clear(); SubStations.Clear(); if (attrs.ContainsKey("buildings")) { string[] strs = attrs["buildings"].Split(' '); foreach (var item in strs) { int id = ModelIdManager.Parse(item); Buildings.Add((Building)BaseModel.GetModelById(id)); } } if (attrs.ContainsKey("substations")) { string[] strs = attrs["substations"].Split(' '); foreach (var item in strs) { int id = ModelIdManager.Parse(item); SubStations.Add((SubStation)BaseModel.GetModelById(id)); } } if (attrs.ContainsKey("heatproducers")) { string[] strs = attrs["heatproducers"].Split(' '); foreach (var item in strs) { int id = ModelIdManager.Parse(item); HeatProducers.Add((HeatProducer)BaseModel.GetModelById(id)); } } if (attrs.ContainsKey("solution")) { this.OwnSolution = (Solution)BaseModel.GetModelById(Utils.ModelIdManager.Parse(attrs["solution"])); if (this.OwnSolution != null) { this.OwnSolution.Districts.Add(this.BaseObjectId, this); } } }
protected override void GetAttributes() { attrs.Clear(); attrs.Add("centerpoint", CenterPoint.ToString()); string str = ""; foreach (var item in ConnectedPipes) { str += ModelIdManager.toString(item.BaseModelId) + ","; } attrs.Add("connectedpipes", str); if (this.OwnSolution != null) { attrs.Add("solution", Utils.ModelIdManager.toString(this.OwnSolution.BaseModelId)); } attrs.Add("style", ((int)Style).ToString()); }
protected override void GetAttributes() { attrs.Clear(); attrs.Add("WaterPumpCount", this.WaterPumpCount.ToString()); attrs.Add("HeatStyle", this.HeatStyle.ToString()); attrs.Add("supplywatertemp", this.SupplyWaterTemp.ToString()); attrs.Add("returnwatertemp", this.ReturnWaterTemp.ToString()); attrs.Add("HeatSwitcherCount", this.HeatSwitcherCount.ToString()); attrs.Add("HeatSwitcherVolumn", this.HeatSwitcherVolumn.ToString()); attrs.Add("WaterPumpPower", this.WaterPumpPower.ToString()); attrs.Add("WaterPumpTemp", this.WaterPumpTemp.ToString()); attrs.Add("solution", Utils.ModelIdManager.toString(this.OwnSolution.BaseModelId)); if (OwnMasterDistrict != null) { attrs.Add("masterdistrict", ModelIdManager.toString(OwnMasterDistrict.BaseModelId)); } if (OwnSlaveDistrict != null) { attrs.Add("slavedistrict", ModelIdManager.toString(OwnSlaveDistrict.BaseModelId)); } }
protected override void GetAttributes() { string str1 = ""; if (Buildings.Count > 0) { foreach (var item in Buildings) { str1 += ModelIdManager.toString(item.BaseModelId) + " "; } str1 = str1.Substring(0, str1.Length - 1); attrs.Add("buildings", str1); } if (SubStations.Count > 0) { string str2 = ""; foreach (var item in SubStations) { str2 += ModelIdManager.toString(item.BaseModelId) + " "; } str2 = str2.Substring(0, str2.Length - 1); attrs.Add("substations", str2); } if (HeatProducers.Count > 0) { string str3 = ""; foreach (var item in HeatProducers) { str3 += ModelIdManager.toString(item.BaseModelId) + " "; } str3 = str3.Substring(0, str3.Length - 1); attrs.Add("heatproducers", str3); } if (this.OwnSolution != null) { attrs.Add("solution", Utils.ModelIdManager.toString(this.OwnSolution.BaseModelId)); } }
protected override void _SetAttributes(Dictionary <string, string> _attrs) { Dictionary <string, string> attrs = new Dictionary <string, string>(); foreach (var item in _attrs) { attrs[item.Key] = item.Value; } if (attrs.ContainsKey("centerpoint")) { CenterPoint = Utility.ParsePoint3d(attrs["centerpoint"]); } if (attrs.ContainsKey("connectedpipes")) { string[] strs = attrs["connectedpipes"].Split(','); List <PipeLine> lines = new List <PipeLine>(); for (int i = 0; i < strs.Count() - 1; i++) { int modelId = ModelIdManager.Parse(strs[i]); lines.Add((PipeLine)BaseModel.GetModelById(modelId)); } this.SetPipeLines(lines); } if (attrs.ContainsKey("solution")) { this.OwnSolution = (Solution)BaseModel.GetModelById(Utils.ModelIdManager.Parse(attrs["solution"])); if (this.OwnSolution != null) { this.OwnSolution.MultiPipeJoints.Add(this.BaseObjectId, this); } } if (attrs.ContainsKey("style")) { Style = (Solution.PipeLineStyle) int.Parse(attrs["style"]); } }
public void AddBuildingNumber() { if (this.BuildingNum == 0) { this.BuildingNum = GetBuildingNumber(); } Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Database db = Application.DocumentManager.MdiActiveDocument.Database; ObjectIdCollection col = new ObjectIdCollection(); col.Add(this.BaseObjectId); using (DocumentLock docLock = Application.DocumentManager.MdiActiveDocument.LockDocument()) { using (Transaction trans = db.TransactionManager.StartTransaction()) { Polyline l = (Polyline)trans.GetObject(this.BaseObjectId, OpenMode.ForRead, false); Point3d center = new Point3d(0, 0, 0); double minX = Double.MaxValue, minY = double.MaxValue, maxX = double.MinValue, maxY = double.MinValue; for (int i = 0; i < l.NumberOfVertices; i++) { Point3d p = l.GetPoint3dAt(i); if (p.X < minX) { minX = p.X; } if (p.Y < minY) { minY = p.Y; } if (p.X > maxX) { maxX = p.X; } if (p.Y > maxY) { maxY = p.Y; } center = center + (p - new Point3d()); } center = center / (l.NumberOfVertices); double radius = Math.Min(maxX - minX, maxY - minY) / 4; Circle c = new Circle(center, new Vector3d(0, 0, 1), radius); TextStyleTable ts = (TextStyleTable)trans.GetObject(db.TextStyleTableId, OpenMode.ForRead); ObjectId mtStyleid = Utility.GetDefaultStyleId(); MText text = new MText(); text.TextStyleId = mtStyleid; text.Width = radius * Math.Sqrt(2); text.Height = radius * Math.Sqrt(2); text.TextHeight = text.Height * 0.8; text.Contents = this.BuildingNum.ToString(); text.Location = new Point3d(center.X - text.ActualWidth / 2, center.Y + text.ActualHeight / 2, 0); BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord ms = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); col.Add(ms.AppendEntity(text)); trans.AddNewlyCreatedDBObject(text, true); col.Add(ms.AppendEntity(c)); trans.AddNewlyCreatedDBObject(c, true); trans.Commit(); } } Utility.createGroup(col, ModelIdManager.toString(this.BaseModelId)); }