프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / OdReadExMgd / OdReadExMgd.cs @ 8041a16f

이력 | 보기 | 이력해설 | 다운로드 (192 KB)

1
/////////////////////////////////////////////////////////////////////////////// 
2
// Copyright (C) 2002-2019, Open Design Alliance (the "Alliance"). 
3
// All rights reserved. 
4
// 
5
// This software and its documentation and related materials are owned by 
6
// the Alliance. The software may only be incorporated into application 
7
// programs owned by members of the Alliance, subject to a signed 
8
// Membership Agreement and Supplemental Software License Agreement with the
9
// Alliance. The structure and organization of this software are the valuable  
10
// trade secrets of the Alliance and its suppliers. The software is also 
11
// protected by copyright law and international treaty provisions. Application  
12
// programs incorporating this software must include the following statement 
13
// with their copyright notices:
14
//   
15
//   This application incorporates Open Design Alliance software pursuant to a license 
16
//   agreement with Open Design Alliance.
17
//   Open Design Alliance Copyright (C) 2002-2019 by Open Design Alliance. 
18
//   All rights reserved.
19
//
20
// By use of this software, its documentation or related materials, you 
21
// acknowledge and accept the above terms.
22
///////////////////////////////////////////////////////////////////////////////
23
using System;
24
using System.Collections.Generic;
25
using System.Text;
26
using System.IO;
27
using System.Xml;
28
using Teigha.DatabaseServices;
29
using Teigha.Geometry;
30
using Teigha.GraphicsInterface;
31
using Teigha.Colors;
32
using Teigha;
33
// note that GetObject doesn't work in Acad 2009, so we use "obsolete" Open instead
34
#pragma warning disable 618
35

    
36
namespace OdReadExMgd
37
{
38
    class DbDumper
39
    {
40
        public DbDumper() { }
41

    
42
        static string toDegreeString(double val)
43
        {
44
            return (val * 180.0 / Math.PI) + "d";
45
        }
46
        static string toHexString(int val)
47
        {
48
            return string.Format("0{0:X}", val);
49
        }
50
        static string toArcSymbolTypeString(int val)
51
        {
52
            switch (val)
53
            {
54
                case 0: return "Precedes text";
55
                case 1: return "Above text";
56
                case 2: return "None";
57
            }
58
            return "???";
59
        }
60
        /************************************************************************/
61
        /* Shorten a path with ellipses.                                        */
62
        /************************************************************************/
63
        static string shortenPath(string Inpath, int maxPath)
64
        {
65
            string path = Inpath;
66
            /**********************************************************************/
67
            /* If the path fits, just return it                                   */
68
            /**********************************************************************/
69
            if (path.Length <= maxPath)
70
            {
71
                return path;
72
            }
73
            /**********************************************************************/
74
            /* If there's no backslash, just truncate the path                    */
75
            /**********************************************************************/
76
            int lastBackslash = path.LastIndexOf('\\');
77
            if (lastBackslash < 0)
78
            {
79
                return path.Substring(0, maxPath - 3) + "...";
80
            }
81

    
82
            /**********************************************************************/
83
            /* Shorten the front of the path                                      */
84
            /**********************************************************************/
85
            int fromLeft = (lastBackslash - 3) - (path.Length - maxPath);
86
            // (12 - 3) - (19 - 10) = 9 - 9 = 0 
87
            if ((lastBackslash <= 3) || (fromLeft < 1))
88
            {
89
                path = "..." + path.Substring(lastBackslash);
90
            }
91
            else
92
            {
93
                path = path.Substring(0, fromLeft) + "..." + path.Substring(lastBackslash);
94
            }
95

    
96
            /**********************************************************************/
97
            /* Truncate the path                                                  */
98
            /**********************************************************************/
99
            if (path.Length > maxPath)
100
            {
101
                path = path.Substring(0, maxPath - 3) + "...";
102
            }
103

    
104
            return path;
105
        }
106
        static string shortenPath(string Inpath)
107
        {
108
            return shortenPath(Inpath, 40);
109
        }
110

    
111
        /************************************************************************/
112
        /* Output a string in the form                                          */
113
        /*   leftString:. . . . . . . . . . . .rightString                      */
114
        /************************************************************************/
115
        static void writeLine(int indent, object leftString, object rightString, int colWidth)
116
        {
117
            string spaces = "                                                            ";
118
            string leader = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ";
119

    
120
            const int tabSize = 2;
121

    
122
            /**********************************************************************/
123
            /* Indent leftString with spaces characters                           */
124
            /**********************************************************************/
125
            string newleftString = spaces.Substring(0, tabSize * indent) + leftString.ToString();
126

    
127
            /**********************************************************************/
128
            /* If rightString is not specified, just output the indented          */
129
            /* leftString. Otherwise, fill the space between leftString and       */
130
            /* rightString with leader characters.                                */
131
            /**********************************************************************/
132
            if (rightString == null || ((rightString is string) && ((string)rightString) == ""))
133
            {
134
                Console.WriteLine(newleftString);
135
            }
136
            else
137
            {
138
                int leaders = colWidth - newleftString.Length;
139
                if (leaders > 0)
140
                {
141
                    Console.WriteLine(newleftString + leader.Substring(newleftString.Length, leaders) + rightString.ToString());
142
                }
143
                else
144
                {
145
                    Console.WriteLine(newleftString + ' ' + rightString.ToString());
146
                }
147
            }
148
        }
149
        static void writeLine(int indent, object leftString, object rightString)
150
        {
151
            writeLine(indent, leftString, rightString, 38);
152
        }
153
        static void writeLine(int indent, object leftString)
154
        {
155
            writeLine(indent, leftString, null, 38);
156
        }
157
        static void writeLine()
158
        {
159
            Console.WriteLine();
160
        }
161
        static void dumpEntityData(Entity pEnt, int indent, XmlNode node)
162
        {
163
            if (node != null)
164
            {
165
                try
166
                {
167
                    Extents3d ext = pEnt.GeometricExtents;
168

    
169
                    XmlAttribute MinExtentsAttr = Program.xml.CreateAttribute("MinExtents");
170
                    MinExtentsAttr.Value = ext.MinPoint.ToString();
171
                    node.Attributes.SetNamedItem(MinExtentsAttr);
172

    
173
                    XmlAttribute MaxExtentsAttr = Program.xml.CreateAttribute("MaxExtents");
174
                    MaxExtentsAttr.Value = ext.MaxPoint.ToString();
175
                    node.Attributes.SetNamedItem(MaxExtentsAttr);
176
                }
177
                catch (System.Exception)
178
                {
179
                }
180

    
181
                XmlAttribute LayerAttr = Program.xml.CreateAttribute("Layer");
182
                LayerAttr.Value = pEnt.Layer;
183
                node.Attributes.SetNamedItem(LayerAttr);
184

    
185
                writeLine(indent, "Color Index", pEnt.ColorIndex);
186
                writeLine(indent, "Color", pEnt.Color);
187

    
188
                XmlAttribute LinetypeAttr = Program.xml.CreateAttribute("Linetype");
189
                LinetypeAttr.Value = pEnt.Linetype;
190
                node.Attributes.SetNamedItem(LinetypeAttr);
191

    
192
                writeLine(indent, "LTscale", pEnt.LinetypeScale);
193
                writeLine(indent, "Lineweight", pEnt.LineWeight);
194
                writeLine(indent, "Plot Style", pEnt.PlotStyleName);
195
                writeLine(indent, "Transparency Method", pEnt.Transparency);
196
                writeLine(indent, "Visibility", pEnt.Visible);
197
                writeLine(indent, "Planar", pEnt.IsPlanar);
198

    
199
                if (pEnt.IsPlanar)
200
                {
201
                    try
202
                    {
203
                        CoordinateSystem3d cs = (CoordinateSystem3d)pEnt.GetPlane().GetCoordinateSystem();
204
                        writeLine(indent + 1, "Origin", cs.Origin);
205
                        writeLine(indent + 1, "u-Axis", cs.Xaxis);
206
                        writeLine(indent + 1, "v-Axis", cs.Yaxis);
207
                    }
208
                    catch (System.Exception ex)
209
                    {
210
                        writeLine(indent + 1, "pEnt.GetPlane().GetCoordinateSystem() failed", ex.Message);
211
                    }
212
                }
213
            }
214
        }
215

    
216
        /************************************************************************/
217
        /* Dump Text data                                                       */
218
        /************************************************************************/
219
        static XmlNode dumpTextData(DBText pText, int indent, XmlNode node)
220
        {
221
            XmlNode TextNode = null;
222
            /// write text information to xml file
223
            if (node != null)
224
            {
225
                TextNode = Program.xml.CreateElement(pText.GetRXClass().Name);
226

    
227
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
228
                XAttr.Value = pText.Position.X.ToString();
229
                TextNode.Attributes.SetNamedItem(XAttr);
230

    
231
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
232
                YAttr.Value = pText.Position.Y.ToString();
233
                TextNode.Attributes.SetNamedItem(YAttr);
234

    
235
                TextNode.InnerText = pText.TextString.Replace("%%U", "");
236

    
237
                XmlAttribute AngleAttr = Program.xml.CreateAttribute("Angle");
238
                AngleAttr.Value = pText.Rotation.ToString();
239
                TextNode.Attributes.SetNamedItem(AngleAttr);
240

    
241
                XmlAttribute WidthAttr = Program.xml.CreateAttribute("Width");
242
                WidthAttr.Value = String.Format("{0}", pText.WidthFactor * pText.Height * pText.TextString.Length);
243
                TextNode.Attributes.SetNamedItem(WidthAttr);
244

    
245
                XmlAttribute HeightAttr = Program.xml.CreateAttribute("Height");
246
                HeightAttr.Value = pText.Height.ToString();
247
                TextNode.Attributes.SetNamedItem(HeightAttr);
248

    
249
                XmlAttribute WidthFactorAttr = Program.xml.CreateAttribute("WidthFactor");
250
                WidthFactorAttr.Value = pText.WidthFactor.ToString();
251
                TextNode.Attributes.SetNamedItem(WidthFactorAttr);
252

    
253
                XmlAttribute IsDefaultAlignmentAttr = Program.xml.CreateAttribute("IsDefaultAlignment");
254
                IsDefaultAlignmentAttr.Value = pText.IsDefaultAlignment.ToString();
255
                TextNode.Attributes.SetNamedItem(IsDefaultAlignmentAttr);
256

    
257
                XmlAttribute AlignmentPointAttr = Program.xml.CreateAttribute("AlignmentPoint");
258
                AlignmentPointAttr.Value = pText.AlignmentPoint.ToString();
259
                TextNode.Attributes.SetNamedItem(AlignmentPointAttr);
260

    
261
                XmlAttribute HorizontalModeAttr = Program.xml.CreateAttribute("HorizontalMode");
262
                HorizontalModeAttr.Value = pText.HorizontalMode.ToString();
263
                TextNode.Attributes.SetNamedItem(HorizontalModeAttr);
264

    
265
                XmlAttribute VerticalModeAttr = Program.xml.CreateAttribute("VerticalMode");
266
                VerticalModeAttr.Value = pText.VerticalMode.ToString();
267
                TextNode.Attributes.SetNamedItem(VerticalModeAttr);
268

    
269
                XmlAttribute IsMirroredInXAttr = Program.xml.CreateAttribute("IsMirroredInX");
270
                IsMirroredInXAttr.Value = pText.IsMirroredInX.ToString();
271
                TextNode.Attributes.SetNamedItem(IsMirroredInXAttr);
272

    
273
                XmlAttribute IsMirroredInYAttr = Program.xml.CreateAttribute("IsMirroredInY");
274
                IsMirroredInYAttr.Value = pText.IsMirroredInY.ToString();
275
                TextNode.Attributes.SetNamedItem(IsMirroredInYAttr);
276

    
277
                XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique");
278
                ObliqueAttr.Value = pText.Oblique.ToString();
279
                TextNode.Attributes.SetNamedItem(ObliqueAttr);
280

    
281
                XmlAttribute TextStyleAttr = Program.xml.CreateAttribute("TextStyle");
282
                TextStyleAttr.Value = pText.TextStyleName;
283
                TextNode.Attributes.SetNamedItem(TextStyleAttr);
284

    
285
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
286
                NormalAttr.Value = pText.Normal.ToString();
287
                TextNode.Attributes.SetNamedItem(NormalAttr);
288

    
289
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
290
                ThicknessAttr.Value = pText.Thickness.ToString();
291
                TextNode.Attributes.SetNamedItem(ThicknessAttr);
292

    
293
                dumpEntityData(pText, indent, TextNode);
294

    
295
                node.AppendChild(TextNode);
296
            }
297

    
298
            return TextNode;
299
        }
300

    
301
        /************************************************************************/
302
        /* Dump Attribute data                                                  */
303
        /************************************************************************/
304
        static void dumpAttributeData(int indent, AttributeReference pAttr, int i, XmlNode node)
305
        {
306
            writeLine(indent, "Field Length", pAttr.FieldLength);
307
            writeLine(indent, "Invisible", pAttr.Invisible);
308
            writeLine(indent, "Preset", pAttr.IsPreset);
309
            writeLine(indent, "Verifiable", pAttr.IsVerifiable);
310
            writeLine(indent, "Locked in Position", pAttr.LockPositionInBlock);
311
            writeLine(indent, "Constant", pAttr.IsConstant);
312

    
313
            XmlNode TextNode = dumpTextData(pAttr, indent, node);
314
            if (TextNode != null)
315
            {
316
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
317
                HandleAttr.Value = pAttr.Handle.ToString();
318
                TextNode.Attributes.SetNamedItem(HandleAttr);
319

    
320
                XmlAttribute TagAttr = Program.xml.CreateAttribute("Tag");
321
                TagAttr.Value = pAttr.Tag;
322
                TextNode.Attributes.SetNamedItem(TagAttr);
323
            }
324
        }
325

    
326
        /************************************************************************/
327
        /* Dump Block Reference Data                                             */
328
        /************************************************************************/
329
        static XmlNode dumpBlockRefData(BlockReference pBlkRef, int indent, XmlNode node)
330
        {
331
            if (node != null)
332
            {
333
                XmlNode BlockReferenceNode = Program.xml.CreateElement(pBlkRef.GetRXClass().Name);
334

    
335
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
336
                HandleAttr.Value = pBlkRef.Handle.ToString();
337
                BlockReferenceNode.Attributes.SetNamedItem(HandleAttr);
338

    
339
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
340
                XAttr.Value = pBlkRef.Position.X.ToString();
341
                BlockReferenceNode.Attributes.SetNamedItem(XAttr);
342

    
343
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
344
                YAttr.Value = pBlkRef.Position.Y.ToString();
345
                BlockReferenceNode.Attributes.SetNamedItem(YAttr);
346

    
347
                XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
348
                ZAttr.Value = pBlkRef.Position.Z.ToString();
349
                BlockReferenceNode.Attributes.SetNamedItem(ZAttr);
350

    
351
                XmlAttribute AngleAttr = Program.xml.CreateAttribute("Angle");
352
                AngleAttr.Value = pBlkRef.Rotation.ToString();
353
                BlockReferenceNode.Attributes.SetNamedItem(AngleAttr);
354

    
355
                XmlAttribute ScaleFactorsAttr = Program.xml.CreateAttribute("ScaleFactors");
356
                ScaleFactorsAttr.Value = pBlkRef.ScaleFactors.ToString();
357
                BlockReferenceNode.Attributes.SetNamedItem(ScaleFactorsAttr);
358

    
359
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
360
                NormalAttr.Value = pBlkRef.Normal.ToString();
361
                BlockReferenceNode.Attributes.SetNamedItem(NormalAttr);
362

    
363
                XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
364
                NameAttr.Value = pBlkRef.Name;
365
                BlockReferenceNode.Attributes.SetNamedItem(NameAttr);
366

    
367
                Matrix3d blockTransform = pBlkRef.BlockTransform;
368
                CoordinateSystem3d cs = blockTransform.CoordinateSystem3d;
369
                writeLine(indent + 1, "Origin", cs.Origin);
370
                writeLine(indent + 1, "u-Axis", cs.Xaxis);
371
                writeLine(indent + 1, "v-Axis", cs.Yaxis);
372
                writeLine(indent + 1, "z-Axis", cs.Zaxis);
373

    
374
                dumpEntityData(pBlkRef, indent, BlockReferenceNode);
375

    
376
                /**********************************************************************/
377
                /* Dump the attributes                                                */
378
                /**********************************************************************/
379
                int i = 0;
380
                AttributeCollection attCol = pBlkRef.AttributeCollection;
381
                foreach (ObjectId id in attCol)
382
                {
383
                    try
384
                    {
385
                        using (AttributeReference pAttr = (AttributeReference)id.Open(OpenMode.ForRead))
386
                            dumpAttributeData(indent, pAttr, i++, BlockReferenceNode);
387
                    }
388
                    catch (System.Exception)
389
                    {
390

    
391
                    }
392
                }
393

    
394
                node.AppendChild(BlockReferenceNode);
395

    
396
                return BlockReferenceNode;
397
            }
398

    
399
            return null;
400
        }
401
        /************************************************************************/
402
        /* Dump data common to all OdDbCurves                                   */
403
        /************************************************************************/
404
        static void dumpCurveData(Entity pEnt, int indent, XmlNode node)
405
        {
406
            if (node != null)
407
            {
408
                Curve pEntity = (Curve)pEnt;
409
                try
410
                {
411
                    writeLine(indent, "Start Point", pEntity.StartPoint);
412
                    writeLine(indent, "End Point", pEntity.EndPoint);
413
                }
414
                catch (System.Exception)
415
                {
416
                }
417
                writeLine(indent, "Closed", pEntity.Closed);
418
                writeLine(indent, "Periodic", pEntity.IsPeriodic);
419

    
420
                try
421
                {
422
                    writeLine(indent, "Area", pEntity.Area);
423
                }
424
                catch (System.Exception)
425
                {
426
                }
427
                dumpEntityData(pEntity, indent, node);
428
            }
429
        }
430

    
431
        /************************************************************************/
432
        /* Dump Dimension data                                                  */
433
        /************************************************************************/
434
        static XmlNode dumpDimData(Dimension pDim, int indent, XmlNode node)
435
        {
436
            if (node != null)
437
            {
438
                XmlElement DimDataNode = Program.xml.CreateElement("DimData");
439

    
440
                XmlAttribute CurrentMeasurementAttr = Program.xml.CreateAttribute("CurrentMeasurement");
441
                CurrentMeasurementAttr.Value = pDim.CurrentMeasurement.ToString();
442
                DimDataNode.Attributes.SetNamedItem(CurrentMeasurementAttr);
443

    
444
                XmlAttribute DimensionTextAttr = Program.xml.CreateAttribute("DimensionText");
445
                DimensionTextAttr.Value = pDim.DimensionText.ToString();
446
                DimDataNode.Attributes.SetNamedItem(DimensionTextAttr);
447

    
448
                if (pDim.CurrentMeasurement >= 0.0)
449
                {
450
                    XmlAttribute FormattedMeasurementAttr = Program.xml.CreateAttribute("FormattedMeasurement");
451
                    FormattedMeasurementAttr.Value = pDim.FormatMeasurement(pDim.CurrentMeasurement, pDim.DimensionText);
452
                    DimDataNode.Attributes.SetNamedItem(FormattedMeasurementAttr);
453
                }
454
                if (pDim.DimBlockId.IsNull)
455
                {
456
                    writeLine(indent, "Dimension Block NULL");
457
                }
458
                else
459
                {
460
                    using (BlockTableRecord btr = (BlockTableRecord)pDim.DimBlockId.Open(OpenMode.ForRead))
461
                    {
462
                        XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
463
                        NameAttr.Value = btr.Name;
464
                        DimDataNode.Attributes.SetNamedItem(NameAttr);
465
                    }
466
                }
467

    
468
                XmlAttribute DimBlockPositionAttr = Program.xml.CreateAttribute("DimBlockPosition");
469
                DimBlockPositionAttr.Value = pDim.DimBlockPosition.ToString();
470
                DimDataNode.Attributes.SetNamedItem(DimBlockPositionAttr);
471

    
472
                XmlAttribute TextPositionAttr = Program.xml.CreateAttribute("TextPosition");
473
                TextPositionAttr.Value = pDim.TextPosition.ToString();
474
                DimDataNode.Attributes.SetNamedItem(TextPositionAttr);
475

    
476
                XmlAttribute TextRotationAttr = Program.xml.CreateAttribute("TextRotation");
477
                TextRotationAttr.Value = pDim.TextRotation.ToString();
478
                DimDataNode.Attributes.SetNamedItem(TextRotationAttr);
479

    
480
                XmlAttribute DimensionStyleNameAttr = Program.xml.CreateAttribute("DimensionStyleName");
481
                DimensionStyleNameAttr.Value = pDim.DimensionStyleName.ToString();
482
                DimDataNode.Attributes.SetNamedItem(DimensionStyleNameAttr);
483

    
484
                XmlAttribute DimtfillclrAttr = Program.xml.CreateAttribute("Dimtfillclr");
485
                DimtfillclrAttr.Value = pDim.Dimtfillclr.ToString();
486
                DimDataNode.Attributes.SetNamedItem(DimtfillclrAttr);
487

    
488
                XmlAttribute DimtfillAttr = Program.xml.CreateAttribute("Dimtfill");
489
                DimtfillAttr.Value = pDim.Dimtfill.ToString();
490
                DimDataNode.Attributes.SetNamedItem(DimtfillAttr);
491

    
492
                XmlAttribute Dimltex1Attr = Program.xml.CreateAttribute("Dimltex1");
493
                Dimltex1Attr.Value = pDim.Dimltex1.ToString();
494
                DimDataNode.Attributes.SetNamedItem(Dimltex1Attr);
495

    
496
                XmlAttribute Dimltex2Attr = Program.xml.CreateAttribute("Dimltex2");
497
                Dimltex2Attr.Value = pDim.Dimltex2.ToString();
498
                DimDataNode.Attributes.SetNamedItem(Dimltex2Attr);
499

    
500
                XmlAttribute DimltypeAttr = Program.xml.CreateAttribute("Dimltype");
501
                DimltypeAttr.Value = pDim.Dimltype.ToString();
502
                DimDataNode.Attributes.SetNamedItem(DimltypeAttr);
503

    
504
                XmlAttribute HorizontalRotationAttr = Program.xml.CreateAttribute("HorizontalRotation");
505
                HorizontalRotationAttr.Value = pDim.HorizontalRotation.ToString();
506
                DimDataNode.Attributes.SetNamedItem(HorizontalRotationAttr);
507

    
508
                XmlAttribute ElevationAttr = Program.xml.CreateAttribute("Elevation");
509
                ElevationAttr.Value = pDim.Elevation.ToString();
510
                DimDataNode.Attributes.SetNamedItem(ElevationAttr);
511

    
512
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
513
                NormalAttr.Value = pDim.Normal.ToString();
514
                DimDataNode.Attributes.SetNamedItem(NormalAttr);
515

    
516
                dumpEntityData(pDim, indent, node);
517

    
518
                return DimDataNode;
519
            }
520

    
521
            return null;
522
        }
523

    
524
        /************************************************************************/
525
        /* 2 Line Angular Dimension Dumper                                      */
526
        /************************************************************************/
527
        static XmlNode dump(LineAngularDimension2 pDim, int indent, XmlNode node)
528
        {
529
            if (node != null)
530
            {
531
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
532

    
533
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
534
                HandleAttr.Value = pDim.Handle.ToString();
535
                DimNode.Attributes.SetNamedItem(HandleAttr);
536

    
537
                XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint");
538
                ArcPointAttr.Value = pDim.ArcPoint.ToString();
539
                DimNode.Attributes.SetNamedItem(ArcPointAttr);
540

    
541
                XmlAttribute XLine1StartAttr = Program.xml.CreateAttribute("XLine1Start");
542
                XLine1StartAttr.Value = pDim.XLine1Start.ToString();
543
                DimNode.Attributes.SetNamedItem(XLine1StartAttr);
544

    
545
                XmlAttribute XLine1EndAttr = Program.xml.CreateAttribute("XLine1End");
546
                XLine1EndAttr.Value = pDim.XLine1End.ToString();
547
                DimNode.Attributes.SetNamedItem(XLine1EndAttr);
548

    
549
                XmlAttribute XLine2StartAttr = Program.xml.CreateAttribute("XLine2Start");
550
                XLine2StartAttr.Value = pDim.XLine2Start.ToString();
551
                DimNode.Attributes.SetNamedItem(XLine2StartAttr);
552

    
553
                XmlAttribute XLine2EndAttr = Program.xml.CreateAttribute("XLine2End");
554
                XLine2EndAttr.Value = pDim.XLine2End.ToString();
555
                DimNode.Attributes.SetNamedItem(XLine2EndAttr);
556

    
557
                dumpDimData(pDim, indent, DimNode);
558

    
559
                return DimNode;
560
            }
561

    
562
            return null;
563
        }
564

    
565
        /************************************************************************/
566
        /* Dump 2D Vertex data                                                  */
567
        /************************************************************************/
568
        static XmlNode dump2dVertex(int indent, Vertex2d pVertex, int i, XmlNode node)
569
        {
570
            if (node != null)
571
            {
572
                XmlElement VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name);
573

    
574
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
575
                HandleAttr.Value = pVertex.Handle.ToString();
576
                VertexNode.Attributes.SetNamedItem(HandleAttr);
577

    
578
                XmlAttribute VertexTypeAttr = Program.xml.CreateAttribute("VertexType");
579
                VertexTypeAttr.Value = pVertex.VertexType.ToString();
580
                VertexNode.Attributes.SetNamedItem(VertexTypeAttr);
581

    
582
                XmlAttribute PositionAttr = Program.xml.CreateAttribute("Position");
583
                PositionAttr.Value = pVertex.Position.ToString();
584
                VertexNode.Attributes.SetNamedItem(PositionAttr);
585

    
586
                XmlAttribute StartWidthAttr = Program.xml.CreateAttribute("StartWidth");
587
                StartWidthAttr.Value = pVertex.StartWidth.ToString();
588
                VertexNode.Attributes.SetNamedItem(StartWidthAttr);
589

    
590
                XmlAttribute EndWidthAttr = Program.xml.CreateAttribute("EndWidth");
591
                EndWidthAttr.Value = pVertex.EndWidth.ToString();
592
                VertexNode.Attributes.SetNamedItem(EndWidthAttr);
593

    
594
                XmlAttribute BulgeAttr = Program.xml.CreateAttribute("Bulge");
595
                BulgeAttr.Value = pVertex.Bulge.ToString();
596
                VertexNode.Attributes.SetNamedItem(BulgeAttr);
597

    
598
                if (pVertex.Bulge != 0)
599
                {
600
                    XmlAttribute BulgeAngleAttr = Program.xml.CreateAttribute("BulgeAngle");
601
                    BulgeAngleAttr.Value = (4 * Math.Atan(pVertex.Bulge)).ToString();
602
                    VertexNode.Attributes.SetNamedItem(BulgeAngleAttr);
603
                }
604

    
605
                XmlAttribute TangentUsedAttr = Program.xml.CreateAttribute("TangentUsed");
606
                TangentUsedAttr.Value = pVertex.TangentUsed.ToString();
607
                VertexNode.Attributes.SetNamedItem(TangentUsedAttr);
608
                if (pVertex.TangentUsed)
609
                {
610
                    XmlAttribute TangentAttr = Program.xml.CreateAttribute("Tangent");
611
                    TangentAttr.Value = pVertex.Tangent.ToString();
612
                    VertexNode.Attributes.SetNamedItem(TangentAttr);
613
                }
614

    
615
                node.AppendChild(VertexNode);
616

    
617
                return VertexNode;
618
            }
619

    
620
            return null;
621
        }
622

    
623
        /************************************************************************/
624
        /* 2D Polyline Dumper                                                   */
625
        /************************************************************************/
626
        static XmlNode dump(Polyline2d pPolyline, int indent, XmlNode node)
627
        {
628
            /********************************************************************/
629
            /* Dump the vertices                                                */
630
            /********************************************************************/
631
            List<Vertex2d> Vertices = new List<Vertex2d>();
632
            int i = 0;
633
            foreach (ObjectId obj in pPolyline)
634
            {
635
                using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead))
636
                {
637
                    if (dbObj is Vertex2d)
638
                    {
639
                        Vertices.Add((Vertex2d)dbObj);
640
                        /// dump2dVertex(indent, (Vertex2d)dbObj, i++);
641
                    }
642
                }
643
            }
