Beispiel #1
0
        public void DrawString(string s, Font font, Brush brush, PointF point)
        {
            DxfText dxfText = new DxfText(s, new WW.Math.Point3D((double)point.X, -(double)point.Y, 0.0), (double)font.Size);

            dxfText.AlignmentPoint2   = new WW.Math.Point3D?(dxfText.AlignmentPoint1);
            dxfText.VerticalAlignment = TextVerticalAlignment.Top;
            DxfTextStyle dxfTextStyle = (DxfTextStyle)null;

            foreach (DxfTextStyle textStyle in (DxfHandledObjectCollection <DxfTextStyle>) this.dxfModel_0.TextStyles)
            {
                if (textStyle.FontFilename == font.Name)
                {
                    dxfTextStyle = textStyle;
                    break;
                }
            }
            if (dxfTextStyle == null)
            {
                dxfTextStyle = new DxfTextStyle(font.Name, font.Name);
                this.dxfModel_0.TextStyles.Add(dxfTextStyle);
            }
            dxfText.Style = dxfTextStyle;
            SolidBrush solidBrush = brush as SolidBrush;

            if (solidBrush != null)
            {
                dxfText.Color = EntityColor.CreateFrom((ArgbColor)solidBrush.Color);
            }
            this.list_0.Add((DxfEntity)dxfText);
        }
Beispiel #2
0
        private static DxfModel CreateAutoCadDrawing()
        {
            DxfModel model = new DxfModel();
            DxfText  text  = new DxfText("Welcome to WW.Cad", Point3D.Zero, 1)
            {
                Color = EntityColors.Blue
            };

            model.Entities.Add(text);
            model.Entities.Add(new DxfText("the trial version only supports the orange color", new Point3D(0.2, -0.5, 0), 0.3)
            {
                Color = EntityColors.Gray
            });

            // Make a fancy rectangle with rounded corner around the text.
            var    textBounds         = text.TextBounds;
            double margin             = 1;
            double roundedCornerBulge = 0.5;

            model.Entities.Add(
                new DxfLwPolyline(
                    new DxfLwPolyline.Vertex(textBounds.Min - margin * Vector2D.XAxis, roundedCornerBulge),
                    new DxfLwPolyline.Vertex(textBounds.Min - margin * Vector2D.YAxis),
                    new DxfLwPolyline.Vertex(textBounds.Min + textBounds.Delta.X * Vector2D.XAxis - margin * Vector2D.YAxis, roundedCornerBulge),
                    new DxfLwPolyline.Vertex(textBounds.Min + textBounds.Delta.X * Vector2D.XAxis + margin * Vector2D.XAxis),
                    new DxfLwPolyline.Vertex(textBounds.Max + margin * Vector2D.XAxis, roundedCornerBulge),
                    new DxfLwPolyline.Vertex(textBounds.Max + margin * Vector2D.YAxis),
                    new DxfLwPolyline.Vertex(textBounds.Min + textBounds.Delta.Y * Vector2D.YAxis + margin * Vector2D.YAxis, roundedCornerBulge),
                    new DxfLwPolyline.Vertex(textBounds.Min + textBounds.Delta.Y * Vector2D.YAxis - margin * Vector2D.XAxis)
                    )
            {
                Closed = true, Color = EntityColors.Green
            });
            return(model);
        }
Beispiel #3
0
        private static DxfModel CreateModelWithAxes()
        {
            DxfModel model;
            model = new DxfModel();
            double width = 100d;
            double height = 100d;
            DxfLine xaxis = new DxfLine(new Point2D(0d, 0d), new Point2D(width, 0d));
            xaxis.Color = EntityColors.LightGray;
            model.Entities.Add(xaxis);

            DxfLine yaxis = new DxfLine(new Point2D(0d, 0d), new Point2D(0d, height));
            yaxis.Color = EntityColors.LightGray;
            model.Entities.Add(yaxis);

            DxfText originLabel = new DxfText("0", new Point3D(-1d, -1d, 0d), 0.5d);
            originLabel.Color = EntityColors.GreenYellow;
            model.Entities.Add(originLabel);

            DxfText xaxisLabel = new DxfText("10", new Point3D(width, -1d, 0d), 0.5d);
            xaxisLabel.Color = EntityColors.GreenYellow;
            model.Entities.Add(xaxisLabel);

            DxfText yaxisLabel = new DxfText("10", new Point3D(-1, height, 0d), 0.5d);
            yaxisLabel.Color = EntityColors.GreenYellow;
            model.Entities.Add(yaxisLabel);

            return model;
        }
Beispiel #4
0
 public virtual void CreateText(
     DxfText text,
     DrawContext.Wireframe drawContext,
     ArgbColor color)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Beispiel #5
0
 public void CreateText(DxfText text, DrawContext.Wireframe drawContext, ArgbColor color)
 {
     if (text.Text == null || text.Text.Trim() == string.Empty)
     {
         return;
     }
     this.method_3(Class666.smethod_5(text, text.Color.ToColor(), drawContext.GetLineWeight((DxfEntity)text), drawContext.GetTransformer().Matrix *text.Transform, (Bounds2D)null), (DxfEntity)text, drawContext);
 }
        public static void TopRFTSupportTxt(DxfModel model, int nSpans)
        {
            TopRFTSupprtTxt = new DxfText[nSpans + 1];

            //Case Of Cantilever Start Span
            if (GeometryEditorVM.GeometryEditor.RestraintsCollection[0].SelectedRestraint != Restraints.NoRestraints)
            {
                if (nRebarTopSupport[0] > 0)
                {
                    TopRFTSupprtTxt[0] = new DxfText($"{nRebarTopSupport[0]}T{TopchosenDiameterArr[0]}"
                                                     , new Point3D(DXFRebar.TopSpan[0].Start.X + 10 * 0.15, DXFPoints.startPointsTop[0].Y - 0.3, 0), 0.2d);
                    model.Entities.Add(TopRFTSupprtTxt[0]);
                }
                else
                {
                    TopRFTSupprtTxt[0] = new DxfText($"Increase Dims"
                                                     , new Point3D(DXFRebar.TopSpan[0].Start.X + 10 * 0.15, DXFPoints.startPointsTop[0].Y - 0.3, 0), 0.2d);
                    model.Entities.Add(TopRFTSupprtTxt[0]);
                }
            }

            //Top Support RFT/*------------------*/

            for (int i = 1; i < TopRFTSupprtTxt.Length - 1; i++)
            {
                if (nRebarTopSupport[i] > 0)
                {
                    TopRFTSupprtTxt[i] = new DxfText($"{nRebarTopSupport[i]}T{TopchosenDiameterArr[i]}"
                                                     , new Point3D(DXFPoints.startPointsTop[i].X + 0.60, DXFPoints.startPointsTop[0].Y - 0.3, 0), 0.2d);
                    model.Entities.Add(TopRFTSupprtTxt[i]);
                }
                else
                {
                    TopRFTSupprtTxt[i] = new DxfText($"Increase Dims"
                                                     , new Point3D(DXFPoints.startPointsTop[i].X + 0.60, DXFPoints.startPointsTop[0].Y - 0.3, 0), 0.2d);
                    model.Entities.Add(TopRFTSupprtTxt[i]);
                }
            }

            //Case of Cantilever end Span
            if (GeometryEditorVM.GeometryEditor.RestraintsCollection[RFTCanvas.SpanVals.Length].SelectedRestraint != Restraints.NoRestraints)
            {
                if (nRebarTopSupport[nSpans] > 0)
                {
                    TopRFTSupprtTxt[nSpans] = new DxfText($"{nRebarTopSupport[nSpans]}T{TopchosenDiameterArr[nSpans]}"
                                                          , new Point3D(DXFRebar.TopSpan[nSpans].End.X - 10 * 0.15, DXFPoints.startPointsTop[0].Y - 0.3, 0), 0.2d);
                    model.Entities.Add(TopRFTSupprtTxt[nSpans]);
                }
                else
                {
                    TopRFTSupprtTxt[nSpans] = new DxfText($"Increase Dims"
                                                          , new Point3D(DXFRebar.TopSpan[nSpans].End.X - 10 * 0.15, DXFPoints.startPointsTop[0].Y - 0.3, 0), 0.2d);
                    model.Entities.Add(TopRFTSupprtTxt[nSpans]);
                }
            }
        }
Beispiel #7
0
 public static void BottomRFTTxt(DxfModel model, int nSpans, int[] nRebarBot, double[] chosenDiameter, double[] Ln, Point2D[] startPointsBot)
 {
     //Bottom Rft Text/*------------------*/
     DxfText[] BotRFTTxt = new DxfText[nSpans];
     for (int i = 0; i < BotRFTTxt.Length; i++)
     {
         DxfText text = new DxfText($"{nRebarBot[i]}T{chosenDiameter[i]}", new Point3D(startPointsBot[i].X + 0.60 * Ln[i], 0.10, 0), 0.2d);
         model.Entities.Add(text);
     }
 }
