Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        void _ImportEntity(DxfDomEntity entity)
        {
            switch (entity)
            {
            case DxfDomLine line:
                _ImportLine(line);
                break;

            case DxfDomCircle circle:
                if (circle.IsArc)
                {
                    _ImportArc(circle);
                }
                else
                {
                    _ImportCircle(circle);
                }
                break;

            case DxfDomEllipse ellipse:
                if (ellipse.IsArc)
                {
                    _ImportEllipticalArc(ellipse);
                }
                else
                {
                    _ImportEllipse(ellipse);
                }
                break;

            case DxfDomLwPolyline lwPolyline:
                _ImportLwPolyline(lwPolyline);
                break;

            case DxfDomPolyline polyline:
                _ImportPolyline(polyline);
                break;

            case DxfDomSpline spline:
                _ImportSpline(spline);
                break;

            default:
                Messages.Warning($"Imported DXF entity is of unsupported type {entity.GetType().Name}.");
                break;
            }
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        void _ReadEntities(DxfReader reader)
        {
            while (reader.GroupCode >= 0)
            {
                if (reader.GroupCode != 0)
                {
                    reader.Skip();
                    continue;
                }

                var type = reader.ReadString()?.ToUpper();
                if (type == null)
                {
                    continue;
                }

                DxfDomEntity entity = null;
                switch (type)
                {
                case "ENDSEC":
                    return;

                case "LINE":
                    entity = new DxfDomLine();
                    break;

                case "CIRCLE":
                case "ARC":
                    entity = new DxfDomCircle();
                    break;

                case "ELLIPSE":
                    entity = new DxfDomEllipse();
                    break;

                case "LWPOLYLINE":
                    entity = new DxfDomLwPolyline();
                    break;

                case "POLYLINE":
                    entity = new DxfDomPolyline();
                    break;

                case "SPLINE":
                    entity = new DxfDomSpline();
                    break;
                }

                if (entity == null)
                {
                    continue;
                }

                if (entity.Read(reader))
                {
                    Entities.Add(entity);
                }
                else
                {
                    Messages.Error($"DxfReader: Incomplete entity description at line {reader.Line}.");
                }
            }
        }