644

    
645
            if (node != null)
646
            {
647
                XmlNode Polyline2dNode = Program.xml.CreateElement(pPolyline.GetRXClass().Name);
648

    
649
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
650
                HandleAttr.Value = pPolyline.Handle.ToString();
651
                Polyline2dNode.Attributes.SetNamedItem(HandleAttr);
652

    
653
                XmlAttribute CountAttr = Program.xml.CreateAttribute("Count");
654
                CountAttr.Value = Vertices.Count.ToString();
655
                Polyline2dNode.Attributes.SetNamedItem(CountAttr);
656

    
657
                XmlAttribute ElevationAttr = Program.xml.CreateAttribute("Elevation");
658
                ElevationAttr.Value = pPolyline.Elevation.ToString();
659
                Polyline2dNode.Attributes.SetNamedItem(ElevationAttr);
660

    
661
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
662
                NormalAttr.Value = pPolyline.Normal.ToString();
663
                Polyline2dNode.Attributes.SetNamedItem(NormalAttr);
664

    
665
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
666
                ThicknessAttr.Value = pPolyline.Thickness.ToString();
667
                Polyline2dNode.Attributes.SetNamedItem(ThicknessAttr);
668

    
669
                foreach (var vt in Vertices)
670
                {
671
                    XmlNode VertexNode = Program.xml.CreateElement("Vertex");
672

    
673
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
674
                    XAttr.Value = vt.Position.X.ToString();
675
                    VertexNode.Attributes.SetNamedItem(XAttr);
676

    
677
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
678
                    YAttr.Value = vt.Position.Y.ToString();
679
                    VertexNode.Attributes.SetNamedItem(YAttr);
680

    
681
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
682
                    ZAttr.Value = vt.Position.Z.ToString();
683
                    VertexNode.Attributes.SetNamedItem(ZAttr);
684

    
685
                    Polyline2dNode.AppendChild(VertexNode);
686
                }
687

    
688
                dumpCurveData(pPolyline, indent, node);
689

    
690
                node.AppendChild(Polyline2dNode);
691

    
692
                return Polyline2dNode;
693
            }
694

    
695
            return null;
696
        }
697

    
698

    
699
        /************************************************************************/
700
        /* Dump 3D Polyline Vertex data                                         */
701
        /************************************************************************/
702
        XmlNode dump3dPolylineVertex(int indent, PolylineVertex3d pVertex, int i, XmlNode node)
703
        {
704
            if (node != null)
705
            {
706
                XmlNode VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name);
707

    
708
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
709
                HandleAttr.Value = pVertex.Handle.ToString();
710
                VertexNode.Attributes.SetNamedItem(HandleAttr);
711

    
712
                XmlAttribute VertexxTypeAttr = Program.xml.CreateAttribute("VertexType");
713
                VertexxTypeAttr.Value = pVertex.VertexType.ToString();
714
                VertexNode.Attributes.SetNamedItem(VertexxTypeAttr);
715

    
716
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
717
                XAttr.Value = pVertex.Position.X.ToString();
718
                VertexNode.Attributes.SetNamedItem(XAttr);
719

    
720
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
721
                YAttr.Value = pVertex.Position.Y.ToString();
722
                VertexNode.Attributes.SetNamedItem(YAttr);
723

    
724
                XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
725
                ZAttr.Value = pVertex.Position.Z.ToString();
726
                VertexNode.Attributes.SetNamedItem(ZAttr);
727

    
728
                node.AppendChild(VertexNode);
729

    
730
                return VertexNode;
731
            }
732

    
733
            return null;
734
        }
735

    
736
        /************************************************************************/
737
        /* 3D Polyline Dumper                                                   */
738
        /************************************************************************/
739
        XmlNode dump(Polyline3d pPolyline, int indent, XmlNode node)
740
        {
741
            if (node != null)
742
            {
743
                XmlNode pPolylineNode = Program.xml.CreateElement(pPolyline.GetRXClass().Name);
744

    
745
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
746
                HandleAttr.Value = pPolyline.Handle.ToString();
747
                pPolylineNode.Attributes.SetNamedItem(HandleAttr);
748

    
749
                /********************************************************************/
750
                /* Dump the vertices                                                */
751
                /********************************************************************/
752
                int i = 0;
753
                foreach (ObjectId obj in pPolyline)
754
                {
755
                    using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead))
756
                    {
757
                        if (dbObj is PolylineVertex3d)
758
                        {
759
                            dump3dPolylineVertex(indent, (PolylineVertex3d)dbObj, i++, pPolylineNode);
760
                        }
761
                    }
762
                }
763
                dumpCurveData(pPolyline, indent, pPolylineNode);
764

    
765
                node.AppendChild(pPolylineNode);
766

    
767
                return pPolylineNode;
768
            }
769

    
770
            return null;
771
        }
772

    
773

    
774
        /************************************************************************/
775
        /* 3DSolid Dumper                                                       */
776
        /************************************************************************/
777
        XmlNode dump(Solid3d pSolid, int indent, XmlNode node)
778
        {
779
            if (node != null)
780
            {
781
                XmlNode SolidNode = Program.xml.CreateElement(pSolid.GetRXClass().Name);
782

    
783
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
784
                HandleAttr.Value = pSolid.Handle.ToString();
785
                SolidNode.Attributes.SetNamedItem(HandleAttr);
786

    
787
                dumpEntityData(pSolid, indent, node);
788

    
789
                node.AppendChild(SolidNode);
790

    
791
                return SolidNode;
792
            }
793

    
794
            return null;
795
        }
796

    
797

    
798
        /************************************************************************/
799
        /* 3 Point Angular Dimension Dumper                                     */
800
        /************************************************************************/
801
        XmlNode dump(Point3AngularDimension pDim, int indent, XmlNode node)
802
        {
803
            if (node != null)
804
            {
805
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
806

    
807
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
808
                HandleAttr.Value = pDim.Handle.ToString();
809
                DimNode.Attributes.SetNamedItem(HandleAttr);
810

    
811
                XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint");
812
                ArcPointAttr.Value = pDim.ArcPoint.ToString();
813
                DimNode.Attributes.SetNamedItem(ArcPointAttr);
814

    
815
                XmlAttribute CenterPointAttr = Program.xml.CreateAttribute("CenterPoint");
816
                CenterPointAttr.Value = pDim.CenterPoint.ToString();
817
                DimNode.Attributes.SetNamedItem(CenterPointAttr);
818

    
819
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
820
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
821
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
822

    
823
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
824
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
825
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
826

    
827
                dumpDimData(pDim, indent, DimNode);
828

    
829
                return DimNode;
830
            }
831

    
832
            return null;
833
        }
834

    
835
        /************************************************************************/
836
        /* Aligned Dimension Dumper                                             */
837
        /************************************************************************/
838
        XmlNode dump(AlignedDimension pDim, int indent, XmlNode node)
839
        {
840
            if (node != null)
841
            {
842
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
843

    
844
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
845
                HandleAttr.Value = pDim.Handle.ToString();
846
                DimNode.Attributes.SetNamedItem(HandleAttr);
847

    
848
                XmlAttribute DimLinePointAttr = Program.xml.CreateAttribute("DimLinePoint");
849
                DimLinePointAttr.Value = pDim.DimLinePoint.ToString();
850
                DimNode.Attributes.SetNamedItem(DimLinePointAttr);
851

    
852
                XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique");
853
                ObliqueAttr.Value = pDim.Oblique.ToString();
854
                DimNode.Attributes.SetNamedItem(ObliqueAttr);
855

    
856
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
857
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
858
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
859

    
860
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
861
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
862
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
863

    
864
                dumpDimData(pDim, indent, DimNode);
865

    
866
                return DimNode;
867
            }
868

    
869
            return null;
870
        }
871

    
872
    /************************************************************************/
873
    /* Arc Dumper                                                           */
874
    /************************************************************************/
875
    XmlNode dump(Arc pArc, int indent, XmlNode node)
876
    {
877
        if (node != null)
878
        {
879
            XmlElement ArcNode = Program.xml.CreateElement(pArc.GetRXClass().Name);
880

    
881
            XmlAttribute XAttr = Program.xml.CreateAttribute("X");
882
            XAttr.Value = pArc.Center.X.ToString();
883
            ArcNode.Attributes.SetNamedItem(XAttr);
884

    
885
            XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
886
            YAttr.Value = pArc.Center.Y.ToString();
887
            ArcNode.Attributes.SetNamedItem(YAttr);
888

    
889
            XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
890
            ZAttr.Value = pArc.Center.Z.ToString();
891
            ArcNode.Attributes.SetNamedItem(ZAttr);
892

    
893
            XmlAttribute RadiusAttr = Program.xml.CreateAttribute("Radius");
894
            RadiusAttr.Value = pArc.Radius.ToString();
895
            ArcNode.Attributes.SetNamedItem(RadiusAttr);
896

    
897
            XmlAttribute StartAngleAttr = Program.xml.CreateAttribute("StartAngle");
898
            StartAngleAttr.Value = pArc.StartAngle.ToString();
899
            ArcNode.Attributes.SetNamedItem(StartAngleAttr);
900

    
901
            XmlAttribute EndAngleAttr = Program.xml.CreateAttribute("EndAngle");
902
            EndAngleAttr.Value = pArc.EndAngle.ToString();
903
            ArcNode.Attributes.SetNamedItem(EndAngleAttr);
904

    
905
            XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
906
            NormalAttr.Value = pArc.Normal.ToString();
907
            ArcNode.Attributes.SetNamedItem(NormalAttr);
908

    
909
            XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
910
            ThicknessAttr.Value = pArc.Normal.ToString();
911
            ArcNode.Attributes.SetNamedItem(ThicknessAttr);
912

    
913
            writeLine(indent++, pArc.GetRXClass().Name, pArc.Handle);
914
            dumpCurveData(pArc, indent, ArcNode);
915

    
916
            node.AppendChild(ArcNode);
917

    
918
            return ArcNode;
919
        }
920

    
921
        return null;
922
    }
923

    
924
        /************************************************************************/
925
        /* Arc Dimension Dumper                                                 */
926
        /************************************************************************/
927
        XmlNode dump(ArcDimension pDim, int indent, XmlNode node)
928
        {
929
            if (node != null)
930
            {
931
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
932

    
933
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
934
                HandleAttr.Value = pDim.Handle.ToString();
935
                DimNode.Attributes.SetNamedItem(HandleAttr);
936

    
937
                XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint");
938
                ArcPointAttr.Value = pDim.ArcPoint.ToString();
939
                DimNode.Attributes.SetNamedItem(ArcPointAttr);
940

    
941
                XmlAttribute CenterPointAttr = Program.xml.CreateAttribute("CenterPoint");
942
                CenterPointAttr.Value = pDim.CenterPoint.ToString();
943
                DimNode.Attributes.SetNamedItem(CenterPointAttr);
944

    
945
                XmlAttribute ArcSymbolTypeAttr = Program.xml.CreateAttribute("ArcSymbolType");
946
                ArcSymbolTypeAttr.Value = pDim.ArcSymbolType.ToString();
947
                DimNode.Attributes.SetNamedItem(ArcSymbolTypeAttr);
948

    
949
                XmlAttribute IsPartialAttr = Program.xml.CreateAttribute("IsPartial");
950
                IsPartialAttr.Value = pDim.IsPartial.ToString();
951
                DimNode.Attributes.SetNamedItem(IsPartialAttr);
952

    
953
                XmlAttribute HasLeaderAttr = Program.xml.CreateAttribute("HasLeader");
954
                HasLeaderAttr.Value = pDim.HasLeader.ToString();
955
                DimNode.Attributes.SetNamedItem(HasLeaderAttr);
956

    
957
                if (pDim.HasLeader)
958
                {
959
                    XmlAttribute Leader1PointAttr = Program.xml.CreateAttribute("Leader1Point");
960
                    Leader1PointAttr.Value = pDim.Leader1Point.ToString();
961
                    DimNode.Attributes.SetNamedItem(Leader1PointAttr);
962

    
963
                    XmlAttribute Leader2PointAttr = Program.xml.CreateAttribute("Leader2Point");
964
                    Leader2PointAttr.Value = pDim.Leader2Point.ToString();
965
                    DimNode.Attributes.SetNamedItem(Leader2PointAttr);
966
                }
967

    
968
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
969
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
970
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
971

    
972
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
973
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
974
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
975

    
976
                dumpDimData(pDim, indent, DimNode);
977

    
978
                return DimNode;
979
            }
980

    
981
            return null;
982
        }
983

    
984

    
985
    /************************************************************************/
986
    /* Block Reference Dumper                                                */
987
    /************************************************************************/
988
    void dump(BlockReference pBlkRef, int indent, XmlNode node)
989
    {
990
        writeLine(indent++, pBlkRef.GetRXClass().Name, pBlkRef.Handle);
991

    
992
        using (BlockTableRecord pRecord = (BlockTableRecord)pBlkRef.BlockTableRecord.Open(OpenMode.ForRead))
993
        {
994
                XmlNode BlockRefNode = dumpBlockRefData(pBlkRef, indent, node);
995
                if (BlockRefNode != null)
996
                {
997
                    XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
998
                    NameAttr.Value = pRecord.Name;
999
                    BlockRefNode.Attributes.SetNamedItem(NameAttr);
1000
                }
1001
            /********************************************************************/
1002
            /* Dump the Spatial Filter  (Xref Clip)                             */
1003
            /********************************************************************/
1004
            // TODO:
1005
            /*
1006
            Filters.SpatialFilter pFilt = 
1007
            {
1008
              writeLine(indent++, pFilt.GetRXClass().Name,   pFilt.Handle);
1009
              writeLine(indent, "Normal",                    pFilt.Definition.Normal);
1010
              writeLine(indent, "Elevation",                 pFilt.Definition.Elevation);
1011
              writeLine(indent, "Front Clip Distance",       pFilt.Definition.FrontClip);
1012
              writeLine(indent, "Back Clip Distance",        pFilt.Definition.BackClip);
1013
              writeLine(indent, "Enabled",                   pFilt.Definition.Enabled);
1014
              foreach (Point2d p in pFilt.Definition.GetPoints())
1015
              {
1016
                writeLine(indent, string.Format("Clip point %d",i), p);
1017
              }
1018
            }
1019
             */
1020
        }
1021
    }
1022

    
1023
        /************************************************************************/
1024
        /* Body Dumper                                                          */
1025
        /************************************************************************/
1026
        XmlNode dump(Body pBody, int indent, XmlNode node)
1027
        {
1028
            if (node != null)
1029
            {
1030
                XmlNode BodyNode = Program.xml.CreateElement(pBody.GetRXClass().Name);
1031

    
1032
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1033
                HandleAttr.Value = pBody.Handle.ToString();
1034
                BodyNode.Attributes.SetNamedItem(HandleAttr);
1035

    
1036
                dumpEntityData(pBody, indent, BodyNode);
1037

    
1038
                return BodyNode;
1039
            }
1040

    
1041
            return null;
1042
        }
1043

    
1044

    
1045
        /************************************************************************/
1046
        /* Circle Dumper                                                        */
1047
        /************************************************************************/
1048
        XmlNode dump(Circle pCircle, int indent, XmlNode node)
1049
        {
1050
            if (node != null)
1051
            {
1052
                XmlElement CircleNode = Program.xml.CreateElement(pCircle.GetRXClass().Name);
1053

    
1054
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1055
                XAttr.Value = pCircle.Center.X.ToString();
1056
                CircleNode.Attributes.SetNamedItem(XAttr);
1057

    
1058
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1059
                YAttr.Value = pCircle.Center.Y.ToString();
1060
                CircleNode.Attributes.SetNamedItem(YAttr);
1061

    
1062
                XmlAttribute RadiusAttr = Program.xml.CreateAttribute("Radius");
1063
                RadiusAttr.Value = pCircle.Radius.ToString();
1064
                CircleNode.Attributes.SetNamedItem(RadiusAttr);
1065

    
1066
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
1067
                NormalAttr.Value = pCircle.Normal.ToString();
1068
                CircleNode.Attributes.SetNamedItem(NormalAttr);
1069

    
1070
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
1071
                ThicknessAttr.Value = pCircle.Thickness.ToString();
1072
                CircleNode.Attributes.SetNamedItem(ThicknessAttr);
1073

    
1074
                dumpCurveData(pCircle, indent, CircleNode);
1075

    
1076
                node.AppendChild(CircleNode);
1077

    
1078
                return CircleNode;
1079
            }
1080

    
1081
            return null;
1082
        }
1083

    
1084
        /************************************************************************/
1085
        /* Diametric Dimension Dumper                                           */
1086
        /************************************************************************/
1087
        XmlNode dump(DiametricDimension pDim, int indent, XmlNode node)
1088
        {
1089
            if (node != null)
1090
            {
1091
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
1092

    
1093
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1094
                HandleAttr.Value = pDim.Handle.ToString();
1095
                DimNode.Attributes.SetNamedItem(HandleAttr);
1096

    
1097
                XmlAttribute ChordPointAttr = Program.xml.CreateAttribute("ChordPoint");
1098
                ChordPointAttr.Value = pDim.ChordPoint.ToString();
1099
                DimNode.Attributes.SetNamedItem(ChordPointAttr);
1100

    
1101
                XmlAttribute FarChordPointAttr = Program.xml.CreateAttribute("FarChordPoint");
1102
                FarChordPointAttr.Value = pDim.FarChordPoint.ToString();
1103
                DimNode.Attributes.SetNamedItem(FarChordPointAttr);
1104

    
1105
                XmlAttribute LeaderLengthAttr = Program.xml.CreateAttribute("LeaderLength");
1106
                LeaderLengthAttr.Value = pDim.LeaderLength.ToString();
1107
                DimNode.Attributes.SetNamedItem(LeaderLengthAttr);
1108

    
1109
                dumpDimData(pDim, indent, DimNode);
1110

    
1111
                return DimNode;
1112
            }
1113

    
1114
            return null;
1115
        }
1116

    
1117
    /************************************************************************/
1118
    /* Ellipse Dumper                                                       */
1119
    /************************************************************************/
1120
    void dump(Ellipse pEllipse, int indent, XmlNode node)
1121
    {
1122
            if (node != null)
1123
            {
1124
                XmlElement EllipseNode = Program.xml.CreateElement(pEllipse.GetRXClass().Name);
1125

    
1126
                writeLine(indent++, pEllipse.GetRXClass().Name, pEllipse.Handle);
1127

    
1128
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1129
                XAttr.Value = pEllipse.Center.X.ToString();
1130
                EllipseNode.Attributes.SetNamedItem(XAttr);
1131

    
1132
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1133
                YAttr.Value = pEllipse.Center.Y.ToString();
1134
                EllipseNode.Attributes.SetNamedItem(YAttr);
1135

    
1136
                XmlAttribute MajorAxisAttr = Program.xml.CreateAttribute("MajorAxis");
1137
                MajorAxisAttr.Value = pEllipse.MajorAxis.ToString();
1138
                EllipseNode.Attributes.SetNamedItem(MajorAxisAttr);
1139

    
1140
                XmlAttribute MinorAxisAttr = Program.xml.CreateAttribute("MinorAxis");
1141
                MinorAxisAttr.Value = pEllipse.MinorAxis.ToString();
1142
                EllipseNode.Attributes.SetNamedItem(MinorAxisAttr);
1143

    
1144
                XmlAttribute MajorRadiusAttr = Program.xml.CreateAttribute("MajorRadius");
1145
                MajorRadiusAttr.Value = pEllipse.MajorRadius.ToString();
1146
                EllipseNode.Attributes.SetNamedItem(MajorRadiusAttr);
1147

    
1148
                XmlAttribute MinorRadiusAttr = Program.xml.CreateAttribute("MinorRadius");
1149
                MinorRadiusAttr.Value = pEllipse.MinorRadius.ToString();
1150
                EllipseNode.Attributes.SetNamedItem(MinorRadiusAttr);
1151

    
1152
                XmlAttribute RadiusRatioAttr = Program.xml.CreateAttribute("RadiusRatio");
1153
                RadiusRatioAttr.Value = pEllipse.RadiusRatio.ToString();
1154
                EllipseNode.Attributes.SetNamedItem(RadiusRatioAttr);
1155

    
1156
                XmlAttribute StartAngleAttr = Program.xml.CreateAttribute("StartAngle");
1157
                StartAngleAttr.Value = pEllipse.StartAngle.ToString();
1158
                EllipseNode.Attributes.SetNamedItem(StartAngleAttr);
1159

    
1160
                XmlAttribute EndAngleAttr = Program.xml.CreateAttribute("EndAngle");
1161
                EndAngleAttr.Value = pEllipse.EndAngle.ToString();
1162
                EllipseNode.Attributes.SetNamedItem(EndAngleAttr);
1163

    
1164
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
1165
                NormalAttr.Value = pEllipse.Normal.ToString();
1166
                EllipseNode.Attributes.SetNamedItem(NormalAttr);
1167

    
1168
                dumpCurveData(pEllipse, indent, EllipseNode);
1169

    
1170
                node.AppendChild(EllipseNode);
1171
            }
1172
    }