Beispiel #8
0
 public static void StirrupMidSpanTxt(DxfModel model, int nSpans, DxfLine[,] stirrupsMidspan)
 {
     //Stirrups Text MidSpan/*------------------*/
     DxfText[] stirMidSpanTxt = new DxfText[nSpans];
     for (int i = 0; i < stirMidSpanTxt.Length; i++)
     {
         stirMidSpanTxt[i] = new DxfText($"Y8@200mm", new Point3D(stirrupsMidspan[i, 2].Start.X - 0.85, -1.40, 0), 0.2d);
         model.Entities.Add(stirMidSpanTxt[i]);
     }
 }
        public static void BottomRFTTxt(DxfModel model, int nSpans)
        {
            BotRFTTxt = new DxfText[nSpans];

            //Case of Cantilever at start
            if (GeometryEditorVM.GeometryEditor.RestraintsCollection[0].SelectedRestraint != Restraints.NoRestraints)
            {
                if (nRebarBot[0] > 0)
                {
                    DxfText text = new DxfText($"{nRebarBot[0]}T{BotchosenDiameterArr[0]}"
                                               , new Point3D(DXFPoints.startPointsBot[0].X + 0.60 * DXFRebar.Ln[0], DXFPoints.startPointsBot[0].Y + 0.10 /*---*/, 0), 0.2d);
                    model.Entities.Add(text);
                }
                else
                {
                    DxfText text = new DxfText($"Increase Dims"
                                               , new Point3D(DXFPoints.startPointsBot[0].X + 0.60 * DXFRebar.Ln[0], DXFPoints.startPointsBot[0].Y + 0.10 /*---*/, 0), 0.2d);
                    model.Entities.Add(text);
                }
            }

            //Bottom Rft Text/*------------------*/
            for (int i = 1; i < BotRFTTxt.Length - 1; i++)
            {
                if (nRebarBot[i] > 0)
                {
                    DxfText text = new DxfText($"{nRebarBot[i]}T{BotchosenDiameterArr[i]}"
                                               , new Point3D(DXFPoints.startPointsBot[i].X + 0.60 * DXFRebar.Ln[i], DXFPoints.startPointsBot[i].Y + 0.10 /*---*/, 0), 0.2d);
                    model.Entities.Add(text);
                }
                else
                {
                    DxfText text = new DxfText($"Increase Dims"
                                               , new Point3D(DXFPoints.startPointsBot[i].X + 0.60 * DXFRebar.Ln[i], DXFPoints.startPointsBot[i].Y + 0.10 /*---*/, 0), 0.2d);
                    model.Entities.Add(text);
                }
            }

            //Case of Cantilever End
            if (GeometryEditorVM.GeometryEditor.RestraintsCollection[RFTCanvas.SpanVals.Length].SelectedRestraint != Restraints.NoRestraints)
            {
                if (nRebarBot[BotRFTTxt.Length - 1] > 0)
                {
                    DxfText text = new DxfText($"{nRebarBot[BotRFTTxt.Length - 1]}T{BotchosenDiameterArr[BotRFTTxt.Length - 1]}"
                                               , new Point3D(DXFPoints.startPointsBot[BotRFTTxt.Length - 1].X + 0.60 * DXFRebar.Ln[BotRFTTxt.Length - 1], DXFPoints.startPointsBot[BotRFTTxt.Length - 1].Y + 0.10 /*---*/, 0), 0.2d);
                    model.Entities.Add(text);
                }
                else
                {
                    DxfText text = new DxfText($"Increase Dims"
                                               , new Point3D(DXFPoints.startPointsBot[BotRFTTxt.Length - 1].X + 0.60 * DXFRebar.Ln[BotRFTTxt.Length - 1], DXFPoints.startPointsBot[BotRFTTxt.Length - 1].Y + 0.10 /*---*/, 0), 0.2d);
                    model.Entities.Add(text);
                }
            }
        }
Beispiel #10
0
        internal static IList <Class908> smethod_5(
            DxfText text,
            Color color,
            short lineWeight,
            Matrix4D insertionTransformation,
            Bounds2D collectBounds)
        {
            Vector2D alignmentTranslation;
            Vector2D alignmentScaling;

            return(Class666.smethod_6(text, color, lineWeight, insertionTransformation, collectBounds, out alignmentTranslation, out alignmentScaling));
        }
Beispiel #11
0
        //For a given Polygon Find related booth number and pass the booth data
        public static Booth PassBooth(DxfModel _model, string _boothNumberLayer, List <string> _vertices, string _screenOrigin)
        {
            int    _sizeX = 0;
            int    _sizeY = 0;
            string _insertPoint;
            string _boothNumber;
            string _shape;
            var    booth = new Booth();

            List <string> _verticesList = new List <string>();

            foreach (var item in _vertices)
            {
                _verticesList.Add(item);
            }
            Point[] verticesArray = VerticesToList(_vertices).ToArray();
            foreach (DxfEntity _textEntity in _model.Entities)
            {
                DxfText textTo = _textEntity as DxfText;

                //Logic to relate booth and booth number
                if (_textEntity.EntityType.ToString() == "TEXT" && (_textEntity.Layer.ToString().Equals(_boothNumberLayer, StringComparison.InvariantCultureIgnoreCase)))
                //_textEntity.Layer.ToString() == _boothNumberLayer
                {
                    var textString = RemoveSpaces(textTo.TextBounds.Center.ToString());
                    var textPoint  = TransformPoint(textTo.Transform.Transform(textTo.TextBounds.Center).ToString(), _screenOrigin);
                    var textPoint1 = StringToPoint(textPoint);
                    if (PointInPolygon(verticesArray, textPoint1) == true)
                    {
                        _insertPoint = RemoveSpaces(string.Join(",", _verticesList));
                        _boothNumber = textTo.Text;
                        _shape       = "Polygon";

                        //If the polygon has 4 sides
                        if (verticesArray.Length == 4)
                        {
                            _sizeX       = GetWidth(_vertices[0].ToString(), _vertices[2].ToString());
                            _sizeY       = GetHeight(_vertices[1].ToString(), _vertices[3].ToString());
                            _insertPoint = FindMinimum(verticesArray).ToString();
                            _shape       = "Box";
                        }
                        booth.BOOTHNUMBER = _boothNumber;
                        booth.INSERTPOINT = _insertPoint;
                        booth.SIZEX       = _sizeX.ToString();
                        booth.SIZEY       = _sizeY.ToString();
                        booth.SHAPE       = _shape;
                    }
                }
            }
            return(booth);
        }
Beispiel #12
0
 public static void TopRFTSupportTxt(DxfModel model, int nSpans, double thickness,
                                     int[] nRebarTopSupportArr, double[] chosenDiameterTopSupport, DxfLine[] TopSpan, DxfLine[] TopSupport)
 {
     //Top Support RFT/*------------------*/
     DxfText[] TopRFTSupprtTxt = new DxfText[nSpans + 1];
     TopRFTSupprtTxt[0] = new DxfText($"{nRebarTopSupportArr[0]}T{chosenDiameterTopSupport[0]}", new Point3D(TopSpan[0].Start.X + 10 * 0.15, thickness - 0.3, 0), 0.2d);
     model.Entities.Add(TopRFTSupprtTxt[0]);
     for (int i = 1; i < TopRFTSupprtTxt.Length - 1; i++)
     {
         TopRFTSupprtTxt[i] = new DxfText($"{nRebarTopSupportArr[i]}T{chosenDiameterTopSupport[i]}", new Point3D(TopSupport[i - 1].Start.X + 0.60, thickness - 0.3, 0), 0.2d);
         model.Entities.Add(TopRFTSupprtTxt[i]);
     }
     TopRFTSupprtTxt[nSpans] = new DxfText($"{nRebarTopSupportArr[nSpans]}T{chosenDiameterTopSupport[nSpans]}", new Point3D(TopSpan[nSpans].End.X - 10 * 0.15, thickness - 0.3, 0), 0.2d);
     model.Entities.Add(TopRFTSupprtTxt[nSpans]);
 }
Beispiel #13
0
        public static void Draw(DxfModel dxf, DLocation DLocation,List<string> configurations)
        {
            Point3D confStrPoint3D = new Point3D(DLocation.X + 5.0d, DLocation.Y - 5.0d, DLocation.Z);
            DxfText DxfText1 = new DxfText("CONFIGURATION:                   NOTE:  Assembly drawing for overall dimesions,  actual door size and handle position may vary",
                confStrPoint3D, 2.0d);
            //DxfText1.Layer.Color.Index = 8;
            dxf.Entities.Add(DxfText1);

            for (int i = 0; i < configurations.Count(); i++)
            {
                Point3D confPoint3D = new Point3D(DLocation.X+10.0d, DLocation.Y - 5.0d * (i + 2), DLocation.Z);
                DxfText DxfText = new DxfText(configurations[i], confPoint3D, 2.0d);
                dxf.Entities.Add(DxfText);
            }
        }
        private static PdfText ConvertText(DxfText text, DxfLayer layer, Matrix4 affine, Matrix4 scale)
        {
            // TODO horizontal and vertical justification (manual calculation for PDF, measure text?)
            // TODO Thickness, Rotation, TextStyleName, SecondAlignmentPoint
            // TODO IsTextUpsideDown, IsTextBackwards
            // TODO RelativeXScaleFactor
            // TODO TextHeight unit? Same as other scale?
            // TODO TextStyleName probably maps to something meaningfull (bold, italic, etc?)
            PdfMeasurement fontSize = scale.Transform(new Vector(0, text.TextHeight, 0))
                                      .ToPdfPoint(PdfMeasurementType.Point).Y;
            PdfPoint location       = affine.Transform(text.Location).ToPdfPoint(PdfMeasurementType.Point);
            var      pdfStreamState = new PdfStreamState(GetPdfColor(text, layer));

            return(new PdfText(text.Value, Font, fontSize, location, pdfStreamState));
        }
Beispiel #15
0
 public DxfTextObjectContextData(DxfText text, DxfScale scale)
     : base(scale)
 {
     this.textHorizontalAlignment_0 = text.HorizontalAlignment;
     this.double_0    = text.Rotation;
     this.point2D_1.X = text.AlignmentPoint1.X;
     this.point2D_1.Y = text.AlignmentPoint1.Y;
     if (text.AlignmentPoint2.HasValue)
     {
         this.point2D_0.X = text.AlignmentPoint2.Value.X;
         this.point2D_0.Y = text.AlignmentPoint2.Value.Y;
     }
     else
     {
         this.point2D_0 = this.point2D_1;
     }
 }
