internal Layer(string name, bool checkName) : base(name, DxfObjectCode.Layer, checkName) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "The layer name should be at least one character long."); this.IsReserved = name.Equals(DefaultName, StringComparison.OrdinalIgnoreCase); this.color = AciColor.Default; this.linetype = Linetype.Continuous; this.isVisible = true; this.plot = true; this.lineweight = Lineweight.Default; this.transparency = new Transparency(0); }
protected EntityObject(EntityType type, string dxfCode) : base(dxfCode) { this.type = type; this.color = AciColor.ByLayer; this.layer = Layer.Default; this.linetype = Linetype.ByLayer; this.lineweight = Lineweight.ByLayer; this.transparency = Transparency.ByLayer; this.linetypeScale = 1.0; this.isVisible = true; this.normal = Vector3.UnitZ; this.reactors = new List<DxfObject>(); this.xData = new XDataDictionary(); this.xData.AddAppReg += this.XData_AddAppReg; this.xData.RemoveAppReg += this.XData_RemoveAppReg; }
protected virtual Linetype OnMLineStyleElementLinetypeChangedEvent(Linetype oldLinetype, Linetype newLinetype) { MLineStyleElementLinetypeChangedEventHandler ae = this.MLineStyleElementLinetypeChanged; if (ae != null) { TableObjectChangedEventArgs<Linetype> eventArgs = new TableObjectChangedEventArgs<Linetype>(oldLinetype, newLinetype); ae(this, eventArgs); return eventArgs.NewValue; } return newLinetype; }
private static Line ExtensionLine(Vector2 start, Vector2 end, DimensionStyle style, Linetype linetype) { return new Line(start, end) { Color = style.ExtLineColor, Linetype = linetype, Lineweight = style.ExtLineLineweight }; }
internal DimensionStyle(string name, bool checkName) : base(name, DxfObjectCode.DimStyle, checkName) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "The dimension style name should be at least one character long."); this.IsReserved = name.Equals(DefaultName, StringComparison.OrdinalIgnoreCase); // dimension lines this.dimclrd = AciColor.ByBlock; this.dimltype = Linetype.ByBlock; this.dimlwd = Lineweight.ByBlock; this.dimdli = 0.38; this.dimdle = 0.0; // extension lines this.dimclre = AciColor.ByBlock; this.dimltex1 = Linetype.ByBlock; this.dimltex2 = Linetype.ByBlock; this.dimlwe = Lineweight.ByBlock; this.dimse1 = false; this.dimse2 = false; this.dimexo = 0.0625; this.dimexe = 0.18; // symbols and arrows this.dimasz = 0.18; this.dimcen = 0.09; this.dimldrblk = null; this.dimblk1 = null; this.dimblk2 = null; // text this.dimtxsty = TextStyle.Default; this.dimclrt = AciColor.ByBlock; this.dimtxt = 0.18; this.dimtad = 1; this.dimjust = 0; this.dimgap = 0.09; // fit this.dimscale = 1.0; // primary units this.dimdec = 2; this.dimadec = 0; this.dimPrefix = string.Empty; this.dimSuffix = string.Empty; this.dimtih = 0; this.dimtoh = 0; this.dimdsep = '.'; this.dimlfac = 1.0; this.dimaunit = AngleUnitType.DecimalDegrees; this.dimlunit = LinearUnitType.Decimal; this.dimfrac = FractionFormatType.Horizontal; this.suppressLinearLeadingZeros = false; this.suppressLinearTrailingZeros = false; this.suppressAngularLeadingZeros = false; this.suppressAngularTrailingZeros = false; this.suppressZeroFeet = true; this.suppressZeroInches = true; this.dimrnd = 0.0; }
/// <summary> /// Writes a new line type to the table section. /// </summary> /// <param name="tl">Line type.</param> private void WriteLinetype(Linetype tl) { Debug.Assert(this.activeTable == DxfObjectCode.LinetypeTable); this.chunk.Write(0, tl.CodeName); this.chunk.Write(5, tl.Handle); this.chunk.Write(330, tl.Owner.Handle); this.chunk.Write(100, SubclassMarker.TableRecord); this.chunk.Write(100, SubclassMarker.Linetype); this.chunk.Write(70, (short) 0); this.chunk.Write(2, this.EncodeNonAsciiCharacters(tl.Name)); this.chunk.Write(3, this.EncodeNonAsciiCharacters(tl.Description)); this.chunk.Write(72, (short) 65); this.chunk.Write(73, (short) tl.Segments.Count); this.chunk.Write(40, tl.Length()); foreach (double s in tl.Segments) { this.chunk.Write(49, s); this.chunk.Write(74, (short) 0); } }
/// <summary> /// Creates a new line type from the definition in a .lin file. /// </summary> /// <remarks>Only simple line types are supported.</remarks> /// <param name="file">Lin file where the definition is located.</param> /// <param name="linetypeName">Name of the line type definition that wants to be read (ignore case).</param> /// <returns>A line type defined by the .lin file.</returns> public static Linetype FromFile(string file, string linetypeName) { Linetype linetype = null; using (StreamReader reader = new StreamReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line == null) throw new FileLoadException("Unknown error reading .lin file.", file); // lines starting with semicolons are comments if (line.StartsWith(";")) continue; // every line type definition starts with '*' if (!line.StartsWith("*")) continue; // reading line type name and description int endName = line.IndexOf(','); // the first semicolon divides the name from the description that might contain more semicolons string name = line.Substring(1, endName - 1); string description = line.Substring(endName + 1, line.Length - endName - 1); // remove start and end spaces description = description.Trim(); if (!name.Equals(linetypeName, StringComparison.OrdinalIgnoreCase)) continue; // we have found the line type name, the next line of the file contains the line type definition line = reader.ReadLine(); if (line == null) throw new FileLoadException("Unknown error reading .lin file.", file); linetype = new Linetype(name, description); string[] tokens = line.Split(','); // the index 0 is always A (alignment field) for (int i = 1; i < tokens.Length; i++) { double segment; if (double.TryParse(tokens[i], out segment)) linetype.Segments.Add(segment); else { // only simple line types are supported. linetype = null; break; } } break; } } return linetype; }
internal DimensionStyle(string name, bool checkName) : base(name, DxfObjectCode.DimStyle, checkName) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name), "The dimension style name should be at least one character long."); } this.IsReserved = name.Equals(DefaultName, StringComparison.OrdinalIgnoreCase); // dimension lines this.dimclrd = AciColor.ByBlock; this.dimltype = Linetype.ByBlock; this.dimlwd = Lineweight.ByBlock; this.dimsd = false; this.dimdli = 0.38; this.dimdle = 0.0; // extension lines this.dimclre = AciColor.ByBlock; this.dimltex1 = Linetype.ByBlock; this.dimltex2 = Linetype.ByBlock; this.dimlwe = Lineweight.ByBlock; this.dimse1 = false; this.dimse2 = false; this.dimexo = 0.0625; this.dimexe = 0.18; // symbols and arrows this.dimasz = 0.18; this.dimcen = 0.09; this.dimldrblk = null; this.dimblk1 = null; this.dimblk2 = null; // text this.dimtxsty = TextStyle.Default; this.dimclrt = AciColor.ByBlock; this.dimtxt = 0.18; this.dimtad = 1; this.dimjust = 0; this.dimgap = 0.09; // fit this.dimscale = 1.0; // primary units this.dimdec = 2; this.dimadec = 0; this.dimPrefix = string.Empty; this.dimSuffix = string.Empty; this.dimtih = 0; this.dimtoh = 0; this.dimdsep = '.'; this.dimlfac = 1.0; this.dimaunit = AngleUnitType.DecimalDegrees; this.dimlunit = LinearUnitType.Decimal; this.dimfrac = FractionFormatType.Horizontal; this.suppressLinearLeadingZeros = false; this.suppressLinearTrailingZeros = false; this.suppressAngularLeadingZeros = false; this.suppressAngularTrailingZeros = false; this.suppressZeroFeet = true; this.suppressZeroInches = true; this.dimrnd = 0.0; }
/// <summary> /// Creates a new line type from the definition in a LIN file. /// </summary> /// <param name="file">Lin file where the definition is located.</param> /// <param name="linetypeName">Name of the line type definition to read (ignore case).</param> /// <returns>The linetype defined in the LIN file with the specified name, null if the linetype has not been found in the linetype definitions file.</returns> public static Linetype Load(string file, string linetypeName) { Linetype linetype = null; List <LinetypeSegment> segments = new List <LinetypeSegment>(); using (StreamReader reader = new StreamReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line == null) { throw new FileLoadException("Unknown error reading LIN file.", file); } // every line type definition starts with '*' if (!line.StartsWith("*")) { continue; } // reading line type name and description int endName = line.IndexOf(','); // the first semicolon divides the name from the description that might contain more semicolons string name = line.Substring(1, endName - 1); string description = line.Substring(endName + 1, line.Length - endName - 1); // remove start and end spaces description = description.Trim(); if (name.Equals(linetypeName, StringComparison.OrdinalIgnoreCase)) { // we have found the line type name, the next line of the file contains the line type definition line = reader.ReadLine(); if (line == null) { throw new FileLoadException("Unknown error reading LIN file.", file); } string[] tokens = line.Split(','); // the index 0 is always A (alignment field) for (int i = 1; i < tokens.Length; i++) { double length; if (double.TryParse(tokens[i], NumberStyles.Float, CultureInfo.InvariantCulture, out length)) { // is the length followed by a shape o text segment if (i + 1 < tokens.Length) { if (tokens[i + 1].StartsWith("[")) { StringBuilder data = new StringBuilder(); // there are two kinds of complex linetype Text and Shape, the data is enclosed in brackets for (++i; i < tokens.Length; i++) { data.Append(tokens[i]); // text and shape data must be enclosed by brackets if (i >= tokens.Length) { throw new FormatException("The linetype definition is not well formatted."); } if (tokens[i].EndsWith("]")) { break; } data.Append(","); } LinetypeSegment segment = ReadLineTypeComplexSegment(data.ToString(), length); if (segment != null) { segments.Add(segment); } } else { segments.Add(new LinetypeSimpleSegment(length)); } } else { segments.Add(new LinetypeSimpleSegment(length)); } } else { throw new FormatException("The linetype definition is not well formatted."); } } linetype = new Linetype(name, segments, description); break; } } } return(linetype); }
internal DimensionStyle(string name, bool checkName) : base(name, DxfObjectCode.DimStyle, checkName) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name), "The dimension style name should be at least one character long."); } this.IsReserved = name.Equals(DefaultName, StringComparison.OrdinalIgnoreCase); // dimension and extension lines this.dimclrd = AciColor.ByBlock; this.dimltype = Linetype.ByBlock; this.dimlwd = Lineweight.ByBlock; this.dimdle = 0.0; this.dimdli = 0.38; this.dimsd1 = false; this.dimsd2 = false; this.dimclre = AciColor.ByBlock; this.dimltex1 = Linetype.ByBlock; this.dimltex2 = Linetype.ByBlock; this.dimlwe = Lineweight.ByBlock; this.dimse1 = false; this.dimse2 = false; this.dimexo = 0.0625; this.dimexe = 0.18; this.dimfxlon = false; this.dimfxl = 1.0; // symbols and arrows this.dimldrblk = null; this.dimblk1 = null; this.dimblk2 = null; this.dimasz = 0.18; this.dimcen = 0.09; // text this.dimtxsty = TextStyle.Default; this.dimclrt = AciColor.ByBlock; this.dimtfillclr = null; this.dimtxt = 0.18; this.dimtad = DimensionStyleTextVerticalPlacement.Centered; this.dimjust = DimensionStyleTextHorizontalPlacement.Centered; this.dimgap = 0.09; this.dimtih = false; this.dimtoh = false; this.dimtxtdirection = DimensionStyleTextDirection.LeftToRight; this.dimtfac = 1.0; // fit this.dimtofl = false; this.dimsoxd = true; this.dimscale = 1.0; this.dimatfit = DimensionStyleFitOptions.BestFit; this.dimtix = false; this.dimtmove = DimensionStyleFitTextMove.BesideDimLine; // primary units this.dimdec = 4; this.dimadec = 0; this.dimPrefix = string.Empty; this.dimSuffix = string.Empty; this.dimdsep = '.'; this.dimlfac = 1.0; this.dimaunit = AngleUnitType.DecimalDegrees; this.dimlunit = LinearUnitType.Decimal; this.dimfrac = FractionFormatType.Horizontal; this.suppressLinearLeadingZeros = false; this.suppressLinearTrailingZeros = false; this.suppressZeroFeet = true; this.suppressZeroInches = true; this.suppressAngularLeadingZeros = false; this.suppressAngularTrailingZeros = false; this.dimrnd = 0.0; // alternate units this.alternateUnits = new DimensionStyleAlternateUnits(); // tolerances this.tolerances = new DimensionStyleTolerances(); }
/// <summary> /// Initializes a new instance of the <c>Vertex</c> class. /// </summary> /// <param name="position">Vertex <see cref="Vector3">location</see>.</param> public Vertex(Vector3 position) : base(DxfObjectCode.Vertex) { this.flags = VertexTypeFlags.PolylineVertex; this.position = position; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.linetype = Linetype.ByLayer; this.bulge = 0.0; this.startWidth = 0.0; this.endWidth = 0.0; }