1173

    
1174
        /************************************************************************/
1175
        /* Face Dumper                                                       */
1176
        /************************************************************************/
1177
        XmlNode dump(Face pFace, int indent, XmlNode node)
1178
        {
1179
            if (node != null)
1180
            {
1181
                XmlElement FaceNode = Program.xml.CreateElement(pFace.GetRXClass().Name);
1182

    
1183
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1184
                HandleAttr.Value = pFace.Handle.ToString();
1185
                FaceNode.Attributes.SetNamedItem(HandleAttr);
1186

    
1187
                for (short i = 0; i < 4; i++)
1188
                {
1189
                    XmlElement VertexNode = Program.xml.CreateElement("Vertex");
1190

    
1191
                    Point3d pt = pFace.GetVertexAt(i);
1192
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1193
                    XAttr.Value = pt.X.ToString();
1194
                    VertexNode.Attributes.SetNamedItem(XAttr);
1195

    
1196
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1197
                    YAttr.Value = pt.Y.ToString();
1198
                    VertexNode.Attributes.SetNamedItem(YAttr);
1199

    
1200
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1201
                    ZAttr.Value = pt.Z.ToString();
1202
                    VertexNode.Attributes.SetNamedItem(ZAttr);
1203

    
1204
                    XmlAttribute VisibleAttr = Program.xml.CreateAttribute("Visible");
1205
                    VisibleAttr.Value = pFace.IsEdgeVisibleAt(i).ToString();
1206
                    VertexNode.Attributes.SetNamedItem(VisibleAttr);
1207

    
1208
                    FaceNode.AppendChild(VertexNode);
1209
                }
1210
                dumpEntityData(pFace, indent, FaceNode);
1211

    
1212
                node.AppendChild(FaceNode);
1213

    
1214
                return FaceNode;
1215
            }
1216

    
1217
            return null;
1218
        }
1219

    
1220
    /************************************************************************/
1221
    /* FCF Dumper                                                           */
1222
    /************************************************************************/
1223
    void dump(FeatureControlFrame pFcf, int indent)
1224
    {
1225
      writeLine(indent++, pFcf.GetRXClass().Name, pFcf.Handle);
1226
      writeLine(indent, "Location", pFcf.Location);
1227
      writeLine(indent, "Text", pFcf.Text);
1228
      writeLine(indent, "Dimension Style", pFcf.DimensionStyleName);
1229
      writeLine(indent, "Dimension Gap", pFcf.Dimgap);
1230
      writeLine(indent, "Dimension Scale", pFcf.Dimscale);
1231
      writeLine(indent, "Text Height", pFcf.Dimtxt);
1232
      writeLine(indent, "Frame Color", pFcf.Dimclrd);
1233
      writeLine(indent, "Text Style", pFcf.TextStyleName);
1234
      writeLine(indent, "Text Color", pFcf.Dimclrd);
1235
      writeLine(indent, "X-Direction", pFcf.Direction);
1236
      writeLine(indent, "Normal", pFcf.Normal);
1237
      dumpEntityData(pFcf, indent, Program.xml.DocumentElement);
1238
    }
1239

    
1240
    /************************************************************************/
1241
    /* Hatch Dumper                                                         */
1242
    /************************************************************************/
1243
    /***********************************************************************/
1244
    /* Dump Polyline Loop                                                  */
1245
    /***********************************************************************/
1246
    static void dumpPolylineType(int loopIndex, Hatch pHatch, int indent)
1247
    {
1248
      HatchLoop hl = pHatch.GetLoopAt(loopIndex);
1249
      for (int i = 0; i < hl.Polyline.Count; i++)
1250
      {
1251
        BulgeVertex bv = hl.Polyline[i];
1252
        writeLine(indent, "Vertex " + i.ToString(), bv.Vertex.ToString());
1253
        writeLine(indent + 1, "Bulge " + i.ToString(), bv.Bulge);
1254
        writeLine(indent + 1, "Bulge angle " + i.ToString(), toDegreeString(4 * Math.Atan(bv.Bulge)));
1255
      }
1256
    }
1257

    
1258
    /**********************************************************************/
1259
    /* Dump Circular Arc Edge                                             */
1260
    /**********************************************************************/
1261
    static void dumpCircularArcEdge(int indent, CircularArc2d pCircArc)
1262
    {
1263
      writeLine(indent, "Center", pCircArc.Center);
1264
      writeLine(indent, "Radius", pCircArc.Radius);
1265
      writeLine(indent, "Start Angle", toDegreeString(pCircArc.StartAngle));
1266
      writeLine(indent, "End Angle", toDegreeString(pCircArc.EndAngle));
1267
      writeLine(indent, "Clockwise", pCircArc.IsClockWise);
1268
    }
1269

    
1270
    /**********************************************************************/
1271
    /* Dump Elliptical Arc Edge                                           */
1272
    /**********************************************************************/
1273
    static void dumpEllipticalArcEdge(int indent, EllipticalArc2d pEllipArc)
1274
    {
1275
      writeLine(indent, "Center", pEllipArc.Center);
1276
      writeLine(indent, "Major Radius", pEllipArc.MajorRadius);
1277
      writeLine(indent, "Minor Radius", pEllipArc.MinorRadius);
1278
      writeLine(indent, "Major Axis", pEllipArc.MajorAxis);
1279
      writeLine(indent, "Minor Axis", pEllipArc.MinorAxis);
1280
      writeLine(indent, "Start Angle", toDegreeString(pEllipArc.StartAngle));
1281
      writeLine(indent, "End Angle", toDegreeString(pEllipArc.EndAngle));
1282
      writeLine(indent, "Clockwise", pEllipArc.IsClockWise);
1283
    }
1284
    /**********************************************************************/
1285
    /* Dump NurbCurve Edge                                           */
1286
    /**********************************************************************/
1287
    static void dumpNurbCurveEdge(int indent, NurbCurve2d pNurbCurve)
1288
    {
1289
      NurbCurve2dData d = pNurbCurve.DefinitionData;
1290
      writeLine(indent, "Degree", d.Degree);
1291
      writeLine(indent, "Rational", d.Rational);
1292
      writeLine(indent, "Periodic", d.Periodic);
1293

    
1294
      writeLine(indent, "Number of Control Points", d.ControlPoints.Count);
1295
      for (int i = 0; i < d.ControlPoints.Count; i++)
1296
      {
1297
        writeLine(indent, "Control Point " + i.ToString(), d.ControlPoints[i]);
1298
      }
1299
      writeLine(indent, "Number of Knots", d.Knots.Count);
1300
      for (int i = 0; i < d.Knots.Count; i++)
1301
      {
1302
        writeLine(indent, "Knot " + i.ToString(), d.Knots[i]);
1303
      }
1304

    
1305
      if (d.Rational)
1306
      {
1307
        writeLine(indent, "Number of Weights", d.Weights.Count);
1308
        for (int i = 0; i < d.Weights.Count; i++)
1309
        {
1310
          writeLine(indent, "Weight " + i.ToString(), d.Weights[i]);
1311
        }
1312
      }
1313
    }
1314

    
1315
    /***********************************************************************/
1316
    /* Dump Edge Loop                                                      */
1317
    /***********************************************************************/
1318
    static void dumpEdgesType(int loopIndex, Hatch pHatch, int indent)
1319
    {
1320
      Curve2dCollection edges = pHatch.GetLoopAt(loopIndex).Curves;
1321
      for (int i = 0; i < (int)edges.Count; i++)
1322
      {
1323
        using (Curve2d pEdge = edges[i])
1324
        {
1325
          writeLine(indent, string.Format("Edge {0}", i), pEdge.GetType().Name);
1326
          switch (pEdge.GetType().Name)
1327
          {
1328
            case "LineSegment2d":
1329
              break;
1330
            case "CircularArc2d":
1331
              dumpCircularArcEdge(indent + 1, (CircularArc2d)pEdge);
1332
              break;
1333
            case "EllipticalArc2d":
1334
              dumpEllipticalArcEdge(indent + 1, (EllipticalArc2d)pEdge);
1335
              break;
1336
            case "NurbCurve2d":
1337
              dumpNurbCurveEdge(indent + 1, (NurbCurve2d)pEdge);
1338
              break;
1339
          }
1340

    
1341
          /******************************************************************/
1342
          /* Common Edge Properties                                         */
1343
          /******************************************************************/
1344
          Interval interval = pEdge.GetInterval();
1345
          writeLine(indent + 1, "Start Point", pEdge.EvaluatePoint(interval.LowerBound));
1346
          writeLine(indent + 1, "End Point", pEdge.EvaluatePoint(interval.UpperBound));
1347
          writeLine(indent + 1, "Closed", pEdge.IsClosed());
1348
        }
1349
      }
1350
    }
1351
    /************************************************************************/
1352
    /* Convert the specified value to a LoopType string                     */
1353
    /************************************************************************/
1354
    string toLooptypeString(HatchLoopTypes loopType)
1355
    {
1356
      string retVal = "";
1357
      if ((loopType & HatchLoopTypes.External) != 0)
1358
        retVal = retVal + " | kExternal";
1359

    
1360
      if ((loopType & HatchLoopTypes.Polyline) != 0)
1361
        retVal = retVal + " | kPolyline";
1362

    
1363
      if ((loopType & HatchLoopTypes.Derived) != 0)
1364
        retVal = retVal + " | kDerived";
1365

    
1366
      if ((loopType & HatchLoopTypes.Textbox) != 0)
1367
        retVal = retVal + " | kTextbox";
1368

    
1369
      if ((loopType & HatchLoopTypes.Outermost) != 0)
1370
        retVal = retVal + " | kOutermost";
1371

    
1372
      if ((loopType & HatchLoopTypes.NotClosed) != 0)
1373
        retVal = retVal + " | kNotClosed";
1374

    
1375
      if ((loopType & HatchLoopTypes.SelfIntersecting) != 0)
1376
        retVal = retVal + " | kSelfIntersecting";
1377

    
1378
      if ((loopType & HatchLoopTypes.TextIsland) != 0)
1379
        retVal = retVal + " | kTextIsland";
1380

    
1381
      if ((loopType & HatchLoopTypes.Duplicate) != 0)
1382
        retVal = retVal + " | kDuplicate";
1383

    
1384
      return retVal == "" ? "kDefault" : retVal.Substring(3);
1385
    }
1386

    
1387
    void dump(Hatch pHatch, int indent)
1388
    {
1389
      writeLine(indent++, pHatch.GetRXClass().Name, pHatch.Handle);
1390
      writeLine(indent, "Hatch Style", pHatch.HatchStyle);
1391
      writeLine(indent, "Hatch Object Type", pHatch.HatchObjectType);
1392
      writeLine(indent, "Is Hatch", pHatch.IsHatch);
1393
      writeLine(indent, "Is Gradient", !pHatch.IsGradient);
1394
      if (pHatch.IsHatch)
1395
      {
1396
        /******************************************************************/
1397
        /* Dump Hatch Parameters                                          */
1398
        /******************************************************************/
1399
        writeLine(indent, "Pattern Type", pHatch.PatternType);
1400
        switch (pHatch.PatternType)
1401
        {
1402
          case HatchPatternType.PreDefined:
1403
          case HatchPatternType.CustomDefined:
1404
            writeLine(indent, "Pattern Name", pHatch.PatternName);
1405
            writeLine(indent, "Solid Fill", pHatch.IsSolidFill);
1406
            if (!pHatch.IsSolidFill)
1407
            {
1408
              writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle));
1409
              writeLine(indent, "Pattern Scale", pHatch.PatternScale);
1410
            }
1411
            break;
1412
          case HatchPatternType.UserDefined:
1413
            writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle));
1414
            writeLine(indent, "Pattern Double", pHatch.PatternDouble);
1415
            writeLine(indent, "Pattern Space", pHatch.PatternSpace);
1416
            break;
1417
        }
1418
        DBObjectCollection entitySet = new DBObjectCollection();
1419
        Handle hhh = pHatch.Handle;
1420
        if (hhh.Value == 1692) //69C)
1421
        {
1422
          pHatch.Explode(entitySet);
1423
          return;
1424
        }
1425
        if (hhh.Value == 1693) //69D)
1426
        {
1427
          try
1428
          {
1429
            pHatch.Explode(entitySet);
1430
          }
1431
          catch (System.Exception e)
1432
          {
1433
            if (e.Message == "eCannotExplodeEntity")
1434
            {
1435
              writeLine(indent, "Hatch " + e.Message + ": ", pHatch.Handle);
1436
              return;
1437
            }
1438
          }
1439
        }
1440
      }
1441
      if (pHatch.IsGradient)
1442
      {
1443
        /******************************************************************/
1444
        /* Dump Gradient Parameters                                       */
1445
        /******************************************************************/
1446
        writeLine(indent, "Gradient Type", pHatch.GradientType);
1447
        writeLine(indent, "Gradient Name", pHatch.GradientName);
1448
        writeLine(indent, "Gradient Angle", toDegreeString(pHatch.GradientAngle));
1449
        writeLine(indent, "Gradient Shift", pHatch.GradientShift);
1450
        writeLine(indent, "Gradient One-Color Mode", pHatch.GradientOneColorMode);
1451
        if (pHatch.GradientOneColorMode)
1452
        {
1453
          writeLine(indent, "ShadeTintValue", pHatch.ShadeTintValue);
1454
        }
1455
        GradientColor[] colors = pHatch.GetGradientColors();
1456
        for (int i = 0; i < colors.Length; i++)
1457
        {
1458
          writeLine(indent, string.Format("Color         {0}", i), colors[i].get_Color());
1459
          writeLine(indent, string.Format("Interpolation {0}", i), colors[i].get_Value());
1460
        }
1461
      }
1462

    
1463
      /********************************************************************/
1464
      /* Dump Associated Objects                                          */
1465
      /********************************************************************/
1466
      writeLine(indent, "Associated objects", pHatch.Associative);
1467
      foreach (ObjectId id in pHatch.GetAssociatedObjectIds())
1468
      {
1469
        writeLine(indent + 1, id.ObjectClass.Name, id.Handle);
1470
      }
1471

    
1472
      /********************************************************************/
1473
      /* Dump Loops                                                       */
1474
      /********************************************************************/
1475
      writeLine(indent, "Loops", pHatch.NumberOfLoops);
1476
      for (int i = 0; i < pHatch.NumberOfLoops; i++)
1477
      {
1478
        writeLine(indent + 1, "Loop " + i.ToString(), toLooptypeString(pHatch.LoopTypeAt(i)));
1479

    
1480
        /******************************************************************/
1481
        /* Dump Loop                                                      */
1482
        /******************************************************************/
1483
        if ((pHatch.LoopTypeAt(i) & HatchLoopTypes.Polyline) != 0)
1484
        {
1485
          dumpPolylineType(i, pHatch, indent + 2);
1486
        }
1487
        else
1488
        {
1489
          dumpEdgesType(i, pHatch, indent + 2);
1490
        }
1491
        /******************************************************************/
1492
        /* Dump Associated Objects                                        */
1493
        /******************************************************************/
1494
        if (pHatch.Associative)
1495
        {
1496
          writeLine(indent + 2, "Associated objects");
1497
          foreach (ObjectId id in pHatch.GetAssociatedObjectIdsAt(i))
1498
          {
1499
            writeLine(indent + 3, id.ObjectClass.Name, id.Handle);
1500
          }
1501
        }
1502
      }
1503

    
1504
      writeLine(indent, "Elevation", pHatch.Elevation);
1505
      writeLine(indent, "Normal", pHatch.Normal);
1506
      dumpEntityData(pHatch, indent, Program.xml.DocumentElement);
1507
    }
1508

    
1509
    /************************************************************************/
1510
    /* Leader Dumper                                                          */
1511
    /************************************************************************/
1512
    void dump(Leader pLeader, int indent)
1513
    {
1514
      writeLine(indent++, pLeader.GetRXClass().Name, pLeader.Handle);
1515
      writeLine(indent, "Dimension Style", pLeader.DimensionStyleName);
1516

    
1517
      writeLine(indent, "Annotation");
1518
      if (!pLeader.Annotation.IsNull)
1519
      {
1520
        writeLine(indent++, pLeader.Annotation.ObjectClass.Name, pLeader.Annotation.Handle);
1521
      }
1522
      writeLine(indent + 1, "Type", pLeader.AnnoType);
1523
      writeLine(indent + 1, "Height", pLeader.AnnoHeight);
1524
      writeLine(indent + 1, "Width", pLeader.AnnoWidth);
1525
      writeLine(indent + 1, "Offset", pLeader.AnnotationOffset);
1526
      writeLine(indent, "Has Arrowhead", pLeader.HasArrowHead);
1527
      writeLine(indent, "Has Hook Line", pLeader.HasHookLine);
1528
      writeLine(indent, "Splined", pLeader.IsSplined);
1529

    
1530
      for (int i = 0; i < pLeader.NumVertices; i++)
1531
      {
1532
        writeLine(indent, string.Format("Vertex {0}", i), pLeader.VertexAt(i));
1533
      }
1534
      writeLine(indent, "Normal", pLeader.Normal);
1535
      dumpCurveData(pLeader, indent, Program.xml.DocumentElement);
1536
    }
1537

    
1538
        /************************************************************************/
1539
        /* Line Dumper                                                          */
1540
        /************************************************************************/
1541
        void dump(Line pLine, int indent, XmlNode node)
1542
        {
1543
            if (node != null)
1544
            {
1545
                XmlNode LineNode = Program.xml.CreateElement(pLine.GetRXClass().Name);
1546

    
1547
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1548
                HandleAttr.Value = pLine.Handle.ToString();
1549
                LineNode.Attributes.SetNamedItem(HandleAttr);
1550

    
1551
                XmlNode StartPointNode = Program.xml.CreateElement("Vertex");
1552
                {
1553
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1554
                    XAttr.Value = pLine.StartPoint.X.ToString();
1555
                    StartPointNode.Attributes.SetNamedItem(XAttr);
1556

    
1557
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1558
                    YAttr.Value = pLine.StartPoint.Y.ToString();
1559
                    StartPointNode.Attributes.SetNamedItem(YAttr);
1560

    
1561
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1562
                    ZAttr.Value = pLine.StartPoint.Z.ToString();
1563
                    StartPointNode.Attributes.SetNamedItem(ZAttr);
1564
                }
1565
                LineNode.AppendChild(StartPointNode);
1566

    
1567
                XmlNode EndPointNode = Program.xml.CreateElement("Vertex");
1568
                {
1569
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1570
                    XAttr.Value = pLine.EndPoint.X.ToString();
1571
                    EndPointNode.Attributes.SetNamedItem(XAttr);
1572

    
1573
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1574
                    YAttr.Value = pLine.EndPoint.Y.ToString();
1575
                    EndPointNode.Attributes.SetNamedItem(YAttr);
1576

    
1577
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1578
                    ZAttr.Value = pLine.EndPoint.Z.ToString();
1579
                    EndPointNode.Attributes.SetNamedItem(ZAttr);
1580
                }
1581
                LineNode.AppendChild(EndPointNode);
1582

    
1583
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
1584
                NormalAttr.Value = pLine.Normal.ToString();
1585
                LineNode.Attributes.SetNamedItem(NormalAttr);
1586

    
1587
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
1588
                ThicknessAttr.Value = pLine.Thickness.ToString();
1589
                LineNode.Attributes.SetNamedItem(ThicknessAttr);
1590

    
1591
                dumpEntityData(pLine, indent, LineNode);
1592

    
1593
                node.AppendChild(LineNode);
1594
            }
1595
        }
1596

    
1597
    /************************************************************************/
1598
    /* MInsertBlock Dumper                                                  */
1599
    /************************************************************************/
1600
    void dump(MInsertBlock pMInsert, int indent, XmlNode node)
1601
    {
1602
      writeLine(indent++, pMInsert.GetRXClass().Name, pMInsert.Handle);
1603

    
1604
      using (BlockTableRecord pRecord = (BlockTableRecord)pMInsert.BlockTableRecord.Open(OpenMode.ForRead))
1605
      {
1606
            writeLine(indent, "Name", pRecord.Name);
1607
            writeLine(indent, "Rows", pMInsert.Rows);
1608
            writeLine(indent, "Columns", pMInsert.Columns);
1609
            writeLine(indent, "Row Spacing", pMInsert.RowSpacing);
1610
            writeLine(indent, "Column Spacing", pMInsert.ColumnSpacing);
1611
            dumpBlockRefData(pMInsert, indent, node);
1612
      }
1613
    }
1614

    
1615
    /************************************************************************/
1616
    /* Mline Dumper                                                         */
1617
    /************************************************************************/
1618
    void dump(Mline pMline, int indent)
1619
    {
1620
      writeLine(indent++, pMline.GetRXClass().Name, pMline.Handle);
1621
      writeLine(indent, "Style", pMline.Style);
1622
      writeLine(indent, "Closed", pMline.IsClosed);
1623
      writeLine(indent, "Scale", pMline.Scale);
1624
      writeLine(indent, "Suppress Start Caps", pMline.SupressStartCaps);
1625
      writeLine(indent, "Suppress End Caps", pMline.SupressEndCaps);
1626
      writeLine(indent, "Normal", pMline.Normal);
1627

    
1628
      /********************************************************************/
1629
      /* Dump the segment data                                            */
1630
      /********************************************************************/
1631
      for (int i = 0; i < pMline.NumberOfVertices; i++)
1632
      {
1633
        writeLine(indent, "Segment", i);
1634
        writeLine(indent + 1, "Vertex", pMline.VertexAt(i));
1635
      }
1636
      dumpEntityData(pMline, indent, Program.xml.DocumentElement);
1637
    }
1638
    /************************************************************************/
1639
    /* MText Dumper                                                         */
1640
    /************************************************************************/
1641
    void dump(MText pMText, int indent)
1642
    {
1643
      writeLine(indent++, pMText.GetRXClass().Name, pMText.Handle);
1644
      writeLine(indent, "Contents", pMText.Contents);
1645
      writeLine(indent, "Location", pMText.Location);
1646
      writeLine(indent, "Height", pMText.TextHeight);
1647
      writeLine(indent, "Rotation", toDegreeString(pMText.Rotation));
1648
      writeLine(indent, "Text Style Id", pMText.TextStyleId);
1649
      writeLine(indent, "Attachment", pMText.Attachment);
1650
      writeLine(indent, "Background Fill On", pMText.BackgroundFill);
1651
      writeLine(indent, "Background Fill Color", pMText.BackgroundFillColor);
1652
      writeLine(indent, "Background Scale Factor", pMText.BackgroundScaleFactor);
1653
      writeLine(indent, "Background Transparency Method", pMText.BackgroundTransparency);
1654
      writeLine(indent, "X-Direction", pMText.Direction);
1655
      writeLine(indent, "Flow Direction", pMText.FlowDirection);
1656
      writeLine(indent, "Width", pMText.Width);
1657
      writeLine(indent, "Actual Height", pMText.ActualHeight);
1658
      writeLine(indent, "Actual Width", pMText.ActualWidth);
1659

    
1660
      Point3dCollection points = pMText.GetBoundingPoints();
1661
      writeLine(indent, "TL Bounding Point", points[0]);
1662
      writeLine(indent, "TR Bounding Point", points[1]);
1663
      writeLine(indent, "BL Bounding Point", points[2]);
1664
      writeLine(indent, "BR Bounding Point", points[3]);
1665
      writeLine(indent, "Normal", pMText.Normal);
1666

    
1667
      dumpEntityData(pMText, indent, Program.xml.DocumentElement);
1668
    }
