예제 #1
1
 /// <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;
 }
예제 #2
0
파일: Fan.cs 프로젝트: Spritutu/ntxx
        /// <summary>
        /// 绘制风扇
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="startPoint">风扇起点,如果为横置,由左向右;如果为竖置,由下到上</param>
        /// <param name="endPoint">风扇终点,如果为横置,由左向右;如果为竖置,由下到上</param>
        /// <param name="pointerLocation">箭头位置,默认=0为无,=1代表箭头在中间,=2代表箭头在底部</param>
        public static void Draw(DxfDocument dxf, Vector3f startPoint, Vector3f endPoint,int pointerLocation=0)
        {
            Layer layer = new Layer("line");
            Line line = new Line(startPoint, endPoint);
            line.Layer = layer;
            dxf.AddEntity(line);

            //如果为横置
            if (startPoint.Y == endPoint.Y)
            {
                float segment = (endPoint.X - startPoint.X) / 4;
                Slash.Draw(dxf, new Location(startPoint.X + segment, startPoint.Y, startPoint.Z));
                Slash.Draw(dxf, new Location(startPoint.X + 2 * segment, startPoint.Y, startPoint.Z));
                Slash.Draw(dxf, new Location(startPoint.X + 3 * segment, startPoint.Y, startPoint.Z));
            }
            //如果为竖置
            else if (startPoint.X == endPoint.X)
            {
                float segment = (endPoint.Y - startPoint.Y) / 5;
                Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + segment, startPoint.Z));
                Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + 2 * segment, startPoint.Z));
                Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + 3 * segment, startPoint.Z));
                Slash.Draw(dxf, new Location(startPoint.X, startPoint.Y + 4 * segment, startPoint.Z));
                if (pointerLocation == 1)
                {
                    LinePointer.Draw(dxf,new Location(startPoint.X,(startPoint.Y+endPoint.Y)/2,startPoint.Z));
                }
                else if(pointerLocation==2)
                {
                    LinePointer.Draw(dxf, new Location(startPoint.X, startPoint.Y, startPoint.Z));
                }
            }
        }
예제 #3
0
 /// <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;
 }
예제 #4
0
 /// <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;
 }
예제 #5
0
 /// <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;
 }
예제 #6
0
 /// <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();
 }
예제 #7
0
 /// <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();
 }
예제 #8
0
 /// <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();
 }
예제 #9
0
파일: Slash.cs 프로젝트: Spritutu/ntxx
        public static void Draw(DxfDocument dxf, Location location)
        {
            Vector3f v1 = new Vector3f(location.X - 2.0f, location.Y - 4.0f, location.Z);
            Vector3f v2 = new Vector3f(location.X + 2.0f, location.Y + 4.0f, location.Z);
            Layer layer = new Layer("line");

            Line line12 = new Line(v1, v2);
            line12.Layer = layer;
            dxf.AddEntity(line12);
        }
예제 #10
0
파일: Point.cs 프로젝트: fearog/axecalc
 /// <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;
 }
