/// <summary> /// Initializes a new instance of the <c>PolylineVertex</c> class. /// </summary> /// <param name="location">Polyface mesh vertex <see cref="Vector3d">location</see>.</param> public PolyfaceMeshVertex(Vector3d location) : base(DxfObjectCode.Vertex) { this.flags = VertexTypeFlags.PolyfaceMeshVertex | VertexTypeFlags.Polygon3dMesh; this.location = location; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; }
/// <summary> /// Intitializes a new instance of the <c>Attribute</c> class. /// </summary> /// <param name="definition"><see cref="AttributeDefinition">Attribute definition</see>.</param> /// <param name="value">Attribute value.</param> public Attribute(AttributeDefinition definition, object value) : base(DxfObjectCode.Attribute) { this.definition = definition; this.value = value; this.color = definition.Color; this.layer = definition.Layer; this.lineType = definition.LineType; }
/// <summary> /// Initializes a new instance of the <c>PolyfaceMeshFace</c> class. /// </summary> /// <remarks> /// By default the face is made up of three vertexes. /// </remarks> public PolyfaceMeshFace() : base(DxfObjectCode.Vertex) { this.flags = VertexTypeFlags.PolyfaceMeshVertex; this.vertexIndexes = new int[3]; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; }
/// <summary> /// Initializes a new instance of the <c><Polyline3dVertex/c> class. /// </summary> public Polyline3dVertex() : base(DxfObjectCode.Vertex) { this.flags = VertexTypeFlags.Polyline3dVertex; this.location = Vector3d.Zero; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; }
/// <summary> /// Initializes a new instance of the <c>PolyfaceMesh</c> class. /// </summary> public PolyfaceMesh() : base(DxfObjectCode.Polyline) { this.flags = PolylineTypeFlags.PolyfaceMesh; this.faces = new List<PolyfaceMeshFace>(); this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.endSequence = new EndSequence(); }
/// <summary> /// Initializes a new instance of the <c>Point</c> class. /// </summary> public Point() : base(DxfObjectCode.Point) { this.location = Vector3d.Zero; this.thickness = 0.0f; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; }
/// <summary> /// Initializes a new instance of the <c>Layer</c> class. /// </summary> /// <param name="name">Layer name.</param> public Layer(string name) : base(DxfObjectCode.Layer) { if (string.IsNullOrEmpty(name)) throw (new ArgumentNullException("name")); this.name = name; this.color = AciColor.Default; this.lineType = LineType.Continuous; this.isVisible = true; }
/// <summary> /// Initializes a new instance of the <c>Polyline3d</c> class. /// </summary> /// <param name="vertexes">3d polyline <see cref="Polyline3dVertex">vertex</see> list.</param> public Polyline3d(List<Polyline3dVertex> vertexes) : base(DxfObjectCode.Polyline) { this.flags = PolylineTypeFlags.Polyline3D; this.vertexes = vertexes; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.endSequence = new EndSequence(); }
/// <summary> /// Initializes a new instance of the <c>Polyline3d</c> class. /// </summary> /// <param name="vertexes">3d polyline <see cref="Polyline3dVertex">vertex</see> list.</param> /// <param name="isClosed">Sets if the polyline is closed</param> public Polyline3d(List<Polyline3dVertex> vertexes, bool isClosed) : base(DxfObjectCode.Polyline) { this.flags = isClosed ? PolylineTypeFlags.ClosedPolylineOrClosedPolygonMeshInM | PolylineTypeFlags.Polyline3D : PolylineTypeFlags.Polyline3D; this.vertexes = vertexes; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.endSequence = new EndSequence(); }
/// <summary> /// Initializes a new instance of the <c>Circle</c> class. /// </summary> public Circle() : base(DxfObjectCode.Circle) { this.center = Vector3d.Zero; this.radius = 1.0; this.thickness = 0.0f; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; }
/// <summary> /// Initializes a new instance of the <c>Line</c> class. /// </summary> public Line() : base(DxfObjectCode.Line) { this.startPoint = Vector3d.Zero; this.endPoint = Vector3d.Zero; this.thickness = 0.0f; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; }
protected virtual LineType OnLineTypeChangeEvent(LineType oldLineType, LineType newLineType) { LineTypeChangeEventHandler ae = this.LineTypeChange; if (ae != null) { TableObjectChangeEventArgs<LineType> eventArgs = new TableObjectChangeEventArgs<LineType>(oldLineType, newLineType); ae(this, eventArgs); return eventArgs.NewValue; } return newLineType; }
/// <summary> /// Initializes a new instance of the <c>PolylineVertex</c> class. /// </summary> /// <param name="location">Polyline <see cref="Vector2d">vertex</see> coordinates.</param> public PolylineVertex(Vector2d location) : base(DxfObjectCode.Vertex) { this.flags = VertexTypeFlags.PolylineVertex; this.location = location; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.bulge = 0.0f; this.beginThickness = 0.0f; this.endThickness = 0.0f; }
/// <summary> /// Initializes a new instance of the <c>NurbsCurve</c> class. /// </summary> public NurbsCurve() { this.controlPoints = new List<NurbsVertex>(); this.normal = Vector3d.UnitZ; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.order = 0; this.curvePoints = 30; this.elevation = 0.0; this.thickness = 0.0f; this.normal = Vector3d.UnitZ; }
/// <summary> /// Initializes a new instance of the <c>Solid</c> class. /// </summary> /// <param name="firstVertex">Solid <see cref="Vector3d">first vertex</see>.</param> /// <param name="secondVertex">Solid <see cref="Vector3d">second vertex</see>.</param> /// <param name="thirdVertex">Solid <see cref="Vector3d">third vertex</see>.</param> /// <param name="fourthVertex">Solid <see cref="Vector3d">fourth vertex</see>.</param> public Solid(Vector3d firstVertex, Vector3d secondVertex, Vector3d thirdVertex, Vector3d fourthVertex) : base(DxfObjectCode.Solid) { this.firstVertex = firstVertex; this.secondVertex = secondVertex; this.thirdVertex = thirdVertex; this.fourthVertex = fourthVertex; this.thickness = 0.0f; this.normal = Vector3d.UnitZ; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; }
/// <summary> /// Initializes a new instance of the <c>Arc</c> class. /// </summary> /// <param name="center">Arc <see cref="netDxf.Vector3d">center</see> in object coordinates.</param> /// <param name="radius">Arc radius.</param> /// <param name="startAngle">Arc start angle in degrees.</param> /// <param name="endAngle">Arc end angle in degrees.</param> /// <remarks>The center Z coordinate represents the elevation of the arc along the normal.</remarks> public Arc(Vector3d center, double radius, double startAngle, double endAngle) : base(DxfObjectCode.Arc) { this.center = center; this.radius = radius; this.startAngle = startAngle; this.endAngle = endAngle; this.thickness = 0.0f; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; }
/// <summary> /// Initializes a new instance of the <c>Polyline</c> class. /// </summary> /// <param name="vertexes">Polyline <see cref="LightWeightPolylineVertex">vertex</see> list in object coordinates.</param> /// <param name="isClosed">Sets if the polyline is closed</param> public LightWeightPolyline(List<LightWeightPolylineVertex> vertexes, bool isClosed) : base(DxfObjectCode.LightWeightPolyline) { this.vertexes = vertexes; this.isClosed = isClosed; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; this.elevation = 0.0; this.thickness = 0.0f; this.flags = isClosed ? PolylineTypeFlags.ClosedPolylineOrClosedPolygonMeshInM : PolylineTypeFlags.OpenPolyline; }
/// <summary> /// Initializes a new instance of the <c>Text</c> class. /// </summary> public Text() : base(DxfObjectCode.Text) { this.value = string.Empty; this.basePoint = Vector3d.Zero; this.alignment = TextAlignment.BaselineLeft; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; this.style = TextStyle.Default; this.rotation = 0.0f; this.height = 0.0f; this.widthFactor = 1.0f; this.obliqueAngle = 0.0f; }
/// <summary> /// Initializes a new instance of the <c>Ellipse</c> class. /// </summary> /// <param name="center">Ellipse <see cref="Vector3d">center</see> in object coordinates.</param> /// <param name="majorAxis">Ellipse major axis.</param> /// <param name="minorAxis">Ellipse minor axis.</param> /// <remarks>The center Z coordinate represents the elevation of the arc along the normal.</remarks> public Ellipse(Vector3d center, double majorAxis, double minorAxis) : base(DxfObjectCode.Ellipse) { this.center = center; this.majorAxis = majorAxis; this.minorAxis = minorAxis; this.startAngle = 0.0; this.endAngle = 360.0; this.rotation = 0.0; this.curvePoints = 30; this.thickness = 0.0f; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; }
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; }
/// <summary> /// Initializes a new instance of the <c>Insert</c> class. /// </summary> /// <param name="block">Insert block definition.</param> /// <param name="insertionPoint">Insert <see cref="Vector3d">point</see>.</param> public Insert(Block block, Vector3d insertionPoint) : base(DxfObjectCode.Insert) { if (block == null) throw new ArgumentNullException("block"); this.block = block; this.insertionPoint = insertionPoint; this.scale = new Vector3d(1.0f, 1.0f, 1.0f); this.rotation = 0.0f; this.normal = Vector3d.UnitZ; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.attributes = new List<Attribute>(); foreach (AttributeDefinition attdef in block.Attributes.Values) { this.attributes.Add(new Attribute(attdef)); } this.endSequence = new EndSequence(); }
/// <summary> /// Obtains an AutoCad layer for a spatial feature (creates the /// layer if necessary). /// </summary> /// <param name="f">The feature that's being exported</param> /// <param name="lineType">The AutoCad line type</param> /// <param name="useOtherLayer">Should a layer associated with a topological /// layer, or an angle, or a distance be obtained?</param> /// <returns>The matching AutoCad layer</returns> internal Layer GetLayer(IFeature f, LineType lineType, bool useOtherLayer) { // Get the entity type for the feature (possibly derived in // the case of a line). IEntity ent = GetEntity(f); // No layer if there is no entity type (e.g. construction circles). if (ent == null) return null; // Return the layer (if any). return GetLayer(ent, lineType, useOtherLayer); }
/// <summary> /// Creates a new AutoCad layer /// </summary> /// <param name="lineType">The AutoCad line type</param> /// <param name="entity">The Backsight entity type</param> /// <param name="layerName">The name to assign to the new layer</param> /// <returns>The created layer</returns> Layer MakeALayer(LineType lineType, IEntity entity, string layerName) { // TODO: May need to ensure the name isn't TOO long (older versions of AutoCad may // have assumed 32 chars max). // Return existing layer if it has already been created Layer result; if (m_Layers.TryGetValue(layerName, out result)) return result; // Create the new layer. There's no need to add to the output DXF document (in // fact, there's no method to do so). The layer will be added by netDxf when // we call DxfDocument.AddEntity using an object that refers to a previously // unseen AutoCad layer. result = new Layer(layerName); result.Color = new AciColor(EntityUtil.GetColor(entity)); result.LineType = lineType; // Remember the created object for subsequent lookup by this class. m_Layers.Add(layerName, result); return result; }
/// <summary> /// Obtains an AutoCad layer for a specific entity type (creates the /// layer if necessary). /// </summary> /// <param name="entity">The entity type to translate (not null)</param> /// <param name="lineType">The AutoCad line type</param> /// <param name="useOtherLayer">Should a layer associated with a topological /// layer, or an angle, or a distance be obtained?</param> /// <returns></returns> Layer GetLayer(IEntity entity, LineType lineType, bool useOtherLayer) { if (entity == null) throw new ArgumentNullException(); // Find the AC layer name string layerName = m_EntityToLayer[entity.Name]; // If we're dealing with a polygon ID, or an angle annotation, or a distance // annotation, append any suffix if (useOtherLayer) { if (entity.IsPolygonValid && m_PinLayerSuffix != null) layerName += m_PinLayerSuffix; else if (entity.IsPointValid && m_AngleLayerSuffix != null) layerName += m_AngleLayerSuffix; else if (entity.IsLineValid && m_DistLayerSuffix != null) layerName += m_DistLayerSuffix; } // Return the layer object if it was previously created. Layer layer; if (m_Layers.TryGetValue(layerName, out layer)) return layer; // Create new layer return MakeALayer(lineType, entity, layerName); }
/// <summary> /// Initializes a new instance of the <c>Text</c> class. /// </summary> /// <param name="text">Text string.</param> /// <param name="basePoint">Text base <see cref="Vector3d">point</see>.</param> /// <param name="height">Text height.</param> /// <param name="style">Text <see cref="TextStyle">style</see>.</param> public Text(string text, Vector3d basePoint, float height, TextStyle style) : base(DxfObjectCode.Text) { this.value = text; this.basePoint = basePoint; this.alignment = TextAlignment.BaselineLeft; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; this.style = style; this.height = height; this.widthFactor = style.WidthFactor; this.obliqueAngle = style.ObliqueAngle; this.rotation = 0.0f; }
/// <summary> /// Initializes a new instance of the PolylineVertex class. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="z">Z coordinate.</param> public PolyfaceMeshVertex(float x, float y, float z) : base(DxfObjectCode.Vertex) { this.flags = VertexTypeFlags.PolyfaceMeshVertex | VertexTypeFlags.Polygon3dMesh; this.location = new Vector3d(x, y, z); this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; }
/// <summary> /// Initializes a new instance of the <c>NurbsCurve</c> class. /// </summary> /// <param name="controlPoints">The nurbs curve <see cref="netDxf.Entities.NurbsVertex">control point</see> list.</param> /// <param name="order">The nurbs curve order.</param> public NurbsCurve(List<NurbsVertex> controlPoints, int order) { if (controlPoints.Count<order) throw new ArgumentOutOfRangeException("order",order,"The order of the curve must be less or equal the number of control points."); this.controlPoints = controlPoints; this.normal = Vector3d.UnitZ; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.order = order; this.curvePoints = 30; this.elevation = 0.0; this.thickness = 0.0f; this.normal = Vector3d.UnitZ; }
static LineType() { byLayer = new LineType("ByLayer"); byBlock = new LineType("ByBlock"); continuous = new LineType("Continuous", "Solid line"); }
private LineType GetLineType(string name) { if (this.lineTypes.ContainsKey(name)) { return this.lineTypes[name]; } //just in case the line type has not been defined in the table section var lineType = new LineType(name); this.lineTypes.Add(lineType.Name, lineType); return lineType; }
/// <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; StreamReader reader; try { reader = new StreamReader(File.OpenRead(file), Encoding.ASCII); } catch (Exception ex) { throw (new FileLoadException("Unknown error reading lin file.", file, ex)); } 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.InvariantCultureIgnoreCase)) { 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 linetypes are supported. lineType = null; break; } } break; } reader.Close(); return(lineType); }
/// <summary> /// Initializes a new instance of the <c>Arc</c> class. /// </summary> public Arc() : base(DxfObjectCode.Arc) { this.center = Vector3d.Zero; this.radius = 0.0; this.startAngle = 0.0; this.endAngle = 0.0; this.thickness = 0.0f; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.normal = Vector3d.UnitZ; }
/// <summary> /// Initializes a new instance of the <c>Face3D</c> class. /// </summary> /// <param name="firstVertex">3d face <see cref="Vector3d">first vertex</see>.</param> /// <param name="secondVertex">3d face <see cref="Vector3d">second vertex</see>.</param> /// <param name="thirdVertex">3d face <see cref="Vector3d">third vertex</see>.</param> /// <param name="fourthVertex">3d face <see cref="Vector3d">fourth vertex</see>.</param> public Face3d(Vector3d firstVertex, Vector3d secondVertex, Vector3d thirdVertex, Vector3d fourthVertex) : base(DxfObjectCode.Face3D) { this.firstVertex = firstVertex; this.secondVertex = secondVertex; this.thirdVertex = thirdVertex; this.fourthVertex = fourthVertex; this.edgeFlags = EdgeFlags.Visibles; this.layer = Layer.Default; this.color = AciColor.ByLayer; this.lineType = LineType.ByLayer; this.xData = new Dictionary<ApplicationRegistry, XData>(); }
/// <summary> /// Initializes a new instance of the <c>DimensionStyle</c> class. /// </summary> /// <param name="name">The dimension style name.</param> public DimensionStyle(string name) : base(name, DxfObjectCode.DimStyle, true) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name", "The dimension style name should be at least one character long."); } this.reserved = name.Equals("Standard", 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.dimsah = false; this.dimblk = 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.dimpost = "<>"; this.dimatfit = 0; 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; }