1669

    
1670
        /************************************************************************/
1671
        /* Ordinate Dimension Dumper                                            */
1672
        /************************************************************************/
1673
        XmlNode dump(OrdinateDimension pDim, int indent, XmlNode node)
1674
        {
1675
            if (node != null)
1676
            {
1677
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
1678

    
1679
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1680
                HandleAttr.Value = pDim.Handle.ToString();
1681
                DimNode.Attributes.SetNamedItem(HandleAttr);
1682

    
1683
                XmlAttribute DefiningPointAttr = Program.xml.CreateAttribute("DefiningPoint");
1684
                DefiningPointAttr.Value = pDim.DefiningPoint.ToString();
1685
                DimNode.Attributes.SetNamedItem(DefiningPointAttr);
1686

    
1687
                XmlAttribute UsingXAxisAttr = Program.xml.CreateAttribute("UsingXAxis");
1688
                UsingXAxisAttr.Value = pDim.UsingXAxis.ToString();
1689
                DimNode.Attributes.SetNamedItem(UsingXAxisAttr);
1690

    
1691
                XmlAttribute UsingYAxisAttr = Program.xml.CreateAttribute("UsingYAxis");
1692
                UsingYAxisAttr.Value = pDim.UsingYAxis.ToString();
1693
                DimNode.Attributes.SetNamedItem(UsingYAxisAttr);
1694

    
1695
                XmlAttribute LeaderEndPointAttr = Program.xml.CreateAttribute("LeaderEndPoint");
1696
                LeaderEndPointAttr.Value = pDim.LeaderEndPoint.ToString();
1697
                DimNode.Attributes.SetNamedItem(LeaderEndPointAttr);
1698

    
1699
                XmlAttribute OriginAttr = Program.xml.CreateAttribute("Origin");
1700
                OriginAttr.Value = pDim.Origin.ToString();
1701
                DimNode.Attributes.SetNamedItem(OriginAttr);
1702

    
1703
                dumpDimData(pDim, indent, DimNode);
1704

    
1705
                return DimNode;
1706
            }
1707

    
1708
            return null;
1709
        }
1710

    
1711
        /************************************************************************/
1712
        /* PolyFaceMesh Dumper                                                  */
1713
        /************************************************************************/
1714
        XmlNode dump(PolyFaceMesh pPoly, int indent, XmlNode node)
1715
        {
1716
            if (node != null)
1717
            {
1718
                XmlElement PolyNode = Program.xml.CreateElement(pPoly.GetRXClass().Name);
1719

    
1720
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1721
                HandleAttr.Value = pPoly.Handle.ToString();
1722
                PolyNode.Attributes.SetNamedItem(HandleAttr);
1723

    
1724
                XmlAttribute NumVerticesAttr = Program.xml.CreateAttribute("NumVertices");
1725
                NumVerticesAttr.Value = pPoly.NumVertices.ToString();
1726
                PolyNode.Attributes.SetNamedItem(NumVerticesAttr);
1727

    
1728
                XmlAttribute NumFacesAttr = Program.xml.CreateAttribute("NumFaces");
1729
                NumFacesAttr.Value = pPoly.NumFaces.ToString();
1730
                PolyNode.Attributes.SetNamedItem(NumFacesAttr);
1731

    
1732
                /********************************************************************/
1733
                /* dump vertices and faces                                          */
1734
                /********************************************************************/
1735
                int vertexCount = 0;
1736
                int faceCount = 0;
1737
                foreach (ObjectId objId in pPoly)
1738
                {
1739
                    using (Entity ent = (Entity)objId.GetObject(OpenMode.ForRead))
1740
                    {
1741
                        if (ent is PolyFaceMeshVertex)
1742
                        {
1743
                            PolyFaceMeshVertex pVertex = (PolyFaceMeshVertex)ent;
1744

    
1745
                            XmlElement VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name);
1746

    
1747
                            XmlAttribute _HandleAttr = Program.xml.CreateAttribute("Handle");
1748
                            _HandleAttr.Value = pVertex.Handle.ToString();
1749
                            VertexNode.Attributes.SetNamedItem(_HandleAttr);
1750

    
1751
                            XmlAttribute PositionAttr = Program.xml.CreateAttribute("Position");
1752
                            PositionAttr.Value = pVertex.Position.ToString();
1753
                            VertexNode.Attributes.SetNamedItem(PositionAttr);
1754

    
1755
                            dumpEntityData(pVertex, indent + 1, VertexNode);
1756

    
1757
                            PolyNode.AppendChild(VertexNode);
1758
                        }
1759
                        else if (ent is FaceRecord)
1760
                        {
1761
                            FaceRecord pFace = (FaceRecord)ent;
1762
                            string face = "{";
1763
                            for (short i = 0; i < 4; i++)
1764
                            {
1765
                                if (i > 0)
1766
                                {
1767
                                    face = face + " ";
1768
                                }
1769
                                face = face + pFace.GetVertexAt(i).ToString();
1770
                            }
1771

    
1772
                            face += "}";
1773

    
1774
                            XmlElement FaceNode = Program.xml.CreateElement(pFace.GetRXClass().Name);
1775

    
1776
                            XmlAttribute _HandleAttr = Program.xml.CreateAttribute("Handle");
1777
                            _HandleAttr.Value = pFace.Handle.ToString();
1778
                            FaceNode.Attributes.SetNamedItem(_HandleAttr);
1779
                            FaceNode.InnerText = face;
1780

    
1781
                            dumpEntityData(pFace, indent + 1, FaceNode);
1782

    
1783
                            PolyNode.AppendChild(FaceNode);
1784
                        }
1785
                        else
1786
                        { // Unknown entity type
1787
                            writeLine(indent, "Unexpected Entity");
1788
                        }
1789
                    }
1790
                }
1791
                dumpEntityData(pPoly, indent, PolyNode);
1792

    
1793
                return PolyNode;
1794
            }
1795

    
1796
            return null;
1797
        }
1798

    
1799
    /************************************************************************/
1800
    /* Ole2Frame                                                            */
1801
    /************************************************************************/
1802
    void dump(Ole2Frame pOle, int indent)
1803
    {
1804
      writeLine(indent++, pOle.GetRXClass().Name, pOle.Handle);
1805

    
1806
      Rectangle3d pos = (Rectangle3d)pOle.Position3d;
1807
      writeLine(indent, "Lower Left", pos.LowerLeft);
1808
      writeLine(indent, "Lower Right", pos.LowerRight);
1809
      writeLine(indent, "Upper Left", pos.UpperLeft);
1810
      writeLine(indent, "Upper Right", pos.UpperRight);
1811
      writeLine(indent, "Type", pOle.Type);
1812
      writeLine(indent, "User Type", pOle.UserType);
1813
      if (pOle.Type == Ole2Frame.ItemType.Link)
1814
      {
1815
        writeLine(indent, "Link Name", pOle.LinkName);
1816
        writeLine(indent, "Link Path", pOle.LinkPath);
1817
      }
1818
      writeLine(indent, "Output Quality", pOle.OutputQuality);
1819
      dumpEntityData(pOle, indent, Program.xml.DocumentElement);
1820
    }
1821

    
1822
    /************************************************************************/
1823
    /* Point Dumper                                                         */
1824
    /************************************************************************/
1825
    void dump(DBPoint pPoint, int indent)
1826
    {
1827
      writeLine(indent++, pPoint.GetRXClass().Name, pPoint.Handle);
1828
      writeLine(indent, "Position", pPoint.Position);
1829
      writeLine(indent, "ECS Rotation", toDegreeString(pPoint.EcsRotation));
1830
      writeLine(indent, "Normal", pPoint.Normal);
1831
      writeLine(indent, "Thickness", pPoint.Thickness);
1832
      dumpEntityData(pPoint, indent, Program.xml.DocumentElement);
1833
    }
1834

    
1835
    /************************************************************************/
1836
    /* Polygon Mesh Dumper                                                  */
1837
    /************************************************************************/
1838
    void dump(PolygonMesh pPoly, int indent)
1839
    {
1840
      writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1841
      writeLine(indent, "m Size", pPoly.MSize);
1842
      writeLine(indent, "m-Closed", pPoly.IsMClosed);
1843
      writeLine(indent, "m Surface Density", pPoly.MSurfaceDensity);
1844
      writeLine(indent, "n Size", pPoly.NSize);
1845
      writeLine(indent, "n-Closed", pPoly.IsNClosed);
1846
      writeLine(indent, "n Surface Density", pPoly.NSurfaceDensity);
1847
      /********************************************************************/
1848
      /* dump vertices                                                    */
1849
      /********************************************************************/
1850
      int vertexCount = 0;
1851
      foreach (object o in pPoly)
1852
      {
1853
        PolygonMeshVertex pVertex = o as PolygonMeshVertex;
1854
        if (pVertex != null)
1855
        {
1856
          writeLine(indent, pVertex.GetRXClass().Name, vertexCount++);
1857
          writeLine(indent + 1, "Handle", pVertex.Handle);
1858
          writeLine(indent + 1, "Position", pVertex.Position);
1859
          writeLine(indent + 1, "Type", pVertex.VertexType);
1860
        }
1861
      }
1862
      dumpEntityData(pPoly, indent, Program.xml.DocumentElement);
1863
    }
1864

    
1865
        /************************************************************************/
1866
        /* Polyline Dumper                                                      */
1867
        /************************************************************************/
1868
        void dump(Teigha.DatabaseServices.Polyline pPoly, int indent, XmlNode node)
1869
        {
1870
            writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1871
            writeLine(indent, "Has Width", pPoly.HasWidth);
1872
            if (!pPoly.HasWidth)
1873
            {
1874
                writeLine(indent, "Constant Width", pPoly.ConstantWidth);
1875
            }
1876
            writeLine(indent, "Has Bulges", pPoly.HasBulges);
1877
            writeLine(indent, "Elevation", pPoly.Elevation);
1878
            writeLine(indent, "Normal", pPoly.Normal);
1879
            writeLine(indent, "Thickness", pPoly.Thickness);
1880

    
1881
            /********************************************************************/
1882
            /* dump vertices                                                    */
1883
            /********************************************************************/
1884
            if (node != null)
1885
            {
1886
                XmlNode PolylineNode = Program.xml.CreateElement(pPoly.GetRXClass().Name);
1887
                XmlAttribute CountAttr = Program.xml.CreateAttribute("Count");
1888
                CountAttr.Value = pPoly.NumberOfVertices.ToString();
1889
                PolylineNode.Attributes.SetNamedItem(CountAttr);
1890

    
1891
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1892
                HandleAttr.Value = pPoly.Handle.ToString();
1893
                PolylineNode.Attributes.SetNamedItem(HandleAttr);
1894

    
1895
                for (int i = 0; i < pPoly.NumberOfVertices; i++)
1896
                {
1897
                    XmlNode VertexNode = Program.xml.CreateElement("Vertex");
1898

    
1899
                    XmlAttribute SegmentTypeAttr = Program.xml.CreateAttribute("SegmentType");
1900
                    SegmentTypeAttr.Value = pPoly.GetSegmentType(i).ToString();
1901

    
1902
                    Point3d pt = pPoly.GetPoint3dAt(i);
1903
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1904
                    XAttr.Value = pt.X.ToString();
1905
                    VertexNode.Attributes.SetNamedItem(XAttr);
1906

    
1907
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1908
                    YAttr.Value = pt.Y.ToString();
1909
                    VertexNode.Attributes.SetNamedItem(YAttr);
1910

    
1911
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1912
                    ZAttr.Value = pt.Z.ToString();
1913
                    VertexNode.Attributes.SetNamedItem(ZAttr);
1914

    
1915
                    if (pPoly.HasWidth)
1916
                    {
1917
                        XmlAttribute StartWidthAttr = Program.xml.CreateAttribute("StartWidth");
1918
                        StartWidthAttr.Value = pPoly.GetStartWidthAt(i).ToString();
1919
                        VertexNode.Attributes.SetNamedItem(StartWidthAttr);
1920

    
1921
                        XmlAttribute EndWidthAttr = Program.xml.CreateAttribute("EndWidth");
1922
                        EndWidthAttr.Value = pPoly.GetEndWidthAt(i).ToString();
1923
                        VertexNode.Attributes.SetNamedItem(EndWidthAttr);
1924
                    }
1925
                    if (pPoly.HasBulges)
1926
                    {
1927
                        XmlAttribute BulgeAttr = Program.xml.CreateAttribute("Bulge");
1928
                        BulgeAttr.Value = pPoly.GetBulgeAt(i).ToString();
1929
                        VertexNode.Attributes.SetNamedItem(BulgeAttr);
1930

    
1931
                        if (pPoly.GetSegmentType(i) == SegmentType.Arc)
1932
                        {
1933
                            XmlAttribute BulgeAngleAttr = Program.xml.CreateAttribute("BulgeAngle");
1934
                            BulgeAngleAttr.Value = pPoly.GetBulgeAt(i).ToString();
1935
                            VertexNode.Attributes.SetNamedItem(BulgeAngleAttr);
1936
                        }
1937
                    }
1938

    
1939
                    PolylineNode.AppendChild(VertexNode);
1940
                }
1941

    
1942
                dumpEntityData(pPoly, indent, PolylineNode);
1943
                node.AppendChild(PolylineNode);
1944
            }
1945
        }
1946

    
1947
    class DrawContextDumper : Context
1948
    {
1949
      Database _db;
1950
      public DrawContextDumper(Database db)
1951
      {
1952
        _db = db;
1953
      }
1954
      public override Database Database
1955
      {
1956
        get { return _db; }
1957
      }
1958
      public override bool IsBoundaryClipping
1959
      {
1960
        get { return false; }
1961
      }
1962
      public override bool IsPlotGeneration
1963
      {
1964
        get { return false; }
1965
      }
1966
      public override bool IsPostScriptOut
1967
      {
1968
        get { return false; }
1969
      }
1970
    }
1971
    class SubEntityTraitsDumper : SubEntityTraits
1972
    {
1973
      short _color;
1974
      int _drawFlags;
1975
      FillType _ft;
1976
      ObjectId _layer;
1977
      ObjectId _linetype;
1978
      LineWeight _lineWeight;
1979
      Mapper _mapper;
1980
      double _lineTypeScale;
1981
      ObjectId _material;
1982
      PlotStyleDescriptor _plotStyleDescriptor;
1983
      bool _sectionable;
1984
      bool _selectionOnlyGeometry;
1985
      ShadowFlags _shadowFlags;
1986
      double _thickness;
1987
      EntityColor _trueColor;
1988
      Transparency _transparency;
1989
      ObjectId _visualStyle;
1990
      public SubEntityTraitsDumper(Database db)
1991
      {
1992
        _drawFlags = 0; // kNoDrawFlags 
1993
        _color = 0;
1994
        _ft = FillType.FillAlways;
1995
        _layer = db.Clayer;
1996
        _linetype = db.Celtype;
1997
        _lineWeight = db.Celweight;
1998
        _lineTypeScale = db.Celtscale;
1999
        _material = db.Cmaterial;
2000
        _shadowFlags = ShadowFlags.ShadowsIgnore;
2001
        _thickness = 0;
2002
        _trueColor = new EntityColor(ColorMethod.None);
2003
        _transparency = new Transparency();
2004
      }
2005

    
2006
      protected override void SetLayerFlags(LayerFlags flags)
2007
      {
2008
        writeLine(0, string.Format("SubEntityTraitsDumper.SetLayerFlags(flags = {0})", flags));
2009
      }
2010
      public override void AddLight(ObjectId lightId)
2011
      {
2012
        writeLine(0, string.Format("SubEntityTraitsDumper.AddLight(lightId = {0})", lightId.ToString()));
2013
      }
2014
      public override void SetupForEntity(Entity entity)
2015
      {
2016
        writeLine(0, string.Format("SubEntityTraitsDumper.SetupForEntity(entity = {0})", entity.ToString()));
2017
      }
2018

    
2019
      public override short Color
2020
      {
2021
        get { return _color; }
2022
        set { _color = value; }
2023
      }
2024
      public override int DrawFlags
2025
      {
2026
        get { return _drawFlags; }
2027
        set { _drawFlags = value; }
2028
      }
2029
      public override FillType FillType
2030
      {
2031
        get { return _ft; }
2032
        set { _ft = value; }
2033
      }
2034
      public override ObjectId Layer
2035
      {
2036
        get { return _layer; }
2037
        set { _layer = value; }
2038
      }
2039
      public override ObjectId LineType
2040
      {
2041
        get { return _linetype; }
2042
        set { _linetype = value; }
2043
      }
2044
      public override double LineTypeScale
2045
      {
2046
        get { return _lineTypeScale; }
2047
        set { _lineTypeScale = value; }
2048
      }
2049
      public override LineWeight LineWeight
2050
      {
2051
        get { return _lineWeight; }
2052
        set { _lineWeight = value; }
2053
      }
2054
      public override Mapper Mapper
2055
      {
2056
        get { return _mapper; }
2057
        set { _mapper = value; }
2058
      }
2059
      public override ObjectId Material
2060
      {
2061
        get { return _material; }
2062
        set { _material = value; }
2063
      }
2064
      public override PlotStyleDescriptor PlotStyleDescriptor
2065
      {
2066
        get { return _plotStyleDescriptor; }
2067
        set { _plotStyleDescriptor = value; }
2068
      }
2069
      public override bool Sectionable
2070
      {
2071
        get { return _sectionable; }
2072
        set { _sectionable = value; }
2073
      }
2074
      public override bool SelectionOnlyGeometry
2075
      {
2076
        get { return _selectionOnlyGeometry; }
2077
        set { _selectionOnlyGeometry = value; }
2078
      }
2079
      public override ShadowFlags ShadowFlags
2080
      {
2081
        get { return _shadowFlags; }
2082
        set { _shadowFlags = value; }
2083
      }
2084
      public override double Thickness
2085
      {
2086
        get { return _thickness; }
2087
        set { _thickness = value; }
2088
      }
2089
      public override EntityColor TrueColor
2090
      {
2091
        get { return _trueColor; }
2092
        set { _trueColor = value; }
2093
      }
2094
      public override Transparency Transparency
2095
      {
2096
        get { return _transparency; }
2097
        set { _transparency = value; }
2098
      }
2099
      public override ObjectId VisualStyle
2100
      {
2101
        get { return _visualStyle; }
2102
        set { _visualStyle = value; }
2103
      }
2104
      public override void SetSelectionMarker(IntPtr sm)
2105
      {
2106
      }
2107
    }
2108
    class WorldGeometryDumper : WorldGeometry
2109
    {
2110
      Stack<Matrix3d> modelMatrix;
2111
      Stack<ClipBoundary> clips;
2112
      int indent;
2113
      public WorldGeometryDumper(int indent)
2114
        : base()
2115
      {
2116
        this.indent = indent;
2117
        modelMatrix = new Stack<Matrix3d>();
2118
        clips = new Stack<ClipBoundary>();
2119
        modelMatrix.Push(Matrix3d.Identity);
2120
      }
2121
      public override Matrix3d ModelToWorldTransform
2122
      {
2123
        get { return modelMatrix.Peek(); }
2124
      }
2125
      public override Matrix3d WorldToModelTransform
2126
      {
2127
        get { return modelMatrix.Peek().Inverse(); }
2128
      }
2129

    
2130
      public override Matrix3d PushOrientationTransform(OrientationBehavior behavior)
2131
      {
2132
        writeLine(indent, string.Format("WorldGeometry.PushOrientationTransform(behavior = {0})", behavior));
2133
        return new Matrix3d();
2134
      }
2135
      public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point2d offset)
2136
      {
2137
        writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset));
2138
        return new Matrix3d();
2139
      }
2140
      public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point3d offset)
2141
      {
2142
        writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset));
2143
        return new Matrix3d();
2144
      }
2145
      public override bool OwnerDraw(GdiDrawObject gdiDrawObject, Point3d position, Vector3d u, Vector3d v)
2146
      {
2147
        writeLine(indent, string.Format("WorldGeometry.OwnerDraw(gdiDrawObject = {0}, position = {1}, u = {2}, v = {3})", gdiDrawObject, position, u, v));
2148
        return false;
2149
      }
2150
      public override bool Polyline(Teigha.GraphicsInterface.Polyline polylineObj)
2151
      {
2152
        writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}", polylineObj));
2153
        return false;
2154
      }
2155
      public override bool Polypoint(Point3dCollection points, Vector3dCollection normals, IntPtrCollection subentityMarkers)
2156
      {
2157
        writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, normals = {1}, subentityMarkers = {2}", points, normals, subentityMarkers));
2158
        return false;
2159
      }
2160
      public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, Vector3dCollection normals, IntPtrCollection subentityMarkers)
2161
      {
2162
        writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, normals = {2}, subentityMarkers = {3}", points, colors, normals, subentityMarkers));
2163
        return false;
2164
      }
2165
      public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, TransparencyCollection transparency, Vector3dCollection normals, IntPtrCollection subentityMarkers, int pointSize)
2166
      {
2167
        writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, transparency = {2}, normals = {3}, subentityMarkers = {4}, pointSize = {5}", points, colors, transparency, normals, subentityMarkers, pointSize));
2168
        return false;
2169
      }
2170
      public override bool PolyPolyline(Teigha.GraphicsInterface.PolylineCollection polylineCollection)
2171
      {
2172
        writeLine(indent, string.Format("WorldGeometry.PolyPolyline(polylineCollection = {0}", polylineCollection));
2173
        return false;
2174
      }
2175
      public override bool PolyPolygon(UInt32Collection numPolygonPositions, Point3dCollection polygonPositions, UInt32Collection numPolygonPoints, Point3dCollection polygonPoints, EntityColorCollection outlineColors, LinetypeCollection outlineTypes, EntityColorCollection fillColors, Teigha.Colors.TransparencyCollection fillOpacities)
2176
      {
2177
        writeLine(indent, string.Format("WorldGeometry.PolyPolygon(numPolygonPositions = {0}, polygonPositions = {1}, numPolygonPoints = {2}, polygonPoints = {3}, outlineColors = {4}, outlineTypes = {5}, fillColors = {6}, fillOpacities = {7})", numPolygonPositions, polygonPositions, numPolygonPoints, polygonPoints, outlineColors, outlineTypes, fillColors, fillOpacities));
2178
        return false;
2179
      }
2180
      public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point2d extents)
2181
      {
2182
        writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents));
2183
        return new Matrix3d();
2184
      }
2185
      public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point3d extents)
2186
      {
2187
        writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents));
2188
        return new Matrix3d();
2189
      }
2190
      public override bool EllipticalArc(Point3d center, Vector3d normal, double majorAxisLength, double minorAxisLength, double startDegreeInRads, double endDegreeInRads, double tiltDegreeInRads, ArcType arType)
2191
      {
2192
        writeLine(indent, string.Format("WorldGeometry.EllipticalArc(center = {0}, normal = {1}, majorAxisLength = {2}, minorAxisLength = {3}, startDegreeInRads = {4}, endDegreeInRads = {5}, tiltDegreeInRads = {6}, arType = {7}", center, normal, majorAxisLength, minorAxisLength, startDegreeInRads, endDegreeInRads, tiltDegreeInRads, arType));
2193
        return false;
2194
      }
2195
      public override bool Circle(Point3d center, double radius, Vector3d normal)