예제 #11
0
파일: Wind.cs 프로젝트: Spritutu/ntxx
        /// <summary>
        /// 风向绘制
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="location"></param>
        /// <param name="isRight"></param>
        public static void Draw(DxfDocument dxf, Location location, bool isRight)
        {
            float factor = 0.5f;
            Vector3f v1 = new Vector3f();
            Vector3f v2 = new Vector3f();
            Vector3f v3 = new Vector3f();
            Vector3f v4 = new Vector3f();
            Vector3f v5 = new Vector3f();
            Vector3f v6 = new Vector3f();
            Vector3f v7 = new Vector3f();
            if (isRight)
            {
                v1 = new Vector3f(10*factor + location.X, location.Y, location.Z);
                v2 = new Vector3f(location.X, location.Y + 10 * factor, location.Z);
                v3 = new Vector3f(location.X + 10 * factor, location.Y + 10 * factor, location.Z);
                v4 = new Vector3f(location.X + 20 * factor, location.Y + 15 * factor, location.Z);
                v5 = new Vector3f(location.X, location.Y + 20 * factor, location.Z);
                v6 = new Vector3f(location.X + 10 * factor, location.Y + 20 * factor, location.Z);
                v7 = new Vector3f(location.X + 10 * factor, location.Y + 30 * factor, location.Z);
            }
            else
            {
                v1 = new Vector3f(10 * factor + location.X, location.Y, location.Z);
                v2 = new Vector3f(location.X + 20 * factor, location.Y + 10 * factor, location.Z);
                v3 = new Vector3f(location.X + 10 * factor, location.Y + 10 * factor, location.Z);
                v4 = new Vector3f(location.X, location.Y + 15 * factor, location.Z);
                v5 = new Vector3f(location.X + 20 * factor, location.Y + 20 * factor, location.Z);
                v6 = new Vector3f(location.X + 10 * factor, location.Y + 20 * factor, location.Z);
                v7 = new Vector3f(location.X + 10 * factor, location.Y + 30 * factor, location.Z);
            }
            Layer layer = new Layer("line");
            Line line23 = new Line(v2, v3);
            line23.Layer = layer;
            dxf.AddEntity(line23);

            Line line56 = new Line(v5, v6);
            line56.Layer = layer;
            dxf.AddEntity(line56);

            Line line14 = new Line(v1, v4);
            line14.Layer = layer;
            dxf.AddEntity(line14);

            Line line74 = new Line(v7, v4);
            line74.Layer = layer;
            dxf.AddEntity(line74);

            Line line25 = new Line(v2, v5);
            line25.Layer = layer;
            dxf.AddEntity(line25);

            Line line71 = new Line(v7, v1);
            line71.Layer = layer;
            dxf.AddEntity(line71);
        }
예제 #12
0
파일: Line.cs 프로젝트: fearog/axecalc
 /// <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;
 }
예제 #13
0
 /// <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;
 }
예제 #14
0
 protected virtual Layer OnLayerChangeEvent(Layer oldLayer, Layer newLayer)
 {
     LayerChangeEventHandler ae = this.LayerChange;
     if (ae != null)
     {
         TableObjectChangeEventArgs<Layer> eventArgs = new TableObjectChangeEventArgs<Layer>(oldLayer, newLayer);
         ae(this, eventArgs);
         return eventArgs.NewValue;
     }
     return newLayer;
 }
예제 #15
0
 /// <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;
 }
예제 #16
0
 /// <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;
 }
예제 #17
0
 /// <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;
 }
예제 #18
0
 /// <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;
 }
예제 #19
0
파일: Solid.cs 프로젝트: fearog/axecalc
 /// <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;
 }
예제 #20
0
        /// <summary>
        /// Initializes a new instance of the <c>Block</c> class.
        /// </summary>
        /// <param name="name">Block name.</param>
        public Block(string name)
            : base(DxfObjectCode.Block)
        {
            if (string.IsNullOrEmpty(name))
                throw (new ArgumentNullException("name"));

            this.name = name;
            this.basePoint = Vector3d.Zero;
            this.layer = Layer.Default;
            this.attributes = new Dictionary<string, AttributeDefinition>();
            this.entities = new List<IEntityObject>();
            this.record=new BlockRecord(name);
            this.end = new BlockEnd(this.layer);
        }