Beispiel #16
0
        public static void StirrupRightTxt(DxfModel model, int nSpans, DxfLine[,] stirrupsRight, double[] spacingRightSec, int[] spacingRightIndexes
                                           , double[] stirDiaArr240, double[] stirDiaArr360, double[] stirDiaArr400)
        {
            //Stirrups Text Left/*------------------*/
            double fystr = -1;

            DxfText[] stirRightTxt = new DxfText[nSpans];
            for (int i = 0; i < stirRightTxt.Length; i++)
            {
                if (spacingRightIndexes[i] != -2)
                {
                    if (spacingRightIndexes[i] < stirDiaArr240.Length)
                    {
                        fystr           = 240;
                        stirRightTxt[i] = new DxfText($"Y{stirDiaArr240[spacingRightIndexes[i]]}@{spacingRightSec[i]}\n{fystr}", new Point3D(stirrupsRight[i, 2].Start.X - 0.85, -1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[i]);
                    }
                    else if (spacingRightIndexes[i] < stirDiaArr240.Length + stirDiaArr360.Length)
                    {
                        fystr           = 360;
                        stirRightTxt[i] = new DxfText($"T{stirDiaArr360[spacingRightIndexes[i] - stirDiaArr240.Length]}@{spacingRightSec[i]}\n{fystr}", new Point3D(stirrupsRight[i, 2].Start.X - 0.85, -1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[i]);
                    }
                    else if (spacingRightIndexes[i] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length)
                    {
                        fystr           = 400;
                        stirRightTxt[i] = new DxfText($"T{stirDiaArr400[spacingRightIndexes[i] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingRightSec[i]}\n{fystr}", new Point3D(stirrupsRight[i, 2].Start.X - 0.85, -1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[i]);
                    }
                }
                else
                {
                    stirRightTxt[i] = new DxfText($"Increase Dims", new Point3D(stirrupsRight[i, 2].Start.X - 0.85, -1.40, 0), 0.2d);
                    model.Entities.Add(stirRightTxt[i]);
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// 绘制订单信息块
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="DLocation"></param>
        /// <param name="boxWidth"></param>
        /// <param name="configurations"></param>
        public static void Draw(DxfModel dxf, DLocation DLocation,double boxWidth, OrderEntity orderEntity)
        {
            double factor = 0.6f;
            Point3D v1 = new Point3D(DLocation.X,DLocation.Y,DLocation.Z);
            Point3D v2 = new Point3D(DLocation.X + boxWidth, DLocation.Y, DLocation.Z);
            Point3D v3 = new Point3D(DLocation.X + boxWidth, DLocation.Y + 40.0d * factor, DLocation.Z);
            Point3D v4 = new Point3D(DLocation.X, DLocation.Y + 40.0d * factor, DLocation.Z);

            Point3D v5 = new Point3D(DLocation.X, DLocation.Y + 10.0d * factor, DLocation.Z);
            Point3D v6 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y + 10.0d * factor, DLocation.Z);
            Point3D v7 = new Point3D(DLocation.X + boxWidth / 2, DLocation.Y + 10.0d * factor, DLocation.Z);
            Point3D v8 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y + 10.0d * factor, DLocation.Z);
            Point3D v9 = new Point3D(DLocation.X + boxWidth * 7 / 8, DLocation.Y + 10.0d * factor, DLocation.Z);

            Point3D v10 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y + 20.0d * factor, DLocation.Z);
            Point3D v11 = new Point3D(DLocation.X + boxWidth / 2, DLocation.Y + 20.0d * factor, DLocation.Z);
            Point3D v12 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y + 20.0d * factor, DLocation.Z);
            Point3D v13 = new Point3D(DLocation.X + boxWidth * 7 / 8, DLocation.Y + 20.0d * factor, DLocation.Z);
            Point3D v14 = new Point3D(DLocation.X + boxWidth, DLocation.Y + 20.0d * factor, DLocation.Z);

            Point3D v15 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y + 40.0d * factor, DLocation.Z);
            Point3D v16 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y + 40.0d * factor, DLocation.Z);

            Point3D v17 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y, DLocation.Z);
            Point3D v18 = new Point3D(DLocation.X + boxWidth / 2, DLocation.Y, DLocation.Z);
            Point3D v19 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y, DLocation.Z);

            Point3D v20 = new Point3D(DLocation.X + boxWidth, DLocation.Y + 10.0d * factor, DLocation.Z);

            //横向四道
            DxfLine DxfLine12 = new DxfLine(v1, v2);
            dxf.Entities.Add(DxfLine12);

            DxfLine DxfLine520 = new DxfLine(v5, v20);
            dxf.Entities.Add(DxfLine520);

            DxfLine DxfLine1014 = new DxfLine(v10, v14);
            dxf.Entities.Add(DxfLine1014);

            DxfLine DxfLine43 = new DxfLine(v4, v3);
            dxf.Entities.Add(DxfLine43);

            //纵向6道
            DxfLine DxfLine41 = new DxfLine(v4, v1);
            dxf.Entities.Add(DxfLine41);

            DxfLine DxfLine1517 = new DxfLine(v15, v17);
            dxf.Entities.Add(DxfLine1517);

            DxfLine DxfLine1118 = new DxfLine(v11, v18);
            dxf.Entities.Add(DxfLine1118);

            DxfLine DxfLine1619 = new DxfLine(v16, v19);
            dxf.Entities.Add(DxfLine1619);

            DxfLine DxfLine139 = new DxfLine(v13, v9);
            dxf.Entities.Add(DxfLine139);

            DxfLine DxfLine32= new DxfLine(v3, v2);
            dxf.Entities.Add(DxfLine32);

            //文字

            Point3D vt1 = new Point3D(v1.X + 1.0d, v1.Y + 2.5f, v1.Z);
            DxfText t1 = new DxfText("Celebrity 1.0.0", vt1, 2.0d);
            dxf.Entities.Add(t1);

            Point3D vt2 = new Point3D(v17.X + 1.0d, v17.Y + 2.5f, v1.Z);
            DxfText t2 = new DxfText("PREPARER:  "+orderEntity.Preparer, vt2, 2.0d);
            dxf.Entities.Add(t2);

            Point3D vt3 = new Point3D(v18.X + 1.0d, v18.Y + 2.5f, v1.Z);
            DxfText t3 = new DxfText("ENGINEER:  "+orderEntity.Engineer, vt3, 2.0d);
            dxf.Entities.Add(t3);

            Point3D vt4 = new Point3D(v19.X + 1.0d, v19.Y + 2.5f, v1.Z);
            DxfText t4 = new DxfText("SHIP ORDER NO:  "+orderEntity.ShipOrderNo, vt4, 2.0d);
            dxf.Entities.Add(t4);

            Point3D vt5 = new Point3D(v4.X + 1.0d, v10.Y + 2.5f, v1.Z);
            DxfText t5= new DxfText("     AAON  COIL  PRODUCTS  inc.", vt5, 3.0d);
            dxf.Entities.Add(t5);

            Point3D vt6 = new Point3D(v5.X + 1.0d, v5.Y + 2.5f, v1.Z);
            DxfText t6 = new DxfText("LONGVIEW  TEXAS", vt6, 2.0d);
            dxf.Entities.Add(t6);

            Point3D vt7 = new Point3D(v6.X + 1.0d, v6.Y + 2.5f, v1.Z);
            DxfText t7 = new DxfText("PURCHASER:  " + orderEntity.Purchaser, vt7, 2.0d);
            dxf.Entities.Add(t7);

            Point3D vt8 = new Point3D(v7.X + 1.0d, v7.Y + 2.5f, v1.Z);
            DxfText t8 = new DxfText("PURCHASE ORDER:  " + orderEntity.PurchaseOrder, vt8, 2.0d);
            dxf.Entities.Add(t8);

            Point3D vt9 = new Point3D(v8.X + 1.0d, v8.Y + 2.5f, v1.Z);
            DxfText t9 = new DxfText("SERIAL NO:  " + orderEntity.SeriaNo, vt9, 2.0d);
            dxf.Entities.Add(t9);

            Point3D vt10 = new Point3D(v9.X + 1.0d, v9.Y + 2.5f, v1.Z);
            DxfText t10 = new DxfText("DATE: "+DateTime.Now.ToShortDateString(), vt10, 2.0d);
            dxf.Entities.Add(t10);

            Point3D vt11 = new Point3D(v15.X + 1.0d, v15.Y - 7.5f, v1.Z);
            DxfText t11 = new DxfText("JOB NAME:", vt11, 2.0d);
            dxf.Entities.Add(t11);

            Point3D vt12 = new Point3D(v10.X + 10.0d, v10.Y + 2.5f, v1.Z);
            DxfText t12 = new DxfText(orderEntity.JobName, vt12, 2.0d);
            dxf.Entities.Add(t12);

            Point3D vt13 = new Point3D(v16.X + 1.0d, v16.Y - 7.5f, v1.Z);
            DxfText t13 = new DxfText("UNIT TAG:", vt13, 2.0d);
            dxf.Entities.Add(t13);

            Point3D vt14 = new Point3D(v12.X + 20.0d, v12.Y + 2.5f, v1.Z);
            DxfText t14 = new DxfText(orderEntity.UnitTag, vt14, 2.0d);
            dxf.Entities.Add(t14);
        }