2196
      {
2197
        writeLine(indent, string.Format("WorldGeometry.Circle(center = {0}, radius = {1}, normal = {2})", center, radius, normal));
2198
        return false;
2199
      }
2200
      public override bool Circle(Point3d firstPoint, Point3d secondPoint, Point3d thirdPoint)
2201
      {
2202
        writeLine(indent, string.Format("WorldGeometry.Circle(firstPoint = {0}, secondPoint = {1}, thirdPoint = {2})", firstPoint, secondPoint, thirdPoint));
2203
        return false;
2204
      }
2205
      public override bool CircularArc(Point3d start, Point3d point, Point3d endingPoint, ArcType arcType)
2206
      {
2207
        writeLine(indent, string.Format("WorldGeometry.CircularArc(start = {0}, point = {1}, endingPoint = {2}, arcType = {3})", start, point, endingPoint, arcType));
2208
        return false;
2209
      }
2210
      public override bool CircularArc(Point3d center, double radius, Vector3d normal, Vector3d startVector, double sweepAngle, ArcType arcType)
2211
      {
2212
        writeLine(indent, string.Format("WorldGeometry.CircularArc(center = {0}, radius = {1}, normal = {2}, startVector = {3}, sweepAngle = {4}, arcType = {5}", center, radius, normal, startVector, sweepAngle, arcType));
2213
        return false;
2214
      }
2215
      public override bool Draw(Drawable value)
2216
      {
2217
        writeLine(indent, string.Format("WorldGeometry.Draw(value = {0}", value));
2218
        return false;
2219
      }
2220
      public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v)
2221
      {
2222
        writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}", position, u, v));
2223
        return false;
2224
      }
2225
      public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v, TransparencyMode transparencyMode)
2226
      {
2227
        writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}, transparencyMode = {4}", position, u, v, transparencyMode));
2228
        return false;
2229
      }
2230
      public override bool Mesh(int rows, int columns, Point3dCollection points, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals)
2231
      {
2232
        writeLine(indent, string.Format("WorldGeometry.Mesh(rows = {0}, columns = {1}, points = {2}, edgeData = {3}, faceData = {4}, vertexData = {5}, bAutoGenerateNormals = {6})", rows, columns, points, edgeData, faceData, vertexData, bAutoGenerateNormals));
2233
        return false;
2234
      }
2235
      public override bool Polygon(Point3dCollection points)
2236
      {
2237
        writeLine(indent, string.Format("WorldGeometry.Polygon(points = {0})", points));
2238
        return false;
2239
      }
2240
      public override bool Polyline(Teigha.DatabaseServices.Polyline value, int fromIndex, int segments)
2241
      {
2242
        writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}, fromIndex = {1}, segments = {2})", value, fromIndex, segments));
2243
        return false;
2244
      }
2245
      public override bool Polyline(Point3dCollection points, Vector3d normal, IntPtr subEntityMarker)
2246
      {
2247
        writeLine(indent, string.Format("WorldGeometry.Polyline(points = {0}, normal = {1}, subEntityMarker = {2})", points, normal, subEntityMarker));
2248
        return false;
2249
      }
2250
      public override void PopClipBoundary()
2251
      {
2252
        writeLine(indent, string.Format("WorldGeometry.PopClipBoundary"));
2253
        clips.Pop();
2254
      }
2255
      public override bool PopModelTransform()
2256
      {
2257
        return true;
2258
      }
2259
      public override bool PushClipBoundary(ClipBoundary boundary)
2260
      {
2261
        writeLine(indent, string.Format("WorldGeometry.PushClipBoundary"));
2262
        clips.Push(boundary);
2263
        return true;
2264
      }
2265
      public override bool PushModelTransform(Matrix3d matrix)
2266
      {
2267
        writeLine(indent, "WorldGeometry.PushModelTransform(Matrix3d)");
2268
        Matrix3d m = modelMatrix.Peek();
2269
        modelMatrix.Push(m * matrix);
2270
        return true;
2271
      }
2272
      public override bool PushModelTransform(Vector3d normal)
2273
      {
2274
        writeLine(indent, "WorldGeometry.PushModelTransform(Vector3d)");
2275
        PushModelTransform(Matrix3d.PlaneToWorld(normal));
2276
        return true;
2277
      }
2278
      public override bool RowOfDots(int count, Point3d start, Vector3d step)
2279
      {
2280
        writeLine(indent, string.Format("ViewportGeometry.RowOfDots(count = {0}, start = {1}, step = {1})", count, start, step));
2281
        return false;
2282
      }
2283
      public override bool Ray(Point3d point1, Point3d point2)
2284
      {
2285
        writeLine(indent, string.Format("WorldGeometry.Ray(point1 = {0}, point2 = {1})", point1, point2));
2286
        return false;
2287
      }
2288
      public override bool Shell(Point3dCollection points, IntegerCollection faces, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals)
2289
      {
2290
        writeLine(indent, string.Format("WorldGeometry.Shell(points = {0}, faces = {1}, edgeData = {2}, faceData = {3}, vertexData = {4}, bAutoGenerateNormals = {5})", points, faces, edgeData, faceData, vertexData, bAutoGenerateNormals));
2291
        return false;
2292
      }
2293
      public override bool Text(Point3d position, Vector3d normal, Vector3d direction, string message, bool raw, TextStyle textStyle)
2294
      {
2295
        writeLine(indent, string.Format("WorldGeometry.Text(position = {0}, normal = {1}, direction = {2}, message = {3}, raw = {4}, textStyle = {5})", position, normal, direction, message, raw, textStyle));
2296
        return false;
2297
      }
2298
      public override bool Text(Point3d position, Vector3d normal, Vector3d direction, double height, double width, double oblique, string message)
2299
      {
2300
        writeLine(indent, string.Format("WorldGeometry.Text(position = {0}, normal = {1}, direction = {2}, height = {3}, width = {4}, oblique = {5}, message = {6})", position, normal, direction, height, width, oblique, message));
2301
        return false;
2302
      }
2303
      public override bool WorldLine(Point3d startPoint, Point3d endPoint)
2304
      {
2305
        writeLine(indent, string.Format("WorldGeometry.WorldLine(startPoint = {0}, endPoint = {1})", startPoint, endPoint));
2306
        return false;
2307
      }
2308
      public override bool Xline(Point3d point1, Point3d point2)
2309
      {
2310
        writeLine(indent, string.Format("WorldGeometry.Xline(point1 = {0}, point2 = {1})", point1, point2));
2311
        return false;
2312
      }
2313

    
2314
      public override void SetExtents(Extents3d extents)
2315
      {
2316
        writeLine(indent, "WorldGeometry.SetExtents({0}) ", extents);
2317
      }
2318
      public override void StartAttributesSegment()
2319
      {
2320
        writeLine(indent, "WorldGeometry.StartAttributesSegment called");
2321
      }
2322
    }
2323

    
2324
    class WorldDrawDumper : WorldDraw
2325
    {
2326
      WorldGeometryDumper _geom;
2327
      DrawContextDumper _ctx;
2328
      SubEntityTraits _subents;
2329
      RegenType _regenType;
2330
      int indent;
2331
      public WorldDrawDumper(Database db, int indent)
2332
        : base()
2333
      {
2334
        _regenType = RegenType;
2335
        this.indent = indent;
2336
        _geom = new WorldGeometryDumper(indent);
2337
        _ctx = new DrawContextDumper(db);
2338
        _subents = new SubEntityTraitsDumper(db);
2339
      }
2340
      public override double Deviation(DeviationType deviationType, Point3d pointOnCurve)
2341
      {
2342
        return 1e-9;
2343
      }
2344
      public override WorldGeometry Geometry
2345
      {
2346
        get
2347
        {
2348
          return _geom;
2349
        }
2350
      }
2351
      public override bool IsDragging
2352
      {
2353
        get
2354
        {
2355
          return false;
2356
        }
2357
      }
2358
      public override Int32 NumberOfIsolines
2359
      {
2360
        get
2361
        {
2362
          return 10;
2363
        }
2364
      }
2365
      public override Geometry RawGeometry
2366
      {
2367
        get
2368
        {
2369
          return _geom;
2370
        }
2371
      }
2372
      public override bool RegenAbort
2373
      {
2374
        get
2375
        {
2376
          return false;
2377
        }
2378
      }
2379
      public override RegenType RegenType
2380
      {
2381
        get
2382
        {
2383
          writeLine(indent, "RegenType is asked");
2384
          return _regenType;
2385
        }
2386
      }
2387
      public override SubEntityTraits SubEntityTraits
2388
      {
2389
        get
2390
        {
2391
          return _subents;
2392
        }
2393
      }
2394
      public override Context Context
2395
      {
2396
        get
2397
        {
2398
          return _ctx;
2399
        }
2400
      }
2401
    }
2402

    
2403
        /************************************************************************/
2404
        /* Dump the common data and WorldDraw information for all               */
2405
        /* entities without explicit dumpers                                    */
2406
        /************************************************************************/
2407
        XmlNode dump(Entity pEnt, int indent, XmlNode node)
2408
        {
2409
            if (node != null)
2410
            {
2411
                XmlElement EntNode = Program.xml.CreateElement(pEnt.GetRXClass().Name);
2412

    
2413
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2414
                HandleAttr.Value = pEnt.Handle.ToString();
2415
                EntNode.Attributes.SetNamedItem(HandleAttr);
2416

    
2417
                dumpEntityData(pEnt, indent, EntNode);
2418
                writeLine(indent, "WorldDraw()");
2419
                using (Database db = pEnt.Database)
2420
                {
2421
                    /**********************************************************************/
2422
                    /* Create an OdGiWorldDraw instance for the vectorization             */
2423
                    /**********************************************************************/
2424
                    WorldDrawDumper wd = new WorldDrawDumper(db, indent + 1);
2425
                    /**********************************************************************/
2426
                    /* Call worldDraw()                                                   */
2427
                    /**********************************************************************/
2428
                    pEnt.WorldDraw(wd);
2429
                }
2430

    
2431
                node.AppendChild(EntNode);
2432

    
2433
                return EntNode;
2434
            }
2435

    
2436
            return null;
2437
        }
2438

    
2439
        /************************************************************************/
2440
        /* Proxy Entity Dumper                                                  */
2441
        /************************************************************************/
2442
        XmlNode dump(ProxyEntity pProxy, int indent, XmlNode node)
2443
        {
2444
            if (node != null)
2445
            {
2446
                XmlElement ProxyNode = Program.xml.CreateElement(pProxy.GetRXClass().Name);
2447

    
2448
                XmlAttribute OriginalClassNameAttr = Program.xml.CreateAttribute("OriginalClassName");
2449
                OriginalClassNameAttr.Value = pProxy.OriginalClassName.ToString();
2450
                ProxyNode.Attributes.SetNamedItem(OriginalClassNameAttr);
2451

    
2452
                // this will dump proxy entity graphics
2453
                dump((Entity)pProxy, indent, node);
2454

    
2455
                DBObjectCollection collection = new DBObjectCollection(); ;
2456
                try
2457
                {
2458
                    pProxy.ExplodeGeometry(collection);
2459
                }
2460
                catch (System.Exception)
2461
                {
2462
                    return null;
2463
                }
2464

    
2465
                foreach (Entity ent in collection)
2466
                {
2467
                    if (ent is Polyline2d)
2468
                    {
2469
                        Polyline2d pline2d = (Polyline2d)ent;
2470
                        int i = 0;
2471

    
2472
                        try
2473
                        {
2474
                            foreach (Entity ent1 in pline2d)
2475
                            {
2476
                                if (ent1 is Vertex2d)
2477
                                {
2478
                                    Vertex2d vtx2d = (Vertex2d)ent1;
2479
                                    dump2dVertex(indent, vtx2d, i++, ProxyNode);
2480
                                }
2481
                            }
2482
                        }
2483
                        catch (System.Exception)
2484
                        {
2485
                            return null;
2486
                        }
2487
                    }
2488
                }
2489

    
2490
                node.AppendChild(ProxyNode);
2491
                return ProxyNode;
2492
            }
2493

    
2494
            return null;
2495
        }
2496

    
2497
        /************************************************************************/
2498
        /* Radial Dimension Dumper                                              */
2499
        /************************************************************************/
2500
        XmlNode dump(RadialDimension pDim, int indent, XmlNode node)
2501
        {
2502
            if (node != null)
2503
            {
2504
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
2505

    
2506
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2507
                HandleAttr.Value = pDim.Handle.ToString();
2508
                DimNode.Attributes.SetNamedItem(HandleAttr);
2509

    
2510
                XmlAttribute CenterAttr = Program.xml.CreateAttribute("Center");
2511
                CenterAttr.Value = pDim.Center.ToString();
2512
                DimNode.Attributes.SetNamedItem(CenterAttr);
2513

    
2514
                XmlAttribute ChordPointAttr = Program.xml.CreateAttribute("ChordPoint");
2515
                ChordPointAttr.Value = pDim.ChordPoint.ToString();
2516
                DimNode.Attributes.SetNamedItem(ChordPointAttr);
2517

    
2518
                XmlAttribute LeaderLengthAttr = Program.xml.CreateAttribute("LeaderLength");
2519
                LeaderLengthAttr.Value = pDim.LeaderLength.ToString();
2520
                DimNode.Attributes.SetNamedItem(LeaderLengthAttr);
2521

    
2522
                dumpDimData(pDim, indent, DimNode);
2523

    
2524
                node.AppendChild(DimNode);
2525

    
2526
                return DimNode;
2527
            }
2528

    
2529
            return null;
2530
        }
2531

    
2532
    /************************************************************************/
2533
    /* Dump Raster Image Def                                               */
2534
    /************************************************************************/
2535
    void dumpRasterImageDef(ObjectId id, int indent)
2536
    {
2537
      if (!id.IsValid)
2538
        return;
2539
      using (RasterImageDef pDef = (RasterImageDef)id.Open(OpenMode.ForRead))
2540
      {
2541
        writeLine(indent++, pDef.GetRXClass().Name, pDef.Handle);
2542
        writeLine(indent, "Source Filename", shortenPath(pDef.SourceFileName));
2543
        writeLine(indent, "Loaded", pDef.IsLoaded);
2544
        writeLine(indent, "mm per Pixel", pDef.ResolutionMMPerPixel);
2545
        writeLine(indent, "Loaded", pDef.IsLoaded);
2546
        writeLine(indent, "Resolution Units", pDef.ResolutionUnits);
2547
        writeLine(indent, "Size", pDef.Size);
2548
      }
2549
    }
2550
    /************************************************************************/
2551
    /* Dump Raster Image Data                                               */
2552
    /************************************************************************/
2553
    void dumpRasterImageData(RasterImage pImage, int indent)
2554
    {
2555
      writeLine(indent, "Brightness", pImage.Brightness);
2556
      writeLine(indent, "Clipped", pImage.IsClipped);
2557
      writeLine(indent, "Contrast", pImage.Contrast);
2558
      writeLine(indent, "Fade", pImage.Fade);
2559
      writeLine(indent, "kClip", pImage.DisplayOptions & ImageDisplayOptions.Clip);
2560
      writeLine(indent, "kShow", pImage.DisplayOptions & ImageDisplayOptions.Show);
2561
      writeLine(indent, "kShowUnAligned", pImage.DisplayOptions & ImageDisplayOptions.ShowUnaligned);
2562
      writeLine(indent, "kTransparent", pImage.DisplayOptions & ImageDisplayOptions.Transparent);
2563
      writeLine(indent, "Scale", pImage.Scale);
2564

    
2565
      /********************************************************************/
2566
      /* Dump clip boundary                                               */
2567
      /********************************************************************/
2568
      if (pImage.IsClipped)
2569
      {
2570
        writeLine(indent, "Clip Boundary Type", pImage.ClipBoundaryType);
2571
        if (pImage.ClipBoundaryType != ClipBoundaryType.Invalid)
2572
        {
2573
          Point2dCollection pt = pImage.GetClipBoundary();
2574
          for (int i = 0; i < pt.Count; i++)
2575
          {
2576
            writeLine(indent, string.Format("Clip Point {0}", i), pt[i]);
2577
          }
2578
        }
2579
      }
2580

    
2581
      /********************************************************************/
2582
      /* Dump frame                                                       */
2583
      /********************************************************************/
2584
      Point3dCollection vertices = pImage.GetVertices();
2585
      for (int i = 0; i < vertices.Count; i++)
2586
      {
2587
        writeLine(indent, "Frame Vertex " + i.ToString(), vertices[i]);
2588
      }
2589

    
2590
      /********************************************************************/
2591
      /* Dump orientation                                                 */
2592
      /********************************************************************/
2593
      writeLine(indent, "Orientation");
2594
      writeLine(indent + 1, "Origin", pImage.Orientation.Origin);
2595
      writeLine(indent + 1, "uVector", pImage.Orientation.Xaxis);
2596
      writeLine(indent + 1, "vVector", pImage.Orientation.Yaxis);
2597
      dumpRasterImageDef(pImage.ImageDefId, indent);
2598
      dumpEntityData(pImage, indent, Program.xml.DocumentElement);
2599
    }
2600

    
2601
    /************************************************************************/
2602
    /* Raster Image Dumper                                                  */
2603
    /************************************************************************/
2604
    void dump(RasterImage pImage, int indent)
2605
    {
2606
      writeLine(indent++, pImage.GetRXClass().Name, pImage.Handle);
2607
      writeLine(indent, "Image size", pImage.ImageSize(true));
2608
      dumpRasterImageData(pImage, indent);
2609
    }
2610

    
2611
    /************************************************************************/
2612
    /* Ray Dumper                                                          */
2613
    /************************************************************************/
2614
    void dump(Ray pRay, int indent)
2615
    {
2616
      writeLine(indent++, pRay.GetRXClass().Name, pRay.Handle);
2617
      writeLine(indent, "Base Point", pRay.BasePoint);
2618
      writeLine(indent, "Unit Direction", pRay.UnitDir);
2619
      dumpCurveData(pRay, indent, Program.xml.DocumentElement);
2620
    }
2621

    
2622
    /************************************************************************/
2623
    /* Region Dumper                                                        */
2624
    /************************************************************************/
2625
    void dump(Region pRegion, int indent)
2626
    {
2627
      writeLine(indent++, pRegion.GetRXClass().Name, pRegion.Handle);
2628
      dumpEntityData(pRegion, indent, Program.xml.DocumentElement);
2629
    }
2630

    
2631
        /************************************************************************/
2632
        /* Rotated Dimension Dumper                                             */
2633
        /************************************************************************/
2634
        XmlNode dump(RotatedDimension pDim, int indent, XmlNode node)
2635
        {
2636
            if (node != null)
2637
            {
2638
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
2639

    
2640
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2641
                HandleAttr.Value = pDim.Handle.ToString();
2642
                DimNode.Attributes.SetNamedItem(HandleAttr);
2643

    
2644
                XmlAttribute DimLinePointAttr = Program.xml.CreateAttribute("DimLinePoint");
2645
                DimLinePointAttr.Value = pDim.DimLinePoint.ToString();
2646
                DimNode.Attributes.SetNamedItem(DimLinePointAttr);
2647

    
2648
                XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique");
2649
                ObliqueAttr.Value = pDim.Oblique.ToString();
2650
                DimNode.Attributes.SetNamedItem(ObliqueAttr);
2651

    
2652
                XmlAttribute RotationAttr = Program.xml.CreateAttribute("Rotation");
2653
                RotationAttr.Value = pDim.Rotation.ToString();
2654
                DimNode.Attributes.SetNamedItem(RotationAttr);
2655

    
2656
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
2657
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
2658
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
2659

    
2660
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
2661
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
2662
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
2663

    
2664
                dumpDimData(pDim, indent, DimNode);
2665
                node.AppendChild(DimNode);
2666

    
2667
                return DimNode;
2668
            }
2669

    
2670
            return null;
2671
        }
2672

    
2673
    /************************************************************************/
2674
    /* Shape Dumper                                                          */
2675
    /************************************************************************/
2676
    void dump(Shape pShape, int indent)
2677
    {
2678
      writeLine(indent++, pShape.GetRXClass().Name, pShape.Handle);
2679

    
2680
      if (!pShape.StyleId.IsNull)
2681
      {
2682
        using (TextStyleTableRecord pStyle = (TextStyleTableRecord)pShape.StyleId.Open(OpenMode.ForRead))
2683
          writeLine(indent, "Filename", shortenPath(pStyle.FileName));
2684
      }
2685

    
2686
      writeLine(indent, "Shape Number", pShape.ShapeNumber);
2687
      writeLine(indent, "Shape Name", pShape.Name);
2688
      writeLine(indent, "Position", pShape.Position);
2689
      writeLine(indent, "Size", pShape.Size);
2690
      writeLine(indent, "Rotation", toDegreeString(pShape.Rotation));
2691
      writeLine(indent, "Oblique", toDegreeString(pShape.Oblique));
2692
      writeLine(indent, "Normal", pShape.Normal);
2693
      writeLine(indent, "Thickness", pShape.Thickness);
2694
      dumpEntityData(pShape, indent, Program.xml.DocumentElement);
2695
    }
2696

    
2697
    /************************************************************************/
2698
    /* Solid Dumper                                                         */
2699
    /************************************************************************/
2700
    // TODO:
2701
    /*  void dump(Solid pSolid, int indent)
2702
  {
2703
    writeLine(indent++, pSolid.GetRXClass().Name, pSolid.Handle);
2704

    
2705
    for (int i = 0; i < 4; i++)
2706
    {
2707
      writeLine(indent, "Point " + i.ToString(),  pSolid .GetPointAt(i));
2708
    }
2709
    dumpEntityData(pSolid, indent);
2710
  }
2711
*/
2712
    /************************************************************************/
2713
    /* Spline Dumper                                                        */
2714
    /************************************************************************/
2715
    void dump(Spline pSpline, int indent)
2716
    {
2717
      writeLine(indent++, pSpline.GetRXClass().Name, pSpline.Handle);
2718

    
2719
      NurbsData data = pSpline.NurbsData;
2720
      writeLine(indent, "Degree", data.Degree);
2721
      writeLine(indent, "Rational", data.Rational);
2722
      writeLine(indent, "Periodic", data.Periodic);
2723
      writeLine(indent, "Control Point Tolerance", data.ControlPointTolerance);
2724
      writeLine(indent, "Knot Tolerance", data.KnotTolerance);
2725

    
2726
      writeLine(indent, "Number of control points", data.GetControlPoints().Count);
2727
      for (int i = 0; i < data.GetControlPoints().Count; i++)
2728
      {
2729
        writeLine(indent, "Control Point " + i.ToString(), data.GetControlPoints()[i]);
2730
      }
2731

    
2732
      writeLine(indent, "Number of Knots", data.GetKnots().Count);
2733
      for (int i = 0; i < data.GetKnots().Count; i++)
2734
      {
2735
        writeLine(indent, "Knot " + i.ToString(), data.GetKnots()[i]);
2736
      }
2737

    
2738
      if (data.Rational)
2739
      {
2740
        writeLine(indent, "Number of Weights", data.GetWeights().Count);
2741
        for (int i = 0; i < data.GetWeights().Count; i++)
2742
        {
2743
          writeLine(indent, "Weight " + i.ToString(), data.GetWeights()[i]);
2744
        }
2745
      }
2746
      dumpCurveData(pSpline, indent, Program.xml.DocumentElement);
2747
    }
2748
    /************************************************************************/
2749
    /* Table Dumper                                                         */
2750
    /************************************************************************/
2751
    void dump(Table pTable, int indent)
2752
    {
2753
      writeLine(indent++, pTable.GetRXClass().Name, pTable.Handle);
2754
      writeLine(indent, "Position", pTable.Position);
2755
      writeLine(indent, "X-Direction", pTable.Direction);
2756
      writeLine(indent, "Normal", pTable.Normal);
2757
      writeLine(indent, "Height", (int)pTable.Height);
2758
      writeLine(indent, "Width", (int)pTable.Width);
2759
      writeLine(indent, "Rows", (int)pTable.NumRows);
2760
      writeLine(indent, "Columns", (int)pTable.NumColumns);
2761

    
2762
      // TODO:
2763
      //TableStyle pStyle = (TableStyle)pTable.TableStyle.Open(OpenMode.ForRead);
2764
      //writeLine(indent, "Table Style",               pStyle.Name);
2765
      dumpEntityData(pTable, indent, Program.xml.DocumentElement);
2766
    }