예제 #21
0
        public static DxfDocument generateDXF(StructuralModel structure)
        {
            var dxf = new netDxf.DxfDocument();

            var ColumnLayer = new netDxf.Tables.Layer("Column")
            {
                Color      = netDxf.AciColor.Red,
                Lineweight = netDxf.Lineweight.W50
            };
            var SlabLayer = new netDxf.Tables.Layer("Slab")
            {
                Color      = netDxf.AciColor.Yellow,
                Lineweight = netDxf.Lineweight.W50
            };
            var OpeningLayer = new netDxf.Tables.Layer("Opening")
            {
                Color      = netDxf.AciColor.Blue,
                Lineweight = netDxf.Lineweight.W50
            };
            var WallLayer = new netDxf.Tables.Layer("Wall")
            {
                Color      = netDxf.AciColor.Green,
                Lineweight = netDxf.Lineweight.W50
            };

            dxf.Layers.Add(ColumnLayer);
            dxf.Layers.Add(SlabLayer);
            dxf.Layers.Add(OpeningLayer);
            dxf.Layers.Add(WallLayer);

            foreach (var item in structure.Columns)
            {
                dxf.AddEntity(getPolylineFromPoints(item.Points, ColumnLayer));
            }
            foreach (var item in structure.Slabs)
            {
                dxf.AddEntity(getPolylineFromPoints(item.Points, SlabLayer));
            }
            foreach (var item in structure.Walls)
            {
                dxf.AddEntity(getPolylineFromPoints(item.Points, WallLayer, false));
            }
            foreach (var item in structure.Openings)
            {
                dxf.AddEntity(getPolylineFromPoints(item.Points, OpeningLayer));
            }

            return(dxf);
        }
예제 #22
0
 /// <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;
 }
예제 #23
0
 /// <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;
 }
예제 #24
0
 /// <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;
 }
예제 #25
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;
 }
예제 #26
0
파일: Insert.cs 프로젝트: fearog/axecalc
        /// <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();
        }
예제 #27
0
        public static void Draw(DxfDocument dxf, Location location,List<string> configurations)
        {
            Vector3f confStrVector3f = new Vector3f(location.X + 5.0f, location.Y - 5.0f, location.Z);
            TextStyle style = new TextStyle("True type font", "Arial.ttf");
            Text text1 = new Text("CONFIGURATION:                   NOTE:  Assembly drawing for overall dimesions,  actual door size and handle position may vary",
                confStrVector3f, 2.0f, style);
            Layer layer = new Layer("text");
            text1.Layer = layer;
            //text1.Layer.Color.Index = 8;
            text1.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(text1);

            for (int i = 0; i < configurations.Count(); i++)
            {
                Vector3f confVector3f = new Vector3f(location.X+10.0f, location.Y - 5.0f * (i + 2), location.Z);
                Text text = new Text(configurations[i], confVector3f, 2.0f, style);
                text.Layer = layer;
                //text.Layer.Color.Index = 8;
                text.Alignment = TextAlignment.TopLeft;
                dxf.AddEntity(text);
            }
        }