Beispiel #18
0
        public void AutoCadReadIxMiliaFileCompatTest()
        {
            // save a DXF file in all the formats that IxMilia.Dxf and AutoCAD support and try to get AutoCAD to read all of them
            using (var directory = new ManageTemporaryDirectory())
            {
                var tempDir  = directory.DirectoryPath;
                var versions = new[]
                {
                    DxfAcadVersion.R9,
                    DxfAcadVersion.R10,
                    DxfAcadVersion.R11,
                    DxfAcadVersion.R12,
                    //DxfAcadVersion.R13,
                    DxfAcadVersion.R14,
                    DxfAcadVersion.R2000,
                    DxfAcadVersion.R2004,
                    DxfAcadVersion.R2007,
                    DxfAcadVersion.R2010,
                    DxfAcadVersion.R2013
                };

                // save the minimal file with all versions
                var file = new DxfFile();
                var text = new DxfText(DxfPoint.Origin, 2.0, "");
                file.Entities.Add(text);
                foreach (var version in versions)
                {
                    var fileName = $"file.{version}.dxf";
                    file.Header.Version = version;
                    text.Value          = version.ToString();
                    var outputPath = Path.Combine(tempDir, fileName);
                    using (var fs = new FileStream(outputPath, FileMode.Create))
                    {
                        file.Save(fs);
                    }
                }

                // open each file in AutoCAD and try to write it back out
                var lines = new List <string>();
                lines.Add("FILEDIA 0");
                foreach (var version in versions)
                {
                    lines.Add("ERASE ALL ");
                    lines.Add($"DXFIN \"{Path.Combine(tempDir, $"file.{version}.dxf")}\"");
                    lines.Add($"DXFOUT \"{Path.Combine(tempDir, $"result.{version}.dxf")}\" V R12 16");
                }

                lines.Add("FILEDIA 1");
                lines.Add("QUIT Y");

                // create and execute the script
                var scriptPath = Path.Combine(tempDir, "script.scr");
                File.WriteAllLines(scriptPath, lines);

                ExecuteAutoCadScript(scriptPath);

                // check each resultant file for the correct version and text
                foreach (var version in versions)
                {
                    DxfFile dxf;
                    using (var fs = new FileStream(Path.Combine(tempDir, $"result.{version}.dxf"), FileMode.Open))
                    {
                        dxf = DxfFile.Load(fs);
                    }

                    Assert.Equal(version.ToString(), ((DxfText)dxf.Entities.Single()).Value);
                }
            }
        }
Beispiel #19
0
 public virtual void Visit(DxfText text)
 {
 }
 /// <summary>
 /// Visits the specified entity.
 /// See the <see cref="IEntityVisitor"/> for more details.
 /// </summary>
 public override void Visit(DxfText text)
 {
     HandleEntity(text);
 }
Beispiel #21
0
 public Class290(DxfText text)
     : base((DxfEntity)text)
 {
 }