2767

    
2768
        /************************************************************************/
2769
        /* Text Dumper                                                          */
2770
        /************************************************************************/
2771
        void dump(DBText pText, int indent, XmlNode node)
2772
        {
2773
            if (node != null)
2774
            {
2775
                dumpTextData(pText, indent, node);
2776
            }
2777
        }
2778
    /************************************************************************/
2779
    /* Trace Dumper                                                         */
2780
    /************************************************************************/
2781
    void dump(Trace pTrace, int indent)
2782
    {
2783
      writeLine(indent++, pTrace.GetRXClass().Name, pTrace.Handle);
2784

    
2785
      for (short i = 0; i < 4; i++)
2786
      {
2787
        writeLine(indent, "Point " + i.ToString(), pTrace.GetPointAt(i));
2788
      }
2789
      dumpEntityData(pTrace, indent, Program.xml.DocumentElement);
2790
    }
2791

    
2792
    /************************************************************************/
2793
    /* Trace UnderlayReference                                                         */
2794
    /************************************************************************/
2795
    void dump(UnderlayReference pEnt, int indent)
2796
    {
2797
      writeLine(indent++, pEnt.GetRXClass().Name, pEnt.Handle);
2798
      writeLine(indent, "UnderlayReference Path ", pEnt.Path);
2799
      writeLine(indent, "UnderlayReference Position ", pEnt.Position);
2800
    }
2801

    
2802
        /************************************************************************/
2803
        /* Viewport Dumper                                                       */
2804
        /************************************************************************/
2805
        XmlNode dump(Teigha.DatabaseServices.Viewport pVport, int indent, XmlNode node)
2806
        {
2807
            if (node != null)
2808
            {
2809
                XmlElement VportNode = Program.xml.CreateElement(pVport.GetRXClass().Name);
2810

    
2811
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2812
                HandleAttr.Value = pVport.Handle.ToString();
2813
                VportNode.Attributes.SetNamedItem(HandleAttr);
2814

    
2815
                writeLine(indent, "Back Clip Distance", pVport.BackClipDistance);
2816
                writeLine(indent, "Back Clip On", pVport.BackClipOn);
2817
                writeLine(indent, "Center Point", pVport.CenterPoint);
2818
                writeLine(indent, "Circle sides", pVport.CircleSides);
2819
                writeLine(indent, "Custom Scale", pVport.CustomScale);
2820
                writeLine(indent, "Elevation", pVport.Elevation);
2821
                writeLine(indent, "Front Clip at Eye", pVport.FrontClipAtEyeOn);
2822
                writeLine(indent, "Front Clip Distance", pVport.FrontClipDistance);
2823
                writeLine(indent, "Front Clip On", pVport.FrontClipOn);
2824
                writeLine(indent, "Plot style sheet", pVport.EffectivePlotStyleSheet);
2825

    
2826
                ObjectIdCollection layerIds = pVport.GetFrozenLayers();
2827
                if (layerIds.Count > 0)
2828
                {
2829
                    writeLine(indent, "Frozen Layers:");
2830
                    for (int i = 0; i < layerIds.Count; i++)
2831
                    {
2832
                        writeLine(indent + 1, i, layerIds[i]);
2833
                    }
2834
                }
2835
                else
2836
                {
2837
                    writeLine(indent, "Frozen Layers", "None");
2838
                }
2839

    
2840
                Point3d origin = new Point3d();
2841
                Vector3d xAxis = new Vector3d();
2842
                Vector3d yAxis = new Vector3d();
2843
                pVport.GetUcs(ref origin, ref xAxis, ref yAxis);
2844
                writeLine(indent, "UCS origin", origin);
2845
                writeLine(indent, "UCS x-Axis", xAxis);
2846
                writeLine(indent, "UCS y-Axis", yAxis);
2847
                writeLine(indent, "Grid Increment", pVport.GridIncrement);
2848
                writeLine(indent, "Grid On", pVport.GridOn);
2849
                writeLine(indent, "Height", pVport.Height);
2850
                writeLine(indent, "Lens Length", pVport.LensLength);
2851
                writeLine(indent, "Locked", pVport.Locked);
2852
                writeLine(indent, "Non-Rectangular Clip", pVport.NonRectClipOn);
2853

    
2854
                if (!pVport.NonRectClipEntityId.IsNull)
2855
                {
2856
                    writeLine(indent, "Non-rectangular Clipper", pVport.NonRectClipEntityId.Handle);
2857
                }
2858
                writeLine(indent, "Render Mode", pVport.RenderMode);
2859
                writeLine(indent, "Remove Hidden Lines", pVport.HiddenLinesRemoved);
2860
                writeLine(indent, "Shade Plot", pVport.ShadePlot);
2861
                writeLine(indent, "Snap Isometric", pVport.SnapIsometric);
2862
                writeLine(indent, "Snap On", pVport.SnapOn);
2863
                writeLine(indent, "Transparent", pVport.Transparent);
2864
                writeLine(indent, "UCS Follow", pVport.UcsFollowModeOn);
2865
                writeLine(indent, "UCS Icon at Origin", pVport.UcsIconAtOrigin);
2866

    
2867
                writeLine(indent, "UCS Orthographic", pVport.UcsOrthographic);
2868
                writeLine(indent, "UCS Saved with VP", pVport.UcsPerViewport);
2869

    
2870
                if (!pVport.UcsName.IsNull)
2871
                {
2872
                    using (UcsTableRecord pUCS = (UcsTableRecord)pVport.UcsName.Open(OpenMode.ForRead))
2873
                        writeLine(indent, "UCS Name", pUCS.Name);
2874
                }
2875
                else
2876
                {
2877
                    writeLine(indent, "UCS Name", "Null");
2878
                }
2879

    
2880
                writeLine(indent, "View Center", pVport.ViewCenter);
2881
                writeLine(indent, "View Height", pVport.ViewHeight);
2882
                writeLine(indent, "View Target", pVport.ViewTarget);
2883
                writeLine(indent, "Width", pVport.Width);
2884
                dumpEntityData(pVport, indent, Program.xml.DocumentElement);
2885

    
2886
                {
2887
                    using (DBObjectCollection collection = new DBObjectCollection())
2888
                    {
2889
                        try
2890
                        {
2891
                            pVport.ExplodeGeometry(collection);
2892

    
2893
                            foreach (Entity ent in collection)
2894
                            {
2895
                                if (ent is Polyline2d)
2896
                                {
2897
                                    Polyline2d pline2d = (Polyline2d)ent;
2898
                                    int i = 0;
2899
                                    foreach (Entity ent1 in pline2d)
2900
                                    {
2901
                                        if (ent1 is Vertex2d)
2902
                                        {
2903
                                            Vertex2d vtx2d = (Vertex2d)ent1;
2904
                                            dump2dVertex(indent, vtx2d, i++, VportNode);
2905
                                        }
2906
                                    }
2907
                                }
2908
                            }
2909
                        }
2910
                        catch (System.Exception)
2911
                        {
2912
                        }
2913
                    }
2914
                }
2915

    
2916
                node.AppendChild(VportNode);
2917
                return VportNode;
2918
            }
2919

    
2920
            return null;
2921
        }
2922

    
2923
    /************************************************************************/
2924
    /* Wipeout Dumper                                                  */
2925
    /************************************************************************/
2926
    void dump(Wipeout pWipeout, int indent)
2927
    {
2928
      writeLine(indent++, pWipeout.GetRXClass().Name, pWipeout.Handle);
2929
      dumpRasterImageData(pWipeout, indent);
2930
    }
2931

    
2932
    /************************************************************************/
2933
    /* Xline Dumper                                                         */
2934
    /************************************************************************/
2935
    void dump(Xline pXline, int indent)
2936
    {
2937
      writeLine(indent++, pXline.GetRXClass().Name, pXline.Handle);
2938
      writeLine(indent, "Base Point", pXline.BasePoint);
2939
      writeLine(indent, "Unit Direction", pXline.UnitDir);
2940
      dumpCurveData(pXline, indent, Program.xml.DocumentElement);
2941
    }
2942

    
2943
        public void dump(Database pDb, int indent, XmlNode node)
2944
        {
2945
            using (BlockTableRecord btr = (BlockTableRecord)pDb.CurrentSpaceId.GetObject(OpenMode.ForRead))
2946
            {
2947
                using (Layout pLayout = (Layout)btr.LayoutId.GetObject(OpenMode.ForRead))
2948
                {
2949
                    string layoutName = "";
2950
                    layoutName = pLayout.LayoutName;
2951

    
2952
                    XmlAttribute LayoutNameAttr = Program.xml.CreateAttribute("LayoutName");
2953
                    LayoutNameAttr.Value = layoutName;
2954
                    node.Attributes.SetNamedItem(LayoutNameAttr);
2955
                }
2956
            }
2957

    
2958
            dumpHeader(pDb, indent, node);
2959
            dumpLayers(pDb, indent, node);
2960
            dumpLinetypes(pDb, indent, node);
2961
            dumpTextStyles(pDb, indent, node);
2962
            dumpDimStyles(pDb, indent, node);
2963
            dumpRegApps(pDb, indent);
2964
            dumpViewports(pDb, indent, node);
2965
            dumpViews(pDb, indent, node);
2966
            dumpMLineStyles(pDb, indent);
2967
            dumpUCSTable(pDb, indent, node);
2968
            dumpObject(pDb.NamedObjectsDictionaryId, "Named Objects Dictionary", indent);
2969

    
2970
            dumpBlocks(pDb, indent, node);
2971
        }
2972

    
2973
        /************************************************************************/
2974
        /* Dump the BlockTable                                                  */
2975
        /************************************************************************/
2976
        public void dumpBlocks(Database pDb, int indent, XmlNode node)
2977
        {
2978
            /**********************************************************************/
2979
            /* Get a pointer to the BlockTable                               */
2980
            /**********************************************************************/
2981
            using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead))
2982
            {
2983
                /**********************************************************************/
2984
                /* Dump the Description                                               */
2985
                /**********************************************************************/
2986
                XmlElement BlocksNode = Program.xml.CreateElement(pTable.GetRXClass().Name);
2987

    
2988
                /**********************************************************************/
2989
                /* Step through the BlockTable                                        */
2990
                /**********************************************************************/
2991
                foreach (ObjectId id in pTable)
2992
                {
2993
                    /********************************************************************/
2994
                    /* Open the BlockTableRecord for Reading                            */
2995
                    /********************************************************************/
2996
                    using (BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead))
2997
                    {
2998
                        /********************************************************************/
2999
                        /* Dump the BlockTableRecord                                        */
3000
                        /********************************************************************/
3001
                        XmlElement BlockNode = Program.xml.CreateElement(pBlock.GetRXClass().Name);
3002

    
3003
                        XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
3004
                        NameAttr.Value = pBlock.Name;
3005
                        BlockNode.Attributes.SetNamedItem(NameAttr);
3006

    
3007
                        XmlAttribute CommentsAttr = Program.xml.CreateAttribute("Comments");
3008
                        CommentsAttr.Value = pBlock.Comments;
3009
                        BlockNode.Attributes.SetNamedItem(CommentsAttr);
3010

    
3011
                        XmlAttribute OriginAttr = Program.xml.CreateAttribute("Origin");
3012
                        OriginAttr.Value = pBlock.Origin.ToString();
3013
                        BlockNode.Attributes.SetNamedItem(OriginAttr);
3014

    
3015
                        writeLine(indent, pBlock.GetRXClass().Name);
3016
                        writeLine(indent + 1, "Anonymous", pBlock.IsAnonymous);
3017
                        writeLine(indent + 1, "Block Insert Units", pBlock.Units);
3018
                        writeLine(indent + 1, "Block Scaling", pBlock.BlockScaling);
3019
                        writeLine(indent + 1, "Explodable", pBlock.Explodable);
3020
                        writeLine(indent + 1, "IsDynamicBlock", pBlock.IsDynamicBlock);
3021

    
3022
                        try
3023
                        {
3024
                            Extents3d extents = new Extents3d(new Point3d(1E+20, 1E+20, 1E+20), new Point3d(1E-20, 1E-20, 1E-20));
3025
                            extents.AddBlockExtents(pBlock);
3026

    
3027
                            XmlAttribute MinExtentsAttr = Program.xml.CreateAttribute("MinExtents");
3028
                            MinExtentsAttr.Value = extents.MinPoint.ToString();
3029
                            BlockNode.Attributes.SetNamedItem(MinExtentsAttr);
3030

    
3031
                            XmlAttribute MaxExtentsAttr = Program.xml.CreateAttribute("MaxExtents");
3032
                            MaxExtentsAttr.Value = extents.MaxPoint.ToString();
3033
                            BlockNode.Attributes.SetNamedItem(MaxExtentsAttr);
3034
                        }
3035
                        catch (System.Exception)
3036
                        {
3037
                        }
3038

    
3039
                        writeLine(indent + 1, "Layout", pBlock.IsLayout);
3040
                        writeLine(indent + 1, "Has Attribute Definitions", pBlock.HasAttributeDefinitions);
3041
                        writeLine(indent + 1, "Xref Status", pBlock.XrefStatus);
3042
                        if (pBlock.XrefStatus != XrefStatus.NotAnXref)
3043
                        {
3044
                          writeLine(indent + 1, "Xref Path", pBlock.PathName);
3045
                          writeLine(indent + 1, "From Xref Attach", pBlock.IsFromExternalReference);
3046
                          writeLine(indent + 1, "From Xref Overlay", pBlock.IsFromOverlayReference);
3047
                          writeLine(indent + 1, "Xref Unloaded", pBlock.IsUnloaded);
3048
                        }
3049

    
3050
                        /********************************************************************/
3051
                        /* Step through the BlockTableRecord                                */
3052
                        /********************************************************************/
3053
                        foreach (ObjectId entid in pBlock)
3054
                        {
3055
                            /********************************************************************/
3056
                            /* Dump the Entity                                                  */
3057
                            /********************************************************************/
3058
                            dumpEntity(entid, indent + 1, BlockNode);
3059
                        }
3060

    
3061
                        BlocksNode.AppendChild(BlockNode);
3062
                    }
3063
                }
3064

    
3065
                node.AppendChild(BlocksNode);
3066
            }
3067
        }
3068

    
3069
    public void dumpDimStyles(Database pDb, int indent, XmlNode node)
3070
    {
3071
      /**********************************************************************/
3072
      /* Get a SmartPointer to the DimStyleTable                            */
3073
      /**********************************************************************/
3074
      using (DimStyleTable pTable = (DimStyleTable)pDb.DimStyleTableId.Open(OpenMode.ForRead))
3075
      {
3076
        /**********************************************************************/
3077
        /* Dump the Description                                               */
3078
        /**********************************************************************/
3079
        writeLine();
3080
        writeLine(indent++, pTable.GetRXClass().Name);
3081

    
3082
        /**********************************************************************/
3083
        /* Step through the DimStyleTable                                    */
3084
        /**********************************************************************/
3085
        foreach (ObjectId id in pTable)
3086
        {
3087
          /*********************************************************************/
3088
          /* Open the DimStyleTableRecord for Reading                         */
3089
          /*********************************************************************/
3090
          using (DimStyleTableRecord pRecord = (DimStyleTableRecord)id.Open(OpenMode.ForRead))
3091
          {
3092
            /*********************************************************************/
3093
            /* Dump the DimStyleTableRecord                                      */
3094
            /*********************************************************************/
3095
            writeLine();
3096
            writeLine(indent, pRecord.GetRXClass().Name);
3097
            writeLine(indent, "Name", pRecord.Name);
3098
            writeLine(indent, "Arc Symbol", toArcSymbolTypeString(pRecord.Dimarcsym));
3099

    
3100
            writeLine(indent, "Background Text Color", pRecord.Dimtfillclr);
3101
            writeLine(indent, "BackgroundText Flags", pRecord.Dimtfill);
3102
            writeLine(indent, "Extension Line 1 Linetype", pRecord.Dimltex1);
3103
            writeLine(indent, "Extension Line 2 Linetype", pRecord.Dimltex2);
3104
            writeLine(indent, "Dimension Line Linetype", pRecord.Dimltype);
3105
            writeLine(indent, "Extension Line Fixed Len", pRecord.Dimfxlen);
3106
            writeLine(indent, "Extension Line Fixed Len Enable", pRecord.DimfxlenOn);
3107
            writeLine(indent, "Jog Angle", toDegreeString(pRecord.Dimjogang));
3108
            writeLine(indent, "Modified For Recompute", pRecord.IsModifiedForRecompute);
3109
            writeLine(indent, "DIMADEC", pRecord.Dimadec);
3110
            writeLine(indent, "DIMALT", pRecord.Dimalt);
3111
            writeLine(indent, "DIMALTD", pRecord.Dimaltd);
3112
            writeLine(indent, "DIMALTF", pRecord.Dimaltf);
3113
            writeLine(indent, "DIMALTRND", pRecord.Dimaltrnd);
3114
            writeLine(indent, "DIMALTTD", pRecord.Dimalttd);
3115
            writeLine(indent, "DIMALTTZ", pRecord.Dimalttz);
3116
            writeLine(indent, "DIMALTU", pRecord.Dimaltu);
3117
            writeLine(indent, "DIMALTZ", pRecord.Dimaltz);
3118
            writeLine(indent, "DIMAPOST", pRecord.Dimapost);
3119
            writeLine(indent, "DIMASZ", pRecord.Dimasz);
3120
            writeLine(indent, "DIMATFIT", pRecord.Dimatfit);
3121
            writeLine(indent, "DIMAUNIT", pRecord.Dimaunit);
3122
            writeLine(indent, "DIMAZIN", pRecord.Dimazin);
3123
            writeLine(indent, "DIMBLK", pRecord.Dimblk);
3124
            writeLine(indent, "DIMBLK1", pRecord.Dimblk1);
3125
            writeLine(indent, "DIMBLK2", pRecord.Dimblk2);
3126
            writeLine(indent, "DIMCEN", pRecord.Dimcen);
3127
            writeLine(indent, "DIMCLRD", pRecord.Dimclrd);
3128
            writeLine(indent, "DIMCLRE", pRecord.Dimclre);
3129
            writeLine(indent, "DIMCLRT", pRecord.Dimclrt);
3130
            writeLine(indent, "DIMDEC", pRecord.Dimdec);
3131
            writeLine(indent, "DIMDLE", pRecord.Dimdle);
3132
            writeLine(indent, "DIMDLI", pRecord.Dimdli);
3133
            writeLine(indent, "DIMDSEP", pRecord.Dimdsep);
3134
            writeLine(indent, "DIMEXE", pRecord.Dimexe);
3135
            writeLine(indent, "DIMEXO", pRecord.Dimexo);
3136
            writeLine(indent, "DIMFRAC", pRecord.Dimfrac);
3137
            writeLine(indent, "DIMGAP", pRecord.Dimgap);
3138
            writeLine(indent, "DIMJUST", pRecord.Dimjust);
3139
            writeLine(indent, "DIMLDRBLK", pRecord.Dimldrblk);
3140
            writeLine(indent, "DIMLFAC", pRecord.Dimlfac);
3141
            writeLine(indent, "DIMLIM", pRecord.Dimlim);
3142
            writeLine(indent, "DIMLUNIT", pRecord.Dimlunit);
3143
            writeLine(indent, "DIMLWD", pRecord.Dimlwd);
3144
            writeLine(indent, "DIMLWE", pRecord.Dimlwe);
3145
            writeLine(indent, "DIMPOST", pRecord.Dimpost);
3146
            writeLine(indent, "DIMRND", pRecord.Dimrnd);
3147
            writeLine(indent, "DIMSAH", pRecord.Dimsah);
3148
            writeLine(indent, "DIMSCALE", pRecord.Dimscale);
3149
            writeLine(indent, "DIMSD1", pRecord.Dimsd1);
3150
            writeLine(indent, "DIMSD2", pRecord.Dimsd2);
3151
            writeLine(indent, "DIMSE1", pRecord.Dimse1);
3152
            writeLine(indent, "DIMSE2", pRecord.Dimse2);
3153
            writeLine(indent, "DIMSOXD", pRecord.Dimsoxd);
3154
            writeLine(indent, "DIMTAD", pRecord.Dimtad);
3155
            writeLine(indent, "DIMTDEC", pRecord.Dimtdec);
3156
            writeLine(indent, "DIMTFAC", pRecord.Dimtfac);
3157
            writeLine(indent, "DIMTIH", pRecord.Dimtih);
3158
            writeLine(indent, "DIMTIX", pRecord.Dimtix);
3159
            writeLine(indent, "DIMTM", pRecord.Dimtm);
3160
            writeLine(indent, "DIMTOFL", pRecord.Dimtofl);
3161
            writeLine(indent, "DIMTOH", pRecord.Dimtoh);
3162
            writeLine(indent, "DIMTOL", pRecord.Dimtol);
3163
            writeLine(indent, "DIMTOLJ", pRecord.Dimtolj);
3164
            writeLine(indent, "DIMTP", pRecord.Dimtp);
3165
            writeLine(indent, "DIMTSZ", pRecord.Dimtsz);
3166
            writeLine(indent, "DIMTVP", pRecord.Dimtvp);
3167
            writeLine(indent, "DIMTXSTY", pRecord.Dimtxsty);
3168
            writeLine(indent, "DIMTXT", pRecord.Dimtxt);
3169
            writeLine(indent, "DIMTZIN", pRecord.Dimtzin);
3170
            writeLine(indent, "DIMUPT", pRecord.Dimupt);
3171
            writeLine(indent, "DIMZIN", pRecord.Dimzin);
3172

    
3173
            dumpSymbolTableRecord(pRecord, indent, node);
3174
          }
3175
        }
3176
      }
3177
    }
3178
    public void dumpEntity(ObjectId id, int indent, XmlNode node)