예제 #28
0
파일: Section.cs 프로젝트: Spritutu/ntxx
        /// <summary>
        /// 绘制左下角区域的Section块
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="location"></param>
        /// <param name="configurations"></param>
        public static void Draw(DxfDocument dxf, Location location,SectionEntity sectionEntity)
        {
            float factor=0.6f;
            Vector3f v1 = new Vector3f(location.X, location.Y + 40.0f*factor, location.Z);
            Vector3f v2 = new Vector3f(location.X + 50.0f * factor, location.Y + 40.0f * factor, location.Z);
            Vector3f v3 = new Vector3f(location.X + 90.0f * factor, location.Y + 40.0f * factor, location.Z);
            Vector3f v4 = new Vector3f(location.X + 140.0f * factor, location.Y + 40.0f * factor, location.Z);

            Vector3f v5 = new Vector3f(location.X, location.Y + 50.0f * factor, location.Z);
            Vector3f v6 = new Vector3f(location.X + 140.0f * factor, location.Y + 50.0f * factor, location.Z);

            Vector3f v7 = new Vector3f(location.X, location.Y + 60.0f * factor, location.Z);
            Vector3f v8 = new Vector3f(location.X + 140.0f * factor, location.Y + 60.0f * factor, location.Z);

            Vector3f v9 = new Vector3f(location.X, location.Y + 70.0f * factor, location.Z);
            Vector3f v10 = new Vector3f(location.X + 50.0f * factor, location.Y + 70.0f * factor, location.Z);
            Vector3f v11 = new Vector3f(location.X + 90.0f * factor, location.Y + 70.0f * factor, location.Z);
            Vector3f v12 = new Vector3f(location.X + 140.0f * factor, location.Y + 70.0f * factor, location.Z);

            Layer layer = new Layer("line");

            //横向四道
            Line line14 = new Line(v1, v4);
            line14.Layer = layer;
            dxf.AddEntity(line14);

            Line line56 = new Line(v5, v6);
            line56.Layer = layer;
            dxf.AddEntity(line56);

            Line line78 = new Line(v7, v8);
            line78.Layer = layer;
            dxf.AddEntity(line78);

            Line line912 = new Line(v9, v12);
            line912.Layer = layer;
            dxf.AddEntity(line912);

            //纵向四道
            Line line91 = new Line(v9, v1);
            line91.Layer = layer;
            dxf.AddEntity(line91);

            Line line210 = new Line(v2, v10);
            line210.Layer = layer;
            dxf.AddEntity(line210);

            Line line311 = new Line(v3, v11);
            line311.Layer = layer;
            dxf.AddEntity(line311);

            Line line412 = new Line(v4, v12);
            line412.Layer = layer;
            dxf.AddEntity(line412);

            TextStyle style = new TextStyle("True type font", "Arial.ttf");
            Vector3f vt1 = new Vector3f(v1.X+1.0f, v1.Y+2.5f, v1.Z);
            Text t1 = new Text("COIL", vt1, 2.0f, style);
            t1.Layer = layer;
            t1.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t1);

            Vector3f vt2 = new Vector3f(v2.X + 1.0f, v2.Y + 2.5f, v2.Z);
            Text t2 = new Text("CLF", vt2, 2.0f, style);
            t2.Layer = layer;
            t2.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t2);

            Vector3f vt3 = new Vector3f(v3.X + 1.0f, v3.Y + 2.5f, v3.Z);
            Text t3 = new Text(sectionEntity.CoolValue, vt3, 2.0f, style);
            t3.Layer = layer;
            t3.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t3);

            Vector3f vt4 = new Vector3f(v5.X + 1.0f, v5.Y + 2.5f, v5.Z);
            Text t4 = new Text("FILTER", vt4, 2.0f, style);
            t4.Layer = layer;
            t4.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t4);

            Vector3f vt5 = new Vector3f(v2.X + 1.0f, v5.Y + 2.5f, v5.Z);
            Text t5 = new Text("FTA", vt5, 2.0f, style);
            t5.Layer = layer;
            t5.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t5);

            Vector3f vt6 = new Vector3f(v3.X + 1.0f, v5.Y + 2.5f, v5.Z);
            Text t6 = new Text(sectionEntity.FilterValue, vt6, 2.0f, style);
            t6.Layer = layer;
            t6.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t6);

            Vector3f vt7 = new Vector3f(v7.X + 1.0f, v7.Y + 2.5f, v7.Z);
            Text t7 = new Text("SECTION", vt7, 2.0f, style);
            t7.Layer = layer;
            t7.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t7);

            Vector3f vt8 = new Vector3f(v2.X + 1.0f, v7.Y + 2.5f, v7.Z);
            Text t8 = new Text("MODULE", vt8, 2.0f, style);
            t8.Layer = layer;
            t8.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t8);

            Vector3f vt9 = new Vector3f(v3.X + 1.0f, v7.Y + 2.5f, v7.Z);
            Text t9 = new Text("CLEARANCE", vt9, 2.0f, style);
            t9.Layer = layer;
            t9.Alignment = TextAlignment.TopLeft;
            dxf.AddEntity(t9);
        }
