private IPipePoint GetPointObject() { IPipePoint pPipePoint = null; AcadObject pAcadObject = PickObject(); if (pAcadObject == null) { return(null); } if (pAcadObject.ObjectName.Equals("AcDbText") || pAcadObject.ObjectName.Equals("AcDbMInsertBlock")) { AcadDictionary pAcadDictionary = pAcadObject.GetExtensionDictionary(); if (pAcadDictionary.Count > 1) { AcadXRecord pAcadXRecord1 = pAcadDictionary.Item(1) as AcadXRecord; AcadXRecord pAcadXRecord2 = pAcadDictionary.Item(0) as AcadXRecord; string TableName, ID; if (pAcadXRecord1.Name.StartsWith("PS_")) { TableName = pAcadXRecord1.Name; ID = pAcadXRecord2.Name; } else { TableName = pAcadXRecord2.Name; ID = pAcadXRecord1.Name; } //if( ) pPipePoint = Pipeobject.GetDataByID(ID, TableName) as IPipePoint; return(pPipePoint); } } return(null); }
private string GetPointID() { //IPipePoint pPipePoint = null; AcadObject pAcadObject = PickObject(); if (pAcadObject == null) { return(null); } if (pAcadObject.ObjectName.Equals("AcDbText") || pAcadObject.ObjectName.Equals("AcDbMInsertBlock")) { AcadDictionary pAcadDictionary = pAcadObject.GetExtensionDictionary(); if (pAcadDictionary.Count == 1) { string ID = (pAcadDictionary.Item(0) as AcadXRecord).Name; return(ID); /* string SURVEYID = GetPointSURVEYID(ID); * if (SURVEYID != string.Empty) * { * * return SURVEYID; * } * else return string.Empty;*/ } } return(string.Empty); }
private static void BackHatch(AcadObject AcadObject) { AcadDictionary dictionary = AcadDoc.ModelSpace.GetExtensionDictionary(); AcadSortentsTable sentityObj = (AcadSortentsTable)dictionary.GetObject("ACAD_SORTENTS"); AcadObject[] entities = new AcadObject[] { AcadObject }; sentityObj.MoveToBottom(entities); }
protected string GetPointObjectID(AcadEntity pAcadObject) { if (pAcadObject == null) { return(""); } AcadDictionary pAcadDictionary = pAcadObject.GetExtensionDictionary(); if (pAcadDictionary.Count == 1) { AcadXRecord pAcadXRecord = pAcadDictionary.Item(0) as AcadXRecord; string ID = pAcadXRecord.Name; return(ID); //} } return(string.Empty); }
public override void DrawCADObject(Autodesk.AutoCAD.Interop.AcadDocument AcadDoc) { double pX = double.Parse(this.X); double pY = double.Parse(this.Y); double[] InsertPoint = new double[] { pX, pY, 0 }; string BlockName = "一般管线点"; int LayerID = GetLayerIndex("0", AcadDoc); //string TrueType = GetTrueType(this.Type); if (this.Type == "雨水篦") { BlockName = "雨篦"; } else if (this.Type == "检修井") { BlockName = "排水检修井"; } else if (this.Type == "出水口") { BlockName = "出水口"; } if (!string.IsNullOrEmpty(this.Type)) { if (this.SURVEY_ID.StartsWith("WS")) { LayerID = GetLayerIndex("WSPoint", AcadDoc); } else if (this.SURVEY_ID.StartsWith("YS")) { LayerID = GetLayerIndex("YSPoint", AcadDoc); } } AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID); AcadMInsertBlock pAcadMInsertBlock = AcadDoc.ModelSpace.AddMInsertBlock(InsertPoint, BlockName, 1, 1, 1, 0, 1, 1, 1, 1); //pAcadMInsertBlock.TrueColor.SetRGB(255, 255, 255); AcadDictionary pAcadDictionary = pAcadMInsertBlock.GetExtensionDictionary(); //pAcadDictionary.AddXRecord(ClassName); pAcadDictionary.AddXRecord(this.ID); LayerID = GetLayerIndex("0", AcadDoc); if (!string.IsNullOrEmpty(this.Type)) { if (this.SURVEY_ID.StartsWith("WS")) { LayerID = GetLayerIndex("WSText", AcadDoc); } else if (this.SURVEY_ID.StartsWith("YS")) { LayerID = GetLayerIndex("YSText", AcadDoc); } } AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID); AcadText pAcadText = AcadDoc.ModelSpace.AddText(this.SURVEY_ID, InsertPoint, 2.0); pAcadDictionary = pAcadText.GetExtensionDictionary(); //pAcadDictionary.AddXRecord(ClassName); pAcadDictionary.AddXRecord(this.ID); AcadDoc.Save(); }
public override void DrawCADObject(Autodesk.AutoCAD.Interop.AcadDocument AcadDoc) { string Linetype = "合流"; int LayerID = GetLayerIndex("YSLine", AcadDoc); if (this.US_SURVEY_ID.StartsWith("WS")) { LayerID = GetLayerIndex("WSLine", AcadDoc); Linetype = "污水"; } else if (this.US_SURVEY_ID.StartsWith("YS")) { Linetype = "雨水"; } AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID); IPCPoint SPoint = GetPointByID(this.US_SURVEY_ID); IPCPoint EPoint = GetPointByID(this.DS_SURVEY_ID); double[] StartPoint = new double[3] { double.Parse(SPoint.X), double.Parse(SPoint.Y), 0 }; double[] EndPoint = new double[3] { double.Parse(EPoint.X), double.Parse(EPoint.Y), 0 }; AcadLine pAcadLine = AcadDoc.ModelSpace.AddLine(StartPoint, EndPoint); AcadDictionary pAcadDictionary = pAcadLine.GetExtensionDictionary(); //pAcadDictionary.AddXRecord(ClassName); pAcadDictionary.AddXRecord(ID); string MinArrowVal = CIni.ReadINI("DrawCAD", "ArrowMin"); bool IsDrawArrow = false; if (string.IsNullOrEmpty(MinArrowVal)) { IsDrawArrow = true; } else { double MinArrow = double.Parse(MinArrowVal); if (pAcadLine.Length < MinArrow) { IsDrawArrow = false; } else { IsDrawArrow = true; } } double[] MidPoint = new double[3] { (double.Parse(SPoint.X) + double.Parse(EPoint.X)) / 2, (double.Parse(SPoint.Y) + double.Parse(EPoint.Y)) / 2, 0 }; if (IsDrawArrow) { string WidthValue = this.Width; AcadMInsertBlock pBlock = AcadDoc.ModelSpace.AddMInsertBlock(MidPoint, "GP4", 1, 1, 1, 0, 1, 1, 1, 1); pBlock.Rotate(MidPoint, pAcadLine.Angle); pAcadDictionary = pBlock.GetExtensionDictionary(); pAcadDictionary.AddXRecord(ID); } string MinLableVal = CIni.ReadINI("DrawCAD", "LableMin"); if (!string.IsNullOrEmpty(MinLableVal)) { double MinLable = double.Parse(MinLableVal); if (pAcadLine.Length < MinLable) { return; } } string pUS_INVERT_LEVEL = double.Parse(SPoint.INVERT_LEVEL).ToString("0.000"); string pDS_INVERT_LEVEL = double.Parse(EPoint.INVERT_LEVEL).ToString("0.000"); string LineLable = string.Format("{0} {1}m {2}Φ{3} {4}m", Linetype, pUS_INVERT_LEVEL, this.MATERIAL, this.Width, pDS_INVERT_LEVEL); LayerID = GetLayerIndex("YSZJ", AcadDoc); if (this.US_SURVEY_ID.StartsWith("WS")) { LayerID = GetLayerIndex("WSZJ", AcadDoc); } else { LayerID = GetLayerIndex("YSZJ", AcadDoc); } AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID); AcadText pAcadText = AcadDoc.ModelSpace.AddText(LineLable, MidPoint, 2.0); double LineAngle = pAcadLine.Angle; if (LineAngle > Math.PI / 2 && LineAngle < 3 * Math.PI / 2) { LineAngle = LineAngle - Math.PI; } pAcadText.Rotate(MidPoint, LineAngle); pAcadDictionary = pAcadText.GetExtensionDictionary(); //pAcadDictionary.AddXRecord(ClassName); pAcadDictionary.AddXRecord(ID); //} AcadDoc.Save(); }