3179
    {
3180
      /**********************************************************************/
3181
      /* Get a pointer to the Entity                                   */
3182
      /**********************************************************************/
3183
      using (Entity pEnt = (Entity)id.Open(OpenMode.ForRead, false, true))
3184
      {
3185
        /**********************************************************************/
3186
        /* Dump the entity                                                    */
3187
        /**********************************************************************/
3188
        writeLine();
3189
        // Protocol extensions are not supported in DD.NET (as well as in ARX.NET)
3190
        // so we just switch by entity type here
3191
        // (maybe it makes sense to make a map: type -> delegate)
3192
        switch (pEnt.GetRXClass().Name)
3193
        {
3194
          case "AcDbAlignedDimension":
3195
            dump((AlignedDimension)pEnt, indent, node);
3196
            break;
3197
          case "AcDbArc":
3198
            dump((Arc)pEnt, indent, node);
3199
            break;
3200
          case "AcDbArcDimension":
3201
            dump((ArcDimension)pEnt, indent, node);
3202
            break;
3203
          case "AcDbBlockReference":
3204
            dump((BlockReference)pEnt, indent, node);
3205
            break;
3206
          case "AcDbBody":
3207
            dump((Body)pEnt, indent, node);
3208
            break;
3209
          case "AcDbCircle":
3210
            dump((Circle)pEnt, indent, node);
3211
            break;
3212
          case "AcDbPoint":
3213
            dump((DBPoint)pEnt, indent);
3214
            break;
3215
          case "AcDbText":
3216
            dump((DBText)pEnt, indent, node);
3217
            break;
3218
          case "AcDbDiametricDimension":
3219
            dump((DiametricDimension)pEnt, indent, node);
3220
            break;
3221
          case "AcDbViewport":
3222
            dump((Teigha.DatabaseServices.Viewport)pEnt, indent, node);
3223
            break;
3224
          case "AcDbEllipse":
3225
            dump((Ellipse)pEnt, indent, node);
3226
            break;
3227
          case "AcDbFace":
3228
            dump((Face)pEnt, indent, node);
3229
            break;
3230
          case "AcDbFcf":
3231
            dump((FeatureControlFrame)pEnt, indent);
3232
            break;
3233
          case "AcDbHatch":
3234
            dump((Hatch)pEnt, indent);
3235
            break;
3236
          case "AcDbLeader":
3237
            dump((Leader)pEnt, indent);
3238
            break;
3239
          case "AcDbLine":
3240
            dump((Line)pEnt, indent, node);
3241
            break;
3242
          case "AcDb2LineAngularDimension":
3243
            dump((LineAngularDimension2)pEnt, indent, node);
3244
            break;
3245
          case "AcDbMInsertBlock":
3246
            dump((MInsertBlock)pEnt, indent, node);
3247
            break;
3248
          case "AcDbMline":
3249
            dump((Mline)pEnt, indent);
3250
            break;
3251
          case "AcDbMText":
3252
            dump((MText)pEnt, indent);
3253
            break;
3254
          case "AcDbOle2Frame":
3255
            dump((Ole2Frame)pEnt, indent);
3256
            break;
3257
          case "AcDbOrdinateDimension":
3258
            dump((OrdinateDimension)pEnt, indent, node);
3259
            break;
3260
          case "AcDb3PointAngularDimension":
3261
            dump((Point3AngularDimension)pEnt, indent, node);
3262
            break;
3263
          case "AcDbPolyFaceMesh":
3264
            dump((PolyFaceMesh)pEnt, indent, node);
3265
            break;
3266
          case "AcDbPolygonMesh":
3267
            dump((PolygonMesh)pEnt, indent);
3268
            break;
3269
          case "AcDbPolyline":
3270
            dump((Teigha.DatabaseServices.Polyline)pEnt, indent, node);
3271
            break;
3272
          case "AcDb2dPolyline":
3273
            dump((Polyline2d)pEnt, indent, node);
3274
            break;
3275
          case "AcDb3dPolyline":
3276
            dump((Polyline3d)pEnt, indent, node);
3277
            break;
3278
          case "AcDbProxyEntity":
3279
            dump((ProxyEntity)pEnt, indent, node);
3280
            break;
3281
          case "AcDbRadialDimension":
3282
            dump((RadialDimension)pEnt, indent, node);
3283
            break;
3284
          case "AcDbRasterImage":
3285
            dump((RasterImage)pEnt, indent);
3286
            break;
3287
          case "AcDbRay":
3288
            dump((Ray)pEnt, indent);
3289
            break;
3290
          case "AcDbRegion":
3291
            dump((Region)pEnt, indent);
3292
            break;
3293
          case "AcDbRotatedDimension":
3294
            dump((RotatedDimension)pEnt, indent, node);
3295
            break;
3296
          case "AcDbShape":
3297
            dump((Shape)pEnt, indent);
3298
            break;
3299
          case "AcDb3dSolid":
3300
            dump((Solid3d)pEnt, indent, node);
3301
            break;
3302
          case "AcDbSpline":
3303
            dump((Spline)pEnt, indent);
3304
            break;
3305
          case "AcDbTable":
3306
            dump((Table)pEnt, indent);
3307
            break;
3308
          case "AcDbTrace":
3309
            dump((Trace)pEnt, indent);
3310
            break;
3311
          case "AcDbWipeout":
3312
            dump((Wipeout)pEnt, indent);
3313
            break;
3314
          case "AcDbXline":
3315
            dump((Xline)pEnt, indent);
3316
            break;
3317
          case "AcDbPdfReference":
3318
          case "AcDbDwfReference":
3319
          case "AcDbDgnReference":
3320
            dump((UnderlayReference)pEnt, indent);
3321
            break;
3322
          default:
3323
            dump(pEnt, indent, node);
3324
            break;
3325
        }
3326
        /* Dump the Xdata                                                     */
3327
        /**********************************************************************/
3328
        dumpXdata(pEnt.XData, indent);
3329

    
3330
        /**********************************************************************/
3331
        /* Dump the Extension Dictionary                                      */
3332
        /**********************************************************************/
3333
        if (!pEnt.ExtensionDictionary.IsNull)
3334
        {
3335
          dumpObject(pEnt.ExtensionDictionary, "ACAD_XDICTIONARY", indent);
3336
        }
3337
      }
3338
    }
3339
        public void dumpHeader(Database pDb, int indent, XmlNode node)
3340
        {
3341
            if (node != null)
3342
            {
3343
                XmlAttribute FileNameAttr = Program.xml.CreateAttribute("FileName");
3344
                FileNameAttr.Value = shortenPath(pDb.Filename);
3345
                node.Attributes.SetNamedItem(FileNameAttr);
3346

    
3347
                XmlAttribute OriginalFileVersionAttr = Program.xml.CreateAttribute("OriginalFileVersion");
3348
                OriginalFileVersionAttr.Value = pDb.OriginalFileVersion.ToString();
3349
                node.Attributes.SetNamedItem(OriginalFileVersionAttr);
3350

    
3351
                writeLine();
3352
                writeLine(indent++, "Header Variables:");
3353

    
3354
                //writeLine();
3355
                //writeLine(indent, "TDCREATE:", pDb.TDCREATE);
3356
                //writeLine(indent, "TDUPDATE:", pDb.TDUPDATE);
3357

    
3358
                writeLine();
3359
                writeLine(indent, "ANGBASE", pDb.Angbase);
3360
                writeLine(indent, "ANGDIR", pDb.Angdir);
3361
                writeLine(indent, "ATTMODE", pDb.Attmode);
3362
                writeLine(indent, "AUNITS", pDb.Aunits);
3363
                writeLine(indent, "AUPREC", pDb.Auprec);
3364
                writeLine(indent, "CECOLOR", pDb.Cecolor);
3365
                writeLine(indent, "CELTSCALE", pDb.Celtscale);
3366
                writeLine(indent, "CHAMFERA", pDb.Chamfera);
3367
                writeLine(indent, "CHAMFERB", pDb.Chamferb);
3368
                writeLine(indent, "CHAMFERC", pDb.Chamferc);
3369
                writeLine(indent, "CHAMFERD", pDb.Chamferd);
3370
                writeLine(indent, "CMLJUST", pDb.Cmljust);
3371
                writeLine(indent, "CMLSCALE", pDb.Cmljust);
3372
                writeLine(indent, "DIMADEC", pDb.Dimadec);
3373
                writeLine(indent, "DIMALT", pDb.Dimalt);
3374
                writeLine(indent, "DIMALTD", pDb.Dimaltd);
3375
                writeLine(indent, "DIMALTF", pDb.Dimaltf);
3376
                writeLine(indent, "DIMALTRND", pDb.Dimaltrnd);
3377
                writeLine(indent, "DIMALTTD", pDb.Dimalttd);
3378
                writeLine(indent, "DIMALTTZ", pDb.Dimalttz);
3379
                writeLine(indent, "DIMALTU", pDb.Dimaltu);
3380
                writeLine(indent, "DIMALTZ", pDb.Dimaltz);
3381
                writeLine(indent, "DIMAPOST", pDb.Dimapost);
3382
                writeLine(indent, "DIMASZ", pDb.Dimasz);
3383
                writeLine(indent, "DIMATFIT", pDb.Dimatfit);
3384
                writeLine(indent, "DIMAUNIT", pDb.Dimaunit);
3385
                writeLine(indent, "DIMAZIN", pDb.Dimazin);
3386
                writeLine(indent, "DIMBLK", pDb.Dimblk);
3387
                writeLine(indent, "DIMBLK1", pDb.Dimblk1);
3388
                writeLine(indent, "DIMBLK2", pDb.Dimblk2);
3389
                writeLine(indent, "DIMCEN", pDb.Dimcen);
3390
                writeLine(indent, "DIMCLRD", pDb.Dimclrd);
3391
                writeLine(indent, "DIMCLRE", pDb.Dimclre);
3392
                writeLine(indent, "DIMCLRT", pDb.Dimclrt);
3393
                writeLine(indent, "DIMDEC", pDb.Dimdec);
3394
                writeLine(indent, "DIMDLE", pDb.Dimdle);
3395
                writeLine(indent, "DIMDLI", pDb.Dimdli);
3396
                writeLine(indent, "DIMDSEP", pDb.Dimdsep);
3397
                writeLine(indent, "DIMEXE", pDb.Dimexe);
3398
                writeLine(indent, "DIMEXO", pDb.Dimexo);
3399
                writeLine(indent, "DIMFRAC", pDb.Dimfrac);
3400
                writeLine(indent, "DIMGAP", pDb.Dimgap);
3401
                writeLine(indent, "DIMJUST", pDb.Dimjust);
3402
                writeLine(indent, "DIMLDRBLK", pDb.Dimldrblk);
3403
                writeLine(indent, "DIMLFAC", pDb.Dimlfac);
3404
                writeLine(indent, "DIMLIM", pDb.Dimlim);
3405
                writeLine(indent, "DIMLUNIT", pDb.Dimlunit);
3406
                writeLine(indent, "DIMLWD", pDb.Dimlwd);
3407
                writeLine(indent, "DIMLWE", pDb.Dimlwe);
3408
                writeLine(indent, "DIMPOST", pDb.Dimpost);
3409
                writeLine(indent, "DIMRND", pDb.Dimrnd);
3410
                writeLine(indent, "DIMSAH", pDb.Dimsah);
3411
                writeLine(indent, "DIMSCALE", pDb.Dimscale);
3412
                writeLine(indent, "DIMSD1", pDb.Dimsd1);
3413
                writeLine(indent, "DIMSD2", pDb.Dimsd2);
3414
                writeLine(indent, "DIMSE1", pDb.Dimse1);
3415
                writeLine(indent, "DIMSE2", pDb.Dimse2);
3416
                writeLine(indent, "DIMSOXD", pDb.Dimsoxd);
3417
                writeLine(indent, "DIMTAD", pDb.Dimtad);
3418
                writeLine(indent, "DIMTDEC", pDb.Dimtdec);
3419
                writeLine(indent, "DIMTFAC", pDb.Dimtfac);
3420
                writeLine(indent, "DIMTIH", pDb.Dimtih);
3421
                writeLine(indent, "DIMTIX", pDb.Dimtix);
3422
                writeLine(indent, "DIMTM", pDb.Dimtm);
3423
                writeLine(indent, "DIMTOFL", pDb.Dimtofl);
3424
                writeLine(indent, "DIMTOH", pDb.Dimtoh);
3425
                writeLine(indent, "DIMTOL", pDb.Dimtol);
3426
                writeLine(indent, "DIMTOLJ", pDb.Dimtolj);
3427
                writeLine(indent, "DIMTP", pDb.Dimtp);
3428
                writeLine(indent, "DIMTSZ", pDb.Dimtsz);
3429
                writeLine(indent, "DIMTVP", pDb.Dimtvp);
3430
                writeLine(indent, "DIMTXSTY", pDb.Dimtxsty);
3431
                writeLine(indent, "DIMTXT", pDb.Dimtxt);
3432
                writeLine(indent, "DIMTZIN", pDb.Dimtzin);
3433
                writeLine(indent, "DIMUPT", pDb.Dimupt);
3434
                writeLine(indent, "DIMZIN", pDb.Dimzin);
3435
                writeLine(indent, "DISPSILH", pDb.DispSilh);
3436
                writeLine(indent, "DRAWORDERCTL", pDb.DrawOrderCtl);
3437
                writeLine(indent, "ELEVATION", pDb.Elevation);
3438
                writeLine(indent, "EXTMAX", pDb.Extmax);
3439
                writeLine(indent, "EXTMIN", pDb.Extmin);
3440
                writeLine(indent, "FACETRES", pDb.Facetres);
3441
                writeLine(indent, "FILLETRAD", pDb.Filletrad);
3442
                writeLine(indent, "FILLMODE", pDb.Fillmode);
3443
                writeLine(indent, "INSBASE", pDb.Insbase);
3444
                writeLine(indent, "ISOLINES", pDb.Isolines);
3445
                writeLine(indent, "LIMCHECK", pDb.Limcheck);
3446
                writeLine(indent, "LIMMAX", pDb.Limmax);
3447
                writeLine(indent, "LIMMIN", pDb.Limmin);
3448
                writeLine(indent, "LTSCALE", pDb.Ltscale);
3449
                writeLine(indent, "LUNITS", pDb.Lunits);
3450
                writeLine(indent, "LUPREC", pDb.Luprec);
3451
                writeLine(indent, "MAXACTVP", pDb.Maxactvp);
3452
                writeLine(indent, "MIRRTEXT", pDb.Mirrtext);
3453
                writeLine(indent, "ORTHOMODE", pDb.Orthomode);
3454
                writeLine(indent, "PDMODE", pDb.Pdmode);
3455
                writeLine(indent, "PDSIZE", pDb.Pdsize);
3456
                writeLine(indent, "PELEVATION", pDb.Pelevation);
3457
                writeLine(indent, "PELLIPSE", pDb.PlineEllipse);
3458
                writeLine(indent, "PEXTMAX", pDb.Pextmax);
3459
                writeLine(indent, "PEXTMIN", pDb.Pextmin);
3460
                writeLine(indent, "PINSBASE", pDb.Pinsbase);
3461
                writeLine(indent, "PLIMCHECK", pDb.Plimcheck);
3462
                writeLine(indent, "PLIMMAX", pDb.Plimmax);
3463
                writeLine(indent, "PLIMMIN", pDb.Plimmin);
3464
                writeLine(indent, "PLINEGEN", pDb.Plinegen);
3465
                writeLine(indent, "PLINEWID", pDb.Plinewid);
3466
                writeLine(indent, "PROXYGRAPHICS", pDb.Saveproxygraphics);
3467
                writeLine(indent, "PSLTSCALE", pDb.Psltscale);
3468
                writeLine(indent, "PUCSNAME", pDb.Pucsname);
3469
                writeLine(indent, "PUCSORG", pDb.Pucsorg);
3470
                writeLine(indent, "PUCSXDIR", pDb.Pucsxdir);
3471
                writeLine(indent, "PUCSYDIR", pDb.Pucsydir);
3472
                writeLine(indent, "QTEXTMODE", pDb.Qtextmode);
3473
                writeLine(indent, "REGENMODE", pDb.Regenmode);
3474
                writeLine(indent, "SHADEDGE", pDb.Shadedge);
3475
                writeLine(indent, "SHADEDIF", pDb.Shadedif);
3476
                writeLine(indent, "SKETCHINC", pDb.Sketchinc);
3477
                writeLine(indent, "SKPOLY", pDb.Skpoly);
3478
                writeLine(indent, "SPLFRAME", pDb.Splframe);
3479
                writeLine(indent, "SPLINESEGS", pDb.Splinesegs);
3480
                writeLine(indent, "SPLINETYPE", pDb.Splinetype);
3481
                writeLine(indent, "SURFTAB1", pDb.Surftab1);
3482
                writeLine(indent, "SURFTAB2", pDb.Surftab2);
3483
                writeLine(indent, "SURFTYPE", pDb.Surftype);
3484
                writeLine(indent, "SURFU", pDb.Surfu);
3485
                writeLine(indent, "SURFV", pDb.Surfv);
3486
                //writeLine(indent, "TEXTQLTY", pDb.TEXTQLTY);
3487
                writeLine(indent, "TEXTSIZE", pDb.Textsize);
3488
                writeLine(indent, "THICKNESS", pDb.Thickness);
3489
                writeLine(indent, "TILEMODE", pDb.TileMode);
3490
                writeLine(indent, "TRACEWID", pDb.Tracewid);
3491
                writeLine(indent, "TREEDEPTH", pDb.Treedepth);
3492
                writeLine(indent, "UCSNAME", pDb.Ucsname);
3493
                writeLine(indent, "UCSORG", pDb.Ucsorg);
3494
                writeLine(indent, "UCSXDIR", pDb.Ucsxdir);
3495
                writeLine(indent, "UCSYDIR", pDb.Ucsydir);
3496
                writeLine(indent, "UNITMODE", pDb.Unitmode);
3497
                writeLine(indent, "USERI1", pDb.Useri1);
3498
                writeLine(indent, "USERI2", pDb.Useri2);
3499
                writeLine(indent, "USERI3", pDb.Useri3);
3500
                writeLine(indent, "USERI4", pDb.Useri4);
3501
                writeLine(indent, "USERI5", pDb.Useri5);
3502
                writeLine(indent, "USERR1", pDb.Userr1);
3503
                writeLine(indent, "USERR2", pDb.Userr2);
3504
                writeLine(indent, "USERR3", pDb.Userr3);
3505
                writeLine(indent, "USERR4", pDb.Userr4);
3506
                writeLine(indent, "USERR5", pDb.Userr5);
3507
                writeLine(indent, "USRTIMER", pDb.Usrtimer);
3508
                writeLine(indent, "VISRETAIN", pDb.Visretain);
3509
                writeLine(indent, "WORLDVIEW", pDb.Worldview);
3510
            }
3511
        }
3512

    
3513
        public void dumpLayers(Database pDb, int indent, XmlNode node)
3514
        {
3515
            if(node != null)
3516
            {
3517
                /**********************************************************************/
3518
                /* Get a SmartPointer to the LayerTable                               */
3519
                /**********************************************************************/
3520
                using (LayerTable pTable = (LayerTable)pDb.LayerTableId.Open(OpenMode.ForRead))
3521
                {
3522
                    /**********************************************************************/
3523
                    /* Dump the Description                                               */
3524
                    /**********************************************************************/
3525
                    XmlElement LayerNode = Program.xml.CreateElement(pTable.GetRXClass().Name);
3526

    
3527
                    /**********************************************************************/
3528
                    /* Get a SmartPointer to a new SymbolTableIterator                    */
3529
                    /**********************************************************************/
3530

    
3531
                    /**********************************************************************/
3532
                    /* Step through the LayerTable                                        */
3533
                    /**********************************************************************/
3534
                    foreach (ObjectId id in pTable)
3535
                    {
3536
                        /********************************************************************/
3537
                        /* Open the LayerTableRecord for Reading                            */
3538
                        /********************************************************************/
3539
                        using (LayerTableRecord pRecord = (LayerTableRecord)id.Open(OpenMode.ForRead))
3540
                        {
3541
                            /********************************************************************/
3542
                            /* Dump the LayerTableRecord                                        */
3543
                            /********************************************************************/
3544
                            XmlElement RecordNode = Program.xml.CreateElement(pRecord.GetRXClass().Name);
3545

    
3546
                            XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
3547
                            NameAttr.Value = pRecord.Name.ToString();
3548
                            RecordNode.Attributes.SetNamedItem(NameAttr);
3549

    
3550
                            XmlAttribute IsUsedAttr = Program.xml.CreateAttribute("IsUsed");
3551
                            IsUsedAttr.Value = pRecord.IsUsed.ToString();
3552
                            RecordNode.Attributes.SetNamedItem(IsUsedAttr);
3553

    
3554
                            XmlAttribute IsOffAttr = Program.xml.CreateAttribute("IsOff");
3555
                            IsOffAttr.Value = pRecord.IsOff.ToString();
3556
                            RecordNode.Attributes.SetNamedItem(IsOffAttr);
3557

    
3558
                            XmlAttribute IsFrozenAttr = Program.xml.CreateAttribute("IsFrozen");
3559
                            IsFrozenAttr.Value = pRecord.IsFrozen.ToString();
3560
                            RecordNode.Attributes.SetNamedItem(IsFrozenAttr);
3561

    
3562
                            XmlAttribute IsLockedAttr = Program.xml.CreateAttribute("IsLocked");
3563
                            IsLockedAttr.Value = pRecord.IsLocked.ToString();
3564
                            RecordNode.Attributes.SetNamedItem(IsLockedAttr);
3565

    
3566
                            XmlAttribute ColorAttr = Program.xml.CreateAttribute("Color");
3567
                            ColorAttr.Value = pRecord.Color.ToString();
3568
                            RecordNode.Attributes.SetNamedItem(ColorAttr);
3569

    
3570
                            XmlAttribute LinetypeObjectIdAttr = Program.xml.CreateAttribute("LinetypeObjectId");
3571
                            LinetypeObjectIdAttr.Value = pRecord.LinetypeObjectId.ToString();
3572
                            RecordNode.Attributes.SetNamedItem(LinetypeObjectIdAttr);
3573

    
3574
                            XmlAttribute LineWeightAttr = Program.xml.CreateAttribute("LineWeight");
3575
                            LineWeightAttr.Value = pRecord.LineWeight.ToString();
3576
                            RecordNode.Attributes.SetNamedItem(LineWeightAttr);
3577

    
3578
                            XmlAttribute PlotStyleNameAttr = Program.xml.CreateAttribute("PlotStyleName");
3579
                            PlotStyleNameAttr.Value = pRecord.PlotStyleName.ToString();
3580
                            RecordNode.Attributes.SetNamedItem(PlotStyleNameAttr);
3581

    
3582
                            XmlAttribute IsPlottableAttr = Program.xml.CreateAttribute("IsPlottable");
3583
                            IsPlottableAttr.Value = pRecord.IsPlottable.ToString();
3584
                            RecordNode.Attributes.SetNamedItem(IsPlottableAttr);
3585

    
3586
                            XmlAttribute ViewportVisibilityDefaultAttr = Program.xml.CreateAttribute("ViewportVisibilityDefault");
3587
                            ViewportVisibilityDefaultAttr.Value = pRecord.ViewportVisibilityDefault.ToString();
3588
                            RecordNode.Attributes.SetNamedItem(ViewportVisibilityDefaultAttr);
3589

    
3590
                            dumpSymbolTableRecord(pRecord, indent, RecordNode);
3591
                            LayerNode.AppendChild(RecordNode);
3592
                        }
3593
                    }
3594

    
3595
                    node.AppendChild(LayerNode);
3596
                }
3597
            }
3598
        }
3599

    
3600
    public void dumpLinetypes(Database pDb, int indent, XmlNode node)
3601
    {
3602
      /**********************************************************************/
3603
      /* Get a pointer to the LinetypeTable                            */
3604
      /**********************************************************************/
3605
      using (LinetypeTable pTable = (LinetypeTable)pDb.LinetypeTableId.Open(OpenMode.ForRead))
3606
      {
3607
        /**********************************************************************/
3608
        /* Dump the Description                                               */
3609
        /**********************************************************************/
3610
        writeLine();
3611
        writeLine(indent++, "<" + pTable.GetRXClass().Name + ">");
3612

    
3613
        /**********************************************************************/
3614
        /* Step through the LinetypeTable                                     */
3615
        /**********************************************************************/
3616
        foreach (ObjectId id in pTable)
3617
        {
3618
          /*********************************************************************/
3619
          /* Open the LinetypeTableRecord for Reading                          */
3620
          /*********************************************************************/
3621
          using (LinetypeTableRecord pRecord = (LinetypeTableRecord)id.Open(OpenMode.ForRead))
3622
          {
3623
            /********************************************************************/
3624
            /* Dump the LinetypeTableRecord                                      */
3625
            /********************************************************************/
3626
            writeLine();
3627
            writeLine(indent, "<" + pRecord.GetRXClass().Name + ">");
3628
            /********************************************************************/
3629
            /* Dump the first line of record as in ACAD.LIN                     */
3630
            /********************************************************************/
3631
            string buffer = "*" + pRecord.Name;
3632
            if (pRecord.Comments != "")
3633
            {
3634
              buffer = buffer + "," + pRecord.Comments;
3635
            }
3636
            writeLine(indent, buffer);
3637

    
3638
            /********************************************************************/
3639
            /* Dump the second line of record as in ACAD.LIN                    */
3640
            /********************************************************************/
3641
            if (pRecord.NumDashes > 0)
3642
            {
3643
              buffer = pRecord.IsScaledToFit ? "S" : "A";
3644
              for (int i = 0; i < pRecord.NumDashes; i++)
3645
              {
3646
                buffer = buffer + "," + pRecord.DashLengthAt(i);
3647
                int shapeNumber = pRecord.ShapeNumberAt(i);
3648
                string text = pRecord.TextAt(i);
3649

    
3650
                /**************************************************************/
3651
                /* Dump the Complex Line                                      */
3652
                /**************************************************************/
3653
                if (shapeNumber != 0 || text != "")
3654
                {
3655
                  using (TextStyleTableRecord pTextStyle = (TextStyleTableRecord)(pRecord.ShapeStyleAt(i) == ObjectId.Null ? null : pRecord.ShapeStyleAt(i).Open(OpenMode.ForRead)))
3656
                  {
3657
                    if (shapeNumber != 0)
3658
                    {
3659
                      buffer = buffer + ",[" + shapeNumber + ",";
3660
                      if (pTextStyle != null)
3661
                        buffer = buffer + pTextStyle.FileName;
3662
                      else
3663
                        buffer = buffer + "NULL style";
3664
                    }
3665
                    else
3666
                    {
3667
                      buffer = buffer + ",[" + text + ",";
3668
                      if (pTextStyle != null)
3669
                        buffer = buffer + pTextStyle.Name;
3670
                      else
3671
                        buffer = buffer + "NULL style";
3672
                    }
3673
                  }
3674
                  if (pRecord.ShapeScaleAt(i) != 0.0)
3675
                  {
3676
                    buffer = buffer + ",S" + pRecord.ShapeScaleAt(i);
3677
                  }
3678
                  if (pRecord.ShapeRotationAt(i) != 0)
3679
                  {
3680
                    buffer = buffer + ",R" + toDegreeString(pRecord.ShapeRotationAt(i));
3681
                  }
3682
                  if (pRecord.ShapeOffsetAt(i).X != 0)
3683
                  {
3684
                    buffer = buffer + ",X" + pRecord.ShapeOffsetAt(i).X;
3685
                  }
3686
                  if (pRecord.ShapeOffsetAt(i).Y != 0)
3687
                  {
3688
                    buffer = buffer + ",Y" + pRecord.ShapeOffsetAt(i).Y;
3689
                  }
3690
                  buffer = buffer + "]";
3691
                }
3692
              }
3693
              writeLine(indent, buffer);
3694
            }
3695
            dumpSymbolTableRecord(pRecord, indent, node);
3696
          }
3697
        }
3698
      }
3699
    }