예제 #29
0
        internal Block(string name, bool checkName, ICollection<EntityObject> entities, ICollection<AttributeDefinition> attributes)
            : base(name, DxfObjectCode.Block, checkName)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            this.reserved = name.Equals(DefaultModelSpaceName, StringComparison.OrdinalIgnoreCase);
            this.readOnly = this.reserved || name.StartsWith(DefaultPaperSpaceName, StringComparison.OrdinalIgnoreCase);

            this.description = string.Empty;
            this.position = Vector3.Zero;
            this.layer = Layer.Default;

            this.entities = new EntityCollection();
            this.entities.BeforeAddItem += this.Entities_BeforeAddItem;
            this.entities.AddItem += this.Entities_AddItem;
            this.entities.BeforeRemoveItem += this.Entities_BeforeRemoveItem;
            this.entities.RemoveItem += this.Entities_RemoveItem;

            this.attributes = new AttributeDefinitionDictionary();
            this.attributes.BeforeAddItem += this.AttributeDefinitions_BeforeAddItem;
            this.attributes.AddItem += this.AttributeDefinitions_ItemAdd;
            this.attributes.BeforeRemoveItem += this.AttributeDefinitions_BeforeRemoveItem;
            this.attributes.RemoveItem += this.AttributeDefinitions_RemoveItem;

            this.owner = new BlockRecord(name);
            this.flags = BlockTypeFlags.None;
            this.end = new EndBlock
            {
                Owner = this.owner
            };

            if (entities != null) this.entities.AddRange(entities);
            if (attributes != null) this.attributes.AddRange(attributes);
        }
예제 #30
0
 private void SetAttributes(EntityObject entity, IGeoObject go)
 {
     if (go is IColorDef cd && cd.ColorDef != null)
     {
         AciColor clr;
         if (cd.ColorDef.Color.ToArgb().Equals(Color.White.ToArgb()) || cd.ColorDef.Color.ToArgb().Equals(Color.Black.ToArgb()))
         {
             clr = AciColor.Default;
         }
         else
         {
             clr = AciColor.FromTrueColor(cd.ColorDef.Color.ToArgb());
             if (clr.Index > 0 && clr.Index < 256)
             {
                 var indexColor = AciColor.FromCadIndex(clr.Index);
                 if (indexColor.ToColor().ToArgb().Equals(cd.ColorDef.Color.ToArgb()))
                 {
                     // if the color matches the index color exactly
                     // we don't need to use TruColor
                     clr.UseTrueColor = false;
                 }
             }
         }
         entity.Color = clr;
     }
     if (go.Layer != null)
     {
         if (!createdLayers.TryGetValue(go.Layer, out netDxf.Tables.Layer layer))
         {
             layer = new netDxf.Tables.Layer(go.Layer.Name);
             doc.Layers.Add(layer);
             createdLayers[go.Layer] = layer;
         }
         entity.Layer = layer;
     }
     if (go is ILinePattern lp)
     {
         if (!createdLinePatterns.TryGetValue(lp.LinePattern, out Linetype linetype))
         {
             List <LinetypeSegment> segments = new List <LinetypeSegment>();
             if (lp.LinePattern.Pattern != null)
             {
                 for (int i = 0; i < lp.LinePattern.Pattern.Length; i++)
                 {
                     LinetypeSegment ls;
                     if ((i & 0x01) == 0)
                     {
                         ls = new LinetypeSimpleSegment(lp.LinePattern.Pattern[i]);
                     }
                     else
                     {
                         ls = new LinetypeSimpleSegment(-lp.LinePattern.Pattern[i]);
                     }
                     segments.Add(ls);
                 }
             }
             linetype = new Linetype(lp.LinePattern.Name);
             linetype.Segments.AddRange(segments);
             doc.Linetypes.Add(linetype);
             createdLinePatterns[lp.LinePattern] = linetype;
         }
         entity.Linetype = linetype;
     }
     if (go is ILineWidth lw)
     {
         double     minError = double.MaxValue;
         Lineweight found    = Lineweight.Default;
         foreach (Lineweight lwe in Enum.GetValues(typeof(Lineweight)))
         {
             double err = Math.Abs(((int)lwe) / 100.0 - lw.LineWidth.Width);
             if (err < minError)
             {
                 minError = err;
                 found    = lwe;
             }
         }
         entity.Lineweight = found;
     }
 }
