/// <summary> /// 替换审核者、设计者、日期等属性 /// </summary> /// <param name="entity"></param> public static void ReplaceProperty(AcadEntity entity, AcadBlocks blocks, Bussiness.Rules rules) { if (entity.ObjectName == "AcDbBlockReference") { var s = ((AcadBlockReference)entity); var name = blocks.Item(s.Name).Name; blocks.Item(s.Name).Name = rand.Next().ToString(); if (s.HasAttributes) { AcadAttributeReference bb; object[] aa = (object[])s.GetAttributes(); for (int i = 0; i < aa.Length; i++) { bb = aa[i] as AcadAttributeReference; if (bb != null) { if (bb.TagString != "---------" && bb.TagString != "------" && !bb.TagString.Contains("GEN-TITLE-MAT") && !bb.TagString.Contains("GEN-TITLE-DES") && bb.TagString != "01" && !bb.TagString.Contains("GEN-TITLE-SCA{6.14,1}")) { bb.TextString = ""; } if (bb.TagString == "---------") { oldCode = bb.TextString; oldCode = ReplaceStr(oldCode); var startCode = oldCode.Substring(0, RegexCode()); var endCode = oldCode.Substring(RegexCode(), oldCode.Length - RegexCode()); Hashtable hash = rules.GetRules(); foreach (DictionaryEntry de in hash) { if (startCode == de.Key.ToString()) { startCode = de.Value.ToString(); } } newCode = startCode + "0" + Rand(); if (!string.IsNullOrEmpty(newCode)) { bb.TextString = newCode; } } } } } } else if (entity.ObjectName == "AcDbMText") { AcadMText mtext = entity as AcadMText; if (mtext != null) { if (mtext.TextString.Contains("FAX") || mtext.TextString.Contains("TEL") || mtext.TextString.Contains("TOMITA")) { mtext.TextString = ""; } } } }
/// <summary> /// Agrega un nuevo texto al documento actual. /// </summary> /// <param name="TextString">Texto a mostrar</param> /// <param name="P_XYZ">Coordenadas del texto (X,Y,Z).</param> /// <param name="Width">Ancho del texto.</param> /// <param name="Height">Alto del texto.</param> /// <param name="Layer">Capa del texto.</param> /// <param name="Style">Estilo del texto.</param> /// <param name="Rotation">Ángulo de rotación del texto en grados.</param> /// <param name="LineTypeSacale">Tipo de escala de la linea.</param> /// <param name="Width2">Ancho del cuadro de Texto.</param> /// <param name="justifyText">Justificación del Texto.</param> public static void AddText(string TextString, double[] P_XYZ, double Width, double Height, string Layer, string Style, float Rotation, double LineTypeSacale = 1, double Width2 = 1.3, JustifyText justifyText = JustifyText.Left) { if (AcadDoc != null) { AcadMText text = AcadDoc.ModelSpace.AddMText(P_XYZ, Width, TextString); text.Layer = Layer; text.StyleName = Style; text.Height = Height; text.Rotation = Rotation * Math.PI / 180; text.LinetypeScale = LineTypeSacale; text.Width = Width2; text.AttachmentPoint = Clasf_JustyText(justifyText); text.Update(); } }
/// <summary> /// Agrega un nuevo texto al documento actual. /// </summary> /// <param name="TextString">Texto a mostrar</param> /// <param name="P_XY">Coordenadas del texto (X,Y) [System.Drawing].</param> /// <param name="Width">Ancho del texto.</param> /// <param name="Height">Alto del texto.</param> /// <param name="Layer">Capa del texto.</param> /// <param name="Style">Estilo del texto.</param> /// <param name="Rotation">Ángulo de rotación del texto en grados.</param> /// <param name="LineTypeSacale">Tipo de escala de la linea.</param> /// <param name="Width2">Ancho del cuadro de Texto.</param> /// <param name="JustifyText">Justificación del Texto.</param> public static void AddText(string TextString, PointF P_XY, double Width, double Height, string Layer, string Style, float Rotation, double LineTypeSacale = 1, double Width2 = 1.3, JustifyText JustifyText = JustifyText.Left) { if (AcadDoc != null) { try { AcadMText text = AcadDoc.ModelSpace.AddMText(ConvertirPuntoEnDobules3D(P_XY), Width, TextString); text.Layer = Layer; text.StyleName = Style; text.Height = Height; text.Rotation = Rotation * Math.PI / 180; text.LinetypeScale = LineTypeSacale; text.Width = Width2; text.AttachmentPoint = Clasf_JustyText(JustifyText); text.Update(); } catch { NotificadorErrores?.Invoke("Error inesperado."); } } }