3700
    public void dumpRegApps(Database pDb, int indent)
3701
    {
3702
      /**********************************************************************/
3703
      /* Get a pointer to the RegAppTable                            */
3704
      /**********************************************************************/
3705
      using (RegAppTable pTable = (RegAppTable)pDb.RegAppTableId.Open(OpenMode.ForRead))
3706
      {
3707
        /**********************************************************************/
3708
        /* Dump the Description                                               */
3709
        /**********************************************************************/
3710
        writeLine();
3711
        writeLine(indent++, pTable.GetRXClass().Name);
3712

    
3713
        /**********************************************************************/
3714
        /* Step through the RegAppTable                                    */
3715
        /**********************************************************************/
3716
        foreach (ObjectId id in pTable)
3717
        {
3718
          /*********************************************************************/
3719
          /* Open the RegAppTableRecord for Reading                         */
3720
          /*********************************************************************/
3721
          using (RegAppTableRecord pRecord = (RegAppTableRecord)id.Open(OpenMode.ForRead))
3722
          {
3723
            /*********************************************************************/
3724
            /* Dump the RegAppTableRecord                                      */
3725
            /*********************************************************************/
3726
            writeLine();
3727
            writeLine(indent, pRecord.GetRXClass().Name);
3728
            writeLine(indent, "Name", pRecord.Name);
3729
          }
3730
        }
3731
      }
3732
    }
3733

    
3734
        public void dumpSymbolTableRecord(SymbolTableRecord pRecord, int indent, XmlNode node)
3735
        {
3736
            writeLine(indent, "Xref dependent", pRecord.IsDependent);
3737
            if (pRecord.IsDependent)
3738
            {
3739
                writeLine(indent, "Resolved", pRecord.IsResolved);
3740
            }
3741
        }
3742

    
3743
    public void dumpTextStyles(Database pDb, int indent, XmlNode node)
3744
    {
3745
      /**********************************************************************/
3746
      /* Get a SmartPointer to the TextStyleTable                            */
3747
      /**********************************************************************/
3748
      using (TextStyleTable pTable = (TextStyleTable)pDb.TextStyleTableId.Open(OpenMode.ForRead))
3749
      {
3750
        /**********************************************************************/
3751
        /* Dump the Description                                               */
3752
        /**********************************************************************/
3753
        writeLine();
3754
        writeLine(indent++, pTable.GetRXClass().Name);
3755

    
3756
        /**********************************************************************/
3757
        /* Step through the TextStyleTable                                    */
3758
        /**********************************************************************/
3759
        foreach (ObjectId id in pTable)
3760
        {
3761
          /*********************************************************************/
3762
          /* Open the TextStyleTableRecord for Reading                         */
3763
          /*********************************************************************/
3764
          using (TextStyleTableRecord pRecord = (TextStyleTableRecord)id.Open(OpenMode.ForRead))
3765
          {
3766
            /*********************************************************************/
3767
            /* Dump the TextStyleTableRecord                                      */
3768
            /*********************************************************************/
3769
            writeLine();
3770
            writeLine(indent, pRecord.GetRXClass().Name);
3771
            writeLine(indent, "Name", pRecord.Name);
3772
            writeLine(indent, "Shape File", pRecord.IsShapeFile);
3773
            writeLine(indent, "Text Height", pRecord.TextSize);
3774
            writeLine(indent, "Width Factor", pRecord.XScale);
3775
            writeLine(indent, "Obliquing Angle", toDegreeString(pRecord.ObliquingAngle));
3776
            writeLine(indent, "Backwards", (pRecord.FlagBits & 2));
3777
            writeLine(indent, "Vertical", pRecord.IsVertical);
3778
            writeLine(indent, "Upside Down", (pRecord.FlagBits & 4));
3779
            writeLine(indent, "Filename", shortenPath(pRecord.FileName));
3780
            writeLine(indent, "BigFont Filename", shortenPath(pRecord.BigFontFileName));
3781

    
3782
            FontDescriptor fd = pRecord.Font;
3783
            writeLine(indent, "Typeface", fd.TypeFace);
3784
            writeLine(indent, "Character Set", fd.CharacterSet);
3785
            writeLine(indent, "Bold", fd.Bold);
3786
            writeLine(indent, "Italic", fd.Italic);
3787
            writeLine(indent, "Font Pitch & Family", toHexString(fd.PitchAndFamily));
3788
            dumpSymbolTableRecord(pRecord, indent, node);
3789
          }
3790
        }
3791
      }
3792
    }
3793
    public void dumpAbstractViewTableRecord(AbstractViewTableRecord pView, int indent, XmlNode node)
3794
    {
3795
      /*********************************************************************/
3796
      /* Dump the AbstractViewTableRecord                                  */
3797
      /*********************************************************************/
3798
      writeLine(indent, "Back Clip Dist", pView.BackClipDistance);
3799
      writeLine(indent, "Back Clip Enabled", pView.BackClipEnabled);
3800
      writeLine(indent, "Front Clip Dist", pView.FrontClipDistance);
3801
      writeLine(indent, "Front Clip Enabled", pView.FrontClipEnabled);
3802
      writeLine(indent, "Front Clip at Eye", pView.FrontClipAtEye);
3803
      writeLine(indent, "Elevation", pView.Elevation);
3804
      writeLine(indent, "Height", pView.Height);
3805
      writeLine(indent, "Width", pView.Width);
3806
      writeLine(indent, "Lens Length", pView.LensLength);
3807
      writeLine(indent, "Render Mode", pView.RenderMode);
3808
      writeLine(indent, "Perspective", pView.PerspectiveEnabled);
3809
      writeLine(indent, "UCS Name", pView.UcsName);
3810

    
3811
      //writeLine(indent, "UCS Orthographic", pView.IsUcsOrthographic(orthoUCS));
3812
      //writeLine(indent, "Orthographic UCS", orthoUCS);
3813

    
3814
      if (pView.UcsOrthographic != OrthographicView.NonOrthoView)
3815
      {
3816
        writeLine(indent, "UCS Origin", pView.Ucs.Origin);
3817
        writeLine(indent, "UCS x-Axis", pView.Ucs.Xaxis);
3818
        writeLine(indent, "UCS y-Axis", pView.Ucs.Yaxis);
3819
      }
3820

    
3821
      writeLine(indent, "Target", pView.Target);
3822
      writeLine(indent, "View Direction", pView.ViewDirection);
3823
      writeLine(indent, "Twist Angle", toDegreeString(pView.ViewTwist));
3824
      dumpSymbolTableRecord(pView, indent, node);
3825
    }
3826
    public void dumpDimAssoc(DBObject pObject, int indent)
3827
    {
3828

    
3829
    }
3830
    public void dumpMLineStyles(Database pDb, int indent)
3831
    {
3832
      using (DBDictionary pDictionary = (DBDictionary)pDb.MLStyleDictionaryId.Open(OpenMode.ForRead))
3833
      {
3834
        /**********************************************************************/
3835
        /* Dump the Description                                               */
3836
        /**********************************************************************/
3837
        writeLine();
3838
        writeLine(indent++, pDictionary.GetRXClass().Name);
3839

    
3840
        /**********************************************************************/
3841
        /* Step through the MlineStyle dictionary                             */
3842
        /**********************************************************************/
3843
        DbDictionaryEnumerator e = pDictionary.GetEnumerator();
3844
        while (e.MoveNext())
3845
        {
3846
          try
3847
          {
3848
            using (MlineStyle pEntry = (MlineStyle)e.Value.Open(OpenMode.ForRead))
3849
            {
3850
              /*********************************************************************/
3851
              /* Dump the MLineStyle dictionary entry                              */
3852
              /*********************************************************************/
3853
              writeLine();
3854
              writeLine(indent, pEntry.GetRXClass().Name);
3855
              writeLine(indent, "Name", pEntry.Name);
3856
              writeLine(indent, "Description", pEntry.Description);
3857
              writeLine(indent, "Start Angle", toDegreeString(pEntry.StartAngle));
3858
              writeLine(indent, "End Angle", toDegreeString(pEntry.EndAngle));
3859
              writeLine(indent, "Start Inner Arcs", pEntry.StartInnerArcs);
3860
              writeLine(indent, "End Inner Arcs", pEntry.EndInnerArcs);
3861
              writeLine(indent, "Start Round Cap", pEntry.StartRoundCap);
3862
              writeLine(indent, "End Round Cap", pEntry.EndRoundCap);
3863
              writeLine(indent, "Start Square Cap", pEntry.StartRoundCap);
3864
              writeLine(indent, "End Square Cap", pEntry.EndRoundCap);
3865
              writeLine(indent, "Show Miters", pEntry.ShowMiters);
3866
              /*********************************************************************/
3867
              /* Dump the elements                                                 */
3868
              /*********************************************************************/
3869
              if (pEntry.Elements.Count > 0)
3870
              {
3871
                writeLine(indent, "Elements:");
3872
              }
3873
              int i = 0;
3874
              foreach (MlineStyleElement el in pEntry.Elements)
3875
              {
3876
                writeLine(indent, "Index", (i++));
3877
                writeLine(indent + 1, "Offset", el.Offset);
3878
                writeLine(indent + 1, "Color", el.Color);
3879
                writeLine(indent + 1, "Linetype", el.LinetypeId);
3880
              }
3881
            }
3882
          }
3883
          catch (System.Exception)
3884
          {
3885
          }
3886
        }
3887
      }
3888
    }
3889
    public void dumpObject(ObjectId id, string itemName, int indent)
3890
    {
3891
      using (DBObject pObject = id.Open(OpenMode.ForRead))
3892
      {
3893
        /**********************************************************************/
3894
        /* Dump the item name and class name                                  */
3895
        /**********************************************************************/
3896
        if (pObject is DBDictionary)
3897
        {
3898
          writeLine();
3899
        }
3900
        writeLine(indent++, itemName, pObject.GetRXClass().Name);
3901

    
3902
        /**********************************************************************/
3903
        /* Dispatch                                                           */
3904
        /**********************************************************************/
3905
        if (pObject is DBDictionary)
3906
        {
3907
          /********************************************************************/
3908
          /* Dump the dictionary                                               */
3909
          /********************************************************************/
3910
          DBDictionary pDic = (DBDictionary)pObject;
3911

    
3912
          /********************************************************************/
3913
          /* Get a pointer to a new DictionaryIterator                   */
3914
          /********************************************************************/
3915
          DbDictionaryEnumerator pIter = pDic.GetEnumerator();
3916

    
3917
          /********************************************************************/
3918
          /* Step through the Dictionary                                      */
3919
          /********************************************************************/
3920
          while (pIter.MoveNext())
3921
          {
3922
            /******************************************************************/
3923
            /* Dump the Dictionary object                                     */
3924
            /******************************************************************/
3925
            dumpObject(pIter.Value, pIter.Key, indent);
3926
          }
3927
        }
3928
        else if (pObject is Xrecord)
3929
        {
3930
          /********************************************************************/
3931
          /* Dump an Xrecord                                                  */
3932
          /********************************************************************/
3933
          Xrecord pXRec = (Xrecord)pObject;
3934
          dumpXdata(pXRec.Data, indent);
3935
        }
3936
      }
3937
    }
3938

    
3939
    public void dumpUCSTable(Database pDb, int indent, XmlNode node)
3940
    {
3941
      /**********************************************************************/
3942
      /* Get a pointer to the UCSTable                               */
3943
      /**********************************************************************/
3944
      using (UcsTable pTable = (UcsTable)pDb.UcsTableId.Open(OpenMode.ForRead))
3945
      {
3946
        /**********************************************************************/
3947
        /* Dump the Description                                               */
3948
        /**********************************************************************/
3949
        writeLine();
3950
        writeLine(indent++, pTable.GetRXClass().Name);
3951

    
3952
        /**********************************************************************/
3953
        /* Step through the UCSTable                                          */
3954
        /**********************************************************************/
3955
        foreach (ObjectId id in pTable)
3956
        {
3957
          /********************************************************************/
3958
          /* Open the UCSTableRecord for Reading                            */
3959
          /********************************************************************/
3960
          using (UcsTableRecord pRecord = (UcsTableRecord)id.Open(OpenMode.ForRead))
3961
          {
3962
            /********************************************************************/
3963
            /* Dump the UCSTableRecord                                        */
3964
            /********************************************************************/
3965
            writeLine();
3966
            writeLine(indent, pRecord.GetRXClass().Name);
3967
            writeLine(indent, "Name", pRecord.Name);
3968
            writeLine(indent, "UCS Origin", pRecord.Origin);
3969
            writeLine(indent, "UCS x-Axis", pRecord.XAxis);
3970
            writeLine(indent, "UCS y-Axis", pRecord.YAxis);
3971
            dumpSymbolTableRecord(pRecord, indent, node);
3972
          }
3973
        }
3974
      }
3975
    }
3976
    public void dumpViewports(Database pDb, int indent, XmlNode node)
3977
    {
3978
      /**********************************************************************/
3979
      /* Get a pointer to the ViewportTable                            */
3980
      /**********************************************************************/
3981
      using (ViewportTable pTable = (ViewportTable)pDb.ViewportTableId.Open(OpenMode.ForRead))
3982
      {
3983
        /**********************************************************************/
3984
        /* Dump the Description                                               */
3985
        /**********************************************************************/
3986
        writeLine();
3987
        writeLine(indent++, pTable.GetRXClass().Name);
3988

    
3989
        /**********************************************************************/
3990
        /* Step through the ViewportTable                                    */
3991
        /**********************************************************************/
3992
        foreach (ObjectId id in pTable)
3993
        {
3994
          /*********************************************************************/
3995
          /* Open the ViewportTableRecord for Reading                          */
3996
          /*********************************************************************/
3997
          using (ViewportTableRecord pRecord = (ViewportTableRecord)id.Open(OpenMode.ForRead))
3998
          {
3999
            /*********************************************************************/
4000
            /* Dump the ViewportTableRecord                                      */
4001
            /*********************************************************************/
4002
            writeLine();
4003
            writeLine(indent, pRecord.GetRXClass().Name);
4004
            writeLine(indent, "Name", pRecord.Name);
4005
            writeLine(indent, "Circle Sides", pRecord.CircleSides);
4006
            writeLine(indent, "Fast Zooms Enabled", pRecord.FastZoomsEnabled);
4007
            writeLine(indent, "Grid Enabled", pRecord.GridEnabled);
4008
            writeLine(indent, "Grid Increments", pRecord.GridIncrements);
4009
            writeLine(indent, "Icon at Origin", pRecord.IconAtOrigin);
4010
            writeLine(indent, "Icon Enabled", pRecord.IconEnabled);
4011
            writeLine(indent, "Iso snap Enabled", pRecord.IsometricSnapEnabled);
4012
            writeLine(indent, "Iso Snap Pair", pRecord.SnapPair);
4013
            writeLine(indent, "UCS Saved w/Vport", pRecord.UcsSavedWithViewport);
4014
            writeLine(indent, "UCS follow", pRecord.UcsFollowMode);
4015
            writeLine(indent, "Lower-Left Corner", pRecord.LowerLeftCorner);
4016
            writeLine(indent, "Upper-Right Corner", pRecord.UpperRightCorner);
4017
            writeLine(indent, "Snap Angle", toDegreeString(pRecord.SnapAngle));
4018
            writeLine(indent, "Snap Base", pRecord.SnapBase);
4019
            writeLine(indent, "Snap Enabled", pRecord.SnapEnabled);
4020
            writeLine(indent, "Snap Increments", pRecord.SnapIncrements);
4021
            dumpAbstractViewTableRecord(pRecord, indent, node);
4022
          }
4023
        }
4024
      }
4025
    }
4026

    
4027
    /************************************************************************/
4028
    /* Dump the ViewTable                                                   */
4029
    /************************************************************************/
4030
    public void dumpViews(Database pDb, int indent, XmlNode node)
4031
    {
4032
      /**********************************************************************/
4033
      /* Get a pointer to the ViewTable                                */
4034
      /**********************************************************************/
4035
      using (ViewTable pTable = (ViewTable)pDb.ViewTableId.Open(OpenMode.ForRead))
4036
      {
4037
        /**********************************************************************/
4038
        /* Dump the Description                                               */
4039
        /**********************************************************************/
4040
        writeLine();
4041
        writeLine(indent++, pTable.GetRXClass().Name);
4042

    
4043
        /**********************************************************************/
4044
        /* Step through the ViewTable                                         */
4045
        /**********************************************************************/
4046
        foreach (ObjectId id in pTable)
4047
        {
4048
          /*********************************************************************/
4049
          /* Open the ViewTableRecord for Reading                              */
4050
          /*********************************************************************/
4051
          using (ViewTableRecord pRecord = (ViewTableRecord)id.Open(OpenMode.ForRead))
4052
          {
4053
            /*********************************************************************/
4054
            /* Dump the ViewTableRecord                                          */
4055
            /*********************************************************************/
4056
            writeLine();
4057
            writeLine(indent, pRecord.GetRXClass().Name);
4058
            writeLine(indent, "Name", pRecord.Name);
4059
            writeLine(indent, "Category Name", pRecord.CategoryName);
4060
            writeLine(indent, "Layer State", pRecord.LayerState);
4061

    
4062
            string layoutName = "";
4063
            if (!pRecord.Layout.IsNull)
4064
            {
4065
              using (Layout pLayout = (Layout)pRecord.Layout.Open(OpenMode.ForRead))
4066
                layoutName = pLayout.LayoutName;
4067
            }
4068
            writeLine(indent, "Layout Name", layoutName);
4069
            writeLine(indent, "PaperSpace View", pRecord.IsPaperspaceView);
4070
            writeLine(indent, "Associated UCS", pRecord.IsUcsAssociatedToView);
4071
            writeLine(indent, "PaperSpace View", pRecord.ViewAssociatedToViewport);
4072
            dumpAbstractViewTableRecord(pRecord, indent, node);
4073
          }
4074
        }
4075
      }
4076
    }
4077
    /************************************************************************/
4078
    /* Dump Xdata                                                           */
4079
    /************************************************************************/
4080
    public void dumpXdata(ResultBuffer xIter, int indent)
4081
    {
4082
      if (xIter == null)
4083
        return;
4084
      writeLine(indent++, "Xdata:");
4085
      /**********************************************************************/
4086
      /* Step through the ResBuf chain                                      */
4087
      /**********************************************************************/
4088
      foreach (TypedValue resbuf in xIter)
4089
      {
4090
        writeLine(indent, resbuf);
4091
      }
4092
    }
4093
  }
4094
  class ExProtocolExtension
4095
  {
4096
  }
4097

    
4098
  class Program
4099
  {
4100
        public static XmlDocument xml = null;
4101
        public static double OffsetX = 0;
4102
        public static double OffsetY = 0;
4103
        public static double Scale = 0;
4104
        public static List<string> Layers = new List<string>(){ "MINOR", "INSTR", "ELECT", "INSTRUMENT", "LINES" };
4105

    
4106
    static void Main(string[] args)
4107
    {
4108
      /********************************************************************/
4109
      /* Initialize Drawings.NET.                                         */
4110
      /********************************************************************/
4111
      bool bSuccess = true;
4112
      Teigha.Runtime.Services.odActivate(ActivationData.userInfo, ActivationData.userSignature);
4113
      using (Teigha.Runtime.Services srv = new Teigha.Runtime.Services())
4114
      {
4115
        try
4116
        {
4117
          HostApplicationServices.Current = new OdaMgdMViewApp.HostAppServ();
4118
          /**********************************************************************/
4119
          /* Display the Product and Version that created the executable        */
4120
          /**********************************************************************/
4121
          Console.WriteLine("\nReadExMgd developed using {0} ver {1}", HostApplicationServices.Current.Product, HostApplicationServices.Current.VersionString);
4122

    
4123
          if (args.Length != 4)
4124
          {
4125
            Console.WriteLine("\n\n\tusage: OdReadExMgd <filename> <OffsetX> <OffsetY> <Scale>");
4126
            Console.WriteLine("\nPress ENTER to continue...\n");
4127
            Console.ReadLine();
4128
            bSuccess = false;
4129
          }
4130
          else
4131
          {
4132
            double.TryParse(args[1], out Program.OffsetX);
4133
            double.TryParse(args[2], out Program.OffsetY);
4134
            double.TryParse(args[3], out Program.Scale);
4135
            Program.xml = new XmlDocument();
4136
            {
4137
                XmlNode root = xml.CreateElement("ID2");
4138
                Program.xml.AppendChild(root);
4139

    
4140
                /******************************************************************/
4141
                /* Create a database and load the drawing into it.                
4142
                /* first parameter means - do not initialize database- it will be read from file
4143
                 * second parameter is not used by Teigha.NET Classic - it is left for ARX compatibility.
4144
                 * Note the 'using' clause - generally, wrappers should disposed after use, 
4145
                 * to close underlying database objects
4146
                /******************************************************************/
4147
                using (Database pDb = new Database(false, false))
4148
                {
4149
                    pDb.ReadDwgFile(args[0], FileShare.Read, true, "");
4150
                    HostApplicationServices.WorkingDatabase = pDb;
4151
                    /****************************************************************/
4152
                    /* Display the File Version                                     */
4153
                    /****************************************************************/
4154
                    Console.WriteLine("File Version: {0}", pDb.OriginalFileVersion);
4155
                    /****************************************************************/
4156
                    /* Dump the database                                            */
4157
                    /****************************************************************/
4158
                    DbDumper dumper = new DbDumper();
4159
                    dumper.dump(pDb, 0, Program.xml.DocumentElement);
4160
                }
4161
                Program.xml.Save(Path.Combine(Path.GetDirectoryName(args[0]) , Path.GetFileNameWithoutExtension(args[0]) + ".xml"));
4162
            }
4163
          }
4164
        }
4165
        /********************************************************************/
4166
        /* Display the error                                                */
4167
        /********************************************************************/
4168
        catch (System.Exception e)
4169
        {
4170
          bSuccess = false;
4171
          Console.WriteLine("Teigha?NET for .dwg files Error: " + e.Message);
4172
        }
4173

    
4174
        if (bSuccess)
4175
          Console.WriteLine("OdReadExMgd Finished Successfully");
4176
      }
4177
    }
4178
  }
4179
}
클립보드 이미지 추가 (최대 크기: 500 MB)