예제 #31
0
파일: Export.cs 프로젝트: SOFAgh/CADability
 private void SetAttributes(EntityObject entity, IGeoObject go)
 {
     if (go is IColorDef cd && cd.ColorDef != null)
     {
         AciColor clr = AciColor.FromTrueColor(cd.ColorDef.Color.ToArgb());
         entity.Color = clr;
     }
     if (go.Layer != null)
     {
         if (!createdLayers.TryGetValue(go.Layer, out netDxf.Tables.Layer layer))
         {
             layer = new netDxf.Tables.Layer(go.Layer.Name);
             doc.Layers.Add(layer);
             createdLayers[go.Layer] = layer;
         }
         entity.Layer = layer;
     }
     if (go is ILinePattern lp)
     {
         if (!createdLinePatterns.TryGetValue(lp.LinePattern, out Linetype linetype))
         {
             List <LinetypeSegment> segments = new List <LinetypeSegment>();
             if (lp.LinePattern.Pattern != null)
             {
                 for (int i = 0; i < lp.LinePattern.Pattern.Length; i++)
                 {
                     LinetypeSegment ls;
                     if ((i & 0x01) == 0)
                     {
                         ls = new LinetypeSimpleSegment(lp.LinePattern.Pattern[i]);
                     }
                     else
                     {
                         ls = new LinetypeSimpleSegment(-lp.LinePattern.Pattern[i]);
                     }
                     segments.Add(ls);
                 }
             }
             linetype = new Linetype(lp.LinePattern.Name);
             linetype.Segments.AddRange(segments);
             doc.Linetypes.Add(linetype);
             createdLinePatterns[lp.LinePattern] = linetype;
         }
         entity.Linetype = linetype;
     }
     if (go is ILineWidth lw)
     {
         double     minError = double.MaxValue;
         Lineweight found    = Lineweight.Default;
         foreach (Lineweight lwe in Enum.GetValues(typeof(Lineweight)))
         {
             double err = Math.Abs(((int)lwe) / 100.0 - lw.LineWidth.Width);
             if (err < minError)
             {
                 minError = err;
                 found    = lwe;
             }
         }
         entity.Lineweight = found;
     }
 }