Beispiel #22
0
        static void FindEntities(DxfEntityCollection Entities)
        {
            foreach (var entityGroups in Entities)
            {
                if (typeof(DxfLine) != entityGroups.GetType() && typeof(DxfLwPolyline) != entityGroups.GetType() && typeof(DxfMText) != entityGroups.GetType() && typeof(DxfText) != entityGroups.GetType() && typeof(DxfCircle) != entityGroups.GetType() && typeof(DxfHatch) != entityGroups.GetType() && typeof(DxfInsert) != entityGroups.GetType() && typeof(DxfSpline) != entityGroups.GetType())
                {
                    // Console.WriteLine(entityGroups.GetType());
                }

                dxfType.Add(entityGroups.GetType().Name);
                if (typeof(DxfLine) == entityGroups.GetType())
                {
                    dxfLine = entityGroups as DxfLine;

                    int color;

                    if (dxfLine.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfLine.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfLine.Color.Rgb;
                    }


                    CADLine cADLine = new CADLine
                    {
                        parentHandle = dxfLine.OwnerObjectSoftReference.Handle,
                        type         = dxfLine.GetType().Name,
                        color        = color,
                        transform    = dxfLine.Transform.DebugString,
                        startPoint   = dxfLine.Start.ToString(),
                        endPoint     = dxfLine.End.ToString(),
                        lineWeight   = dxfLine.LineWeight
                    };

                    cadEntities.Add(cADLine);
                }


                if (typeof(DxfLwPolyline) == entityGroups.GetType())
                {
                    //Console.WriteLine(dxfLwPolyline);

                    dxfLwPolyline = entityGroups as DxfLwPolyline;

                    string[] arrVertices = new string[dxfLwPolyline.Vertices.Count];
                    for (int i = 0; i < dxfLwPolyline.Vertices.Count; i++)
                    {
                        arrVertices[i] = dxfLwPolyline.Vertices[i].ToString();
                    }

                    int color;
                    if (dxfLwPolyline.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfLwPolyline.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfLwPolyline.Color.Rgb;
                    }


                    CADLwPolyLine cADLwPolyLine = new CADLwPolyLine
                    {
                        parentHandle = dxfLwPolyline.OwnerObjectSoftReference.Handle,
                        type         = dxfLwPolyline.GetType().Name,
                        color        = color,
                        transform    = dxfLwPolyline.Transform.DebugString,

                        vertices = arrVertices,
                        closed   = dxfLwPolyline.Closed.ToString(),
                    };

                    cadEntities.Add(cADLwPolyLine);
                }


                if (typeof(DxfXLine) == entityGroups.GetType())
                {
                    dxfXLine = entityGroups as DxfXLine;
                }

                if (typeof(DxfSpline) == entityGroups.GetType())
                {
                    dxfSpline = entityGroups as DxfSpline;

                    string[] arrFitPoints = new string[dxfSpline.FitPoints.Count];
                    for (int i = 0; i < dxfSpline.FitPoints.Count; i++)
                    {
                        arrFitPoints[i] = dxfSpline.FitPoints[i].ToString();
                    }

                    int color;
                    if (dxfSpline.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfSpline.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfSpline.Color.Rgb;
                    }


                    CADSpline cADSpline = new CADSpline
                    {
                        parentHandle = dxfSpline.OwnerObjectSoftReference.Handle,
                        type         = dxfSpline.GetType().Name,
                        color        = color,
                        transform    = dxfSpline.Transform.DebugString,

                        fitPoints = arrFitPoints,
                    };

                    cadEntities.Add(cADSpline);
                }


                if (typeof(DxfCircle) == entityGroups.GetType())
                {
                    dxfCircle = entityGroups as DxfCircle;

                    int color;
                    if (dxfCircle.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfCircle.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfCircle.Color.Rgb;
                    }


                    CADCircle cADCircle = new CADCircle
                    {
                        parentHandle = dxfCircle.OwnerObjectSoftReference.Handle,
                        type         = dxfCircle.GetType().Name,
                        color        = color,
                        transform    = dxfCircle.Transform.DebugString,

                        center = dxfCircle.Center.ToString(),
                        radius = dxfCircle.Radius
                    };

                    cadEntities.Add(cADCircle);

                    kcircle.Add(dxfCircle);
                }

                if (typeof(DxfArc) == entityGroups.GetType())
                {
                    dxfArc = entityGroups as DxfArc;

                    int color;
                    if (dxfArc.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfArc.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfArc.Color.Rgb;
                    }

                    CADArc cADArc = new CADArc
                    {
                        parentHandle = dxfArc.OwnerObjectSoftReference.Handle,
                        type         = dxfArc.GetType().Name,
                        color        = color,
                        transform    = dxfArc.Transform.DebugString,

                        center     = dxfArc.Center.ToString(),
                        startAngle = dxfArc.StartAngle,
                        endAngle   = dxfArc.EndAngle,
                        radius     = dxfArc.Radius
                    };

                    cadEntities.Add(cADArc);
                }

                if (typeof(DxfEllipse) == entityGroups.GetType())
                {
                    dxfEllipse = entityGroups as DxfEllipse;

                    int color;
                    if (dxfEllipse.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfEllipse.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfEllipse.Color.Rgb;
                    }

                    CADEllipse cADEllipse = new CADEllipse
                    {
                        parentHandle = dxfEllipse.OwnerObjectSoftReference.Handle,
                        type         = dxfEllipse.GetType().Name,
                        color        = color,
                        transform    = dxfEllipse.Transform.DebugString,

                        center            = dxfEllipse.Center.ToString(),
                        majorAxisEndPoint = dxfEllipse.MajorAxisEndPoint.ToString(),
                        minorAxisEndPoint = dxfEllipse.MinorAxisEndPoint.ToString(),
                        startParameter    = dxfEllipse.StartParameter,
                        endParameter      = dxfEllipse.EndParameter
                    };

                    cadEntities.Add(cADEllipse);
                }



                if (typeof(DxfMText) == entityGroups.GetType())
                {
                    dxfMText = entityGroups as DxfMText;

                    int color;
                    if (dxfMText.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfMText.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfMText.Color.Rgb;
                    }


                    if (dxfMText.SimplifiedText == "C座一层平面图")
                    {
                        ktls.Add(dxfMText);
                    }


                    CADMText cADMText = new CADMText
                    {
                        parentHandle = dxfMText.OwnerObjectSoftReference.Handle,
                        type         = dxfMText.GetType().Name,
                        color        = color,
                        transform    = dxfMText.Transform.DebugString,

                        simplifiedText = dxfMText.SimplifiedText.ToString(),
                        fontStyle      = dxfMText.Style.ToString(),
                        size           = dxfMText.Height,

                        attachmentPoint = dxfMText.AttachmentPoint.ToString(),
                        boxHeight       = dxfMText.BoxHeight,
                        boxWidth        = dxfMText.BoxWidth
                    };

                    cadEntities.Add(cADMText);

                    if (dxfMText.SimplifiedText.ToString() == "图 纸 目 录")
                    {
                        //Console.WriteLine(222222);
                        ktls.Add(dxfMText);
                    }
                    if (dxfMText.SimplifiedText.ToString() == "JS-T5-302")
                    {
                        //Console.WriteLine(222222);
                        ktls.Add(dxfMText);
                    }
                }


                if (typeof(DxfText) == entityGroups.GetType())
                {
                    dxfText = entityGroups as DxfText;

                    int color;
                    if (dxfText.Color.ColorType.ToString() == "ByLayer")
                    {
                        color = dxfText.Layer.Color.Rgb;
                    }
                    else
                    {
                        color = dxfText.Color.Rgb;
                    }

                    CADText cADText = new CADText
                    {
                        parentHandle = dxfText.OwnerObjectSoftReference.Handle,
                        type         = dxfText.GetType().Name,
                        color        = color,
                        transform    = dxfText.Transform.DebugString,

                        simplifiedText = dxfText.SimplifiedText.ToString(),
                        fontStyle      = dxfText.Style.ToString(),
                        size           = dxfText.Height,

                        alignMentPoint1 = dxfText.AlignmentPoint1.ToString(),
                        rotationAngle   = dxfText.Rotation,
                    };


                    if (dxfText.SimplifiedText == "JS-T5-001 ")
                    {
                        ktest.Add(dxfText);
                    }

                    cadEntities.Add(cADText);
                }

                if (typeof(DxfInsert) == entityGroups.GetType())
                {
                    dxfInsert = entityGroups as DxfInsert;
                    kins.Add(dxfInsert);


                    if (dxfInsert.Block != null)
                    {
                        ulong count;
                        if (dxfInsert.Block != null)
                        {
                            count = dxfInsert.Block.Handle;
                        }
                        else
                        {
                            count = 0;
                        }

                        CADInsert cADInsert = new CADInsert();


                        cADInsert.parentHandle = dxfInsert.OwnerObjectSoftReference.Handle;
                        cADInsert.type         = dxfInsert.GetType().Name;
                        cADInsert.transform    = dxfInsert.Transform.DebugString;

                        cADInsert.insertPoint   = dxfInsert.InsertionPoint.ToString();
                        cADInsert.rotationAngle = dxfInsert.Rotation;
                        cADInsert.insertName    = dxfInsert.Block.Name;
                        cADInsert.nowHandle     = count;
                        cADInsert.insertScale   = dxfInsert.ScaleFactor.ToString();

                        cadEntities.Add(cADInsert);

                        FindEntities(dxfInsert.Block.Entities);
                    }
                }



                if (typeof(DxfAttributeDefinition) == entityGroups.GetType())
                {
                    dxfAttributeDefinition = entityGroups as DxfAttributeDefinition;
                    //Console.WriteLine(dxfAttributeDefinition);
                }

                if (typeof(DxfDimension.Linear) == entityGroups.GetType())
                {
                    Console.WriteLine(11111);
                }
            }
        }
        public static void StirrupRightTxt(DxfModel model, int nSpans)
        {
            //Stirrups Text Left/*------------------*/
            double fystr = -1;

            DxfText[] stirRightTxt = new DxfText[nSpans];
            for (int i = 0; i < stirRightTxt.Length - 1; i++)
            {
                if (indexesRight[i] != -2)
                {
                    if (indexesRight[i] < stirDiaArr240.Length)
                    {
                        fystr           = 240;
                        stirRightTxt[i] = new DxfText($"Y{stirDiaArr240[indexesRight[i]]}@{spacingRightSec[i]}"
                                                      , new Point3D(DXFRebar.stirrupsRight[i, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[i]);
                    }
                    else if (indexesRight[i] < stirDiaArr240.Length + stirDiaArr360.Length)
                    {
                        fystr           = 360;
                        stirRightTxt[i] = new DxfText($"T{stirDiaArr360[indexesRight[i] - stirDiaArr240.Length]}@{spacingRightSec[i]}"
                                                      , new Point3D(DXFRebar.stirrupsRight[i, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[i]);
                    }
                    else if (indexesRight[i] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length)
                    {
                        fystr           = 400;
                        stirRightTxt[i] = new DxfText($"T{stirDiaArr400[indexesRight[i] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingRightSec[i]}"
                                                      , new Point3D(DXFRebar.stirrupsRight[i, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[i]);
                    }
                }
                else
                {
                    stirRightTxt[i] = new DxfText($"Increase Dims"
                                                  , new Point3D(DXFRebar.stirrupsRight[i, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                    model.Entities.Add(stirRightTxt[i]);
                }
            }

            //case of cantilever at end
            if (GeometryEditorVM.GeometryEditor.RestraintsCollection[RFTCanvas.SpanVals.Length].SelectedRestraint != Restraints.NoRestraints)
            {
                if (indexesRight[stirRightTxt.Length - 1] != -2)
                {
                    if (indexesRight[stirRightTxt.Length - 1] < stirDiaArr240.Length)
                    {
                        fystr = 240;
                        stirRightTxt[stirRightTxt.Length - 1] = new DxfText($"Y{stirDiaArr240[indexesRight[stirRightTxt.Length - 1]]}@{spacingRightSec[stirRightTxt.Length - 1]}"
                                                                            , new Point3D(DXFRebar.stirrupsRight[stirRightTxt.Length - 1, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[stirRightTxt.Length - 1].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[stirRightTxt.Length - 1]);
                    }
                    else if (indexesRight[stirRightTxt.Length - 1] < stirDiaArr240.Length + stirDiaArr360.Length)
                    {
                        fystr = 360;
                        stirRightTxt[stirRightTxt.Length - 1] = new DxfText($"T{stirDiaArr360[indexesRight[stirRightTxt.Length - 1] - stirDiaArr240.Length]}@{spacingRightSec[stirRightTxt.Length - 1]}"
                                                                            , new Point3D(DXFRebar.stirrupsRight[stirRightTxt.Length - 1, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[stirRightTxt.Length - 1].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[stirRightTxt.Length - 1]);
                    }
                    else if (indexesRight[stirRightTxt.Length - 1] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length)
                    {
                        fystr = 400;
                        stirRightTxt[stirRightTxt.Length - 1] = new DxfText($"T{stirDiaArr400[indexesRight[stirRightTxt.Length - 1] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingRightSec[stirRightTxt.Length - 1]}"
                                                                            , new Point3D(DXFRebar.stirrupsRight[stirRightTxt.Length - 1, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[stirRightTxt.Length - 1].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirRightTxt[stirRightTxt.Length - 1]);
                    }
                }
                else
                {
                    stirRightTxt[stirRightTxt.Length - 1] = new DxfText($"Increase Dims"
                                                                        , new Point3D(DXFRebar.stirrupsRight[stirRightTxt.Length - 1, 2].Start.X - 1.20 /**/, DXFPoints.startPointsBot[stirRightTxt.Length - 1].Y - 1.40, 0), 0.2d);
                    model.Entities.Add(stirRightTxt[stirRightTxt.Length - 1]);
                }
            }
        }

        #endregion
    }
}
Beispiel #24
0
 public void Visit(DxfText text)
 {
     this.method_0((DxfEntity)text);
 }
Beispiel #25
0
 public void Visit(DxfText text)
 {
     this.bool_0 = true;
 }
Beispiel #26
0
 public Class970(DxfText text, DrawContext.Wireframe drawContext, ArgbColor color)
 {
     this.dxfText_0   = text;
     this.wireframe_0 = drawContext;
     this.argbColor_0 = color;
 }
Beispiel #27
0
 public void CreateText(DxfText text, DrawContext.Wireframe drawContext, ArgbColor color)
 {
     this.linkedListNodeRef_0.Insert((IWireframeDrawable) new WireframeGraphicsCache.Class970(text, drawContext, color));
 }
 public void CreateText(DxfText text)
 {
     this.iwireframeGraphicsFactory2_0.CreateText(text);
 }
Beispiel #29
0
        //画单门有门闩的矩形框
        public static void writeDoorBarRectangle(DxfModel doc, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space,double barHeight,double barWidth)
        {
            //最外围矩形
            writeOuterDoorRectangle(doc, DLocation, height, width);

            //中间矩形
            DxfLine midBottomDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z));

            DxfLine midDownLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z), new Point3D(DLocation.X + outer_mid_space, DLocation.Y + height / 4, DLocation.Z));

            DxfLine midMidLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + height / 4 + barHeight, DLocation.Z), new Point3D(DLocation.X + outer_mid_space, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z));

            DxfLine midUpLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + 3*height / 4, DLocation.Z), new Point3D(DLocation.X + outer_mid_space, DLocation.Y +height-outer_mid_space, DLocation.Z));

            DxfLine midTopDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + height - outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + height - outer_mid_space, DLocation.Z));

            DxfLine midRightDxfLine = new DxfLine(new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + height - outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z));

            doc.Entities.Add(midBottomDxfLine);
            doc.Entities.Add(midDownLeftDxfLine);
            doc.Entities.Add(midMidLeftDxfLine);
            doc.Entities.Add(midUpLeftDxfLine);
            doc.Entities.Add(midTopDxfLine);
            doc.Entities.Add(midRightDxfLine);

            //内部矩形

            DxfLine inBottomDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + outer_in_space, DLocation.Z), new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + outer_in_space, DLocation.Z));

            DxfLine inDownLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + outer_in_space, DLocation.Z), new Point3D(DLocation.X + outer_in_space, DLocation.Y + height/4, DLocation.Z));

            DxfLine inmidLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + height / 4 + barHeight, DLocation.Z), new Point3D(DLocation.X + outer_in_space, DLocation.Y + 3*height/4 - barHeight, DLocation.Z));

            DxfLine inUpLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + 3*height / 4, DLocation.Z), new Point3D(DLocation.X + outer_in_space, DLocation.Y + height-outer_in_space, DLocation.Z));

            DxfLine inTopDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + height - outer_in_space, DLocation.Z), new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + height - outer_in_space, DLocation.Z));

            DxfLine inRightDxfLine = new DxfLine(new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + height - outer_in_space, DLocation.Z), new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + outer_in_space, DLocation.Z));

            doc.Entities.Add(inBottomDxfLine);
            doc.Entities.Add(inDownLeftDxfLine);
            doc.Entities.Add(inmidLeftDxfLine);
            doc.Entities.Add(inUpLeftDxfLine);
            doc.Entities.Add(inTopDxfLine);
            doc.Entities.Add(inRightDxfLine);

            //门中文字
            double DxfTextHeight = DoorInitHeightAndWidth.DxfTextHeight;
            for (int i = 0; i < DxfText.Length; i++)
            {
                DxfText doorRectangleDxfText = new DxfText(DxfText[i], new Point3D(DLocation.X + width / 3, DLocation.Y + 3 * height / 4 - i * DxfTextHeight, DLocation.Z), DxfTextHeight);

                doc.Entities.Add(doorRectangleDxfText);
            }
        }