예제 #32
0
파일: Handle.cs 프로젝트: Spritutu/ntxx
        /// <summary>
        /// 门把手绘制
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="location"></param>
        public static void Draw(DxfDocument dxf, Location location)
        {
            float factor = 0.05f;
             float distance = 30;
            //底部小圆的圆心
             Vector3f sCircle = new Vector3f(location.X + 10 * factor, location.Y, location.Z);
            //上部同心圆圆心
             Vector3f bCircle = new Vector3f(location.X + 10 * factor, location.Y + 5 * factor + distance*factor, location.Z);

             double alpha = Math.Asin(3 / distance);
             double beta = Math.Acos(0.8);

             Vector3f v1 = new Vector3f(
                 location.X + 10 * factor - float.Parse((5 * factor * Math.Cos(alpha)).ToString()),
                 location.Y + 5 * factor - float.Parse((5 * factor * Math.Sin(alpha)).ToString()),
                 location.Z);

             Vector3f v2 = new Vector3f(
                  location.X + 10 * factor + float.Parse((5 * factor * Math.Cos(alpha)).ToString()),
                  location.Y + 5 * factor - float.Parse((5 * factor * Math.Sin(alpha)).ToString()),
                  location.Z);

             Vector3f v4 = new Vector3f(
                 location.X + 10 * factor -float.Parse((8*factor* Math.Cos(alpha)).ToString()),
                 location.Y + 5 * factor + distance * factor - float.Parse((8 * factor * Math.Sin(alpha)).ToString()),
                 location.Z
                 );

             Vector3f v5 = new Vector3f(
             location.X + 10 * factor  + float.Parse((8*factor*Math.Cos(alpha)).ToString()),
             location.Y + 5 * factor + distance * factor - float.Parse((8 * factor * Math.Sin(alpha)).ToString()),
             location.Z
             );
             Layer layer = new Layer("line");
             Line line14 = new Line(v1, v4);
             line14.Layer = layer;
             line14.Layer.Color.Index = 6;
             dxf.AddEntity(line14);

             Line line25 = new Line(v2, v5);
             line25.Layer = new Layer("line");
             line25.Layer = layer;
             dxf.AddEntity(line25);

             //arc
             Arc arc = new Arc(
                 new Vector3f(location.X + 10 * factor, location.Y + 5 * factor, location.Z),
                 5 * factor, Convert.ToInt32(180 + alpha * 180 / Math.PI), Convert.ToInt32(360 - alpha * 180 / Math.PI));
             arc.Layer = layer;
             dxf.AddEntity(arc);

             //arcup
             Arc arcup = new Arc(
                 new Vector3f(location.X + 10 * factor, location.Y + 5 * factor + distance * factor, location.Z),
                 8 * factor, Convert.ToInt32(-alpha * 180 / Math.PI), Convert.ToInt32(180 + alpha * 180 / Math.PI));
             arcup.Layer = layer;
             dxf.AddEntity(arcup);

             //arcround
             Arc arcround = new Arc(
                 new Vector3f(location.X + 10 * factor, location.Y + 5 * factor + distance * factor, location.Z),
                 10 * factor,
                 Convert.ToInt32(-(alpha +beta) * 180 / Math.PI),
                 Convert.ToInt32(180 + (alpha +beta) * 180 / Math.PI));
             arcround.Layer = layer;
             dxf.AddEntity(arcround);

             //circle
             Vector3f extrusion = new Vector3f(0, 0, 1);
             Vector3f centerWCS = new Vector3f(location.X+10*factor, location.Y+5*factor+distance*factor, location.Z);
             Vector3d centerOCS = MathHelper.Transform((Vector3d)centerWCS,
                                                       (Vector3d)extrusion,
                                                       MathHelper.CoordinateSystem.World,
                                                       MathHelper.CoordinateSystem.Object);

             Circle circle = new Circle((Vector3f)centerOCS, 7*factor);
             circle.Layer = layer;
             circle.LineType = LineType.Continuous;
             circle.Normal = extrusion;
             dxf.AddEntity(circle);

             //上部同心圆圆心
             Vector3f t1 = new Vector3f(
                 location.X + 8 * factor,
                 location.Y + 5 * factor + (distance - 7) * factor * 0.7f,
                 location.Z);
             Vector3f t2 = new Vector3f(
                 location.X + 8 * factor,
                 location.Y + 5 * factor + (distance - 7) * factor * 0.5f,
                 location.Z);
             Vector3f t3 = new Vector3f(
                 location.X + 8 * factor,
                 location.Y + 5 * factor + (distance - 7) * factor * 0.3f,
                 location.Z);
             Vector3f t4 = new Vector3f(
                 location.X + 8 * factor,
                 location.Y + 5 * factor + (distance - 7) * factor * 0.1f,
                 location.Z);

             //text
             TextStyle style = new TextStyle("True type font", "Arial.ttf");
             Text text1 = new Text("A", t1, 0.2f, style);
             text1.Layer = layer;
             text1.Alignment = TextAlignment.TopLeft;
             dxf.AddEntity(text1);

             //text
             Text text2 = new Text("A", t2, 0.2f, style);
             text2.Layer = layer;
             text2.Alignment = TextAlignment.TopLeft;
             dxf.AddEntity(text2);

             //text
             Text text3 = new Text("O", t3, 0.2f, style);
             text3.Layer = layer;
             text3.Alignment = TextAlignment.TopLeft;
             dxf.AddEntity(text3);

             //text
             Text text4 = new Text("N", t4, 0.2f, style);
             text4.Layer = layer;
             text4.Alignment = TextAlignment.TopLeft;
             dxf.AddEntity(text4);
        }
예제 #33
0
파일: Face3d.cs 프로젝트: fearog/axecalc
 /// <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>();
 }
 static Layer()
 {
     defaultLayer = new Layer("0");
 }