Beispiel #30
0
        /// <summary>
        /// 绘制左下角区域的Section块
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="DLocation"></param>
        /// <param name="configurations"></param>
        public static void Draw(DxfModel dxf, DLocation DLocation,SectionEntity sectionEntity)
        {
            double factor=0.6f;
            Point3D v1 = new Point3D(DLocation.X, DLocation.Y + 40.0d*factor, DLocation.Z);
            Point3D v2 = new Point3D(DLocation.X + 50.0d * factor, DLocation.Y + 40.0d * factor, DLocation.Z);
            Point3D v3 = new Point3D(DLocation.X + 90.0d * factor, DLocation.Y + 40.0d * factor, DLocation.Z);
            Point3D v4 = new Point3D(DLocation.X + 140.0d * factor, DLocation.Y + 40.0d * factor, DLocation.Z);

            Point3D v5 = new Point3D(DLocation.X, DLocation.Y + 50.0d * factor, DLocation.Z);
            Point3D v6 = new Point3D(DLocation.X + 140.0d * factor, DLocation.Y + 50.0d * factor, DLocation.Z);

            Point3D v7 = new Point3D(DLocation.X, DLocation.Y + 60.0d * factor, DLocation.Z);
            Point3D v8 = new Point3D(DLocation.X + 140.0d * factor, DLocation.Y + 60.0d * factor, DLocation.Z);

            Point3D v9 = new Point3D(DLocation.X, DLocation.Y + 70.0d * factor, DLocation.Z);
            Point3D v10 = new Point3D(DLocation.X + 50.0d * factor, DLocation.Y + 70.0d * factor, DLocation.Z);
            Point3D v11 = new Point3D(DLocation.X + 90.0d * factor, DLocation.Y + 70.0d * factor, DLocation.Z);
            Point3D v12 = new Point3D(DLocation.X + 140.0d * factor, DLocation.Y + 70.0d * factor, DLocation.Z);

            //横向四道
            DxfLine DxfLine14 = new DxfLine(v1, v4);
            dxf.Entities.Add(DxfLine14);

            DxfLine DxfLine56 = new DxfLine(v5, v6);
            dxf.Entities.Add(DxfLine56);

            DxfLine DxfLine78 = new DxfLine(v7, v8);
            dxf.Entities.Add(DxfLine78);

            DxfLine DxfLine912 = new DxfLine(v9, v12);
            dxf.Entities.Add(DxfLine912);

            //纵向四道
            DxfLine DxfLine91 = new DxfLine(v9, v1);
            dxf.Entities.Add(DxfLine91);

            DxfLine DxfLine210 = new DxfLine(v2, v10);
            dxf.Entities.Add(DxfLine210);

            DxfLine DxfLine311 = new DxfLine(v3, v11);
            dxf.Entities.Add(DxfLine311);

            DxfLine DxfLine412 = new DxfLine(v4, v12);
            dxf.Entities.Add(DxfLine412);

            //new DxfDxfText("Line, DxfCircle, DxfArc, dimension, DxfText (R12)", new Point3D(0, 18d, 0d), 1.5d,)

            //DxfTextStyle style = new DxfTextStyle("True type font", "Arial.ttf");
            Point3D vt1 = new Point3D(v1.X+1.0d, v1.Y+2.5f, v1.Z);
            DxfText t1 = new DxfText("COIL", vt1, 2.0d);
            dxf.Entities.Add(t1);

            Point3D vt2 = new Point3D(v2.X + 1.0d, v2.Y + 2.5f, v2.Z);
            DxfText t2 = new DxfText("CLF", vt2, 2.0d);
            dxf.Entities.Add(t2);

            Point3D vt3 = new Point3D(v3.X + 1.0d, v3.Y + 2.5f, v3.Z);
            DxfText t3 = new DxfText(sectionEntity.CoolValue, vt3, 2.0d);
            dxf.Entities.Add(t3);

            Point3D vt4 = new Point3D(v5.X + 1.0d, v5.Y + 2.5f, v5.Z);
            DxfText t4 = new DxfText("FILTER", vt4, 2.0d);

            dxf.Entities.Add(t4);

            Point3D vt5 = new Point3D(v2.X + 1.0d, v5.Y + 2.5f, v5.Z);
            DxfText t5 = new DxfText("FTA", vt5, 2.0d);
            dxf.Entities.Add(t5);

            Point3D vt6 = new Point3D(v3.X + 1.0d, v5.Y + 2.5f, v5.Z);
            DxfText t6 = new DxfText(sectionEntity.FilterValue, vt6, 2.0d);
            dxf.Entities.Add(t6);

            Point3D vt7 = new Point3D(v7.X + 1.0d, v7.Y + 2.5f, v7.Z);
            DxfText t7 = new DxfText("SECTION", vt7, 2.0d);
            dxf.Entities.Add(t7);

            Point3D vt8 = new Point3D(v2.X + 1.0d, v7.Y + 2.5f, v7.Z);
            DxfText t8 = new DxfText("MODULE", vt8, 2.0d);
            dxf.Entities.Add(t8);

            Point3D vt9 = new Point3D(v3.X + 1.0d, v7.Y + 2.5f, v7.Z);
            DxfText t9 = new DxfText("CLEARANCE", vt9, 2.0d);
            dxf.Entities.Add(t9);
        }
Beispiel #31
0
        /// <summary>
        /// 门把手绘制
        /// </summary>
        /// <param name="dxf"></param>
        /// <param name="DLocation"></param>
        public static void Draw(DxfModel dxf, DLocation DLocation)
        {
            double factor = 0.05f;
             double distance = 30;
            //底部小圆的圆心
             Point3D sDxfCircle = new Point3D(DLocation.X + 10 * factor, DLocation.Y, DLocation.Z);
            //上部同心圆圆心
             Point3D bDxfCircle = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor + distance*factor, DLocation.Z);

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

             Point3D v1 = new Point3D(
                 DLocation.X + 10 * factor - double.Parse((5 * factor * Math.Cos(alpha)).ToString()),
                 DLocation.Y + 5 * factor - double.Parse((5 * factor * Math.Sin(alpha)).ToString()),
                 DLocation.Z);

             Point3D v2 = new Point3D(
                  DLocation.X + 10 * factor + double.Parse((5 * factor * Math.Cos(alpha)).ToString()),
                  DLocation.Y + 5 * factor - double.Parse((5 * factor * Math.Sin(alpha)).ToString()),
                  DLocation.Z);

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

             Point3D v5 = new Point3D(
             DLocation.X + 10 * factor  + double.Parse((8*factor*Math.Cos(alpha)).ToString()),
             DLocation.Y + 5 * factor + distance * factor - double.Parse((8 * factor * Math.Sin(alpha)).ToString()),
             DLocation.Z
             );
             DxfLine DxfLine14 = new DxfLine(v1, v4);
             dxf.Entities.Add(DxfLine14);

             DxfLine DxfLine25 = new DxfLine(v2, v5);
             dxf.Entities.Add(DxfLine25);

             //DxfArc
             DxfArc DxfArc = new DxfArc(
                 new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor, DLocation.Z),
                 5 * factor, Convert.ToInt32(180 + alpha * 180 / Math.PI), Convert.ToInt32(360 - alpha * 180 / Math.PI));
             dxf.Entities.Add(DxfArc);

             //DxfArcup
             DxfArc DxfArcup = new DxfArc(
                 new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor + distance * factor, DLocation.Z),
                 8 * factor, Convert.ToInt32(-alpha * 180 / Math.PI), Convert.ToInt32(180 + alpha * 180 / Math.PI));
             dxf.Entities.Add(DxfArcup);

             //DxfArcround
             DxfArc DxfArcround = new DxfArc(
                 new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor + distance * factor, DLocation.Z),
                 10 * factor,
                 Convert.ToInt32(-(alpha +beta) * 180 / Math.PI),
                 Convert.ToInt32(180 + (alpha +beta) * 180 / Math.PI));
             dxf.Entities.Add(DxfArcround);

             //DxfCircle
             Point3D centerWCS = new Point3D(DLocation.X+10*factor, DLocation.Y+5*factor+distance*factor, DLocation.Z);
             DxfCircle DxfCircle = new DxfCircle((Point3D)centerWCS, 7 * factor);
             dxf.Entities.Add(DxfCircle);

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

             //DxfText
             DxfText DxfText1 = new DxfText("A", t1, 0.2f);
             dxf.Entities.Add(DxfText1);

             //DxfText
             DxfText DxfText2 = new DxfText("A", t2, 0.2f);
             dxf.Entities.Add(DxfText2);

             //DxfText
             DxfText DxfText3 = new DxfText("O", t3, 0.2f);
             dxf.Entities.Add(DxfText3);

             //DxfText
             DxfText DxfText4 = new DxfText("N", t4, 0.2f);
             dxf.Entities.Add(DxfText4);
        }
        public static void StirrupLeftTxt(DxfModel model, int nSpans)
        {
            //Stirrups Text Left/*------------------*/
            double fystr = -1;

            stirLeftTxt = new DxfText[nSpans];

            //Case of cantilever at start:

            if (GeometryEditorVM.GeometryEditor.RestraintsCollection[0].SelectedRestraint != Restraints.NoRestraints)
            {
                if (indexesLeft[0] != -2)
                {
                    if (indexesLeft[0] < stirDiaArr240.Length)
                    {
                        fystr          = 240;
                        stirLeftTxt[0] = new DxfText($"Y{stirDiaArr240[indexesLeft[0]]}@{spacingLeftSec[0]}"
                                                     , new Point3D(DXFRebar.stirrupsLeft[0, 2].Start.X - 0.85, DXFPoints.startPointsBot[0].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirLeftTxt[0]);
                    }
                    else if (indexesLeft[0] < stirDiaArr240.Length + stirDiaArr360.Length)
                    {
                        fystr          = 360;
                        stirLeftTxt[0] = new DxfText($"T{stirDiaArr360[indexesLeft[0] - stirDiaArr240.Length]}@{spacingLeftSec[0]}"
                                                     , new Point3D(DXFRebar.stirrupsLeft[0, 2].Start.X - 0.85, DXFPoints.startPointsBot[0].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirLeftTxt[0]);
                    }
                    else if (indexesLeft[0] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length)
                    {
                        fystr          = 400;
                        stirLeftTxt[0] = new DxfText($"T{stirDiaArr400[indexesLeft[0] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingLeftSec[0]}"
                                                     , new Point3D(DXFRebar.stirrupsLeft[0, 2].Start.X - 0.85, DXFPoints.startPointsBot[0].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirLeftTxt[0]);
                    }
                }
                else
                {
                    stirLeftTxt[0] = new DxfText($"Increase Dims"
                                                 , new Point3D(DXFRebar.stirrupsLeft[0, 2].Start.X - 0.85, DXFPoints.startPointsBot[0].Y - 1.40, 0), 0.2d);
                    model.Entities.Add(stirLeftTxt[0]);
                }
            }

            for (int i = 1; i < stirLeftTxt.Length; i++)
            {
                if (indexesLeft[i] != -2)
                {
                    if (indexesLeft[i] < stirDiaArr240.Length)
                    {
                        fystr          = 240;
                        stirLeftTxt[i] = new DxfText($"Y{stirDiaArr240[indexesLeft[i]]}@{spacingLeftSec[i]}"
                                                     , new Point3D(DXFRebar.stirrupsLeft[i, 2].Start.X - 0.85, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirLeftTxt[i]);
                    }
                    else if (indexesLeft[i] < stirDiaArr240.Length + stirDiaArr360.Length)
                    {
                        fystr          = 360;
                        stirLeftTxt[i] = new DxfText($"T{stirDiaArr360[indexesLeft[i] - stirDiaArr240.Length]}@{spacingLeftSec[i]}"
                                                     , new Point3D(DXFRebar.stirrupsLeft[i, 2].Start.X - 0.85, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirLeftTxt[i]);
                    }
                    else if (indexesLeft[i] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length)
                    {
                        fystr          = 400;
                        stirLeftTxt[i] = new DxfText($"T{stirDiaArr400[indexesLeft[i] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingLeftSec[i]}"
                                                     , new Point3D(DXFRebar.stirrupsLeft[i, 2].Start.X - 0.85, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                        model.Entities.Add(stirLeftTxt[i]);
                    }
                }
                else
                {
                    stirLeftTxt[i] = new DxfText($"Increase Dims"
                                                 , new Point3D(DXFRebar.stirrupsLeft[i, 2].Start.X - 0.85, DXFPoints.startPointsBot[i].Y - 1.40, 0), 0.2d);
                    model.Entities.Add(stirLeftTxt[i]);
                }
            }
        }
Beispiel #33
0
 public static Text ToText(this DxfText text)
 {
     return(new Text(text.Value ?? string.Empty, text.Location.ToPoint(), text.Normal.ToVector(), text.TextHeight, text.Rotation, text.GetEntityColor(), text));
 }
Beispiel #34
0
        public static void puzzle(List<string> dxfFileNameList,List<string> dxfTopViewList,List<TextValue> valueList,string frameName)
        {
            DxfModel targetModel=new DxfModel();
            testModel = targetModel;
            targetModel.TextStyles.Add(textStyle);
            CloneContext cloneContext = new CloneContext(targetModel, ReferenceResolutionType.CloneMissing);
            for (int i = 0; i < dxfFileNameList.Count;i++ )
            {
                    DxfModel sourceModel = DxfReader.Read(dxfFileNameList[i]);
                    //第一个图形作为初始
                    if (i == 0)
                    {
                        //拼到一个图纸中后,Entity应该参照那个的左下角坐标
                        location = getRelativeStartLocation(sourceModel);
                        //源图纸中Entity的左下角坐标
                        relativeStartLocation = getRelativeStartLocation(sourceModel);
                        //保存第一个算好的左下角坐标
                        firstDimensionLocation = location;
                        foreach (DxfEntity entity in sourceModel.Entities)
                        {
                            DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext);
                            clonedEntity = getCaculateLocationEntity(clonedEntity, location, relativeStartLocation);
                            targetModel.Entities.Add(clonedEntity);
                        }
                        rightLocation = getNextStartLocation(positionList);
                        //记录最后一点坐标
                        lastDimensionLocation = rightLocation;
                        //清空坐标位置链表
                        positionList.RemoveAll(name => { return true;});

                        //花标注
                        DxfDimension.Aligned dxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
                        dxfDimension.ExtensionLine1StartPoint = new Point3D(location.X, location.Y, location.Z);
                        dxfDimension.ExtensionLine2StartPoint = new Point3D(rightLocation.X, rightLocation.Y, rightLocation.Z);
                        dxfDimension.DimensionStyleOverrides.TextHeight = 56d;
                        dxfDimension.DimensionStyleOverrides.ArrowSize = 56d;
                        dxfDimension.Text = getDimensionText(dxfDimension);
                        // dxfDimension.DimensionLineLocation = new Point3D((location.X+rightLocation.X)/2,location.Y-8,location.Z);
                        targetModel.Entities.Add(dxfDimension);
                    }
                    else
                    {
                        location = rightLocation;
                        relativeStartLocation = getRelativeStartLocation(sourceModel);
                        foreach (DxfEntity entity in sourceModel.Entities)
                        {
                            DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext);
                            clonedEntity = getCaculateLocationEntity(clonedEntity, location, relativeStartLocation);
                            targetModel.Entities.Add(clonedEntity);
                        }
                        rightLocation = getNextStartLocation(positionList);
                        lastDimensionLocation = rightLocation;
                        //计算最后一个元素右上角坐标
                        if (i == dxfFileNameList.Count - 1)
                        {
                            rightTopDimensionLocation = getRightTopLocation(positionList);
                            largestLocation = getLargestXLocation(positionList);
                        }

                        positionList.RemoveAll(name => { return true; });

                        //花标注
                        DxfDimension.Aligned dxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
                        dxfDimension.ExtensionLine1StartPoint = new Point3D(location.X, location.Y, location.Z);
                        dxfDimension.ExtensionLine2StartPoint = new Point3D(rightLocation.X, rightLocation.Y, rightLocation.Z);
                        dxfDimension.DimensionStyleOverrides.TextHeight = 56d;
                        dxfDimension.DimensionStyleOverrides.ArrowSize = 56d;
                        dxfDimension.Text = getDimensionText(dxfDimension);
                        targetModel.Entities.Add(dxfDimension);
                    }
            }

            DxfDimension.Aligned wholeDxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
            wholeDxfDimension.ExtensionLine1StartPoint = new Point3D(firstDimensionLocation.X, firstDimensionLocation.Y, firstDimensionLocation.Z);
            wholeDxfDimension.ExtensionLine2StartPoint = new Point3D(lastDimensionLocation.X, lastDimensionLocation.Y, lastDimensionLocation.Z);
            wholeDxfDimension.DimensionStyleOverrides.TextHeight = 56d;
            wholeDxfDimension.DimensionStyleOverrides.ArrowSize = 56d;
            wholeDxfDimension.Text = getDimensionText(wholeDxfDimension);
            wholeDxfDimension.DimensionLineLocation = new Point3D(firstDimensionLocation.X+lastDimensionLocation.X,firstDimensionLocation.Y-1000,firstDimensionLocation.Z);
            targetModel.Entities.Add(wholeDxfDimension);

            DxfDimension.Aligned rightDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle);
            rightDimension.ExtensionLine1StartPoint = new Point3D(lastDimensionLocation.X, lastDimensionLocation.Y, lastDimensionLocation.Z);
            rightDimension.ExtensionLine2StartPoint = new Point3D(rightTopDimensionLocation.X, rightTopDimensionLocation.Y, rightTopDimensionLocation.Z);
            rightDimension.DimensionStyleOverrides.TextHeight = 56d;
            rightDimension.DimensionStyleOverrides.ArrowSize = 56d;
            rightDimension.Text = getDimensionText(rightDimension);
            rightDimension.DimensionLineLocation = new Point3D(largestLocation.X + 200, firstDimensionLocation.Y, firstDimensionLocation.Z);
            targetModel.Entities.Add(rightDimension);

            //绘制俯视图
            for (int i = 0; i < dxfTopViewList.Count;i++ )
            {
                DxfModel topViewSourceModel = new DxfModel();
                topViewSourceModel = DxfReader.Read(dxfTopViewList[i]);
                if (i == 0)
                {
                    topViewLocation = new DLocation(firstDimensionLocation.X, rightTopDimensionLocation.Y + RelativeDistance.yTopViewDistance, firstDimensionLocation.Z);
                    topViewRelativeLocation = getTopViewRelativeStartLocation(topViewSourceModel);
                }
                else
                {
                    topViewLocation = topViewRightLocation;
                        DxfModel filterModel = getFilterBottomNotLineDxfModel(topViewSourceModel);
                        topViewRelativeLocation = getTopViewRelativeStartLocation(filterModel);

                }

                foreach(DxfEntity entity in topViewSourceModel.Entities)
                {
                    DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext);
                    clonedEntity = getCaculateLocationEntity(clonedEntity, topViewLocation, topViewRelativeLocation);
                    targetModel.Entities.Add(clonedEntity);
                }
                topViewRightLocation = getTopViewNextStartLocation(positionList);
                positionList.RemoveAll(name=>{return true;});
            }

            // 复制frame框体
            DxfModel sourceFrameModel = new DxfModel();
            sourceFrameModel = DxfReader.Read(frameName);
            DLocation frameLeftDownLocation = getFrameLeftDownLocation(sourceFrameModel);
            frameLastLineX = getFrameLastVerticalLineX(sourceFrameModel);
            Point2D frameRightPoint2D = getFrameRightPoint(sourceFrameModel);
            //这里求的是宽度比较,因为Frame的最后位置还没确定,不能单纯的考个别点进行位置大小比较
            if ((largestLocation.X-firstDimensionLocation.X+RelativeDistance.xDistance)>= (frameRightPoint2D.X-frameLeftDownLocation.X))
            {
                RelativeDistance.increaseWidth = (largestLocation.X - firstDimensionLocation.X + RelativeDistance.xDistance) - (frameRightPoint2D.X - frameLeftDownLocation.X) + RelativeDistance.xDistance;
            }
            else
            {
                RelativeDistance.increaseWidth = 0;
            }
            foreach (DxfEntity entity in sourceFrameModel.Entities)
            {
                DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext);
                clonedEntity = getFrameEntity(clonedEntity, firstDimensionLocation, frameLeftDownLocation, RelativeDistance.increaseWidth);
                targetModel.Entities.Add(clonedEntity);
            }

            //传递表单数据值
            foreach(TextValue textValue in textValueList){
                foreach(TextValue transFormValue in valueList){
                    if (textValue.text.Equals(transFormValue.text))
                    {
                        DxfText dxfText = new DxfText();
                        dxfText.Text = transFormValue.value;
                        dxfText.Height = textValue.height;
                        dxfText.Thickness = 0.5d;
                        dxfText.AlignmentPoint1 = new Point3D(textValue.valuePosition.X, textValue.valuePosition.Y, textValue.valuePosition.Z);
                        dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                        targetModel.Entities.Add(dxfText);
                    }
                }
            }

            cloneContext.ResolveReferences();

            DxfWriter.Write("cloneTest.dxf", targetModel);
        }
Beispiel #35
0
        //Dxf/dwg Export with eshow layers
        public Stream ExportLayout(Stream input)
        {
            string body = new StreamReader(input).ReadToEnd();
            NameValueCollection _nvc  = HttpUtility.ParseQueryString(body);
            dynamic             _data = @_nvc["Data"];
            string _fileName          = _nvc["FileName"];
            string _client_id         = _nvc["ClientId"];
            string _show_id           = _nvc["ShowId"];
            string _accessKey         = @_nvc["AccessKey"];
            string _secretKey         = @_nvc["SecretKey"];
            string _bucketName        = @_nvc["BucketName"];

            DxfModel _model        = ReadDxf("h://dxf_uploads//" + _client_id + " // " + _show_id + "//" + _fileName);
            DxfLayer _numberLayer  = new DxfLayer("ESHOW_NUMBERS");
            DxfLayer _outlineLayer = new DxfLayer("ESHOW_BOOTHS");

            _model.Layers.Add(_numberLayer);
            _model.Layers.Add(_outlineLayer);

            //parsing Json Array
            List <Booth> _boothList = JsonConvert.DeserializeObject <List <Booth> >(_data);
            string       _origin    = null;

            foreach (var _originInfo in _boothList)
            {
                if (_originInfo.SHAPE.Equals("ORIGIN", StringComparison.InvariantCultureIgnoreCase))
                {
                    _origin = _originInfo.INSERTPOINT;
                }
            }

            if (_origin != null)
            {
                foreach (var _booth in _boothList)
                {
                    if ((!_booth.SHAPE.Equals("ORIGIN", StringComparison.InvariantCultureIgnoreCase)) || (!_booth.SHAPE.Equals("GRIDLINE", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        switch (_booth.SHAPE)
                        {
                        case "Box":
                            string       insertPoint    = _booth.INSERTPOINT;
                            int          deltaX         = int.Parse(_booth.SIZEX) * 12;
                            int          deltaY         = int.Parse(_booth.SIZEY) * 12;
                            string       boothNumber    = _booth.BOOTHNUMBER;
                            string       vertexOriginal = UntransfromPoint(insertPoint, _origin);
                            List <Point> VertexList     = GetVerticesFromVertex(vertexOriginal, deltaX, deltaY);
                            //converting Windows points to Cad Points
                            Point2D[] vertexPoints = new Point2D[4];
                            for (int i = 0; i < VertexList.Count; i++)
                            {
                                vertexPoints[i].X = VertexList[i].X;
                                vertexPoints[i].Y = VertexList[i].Y;
                            }
                            //Add Booth to Dxf
                            DxfPolyline2D booth = new DxfPolyline2D();
                            booth.Vertices.AddRange(vertexPoints);
                            booth.Layer  = _outlineLayer;
                            booth.Closed = true;
                            booth.Color  = EntityColor.ByLayer;
                            _model.Entities.Add(booth);

                            //Add text to DXF
                            Point   textPoint = new Point(VertexList[0].X + 10, VertexList[0].Y - 50);
                            DxfText boothText = new DxfText(boothNumber, new Point3D(textPoint.X, textPoint.Y, 0d), 10d)
                            {
                                Layer = _numberLayer,
                                Color = EntityColor.ByLayer
                            };
                            _model.Entities.Add(boothText);
                            break;

                        case "Polygon":
                            insertPoint = _booth.INSERTPOINT;
                            int[]      ins       = insertPoint.Split(',').Select(n => Convert.ToInt32(n)).ToArray();
                            List <int> insPoints = ins.OfType <int>().ToList();
                            insPoints.RemoveAt(insPoints.Count - 1);
                            insPoints.RemoveAt(insPoints.Count - 1);
                            List <Point> vertexList = new List <Point>();
                            Point        tempPoint;
                            //converting to vertices
                            for (int i = 0; i <= insPoints.Count; i += 2)
                            {
                                tempPoint = new Point(insPoints[i], y: insPoints[i + 1]);
                                vertexList.Add(tempPoint);
                            }
                            boothNumber = _booth.BOOTHNUMBER;
                            //untransfroming points
                            for (int i = 0; i < vertexList.Count; i++)
                            {
                                vertexList[i] = UntransfromPoint(vertexList[i], _origin);
                            }
                            //converting Windows points to Cad Points
                            vertexPoints = new Point2D[vertexList.Count];
                            for (int i = 0; i < vertexList.Count; i++)
                            {
                                vertexPoints[i].X = vertexList[i].X;
                                vertexPoints[i].Y = vertexList[i].Y;
                            }
                            booth = new DxfPolyline2D();
                            booth.Vertices.AddRange(vertexPoints);
                            booth.Layer  = _outlineLayer;
                            booth.Closed = true;
                            booth.Color  = EntityColor.ByLayer;
                            _model.Entities.Add(booth);

                            //Add text to DXF
                            textPoint = new Point(vertexList[0].X + 10, vertexList[0].Y - 50);
                            boothText = new DxfText(boothNumber, new Point3D(textPoint.X, textPoint.Y, 0d), 10d)
                            {
                                Layer = _numberLayer,
                                Color = EntityColor.ByLayer
                            };
                            _model.Entities.Add(boothText);
                            break;
                        }
                    }
                }
            }
            // write new DWG
            Stream dwgStream;
            string outfile    = Path.GetFileNameWithoutExtension(Path.GetFullPath(_fileName));
            string fileNameS3 = outfile + "_export.dwg";
            string filePath   = "h://dxf_uploads//" + _client_id + " // " + _show_id + "//" + fileNameS3;

            using (dwgStream = new FileStream(@filePath, FileMode.Create, FileAccess.Write))
            {
                DwgWriter.Write(dwgStream, _model);
            }
            //Upload to s3
            //string _subDirectory = _client_id + @"/" + _show_id + @"/dxf";
            //AmazonS3Transfer amazonS3Transfer = new AmazonS3Transfer();
            //bool uploadStatus = amazonS3Transfer.sendMyFileToS3(dwgStream, _bucketName, _subDirectory, fileNameS3, _accessKey, _secretKey);
            bool uploadStatus = true;
            Dictionary <string, string> status = new Dictionary <string, string>();

            if (uploadStatus == true)
            {
                status.Add("status_code", "1");
            }
            else
            {
                status.Add("status_code", "0");
            }
            string result = JsonConvert.SerializeObject(status);

            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            return(new MemoryStream(Encoding.UTF8.GetBytes(result)));
        }
Beispiel #36
0
 public void CreateText(DxfText text)
 {
     throw new NotImplementedException();
 }
Beispiel #37
0
        public static IEnumerable <Tuple <string, DxfEntity> > AssociateEntitiesWithDescriptions(IEnumerable <DxfEntity> input_entities)
        {
            List <LocatedEntity>              graphical_object_locations = new List <LocatedEntity>();
            List <LocatedDescription>         desciptions_locations      = new List <LocatedDescription>();
            List <Tuple <string, DxfEntity> > ret = new List <Tuple <string, DxfEntity> >();

            foreach (DxfEntity entity in input_entities)
            {
                DxfPoint point = DxfPoint.Origin;
                string   desc  = null;
                switch (entity.EntityType)
                {
                case DxfEntityType.MText:
                    DxfMText text = entity as DxfMText;
                    desc  = text.Text;
                    point = text.InsertionPoint;
                    break;

                case DxfEntityType.Text:
                    DxfText text2 = entity as DxfText;
                    desc  = text2.Value;
                    point = text2.Location;
                    break;

                default:
                    var bb = entity.GetBoundingBox();
                    if (bb.HasValue == true)
                    {
                        var boundingBox = bb.Value;
                        point = (boundingBox.MinimumPoint + boundingBox.MaximumPoint) / 2;
                    }
                    break;
                }

                if ((point != DxfPoint.Origin) && (desc != null))
                {
                    LocatedDescription md;
                    md.point       = point;
                    md.description = desc;
                    desciptions_locations.Add(md);
                }
                else
                {
                    graphical_object_locations.Add(new LocatedEntity {
                        point = point, entity = entity
                    });
                }
            }

            if (desciptions_locations.Count == 0)
            {
                foreach (var o in graphical_object_locations)
                {
                    ret.Add(new Tuple <string, DxfEntity>(null, o.entity));
                }
            }
            else
            {
                if (desciptions_locations.Count != graphical_object_locations.Count)
                {
                    throw new InvalidOperationException("number of objects differs from number of descriptions");
                }

                foreach (var b in desciptions_locations)
                {
                    double        min_dist       = double.MaxValue;
                    LocatedEntity?closest_object = null;
                    foreach (var c in graphical_object_locations)
                    {
                        var distance = (c.point - b.point).Length;
                        if (distance < min_dist)
                        {
                            min_dist       = distance;
                            closest_object = c;
                        }
                    }
                    if (closest_object != null)
                    {
                        ret.Add(new Tuple <string, DxfEntity>(b.description, closest_object.Value.entity));
                        graphical_object_locations.Remove((LocatedEntity)closest_object);
                    }
                }
            }
            return(ret);
        }