프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / OdReadExMgd / OdReadExMgd.cs @ e8675c2b

이력 | 보기 | 이력해설 | 다운로드 (234 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 System.Linq;
29
using Teigha.DatabaseServices;
30
using Teigha.Geometry;
31
using Teigha.GraphicsInterface;
32
using Teigha.Colors;
33
using Teigha;
34
using Teigha.GraphicsSystem;
35
using Teigha.Runtime;
36
using Teigha.Export_Import;
37
using System.Collections.Specialized;
38
// note that GetObject doesn't work in Acad 2009, so we use "obsolete" Open instead
39
#pragma warning disable 618
40

    
41
namespace OdReadExMgd
42
{
43
    class DbDumper
44
    {
45
        public DbDumper() { }
46

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

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

    
101
            /**********************************************************************/
102
            /* Truncate the path                                                  */
103
            /**********************************************************************/
104
            if (path.Length > maxPath)
105
            {
106
                path = path.Substring(0, maxPath - 3) + "...";
107
            }
108

    
109
            return path;
110
        }
111
        static string shortenPath(string Inpath)
112
        {
113
            return shortenPath(Inpath, 40);
114
        }
115

    
116
        /************************************************************************/
117
        /* Output a string in the form                                          */
118
        /*   leftString:. . . . . . . . . . . .rightString                      */
119
        /************************************************************************/
120
        static void writeLine(int indent, object leftString, object rightString, int colWidth)
121
        {
122
            string spaces = "                                                            ";
123
            string leader = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ";
124

    
125
            const int tabSize = 2;
126

    
127
            /**********************************************************************/
128
            /* Indent leftString with spaces characters                           */
129
            /**********************************************************************/
130
            string newleftString = spaces.Substring(0, tabSize * indent) + leftString.ToString();
131

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

    
167
        static void dumpEntityData(Entity pEnt, int indent, XmlNode node)
168
        {
169
            if (node != null)
170
            {
171
                try
172
                {
173
                    Extents3d ext = pEnt.GeometricExtents;
174

    
175
                    XmlAttribute MinExtentsAttr = Program.xml.CreateAttribute("MinExtents");
176
                    MinExtentsAttr.Value = ext.MinPoint.ToString();
177
                    node.Attributes.SetNamedItem(MinExtentsAttr);
178

    
179
                    XmlAttribute MaxExtentsAttr = Program.xml.CreateAttribute("MaxExtents");
180
                    MaxExtentsAttr.Value = ext.MaxPoint.ToString();
181
                    node.Attributes.SetNamedItem(MaxExtentsAttr);
182
                }
183
                catch (System.Exception)
184
                {
185
                }
186

    
187
                XmlAttribute LayerAttr = Program.xml.CreateAttribute("Layer");
188
                LayerAttr.Value = pEnt.Layer;
189
                node.Attributes.SetNamedItem(LayerAttr);
190

    
191
                writeLine(indent, "Color Index", pEnt.ColorIndex);
192
                writeLine(indent, "Color", pEnt.Color);
193

    
194
                XmlAttribute LinetypeAttr = Program.xml.CreateAttribute("Linetype");
195
                LinetypeAttr.Value = pEnt.Linetype;
196
                node.Attributes.SetNamedItem(LinetypeAttr);
197

    
198
                writeLine(indent, "LTscale", pEnt.LinetypeScale);
199
                writeLine(indent, "Lineweight", pEnt.LineWeight);
200
                writeLine(indent, "Plot Style", pEnt.PlotStyleName);
201
                writeLine(indent, "Transparency Method", pEnt.Transparency);
202
                writeLine(indent, "Visibility", pEnt.Visible);
203
                writeLine(indent, "Planar", pEnt.IsPlanar);
204

    
205
                if (pEnt.IsPlanar)
206
                {
207
                    try
208
                    {
209
                        CoordinateSystem3d cs = (CoordinateSystem3d)pEnt.GetPlane().GetCoordinateSystem();
210
                        writeLine(indent + 1, "Origin", cs.Origin);
211
                        writeLine(indent + 1, "u-Axis", cs.Xaxis);
212
                        writeLine(indent + 1, "v-Axis", cs.Yaxis);
213
                    }
214
                    catch (System.Exception ex)
215
                    {
216
                        writeLine(indent + 1, "pEnt.GetPlane().GetCoordinateSystem() failed", ex.Message);
217
                    }
218
                }
219
            }
220
        }
221

    
222
        /************************************************************************/
223
        /* Dump Text data                                                       */
224
        /************************************************************************/
225
        static XmlNode dumpTextData(DBText pText, int indent, XmlNode node)
226
        {
227
            XmlNode TextNode = null;
228
            /// write text information to xml file
229
            if (node != null)
230
            {
231
                TextNode = Program.xml.CreateElement(pText.GetRXClass().Name);
232

    
233
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
234
                XAttr.Value = pText.Position.X.ToString();
235
                TextNode.Attributes.SetNamedItem(XAttr);
236

    
237
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
238
                YAttr.Value = pText.Position.Y.ToString();
239
                TextNode.Attributes.SetNamedItem(YAttr);
240

    
241
                TextNode.InnerText = pText.TextString.Replace("%%U", "");
242

    
243
                XmlAttribute AngleAttr = Program.xml.CreateAttribute("Angle");
244
                AngleAttr.Value = pText.Rotation.ToString();
245
                TextNode.Attributes.SetNamedItem(AngleAttr);
246

    
247
                XmlAttribute WidthAttr = Program.xml.CreateAttribute("Width");
248
                WidthAttr.Value = String.Format("{0}", pText.WidthFactor * pText.Height * pText.TextString.Length);
249
                TextNode.Attributes.SetNamedItem(WidthAttr);
250

    
251
                XmlAttribute HeightAttr = Program.xml.CreateAttribute("Height");
252
                HeightAttr.Value = pText.Height.ToString();
253
                TextNode.Attributes.SetNamedItem(HeightAttr);
254

    
255
                XmlAttribute WidthFactorAttr = Program.xml.CreateAttribute("WidthFactor");
256
                WidthFactorAttr.Value = pText.WidthFactor.ToString();
257
                TextNode.Attributes.SetNamedItem(WidthFactorAttr);
258

    
259
                XmlAttribute IsDefaultAlignmentAttr = Program.xml.CreateAttribute("IsDefaultAlignment");
260
                IsDefaultAlignmentAttr.Value = pText.IsDefaultAlignment.ToString();
261
                TextNode.Attributes.SetNamedItem(IsDefaultAlignmentAttr);
262

    
263
                XmlAttribute AlignmentPointAttr = Program.xml.CreateAttribute("AlignmentPoint");
264
                AlignmentPointAttr.Value = pText.AlignmentPoint.ToString();
265
                TextNode.Attributes.SetNamedItem(AlignmentPointAttr);
266

    
267
                XmlAttribute HorizontalModeAttr = Program.xml.CreateAttribute("HorizontalMode");
268
                HorizontalModeAttr.Value = pText.HorizontalMode.ToString();
269
                TextNode.Attributes.SetNamedItem(HorizontalModeAttr);
270

    
271
                XmlAttribute VerticalModeAttr = Program.xml.CreateAttribute("VerticalMode");
272
                VerticalModeAttr.Value = pText.VerticalMode.ToString();
273
                TextNode.Attributes.SetNamedItem(VerticalModeAttr);
274

    
275
                XmlAttribute IsMirroredInXAttr = Program.xml.CreateAttribute("IsMirroredInX");
276
                IsMirroredInXAttr.Value = pText.IsMirroredInX.ToString();
277
                TextNode.Attributes.SetNamedItem(IsMirroredInXAttr);
278

    
279
                XmlAttribute IsMirroredInYAttr = Program.xml.CreateAttribute("IsMirroredInY");
280
                IsMirroredInYAttr.Value = pText.IsMirroredInY.ToString();
281
                TextNode.Attributes.SetNamedItem(IsMirroredInYAttr);
282

    
283
                XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique");
284
                ObliqueAttr.Value = pText.Oblique.ToString();
285
                TextNode.Attributes.SetNamedItem(ObliqueAttr);
286

    
287
                XmlAttribute TextStyleAttr = Program.xml.CreateAttribute("TextStyle");
288
                TextStyleAttr.Value = pText.TextStyleName;
289
                TextNode.Attributes.SetNamedItem(TextStyleAttr);
290

    
291
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
292
                NormalAttr.Value = pText.Normal.ToString();
293
                TextNode.Attributes.SetNamedItem(NormalAttr);
294

    
295
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
296
                ThicknessAttr.Value = pText.Thickness.ToString();
297
                TextNode.Attributes.SetNamedItem(ThicknessAttr);
298

    
299
                dumpEntityData(pText, indent, TextNode);
300

    
301
                node.AppendChild(TextNode);
302
            }
303

    
304
            return TextNode;
305
        }
306

    
307
        /************************************************************************/
308
        /* Dump Attribute data                                                  */
309
        /************************************************************************/
310
        static void dumpAttributeData(int indent, AttributeReference pAttr, int i, XmlNode node)
311
        {
312
            writeLine(indent, "Field Length", pAttr.FieldLength);
313
            writeLine(indent, "Invisible", pAttr.Invisible);
314
            writeLine(indent, "Preset", pAttr.IsPreset);
315
            writeLine(indent, "Verifiable", pAttr.IsVerifiable);
316
            writeLine(indent, "Locked in Position", pAttr.LockPositionInBlock);
317
            writeLine(indent, "Constant", pAttr.IsConstant);
318

    
319
            XmlNode TextNode = dumpTextData(pAttr, indent, node);
320
            if (TextNode != null)
321
            {
322
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
323
                HandleAttr.Value = pAttr.Handle.ToString();
324
                TextNode.Attributes.SetNamedItem(HandleAttr);
325

    
326
                XmlAttribute TagAttr = Program.xml.CreateAttribute("Tag");
327
                TagAttr.Value = pAttr.Tag;
328
                TextNode.Attributes.SetNamedItem(TagAttr);
329
            }
330
        }
331

    
332
        /************************************************************************/
333
        /* Dump Block Reference Data                                             */
334
        /************************************************************************/
335
        static XmlNode dumpBlockRefData(BlockReference pBlkRef, int indent, XmlNode node)
336
        {
337
            if (node != null)
338
            {
339
                XmlNode BlockReferenceNode = Program.xml.CreateElement(pBlkRef.GetRXClass().Name);
340

    
341
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
342
                HandleAttr.Value = pBlkRef.Handle.ToString();
343
                BlockReferenceNode.Attributes.SetNamedItem(HandleAttr);
344

    
345
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
346
                XAttr.Value = pBlkRef.Position.X.ToString();
347
                BlockReferenceNode.Attributes.SetNamedItem(XAttr);
348

    
349
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
350
                YAttr.Value = pBlkRef.Position.Y.ToString();
351
                BlockReferenceNode.Attributes.SetNamedItem(YAttr);
352

    
353
                XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
354
                ZAttr.Value = pBlkRef.Position.Z.ToString();
355
                BlockReferenceNode.Attributes.SetNamedItem(ZAttr);
356

    
357
                XmlAttribute AngleAttr = Program.xml.CreateAttribute("Angle");
358
                AngleAttr.Value = pBlkRef.Rotation.ToString();
359
                BlockReferenceNode.Attributes.SetNamedItem(AngleAttr);
360

    
361
                XmlAttribute ScaleFactorsAttr = Program.xml.CreateAttribute("ScaleFactors");
362
                ScaleFactorsAttr.Value = pBlkRef.ScaleFactors.ToString();
363
                BlockReferenceNode.Attributes.SetNamedItem(ScaleFactorsAttr);
364

    
365
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
366
                NormalAttr.Value = pBlkRef.Normal.ToString();
367
                BlockReferenceNode.Attributes.SetNamedItem(NormalAttr);
368

    
369
                XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
370
                NameAttr.Value = pBlkRef.Name;
371
                BlockReferenceNode.Attributes.SetNamedItem(NameAttr);
372

    
373
                // BlockReference DBPoint
374
                string nodePointValue = string.Empty;
375
                Dictionary<long, Point3d> nodePointDic = new Dictionary<long, Point3d>();
376
                using (BlockTableRecord pBtr = (BlockTableRecord)pBlkRef.BlockTableRecord.Open(OpenMode.ForRead, false, true))
377
                {
378
                    foreach (ObjectId blkid in pBtr)
379
                    {
380
                        using (Entity pBlkEnt = (Entity)blkid.Open(OpenMode.ForRead, false, true))
381
                        {
382
                            if (pBlkEnt.GetRXClass().Name == "AcDbPoint")
383
                            {
384
                                DBPoint pt = (DBPoint)pBlkEnt;
385
                                Point3d nodePt = pt.Position.TransformBy(pBlkRef.BlockTransform);
386
                                if (nodePt == pBlkRef.Position)
387
                                {
388
                                    continue;
389
                                }
390

    
391
                                nodePointDic.Add(Convert.ToInt64(pt.Handle.ToString(), 16), nodePt);
392
                            }
393
                        }
394
                    }
395
                }
396
                if (nodePointDic.Count > 0)
397
                {
398
                    foreach (KeyValuePair<long, Point3d> item in nodePointDic.OrderBy(o => o.Key))
399
                    {
400
                        nodePointValue += item.Value.ToString() + "/";
401
                    }
402
                    nodePointValue = nodePointValue.Substring(0, nodePointValue.Length - 1);
403
                }
404

    
405
                XmlAttribute NodePointAttr = Program.xml.CreateAttribute("Nodes");
406
                NodePointAttr.Value = nodePointValue;
407
                BlockReferenceNode.Attributes.SetNamedItem(NodePointAttr);
408

    
409
                Matrix3d blockTransform = pBlkRef.BlockTransform;
410
                CoordinateSystem3d cs = blockTransform.CoordinateSystem3d;
411
                writeLine(indent + 1, "Origin", cs.Origin);
412
                writeLine(indent + 1, "u-Axis", cs.Xaxis);
413
                writeLine(indent + 1, "v-Axis", cs.Yaxis);
414
                writeLine(indent + 1, "z-Axis", cs.Zaxis);
415

    
416
                dumpEntityData(pBlkRef, indent, BlockReferenceNode);
417

    
418
                DBObjectCollection objColl = new DBObjectCollection();
419
                pBlkRef.Explode(objColl);
420
                foreach (var obj in objColl)
421
                {
422
                    if (obj is DBText)
423
                    {
424
                        dumpTextData(obj as DBText, indent, BlockReferenceNode);
425
                    }
426
                }
427

    
428
                /**********************************************************************/
429
                /* Dump the attributes                                                */
430
                /**********************************************************************/
431
                int i = 0;
432
                AttributeCollection attCol = pBlkRef.AttributeCollection;
433
                foreach (ObjectId id in attCol)
434
                {
435
                    try
436
                    {
437
                        using (AttributeReference pAttr = (AttributeReference)id.Open(OpenMode.ForRead))
438
                            dumpAttributeData(indent, pAttr, i++, BlockReferenceNode);
439
                    }
440
                    catch (System.Exception)
441
                    {
442

    
443
                    }
444
                }
445

    
446
                node.AppendChild(BlockReferenceNode);
447

    
448
                return BlockReferenceNode;
449
            }
450

    
451
            return null;
452
        }
453
        /************************************************************************/
454
        /* Dump data common to all OdDbCurves                                   */
455
        /************************************************************************/
456
        static void dumpCurveData(Entity pEnt, int indent, XmlNode node)
457
        {
458
            if (node != null)
459
            {
460
                Curve pEntity = (Curve)pEnt;
461
                try
462
                {
463
                    writeLine(indent, "Start Point", pEntity.StartPoint);
464
                    writeLine(indent, "End Point", pEntity.EndPoint);
465
                }
466
                catch (System.Exception)
467
                {
468
                }
469
                writeLine(indent, "Closed", pEntity.Closed);
470
                writeLine(indent, "Periodic", pEntity.IsPeriodic);
471

    
472
                try
473
                {
474
                    writeLine(indent, "Area", pEntity.Area);
475
                }
476
                catch (System.Exception)
477
                {
478
                }
479
                dumpEntityData(pEntity, indent, node);
480
            }
481
        }
482

    
483
        /************************************************************************/
484
        /* Dump Dimension data                                                  */
485
        /************************************************************************/
486
        static XmlNode dumpDimData(Dimension pDim, int indent, XmlNode node)
487
        {
488
            if (node != null)
489
            {
490
                XmlElement DimDataNode = Program.xml.CreateElement("DimData");
491

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

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

    
500
                if (pDim.CurrentMeasurement >= 0.0)
501
                {
502
                    XmlAttribute FormattedMeasurementAttr = Program.xml.CreateAttribute("FormattedMeasurement");
503
                    FormattedMeasurementAttr.Value = pDim.FormatMeasurement(pDim.CurrentMeasurement, pDim.DimensionText);
504
                    DimDataNode.Attributes.SetNamedItem(FormattedMeasurementAttr);
505
                }
506
                if (pDim.DimBlockId.IsNull)
507
                {
508
                    writeLine(indent, "Dimension Block NULL");
509
                }
510
                else
511
                {
512
                    using (BlockTableRecord btr = (BlockTableRecord)pDim.DimBlockId.Open(OpenMode.ForRead))
513
                    {
514
                        XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
515
                        NameAttr.Value = btr.Name;
516
                        DimDataNode.Attributes.SetNamedItem(NameAttr);
517
                    }
518
                }
519

    
520
                XmlAttribute DimBlockPositionAttr = Program.xml.CreateAttribute("DimBlockPosition");
521
                DimBlockPositionAttr.Value = pDim.DimBlockPosition.ToString();
522
                DimDataNode.Attributes.SetNamedItem(DimBlockPositionAttr);
523

    
524
                XmlAttribute TextPositionAttr = Program.xml.CreateAttribute("TextPosition");
525
                TextPositionAttr.Value = pDim.TextPosition.ToString();
526
                DimDataNode.Attributes.SetNamedItem(TextPositionAttr);
527

    
528
                XmlAttribute TextRotationAttr = Program.xml.CreateAttribute("TextRotation");
529
                TextRotationAttr.Value = pDim.TextRotation.ToString();
530
                DimDataNode.Attributes.SetNamedItem(TextRotationAttr);
531

    
532
                XmlAttribute DimensionStyleNameAttr = Program.xml.CreateAttribute("DimensionStyleName");
533
                DimensionStyleNameAttr.Value = pDim.DimensionStyleName.ToString();
534
                DimDataNode.Attributes.SetNamedItem(DimensionStyleNameAttr);
535

    
536
                XmlAttribute DimtfillclrAttr = Program.xml.CreateAttribute("Dimtfillclr");
537
                DimtfillclrAttr.Value = pDim.Dimtfillclr.ToString();
538
                DimDataNode.Attributes.SetNamedItem(DimtfillclrAttr);
539

    
540
                XmlAttribute DimtfillAttr = Program.xml.CreateAttribute("Dimtfill");
541
                DimtfillAttr.Value = pDim.Dimtfill.ToString();
542
                DimDataNode.Attributes.SetNamedItem(DimtfillAttr);
543

    
544
                XmlAttribute Dimltex1Attr = Program.xml.CreateAttribute("Dimltex1");
545
                Dimltex1Attr.Value = pDim.Dimltex1.ToString();
546
                DimDataNode.Attributes.SetNamedItem(Dimltex1Attr);
547

    
548
                XmlAttribute Dimltex2Attr = Program.xml.CreateAttribute("Dimltex2");
549
                Dimltex2Attr.Value = pDim.Dimltex2.ToString();
550
                DimDataNode.Attributes.SetNamedItem(Dimltex2Attr);
551

    
552
                XmlAttribute DimltypeAttr = Program.xml.CreateAttribute("Dimltype");
553
                DimltypeAttr.Value = pDim.Dimltype.ToString();
554
                DimDataNode.Attributes.SetNamedItem(DimltypeAttr);
555

    
556
                XmlAttribute HorizontalRotationAttr = Program.xml.CreateAttribute("HorizontalRotation");
557
                HorizontalRotationAttr.Value = pDim.HorizontalRotation.ToString();
558
                DimDataNode.Attributes.SetNamedItem(HorizontalRotationAttr);
559

    
560
                XmlAttribute ElevationAttr = Program.xml.CreateAttribute("Elevation");
561
                ElevationAttr.Value = pDim.Elevation.ToString();
562
                DimDataNode.Attributes.SetNamedItem(ElevationAttr);
563

    
564
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
565
                NormalAttr.Value = pDim.Normal.ToString();
566
                DimDataNode.Attributes.SetNamedItem(NormalAttr);
567

    
568
                dumpEntityData(pDim, indent, node);
569

    
570
                return DimDataNode;
571
            }
572

    
573
            return null;
574
        }
575

    
576
        /************************************************************************/
577
        /* 2 Line Angular Dimension Dumper                                      */
578
        /************************************************************************/
579
        static XmlNode dump(LineAngularDimension2 pDim, int indent, XmlNode node)
580
        {
581
            if (node != null)
582
            {
583
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
584

    
585
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
586
                HandleAttr.Value = pDim.Handle.ToString();
587
                DimNode.Attributes.SetNamedItem(HandleAttr);
588

    
589
                XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint");
590
                ArcPointAttr.Value = pDim.ArcPoint.ToString();
591
                DimNode.Attributes.SetNamedItem(ArcPointAttr);
592

    
593
                XmlAttribute XLine1StartAttr = Program.xml.CreateAttribute("XLine1Start");
594
                XLine1StartAttr.Value = pDim.XLine1Start.ToString();
595
                DimNode.Attributes.SetNamedItem(XLine1StartAttr);
596

    
597
                XmlAttribute XLine1EndAttr = Program.xml.CreateAttribute("XLine1End");
598
                XLine1EndAttr.Value = pDim.XLine1End.ToString();
599
                DimNode.Attributes.SetNamedItem(XLine1EndAttr);
600

    
601
                XmlAttribute XLine2StartAttr = Program.xml.CreateAttribute("XLine2Start");
602
                XLine2StartAttr.Value = pDim.XLine2Start.ToString();
603
                DimNode.Attributes.SetNamedItem(XLine2StartAttr);
604

    
605
                XmlAttribute XLine2EndAttr = Program.xml.CreateAttribute("XLine2End");
606
                XLine2EndAttr.Value = pDim.XLine2End.ToString();
607
                DimNode.Attributes.SetNamedItem(XLine2EndAttr);
608

    
609
                dumpDimData(pDim, indent, DimNode);
610

    
611
                return DimNode;
612
            }
613

    
614
            return null;
615
        }
616

    
617
        /************************************************************************/
618
        /* Dump 2D Vertex data                                                  */
619
        /************************************************************************/
620
        static XmlNode dump2dVertex(int indent, Vertex2d pVertex, int i, XmlNode node)
621
        {
622
            if (node != null)
623
            {
624
                XmlElement VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name);
625

    
626
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
627
                HandleAttr.Value = pVertex.Handle.ToString();
628
                VertexNode.Attributes.SetNamedItem(HandleAttr);
629

    
630
                XmlAttribute VertexTypeAttr = Program.xml.CreateAttribute("VertexType");
631
                VertexTypeAttr.Value = pVertex.VertexType.ToString();
632
                VertexNode.Attributes.SetNamedItem(VertexTypeAttr);
633

    
634
                XmlAttribute PositionAttr = Program.xml.CreateAttribute("Position");
635
                PositionAttr.Value = pVertex.Position.ToString();
636
                VertexNode.Attributes.SetNamedItem(PositionAttr);
637

    
638
                XmlAttribute StartWidthAttr = Program.xml.CreateAttribute("StartWidth");
639
                StartWidthAttr.Value = pVertex.StartWidth.ToString();
640
                VertexNode.Attributes.SetNamedItem(StartWidthAttr);
641

    
642
                XmlAttribute EndWidthAttr = Program.xml.CreateAttribute("EndWidth");
643
                EndWidthAttr.Value = pVertex.EndWidth.ToString();
644
                VertexNode.Attributes.SetNamedItem(EndWidthAttr);
645

    
646
                XmlAttribute BulgeAttr = Program.xml.CreateAttribute("Bulge");
647
                BulgeAttr.Value = pVertex.Bulge.ToString();
648
                VertexNode.Attributes.SetNamedItem(BulgeAttr);
649

    
650
                if (pVertex.Bulge != 0)
651
                {
652
                    XmlAttribute BulgeAngleAttr = Program.xml.CreateAttribute("BulgeAngle");
653
                    BulgeAngleAttr.Value = (4 * Math.Atan(pVertex.Bulge)).ToString();
654
                    VertexNode.Attributes.SetNamedItem(BulgeAngleAttr);
655
                }
656

    
657
                XmlAttribute TangentUsedAttr = Program.xml.CreateAttribute("TangentUsed");
658
                TangentUsedAttr.Value = pVertex.TangentUsed.ToString();
659
                VertexNode.Attributes.SetNamedItem(TangentUsedAttr);
660
                if (pVertex.TangentUsed)
661
                {
662
                    XmlAttribute TangentAttr = Program.xml.CreateAttribute("Tangent");
663
                    TangentAttr.Value = pVertex.Tangent.ToString();
664
                    VertexNode.Attributes.SetNamedItem(TangentAttr);
665
                }
666

    
667
                node.AppendChild(VertexNode);
668

    
669
                return VertexNode;
670
            }
671

    
672
            return null;
673
        }
674

    
675
        /************************************************************************/
676
        /* 2D Polyline Dumper                                                   */
677
        /************************************************************************/
678
        static XmlNode dump(Polyline2d pPolyline, int indent, XmlNode node)
679
        {
680
            /********************************************************************/
681
            /* Dump the vertices                                                */
682
            /********************************************************************/
683
            List<Vertex2d> Vertices = new List<Vertex2d>();
684
            int i = 0;
685
            foreach (ObjectId obj in pPolyline)
686
            {
687
                using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead))
688
                {
689
                    if (dbObj is Vertex2d)
690
                    {
691
                        Vertices.Add((Vertex2d)dbObj);
692
                        /// dump2dVertex(indent, (Vertex2d)dbObj, i++);
693
                    }
694
                }
695
            }
696

    
697
            if (node != null)
698
            {
699
                XmlNode Polyline2dNode = Program.xml.CreateElement(pPolyline.GetRXClass().Name);
700

    
701
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
702
                HandleAttr.Value = pPolyline.Handle.ToString();
703
                Polyline2dNode.Attributes.SetNamedItem(HandleAttr);
704

    
705
                XmlAttribute CountAttr = Program.xml.CreateAttribute("Count");
706
                CountAttr.Value = Vertices.Count.ToString();
707
                Polyline2dNode.Attributes.SetNamedItem(CountAttr);
708

    
709
                XmlAttribute ElevationAttr = Program.xml.CreateAttribute("Elevation");
710
                ElevationAttr.Value = pPolyline.Elevation.ToString();
711
                Polyline2dNode.Attributes.SetNamedItem(ElevationAttr);
712

    
713
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
714
                NormalAttr.Value = pPolyline.Normal.ToString();
715
                Polyline2dNode.Attributes.SetNamedItem(NormalAttr);
716

    
717
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
718
                ThicknessAttr.Value = pPolyline.Thickness.ToString();
719
                Polyline2dNode.Attributes.SetNamedItem(ThicknessAttr);
720

    
721
                XmlAttribute ClosedAttr = Program.xml.CreateAttribute("Closed");
722
                ClosedAttr.Value = pPolyline.Closed.ToString();
723
                Polyline2dNode.Attributes.SetNamedItem(ClosedAttr);
724

    
725
                foreach (var vt in Vertices)
726
                {
727
                    XmlNode VertexNode = Program.xml.CreateElement("Vertex");
728

    
729
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
730
                    XAttr.Value = vt.Position.X.ToString();
731
                    VertexNode.Attributes.SetNamedItem(XAttr);
732

    
733
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
734
                    YAttr.Value = vt.Position.Y.ToString();
735
                    VertexNode.Attributes.SetNamedItem(YAttr);
736

    
737
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
738
                    ZAttr.Value = vt.Position.Z.ToString();
739
                    VertexNode.Attributes.SetNamedItem(ZAttr);
740

    
741
                    Polyline2dNode.AppendChild(VertexNode);
742
                }
743

    
744
                dumpCurveData(pPolyline, indent, node);
745

    
746
                node.AppendChild(Polyline2dNode);
747

    
748
                return Polyline2dNode;
749
            }
750

    
751
            return null;
752
        }
753

    
754

    
755
        /************************************************************************/
756
        /* Dump 3D Polyline Vertex data                                         */
757
        /************************************************************************/
758
        XmlNode dump3dPolylineVertex(int indent, PolylineVertex3d pVertex, int i, XmlNode node)
759
        {
760
            if (node != null)
761
            {
762
                XmlNode VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name);
763

    
764
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
765
                HandleAttr.Value = pVertex.Handle.ToString();
766
                VertexNode.Attributes.SetNamedItem(HandleAttr);
767

    
768
                XmlAttribute VertexxTypeAttr = Program.xml.CreateAttribute("VertexType");
769
                VertexxTypeAttr.Value = pVertex.VertexType.ToString();
770
                VertexNode.Attributes.SetNamedItem(VertexxTypeAttr);
771

    
772
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
773
                XAttr.Value = pVertex.Position.X.ToString();
774
                VertexNode.Attributes.SetNamedItem(XAttr);
775

    
776
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
777
                YAttr.Value = pVertex.Position.Y.ToString();
778
                VertexNode.Attributes.SetNamedItem(YAttr);
779

    
780
                XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
781
                ZAttr.Value = pVertex.Position.Z.ToString();
782
                VertexNode.Attributes.SetNamedItem(ZAttr);
783

    
784
                node.AppendChild(VertexNode);
785

    
786
                return VertexNode;
787
            }
788

    
789
            return null;
790
        }
791

    
792
        /************************************************************************/
793
        /* 3D Polyline Dumper                                                   */
794
        /************************************************************************/
795
        XmlNode dump(Polyline3d pPolyline, int indent, XmlNode node)
796
        {
797
            if (node != null)
798
            {
799
                XmlNode pPolylineNode = Program.xml.CreateElement(pPolyline.GetRXClass().Name);
800

    
801
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
802
                HandleAttr.Value = pPolyline.Handle.ToString();
803
                pPolylineNode.Attributes.SetNamedItem(HandleAttr);
804

    
805
                /********************************************************************/
806
                /* Dump the vertices                                                */
807
                /********************************************************************/
808
                int i = 0;
809
                foreach (ObjectId obj in pPolyline)
810
                {
811
                    using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead))
812
                    {
813
                        if (dbObj is PolylineVertex3d)
814
                        {
815
                            dump3dPolylineVertex(indent, (PolylineVertex3d)dbObj, i++, pPolylineNode);
816
                        }
817
                    }
818
                }
819
                dumpCurveData(pPolyline, indent, pPolylineNode);
820

    
821
                node.AppendChild(pPolylineNode);
822

    
823
                return pPolylineNode;
824
            }
825

    
826
            return null;
827
        }
828

    
829

    
830
        /************************************************************************/
831
        /* 3DSolid Dumper                                                       */
832
        /************************************************************************/
833
        XmlNode dump(Solid3d pSolid, int indent, XmlNode node)
834
        {
835
            if (node != null)
836
            {
837
                XmlNode SolidNode = Program.xml.CreateElement(pSolid.GetRXClass().Name);
838

    
839
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
840
                HandleAttr.Value = pSolid.Handle.ToString();
841
                SolidNode.Attributes.SetNamedItem(HandleAttr);
842

    
843
                dumpEntityData(pSolid, indent, node);
844

    
845
                node.AppendChild(SolidNode);
846

    
847
                return SolidNode;
848
            }
849

    
850
            return null;
851
        }
852

    
853

    
854
        /************************************************************************/
855
        /* 3 Point Angular Dimension Dumper                                     */
856
        /************************************************************************/
857
        XmlNode dump(Point3AngularDimension pDim, int indent, XmlNode node)
858
        {
859
            if (node != null)
860
            {
861
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
862

    
863
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
864
                HandleAttr.Value = pDim.Handle.ToString();
865
                DimNode.Attributes.SetNamedItem(HandleAttr);
866

    
867
                XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint");
868
                ArcPointAttr.Value = pDim.ArcPoint.ToString();
869
                DimNode.Attributes.SetNamedItem(ArcPointAttr);
870

    
871
                XmlAttribute CenterPointAttr = Program.xml.CreateAttribute("CenterPoint");
872
                CenterPointAttr.Value = pDim.CenterPoint.ToString();
873
                DimNode.Attributes.SetNamedItem(CenterPointAttr);
874

    
875
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
876
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
877
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
878

    
879
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
880
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
881
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
882

    
883
                dumpDimData(pDim, indent, DimNode);
884

    
885
                return DimNode;
886
            }
887

    
888
            return null;
889
        }
890

    
891
        /************************************************************************/
892
        /* Aligned Dimension Dumper                                             */
893
        /************************************************************************/
894
        XmlNode dump(AlignedDimension pDim, int indent, XmlNode node)
895
        {
896
            if (node != null)
897
            {
898
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
899

    
900
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
901
                HandleAttr.Value = pDim.Handle.ToString();
902
                DimNode.Attributes.SetNamedItem(HandleAttr);
903

    
904
                XmlAttribute DimLinePointAttr = Program.xml.CreateAttribute("DimLinePoint");
905
                DimLinePointAttr.Value = pDim.DimLinePoint.ToString();
906
                DimNode.Attributes.SetNamedItem(DimLinePointAttr);
907

    
908
                XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique");
909
                ObliqueAttr.Value = pDim.Oblique.ToString();
910
                DimNode.Attributes.SetNamedItem(ObliqueAttr);
911

    
912
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
913
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
914
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
915

    
916
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
917
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
918
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
919

    
920
                dumpDimData(pDim, indent, DimNode);
921

    
922
                return DimNode;
923
            }
924

    
925
            return null;
926
        }
927

    
928
        /************************************************************************/
929
        /* Arc Dumper                                                           */
930
        /************************************************************************/
931
        XmlNode dump(Arc pArc, int indent, XmlNode node)
932
        {
933
            if (node != null)
934
            {
935
                XmlElement ArcNode = Program.xml.CreateElement(pArc.GetRXClass().Name);
936

    
937
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
938
                XAttr.Value = pArc.Center.X.ToString();
939
                ArcNode.Attributes.SetNamedItem(XAttr);
940

    
941
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
942
                YAttr.Value = pArc.Center.Y.ToString();
943
                ArcNode.Attributes.SetNamedItem(YAttr);
944

    
945
                XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
946
                ZAttr.Value = pArc.Center.Z.ToString();
947
                ArcNode.Attributes.SetNamedItem(ZAttr);
948

    
949
                XmlAttribute RadiusAttr = Program.xml.CreateAttribute("Radius");
950
                RadiusAttr.Value = pArc.Radius.ToString();
951
                ArcNode.Attributes.SetNamedItem(RadiusAttr);
952

    
953
                XmlAttribute StartAngleAttr = Program.xml.CreateAttribute("StartAngle");
954
                StartAngleAttr.Value = pArc.StartAngle.ToString();
955
                ArcNode.Attributes.SetNamedItem(StartAngleAttr);
956

    
957
                XmlAttribute EndAngleAttr = Program.xml.CreateAttribute("EndAngle");
958
                EndAngleAttr.Value = pArc.EndAngle.ToString();
959
                ArcNode.Attributes.SetNamedItem(EndAngleAttr);
960

    
961
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
962
                NormalAttr.Value = pArc.Normal.ToString();
963
                ArcNode.Attributes.SetNamedItem(NormalAttr);
964

    
965
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
966
                ThicknessAttr.Value = pArc.Normal.ToString();
967
                ArcNode.Attributes.SetNamedItem(ThicknessAttr);
968

    
969
                writeLine(indent++, pArc.GetRXClass().Name, pArc.Handle);
970
                dumpCurveData(pArc, indent, ArcNode);
971

    
972
                XmlNode StartPointNode = Program.xml.CreateElement("Vertex");
973
                {
974
                    XAttr = Program.xml.CreateAttribute("X");
975
                    XAttr.Value = pArc.StartPoint.X.ToString();
976
                    StartPointNode.Attributes.SetNamedItem(XAttr);
977

    
978
                    YAttr = Program.xml.CreateAttribute("Y");
979
                    YAttr.Value = pArc.StartPoint.Y.ToString();
980
                    StartPointNode.Attributes.SetNamedItem(YAttr);
981

    
982
                    ZAttr = Program.xml.CreateAttribute("Z");
983
                    ZAttr.Value = pArc.StartPoint.Z.ToString();
984
                    StartPointNode.Attributes.SetNamedItem(ZAttr);
985
                }
986
                ArcNode.AppendChild(StartPointNode);
987

    
988
                XmlNode EndPointNode = Program.xml.CreateElement("Vertex");
989
                {
990
                    XAttr = Program.xml.CreateAttribute("X");
991
                    XAttr.Value = pArc.EndPoint.X.ToString();
992
                    EndPointNode.Attributes.SetNamedItem(XAttr);
993

    
994
                    YAttr = Program.xml.CreateAttribute("Y");
995
                    YAttr.Value = pArc.EndPoint.Y.ToString();
996
                    EndPointNode.Attributes.SetNamedItem(YAttr);
997

    
998
                    ZAttr = Program.xml.CreateAttribute("Z");
999
                    ZAttr.Value = pArc.EndPoint.Z.ToString();
1000
                    EndPointNode.Attributes.SetNamedItem(ZAttr);
1001
                }
1002
                ArcNode.AppendChild(EndPointNode);
1003

    
1004
                node.AppendChild(ArcNode);
1005

    
1006
                return ArcNode;
1007
            }
1008

    
1009
            return null;
1010
        }
1011

    
1012
        /************************************************************************/
1013
        /* Arc Dimension Dumper                                                 */
1014
        /************************************************************************/
1015
        XmlNode dump(ArcDimension pDim, int indent, XmlNode node)
1016
        {
1017
            if (node != null)
1018
            {
1019
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
1020

    
1021
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1022
                HandleAttr.Value = pDim.Handle.ToString();
1023
                DimNode.Attributes.SetNamedItem(HandleAttr);
1024

    
1025
                XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint");
1026
                ArcPointAttr.Value = pDim.ArcPoint.ToString();
1027
                DimNode.Attributes.SetNamedItem(ArcPointAttr);
1028

    
1029
                XmlAttribute CenterPointAttr = Program.xml.CreateAttribute("CenterPoint");
1030
                CenterPointAttr.Value = pDim.CenterPoint.ToString();
1031
                DimNode.Attributes.SetNamedItem(CenterPointAttr);
1032

    
1033
                XmlAttribute ArcSymbolTypeAttr = Program.xml.CreateAttribute("ArcSymbolType");
1034
                ArcSymbolTypeAttr.Value = pDim.ArcSymbolType.ToString();
1035
                DimNode.Attributes.SetNamedItem(ArcSymbolTypeAttr);
1036

    
1037
                XmlAttribute IsPartialAttr = Program.xml.CreateAttribute("IsPartial");
1038
                IsPartialAttr.Value = pDim.IsPartial.ToString();
1039
                DimNode.Attributes.SetNamedItem(IsPartialAttr);
1040

    
1041
                XmlAttribute HasLeaderAttr = Program.xml.CreateAttribute("HasLeader");
1042
                HasLeaderAttr.Value = pDim.HasLeader.ToString();
1043
                DimNode.Attributes.SetNamedItem(HasLeaderAttr);
1044

    
1045
                if (pDim.HasLeader)
1046
                {
1047
                    XmlAttribute Leader1PointAttr = Program.xml.CreateAttribute("Leader1Point");
1048
                    Leader1PointAttr.Value = pDim.Leader1Point.ToString();
1049
                    DimNode.Attributes.SetNamedItem(Leader1PointAttr);
1050

    
1051
                    XmlAttribute Leader2PointAttr = Program.xml.CreateAttribute("Leader2Point");
1052
                    Leader2PointAttr.Value = pDim.Leader2Point.ToString();
1053
                    DimNode.Attributes.SetNamedItem(Leader2PointAttr);
1054
                }
1055

    
1056
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
1057
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
1058
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
1059

    
1060
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
1061
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
1062
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
1063

    
1064
                dumpDimData(pDim, indent, DimNode);
1065

    
1066
                return DimNode;
1067
            }
1068

    
1069
            return null;
1070
        }
1071

    
1072

    
1073
        /************************************************************************/
1074
        /* Block Reference Dumper                                                */
1075
        /************************************************************************/
1076
        void dump(BlockReference pBlkRef, int indent, XmlNode node)
1077
        {
1078
            using (BlockTableRecord pRecord = (BlockTableRecord)pBlkRef.BlockTableRecord.Open(OpenMode.ForRead))
1079
            {
1080
                XmlNode BlockRefNode = dumpBlockRefData(pBlkRef, indent, node);
1081
                if (BlockRefNode != null)
1082
                {
1083
                    XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
1084
                    NameAttr.Value = pRecord.Name;
1085
                    BlockRefNode.Attributes.SetNamedItem(NameAttr);
1086
                }
1087
            }
1088
        }
1089

    
1090
        /************************************************************************/
1091
        /* Body Dumper                                                          */
1092
        /************************************************************************/
1093
        XmlNode dump(Body pBody, int indent, XmlNode node)
1094
        {
1095
            if (node != null)
1096
            {
1097
                XmlNode BodyNode = Program.xml.CreateElement(pBody.GetRXClass().Name);
1098

    
1099
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1100
                HandleAttr.Value = pBody.Handle.ToString();
1101
                BodyNode.Attributes.SetNamedItem(HandleAttr);
1102

    
1103
                dumpEntityData(pBody, indent, BodyNode);
1104

    
1105
                return BodyNode;
1106
            }
1107

    
1108
            return null;
1109
        }
1110

    
1111

    
1112
        /************************************************************************/
1113
        /* Circle Dumper                                                        */
1114
        /************************************************************************/
1115
        XmlNode dump(Circle pCircle, int indent, XmlNode node)
1116
        {
1117
            if (node != null)
1118
            {
1119
                XmlElement CircleNode = Program.xml.CreateElement(pCircle.GetRXClass().Name);
1120

    
1121
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1122
                XAttr.Value = pCircle.Center.X.ToString();
1123
                CircleNode.Attributes.SetNamedItem(XAttr);
1124

    
1125
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1126
                YAttr.Value = pCircle.Center.Y.ToString();
1127
                CircleNode.Attributes.SetNamedItem(YAttr);
1128

    
1129
                XmlAttribute RadiusAttr = Program.xml.CreateAttribute("Radius");
1130
                RadiusAttr.Value = pCircle.Radius.ToString();
1131
                CircleNode.Attributes.SetNamedItem(RadiusAttr);
1132

    
1133
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
1134
                NormalAttr.Value = pCircle.Normal.ToString();
1135
                CircleNode.Attributes.SetNamedItem(NormalAttr);
1136

    
1137
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
1138
                ThicknessAttr.Value = pCircle.Thickness.ToString();
1139
                CircleNode.Attributes.SetNamedItem(ThicknessAttr);
1140

    
1141
                dumpCurveData(pCircle, indent, CircleNode);
1142

    
1143
                node.AppendChild(CircleNode);
1144

    
1145
                return CircleNode;
1146
            }
1147

    
1148
            return null;
1149
        }
1150

    
1151
        /************************************************************************/
1152
        /* Diametric Dimension Dumper                                           */
1153
        /************************************************************************/
1154
        XmlNode dump(DiametricDimension pDim, int indent, XmlNode node)
1155
        {
1156
            if (node != null)
1157
            {
1158
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
1159

    
1160
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1161
                HandleAttr.Value = pDim.Handle.ToString();
1162
                DimNode.Attributes.SetNamedItem(HandleAttr);
1163

    
1164
                XmlAttribute ChordPointAttr = Program.xml.CreateAttribute("ChordPoint");
1165
                ChordPointAttr.Value = pDim.ChordPoint.ToString();
1166
                DimNode.Attributes.SetNamedItem(ChordPointAttr);
1167

    
1168
                XmlAttribute FarChordPointAttr = Program.xml.CreateAttribute("FarChordPoint");
1169
                FarChordPointAttr.Value = pDim.FarChordPoint.ToString();
1170
                DimNode.Attributes.SetNamedItem(FarChordPointAttr);
1171

    
1172
                XmlAttribute LeaderLengthAttr = Program.xml.CreateAttribute("LeaderLength");
1173
                LeaderLengthAttr.Value = pDim.LeaderLength.ToString();
1174
                DimNode.Attributes.SetNamedItem(LeaderLengthAttr);
1175

    
1176
                dumpDimData(pDim, indent, DimNode);
1177

    
1178
                return DimNode;
1179
            }
1180

    
1181
            return null;
1182
        }
1183

    
1184
        /************************************************************************/
1185
        /* Ellipse Dumper                                                       */
1186
        /************************************************************************/
1187
        void dump(Ellipse pEllipse, int indent, XmlNode node)
1188
        {
1189
            if (node != null)
1190
            {
1191
                XmlElement EllipseNode = Program.xml.CreateElement(pEllipse.GetRXClass().Name);
1192

    
1193
                writeLine(indent++, pEllipse.GetRXClass().Name, pEllipse.Handle);
1194

    
1195
                XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1196
                XAttr.Value = pEllipse.Center.X.ToString();
1197
                EllipseNode.Attributes.SetNamedItem(XAttr);
1198

    
1199
                XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1200
                YAttr.Value = pEllipse.Center.Y.ToString();
1201
                EllipseNode.Attributes.SetNamedItem(YAttr);
1202

    
1203
                XmlAttribute MajorAxisAttr = Program.xml.CreateAttribute("MajorAxis");
1204
                MajorAxisAttr.Value = pEllipse.MajorAxis.ToString();
1205
                EllipseNode.Attributes.SetNamedItem(MajorAxisAttr);
1206

    
1207
                XmlAttribute MinorAxisAttr = Program.xml.CreateAttribute("MinorAxis");
1208
                MinorAxisAttr.Value = pEllipse.MinorAxis.ToString();
1209
                EllipseNode.Attributes.SetNamedItem(MinorAxisAttr);
1210

    
1211
                XmlAttribute MajorRadiusAttr = Program.xml.CreateAttribute("MajorRadius");
1212
                MajorRadiusAttr.Value = pEllipse.MajorRadius.ToString();
1213
                EllipseNode.Attributes.SetNamedItem(MajorRadiusAttr);
1214

    
1215
                XmlAttribute MinorRadiusAttr = Program.xml.CreateAttribute("MinorRadius");
1216
                MinorRadiusAttr.Value = pEllipse.MinorRadius.ToString();
1217
                EllipseNode.Attributes.SetNamedItem(MinorRadiusAttr);
1218

    
1219
                XmlAttribute RadiusRatioAttr = Program.xml.CreateAttribute("RadiusRatio");
1220
                RadiusRatioAttr.Value = pEllipse.RadiusRatio.ToString();
1221
                EllipseNode.Attributes.SetNamedItem(RadiusRatioAttr);
1222

    
1223
                XmlAttribute StartAngleAttr = Program.xml.CreateAttribute("StartAngle");
1224
                StartAngleAttr.Value = pEllipse.StartAngle.ToString();
1225
                EllipseNode.Attributes.SetNamedItem(StartAngleAttr);
1226

    
1227
                XmlAttribute EndAngleAttr = Program.xml.CreateAttribute("EndAngle");
1228
                EndAngleAttr.Value = pEllipse.EndAngle.ToString();
1229
                EllipseNode.Attributes.SetNamedItem(EndAngleAttr);
1230

    
1231
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
1232
                NormalAttr.Value = pEllipse.Normal.ToString();
1233
                EllipseNode.Attributes.SetNamedItem(NormalAttr);
1234

    
1235
                dumpCurveData(pEllipse, indent, EllipseNode);
1236

    
1237
                node.AppendChild(EllipseNode);
1238
            }
1239
        }
1240

    
1241
        /************************************************************************/
1242
        /* Face Dumper                                                       */
1243
        /************************************************************************/
1244
        XmlNode dump(Face pFace, int indent, XmlNode node)
1245
        {
1246
            if (node != null)
1247
            {
1248
                XmlElement FaceNode = Program.xml.CreateElement(pFace.GetRXClass().Name);
1249

    
1250
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1251
                HandleAttr.Value = pFace.Handle.ToString();
1252
                FaceNode.Attributes.SetNamedItem(HandleAttr);
1253

    
1254
                for (short i = 0; i < 4; i++)
1255
                {
1256
                    XmlElement VertexNode = Program.xml.CreateElement("Vertex");
1257

    
1258
                    Point3d pt = pFace.GetVertexAt(i);
1259
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1260
                    XAttr.Value = pt.X.ToString();
1261
                    VertexNode.Attributes.SetNamedItem(XAttr);
1262

    
1263
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1264
                    YAttr.Value = pt.Y.ToString();
1265
                    VertexNode.Attributes.SetNamedItem(YAttr);
1266

    
1267
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1268
                    ZAttr.Value = pt.Z.ToString();
1269
                    VertexNode.Attributes.SetNamedItem(ZAttr);
1270

    
1271
                    XmlAttribute VisibleAttr = Program.xml.CreateAttribute("Visible");
1272
                    VisibleAttr.Value = pFace.IsEdgeVisibleAt(i).ToString();
1273
                    VertexNode.Attributes.SetNamedItem(VisibleAttr);
1274

    
1275
                    FaceNode.AppendChild(VertexNode);
1276
                }
1277
                dumpEntityData(pFace, indent, FaceNode);
1278

    
1279
                node.AppendChild(FaceNode);
1280

    
1281
                return FaceNode;
1282
            }
1283

    
1284
            return null;
1285
        }
1286

    
1287
        /************************************************************************/
1288
        /* FCF Dumper                                                           */
1289
        /************************************************************************/
1290
        void dump(FeatureControlFrame pFcf, int indent)
1291
        {
1292
            writeLine(indent++, pFcf.GetRXClass().Name, pFcf.Handle);
1293
            writeLine(indent, "Location", pFcf.Location);
1294
            writeLine(indent, "Text", pFcf.Text);
1295
            writeLine(indent, "Dimension Style", pFcf.DimensionStyleName);
1296
            writeLine(indent, "Dimension Gap", pFcf.Dimgap);
1297
            writeLine(indent, "Dimension Scale", pFcf.Dimscale);
1298
            writeLine(indent, "Text Height", pFcf.Dimtxt);
1299
            writeLine(indent, "Frame Color", pFcf.Dimclrd);
1300
            writeLine(indent, "Text Style", pFcf.TextStyleName);
1301
            writeLine(indent, "Text Color", pFcf.Dimclrd);
1302
            writeLine(indent, "X-Direction", pFcf.Direction);
1303
            writeLine(indent, "Normal", pFcf.Normal);
1304
            dumpEntityData(pFcf, indent, Program.xml.DocumentElement);
1305
        }
1306

    
1307
        /************************************************************************/
1308
        /* Hatch Dumper                                                         */
1309
        /************************************************************************/
1310
        /***********************************************************************/
1311
        /* Dump Polyline Loop                                                  */
1312
        /***********************************************************************/
1313
        static void dumpPolylineType(int loopIndex, Hatch pHatch, int indent)
1314
        {
1315
            HatchLoop hl = pHatch.GetLoopAt(loopIndex);
1316
            for (int i = 0; i < hl.Polyline.Count; i++)
1317
            {
1318
                BulgeVertex bv = hl.Polyline[i];
1319
                writeLine(indent, "Vertex " + i.ToString(), bv.Vertex.ToString());
1320
                writeLine(indent + 1, "Bulge " + i.ToString(), bv.Bulge);
1321
                writeLine(indent + 1, "Bulge angle " + i.ToString(), toDegreeString(4 * Math.Atan(bv.Bulge)));
1322
            }
1323
        }
1324

    
1325
        /**********************************************************************/
1326
        /* Dump Circular Arc Edge                                             */
1327
        /**********************************************************************/
1328
        static void dumpCircularArcEdge(int indent, CircularArc2d pCircArc)
1329
        {
1330
            writeLine(indent, "Center", pCircArc.Center);
1331
            writeLine(indent, "Radius", pCircArc.Radius);
1332
            writeLine(indent, "Start Angle", toDegreeString(pCircArc.StartAngle));
1333
            writeLine(indent, "End Angle", toDegreeString(pCircArc.EndAngle));
1334
            writeLine(indent, "Clockwise", pCircArc.IsClockWise);
1335
        }
1336

    
1337
        /**********************************************************************/
1338
        /* Dump Elliptical Arc Edge                                           */
1339
        /**********************************************************************/
1340
        static void dumpEllipticalArcEdge(int indent, EllipticalArc2d pEllipArc)
1341
        {
1342
            writeLine(indent, "Center", pEllipArc.Center);
1343
            writeLine(indent, "Major Radius", pEllipArc.MajorRadius);
1344
            writeLine(indent, "Minor Radius", pEllipArc.MinorRadius);
1345
            writeLine(indent, "Major Axis", pEllipArc.MajorAxis);
1346
            writeLine(indent, "Minor Axis", pEllipArc.MinorAxis);
1347
            writeLine(indent, "Start Angle", toDegreeString(pEllipArc.StartAngle));
1348
            writeLine(indent, "End Angle", toDegreeString(pEllipArc.EndAngle));
1349
            writeLine(indent, "Clockwise", pEllipArc.IsClockWise);
1350
        }
1351

    
1352
        /**********************************************************************/
1353
        /* Dump NurbCurve Edge                                           */
1354
        /**********************************************************************/
1355
        static void dumpNurbCurveEdge(int indent, NurbCurve2d pNurbCurve)
1356
        {
1357
            NurbCurve2dData d = pNurbCurve.DefinitionData;
1358
            writeLine(indent, "Degree", d.Degree);
1359
            writeLine(indent, "Rational", d.Rational);
1360
            writeLine(indent, "Periodic", d.Periodic);
1361

    
1362
            writeLine(indent, "Number of Control Points", d.ControlPoints.Count);
1363
            for (int i = 0; i < d.ControlPoints.Count; i++)
1364
            {
1365
                writeLine(indent, "Control Point " + i.ToString(), d.ControlPoints[i]);
1366
            }
1367
            writeLine(indent, "Number of Knots", d.Knots.Count);
1368
            for (int i = 0; i < d.Knots.Count; i++)
1369
            {
1370
                writeLine(indent, "Knot " + i.ToString(), d.Knots[i]);
1371
            }
1372

    
1373
            if (d.Rational)
1374
            {
1375
                writeLine(indent, "Number of Weights", d.Weights.Count);
1376
                for (int i = 0; i < d.Weights.Count; i++)
1377
                {
1378
                    writeLine(indent, "Weight " + i.ToString(), d.Weights[i]);
1379
                }
1380
            }
1381
        }
1382

    
1383
        /***********************************************************************/
1384
        /* Dump Edge Loop                                                      */
1385
        /***********************************************************************/
1386
        static void dumpEdgesType(int loopIndex, Hatch pHatch, int indent)
1387
        {
1388
            Curve2dCollection edges = pHatch.GetLoopAt(loopIndex).Curves;
1389
            for (int i = 0; i < (int)edges.Count; i++)
1390
            {
1391
                using (Curve2d pEdge = edges[i])
1392
                {
1393
                    writeLine(indent, string.Format("Edge {0}", i), pEdge.GetType().Name);
1394
                    switch (pEdge.GetType().Name)
1395
                    {
1396
                        case "LineSegment2d":
1397
                            break;
1398
                        case "CircularArc2d":
1399
                            dumpCircularArcEdge(indent + 1, (CircularArc2d)pEdge);
1400
                            break;
1401
                        case "EllipticalArc2d":
1402
                            dumpEllipticalArcEdge(indent + 1, (EllipticalArc2d)pEdge);
1403
                            break;
1404
                        case "NurbCurve2d":
1405
                            dumpNurbCurveEdge(indent + 1, (NurbCurve2d)pEdge);
1406
                            break;
1407
                    }
1408

    
1409
                    /******************************************************************/
1410
                    /* Common Edge Properties                                         */
1411
                    /******************************************************************/
1412
                    Interval interval = pEdge.GetInterval();
1413
                    writeLine(indent + 1, "Start Point", pEdge.EvaluatePoint(interval.LowerBound));
1414
                    writeLine(indent + 1, "End Point", pEdge.EvaluatePoint(interval.UpperBound));
1415
                    writeLine(indent + 1, "Closed", pEdge.IsClosed());
1416
                }
1417
            }
1418
        }
1419

    
1420
        /************************************************************************/
1421
        /* Convert the specified value to a LoopType string                     */
1422
        /************************************************************************/
1423
        string toLooptypeString(HatchLoopTypes loopType)
1424
        {
1425
            string retVal = "";
1426
            if ((loopType & HatchLoopTypes.External) != 0)
1427
                retVal = retVal + " | kExternal";
1428

    
1429
            if ((loopType & HatchLoopTypes.Polyline) != 0)
1430
                retVal = retVal + " | kPolyline";
1431

    
1432
            if ((loopType & HatchLoopTypes.Derived) != 0)
1433
                retVal = retVal + " | kDerived";
1434

    
1435
            if ((loopType & HatchLoopTypes.Textbox) != 0)
1436
                retVal = retVal + " | kTextbox";
1437

    
1438
            if ((loopType & HatchLoopTypes.Outermost) != 0)
1439
                retVal = retVal + " | kOutermost";
1440

    
1441
            if ((loopType & HatchLoopTypes.NotClosed) != 0)
1442
                retVal = retVal + " | kNotClosed";
1443

    
1444
            if ((loopType & HatchLoopTypes.SelfIntersecting) != 0)
1445
                retVal = retVal + " | kSelfIntersecting";
1446

    
1447
            if ((loopType & HatchLoopTypes.TextIsland) != 0)
1448
                retVal = retVal + " | kTextIsland";
1449

    
1450
            if ((loopType & HatchLoopTypes.Duplicate) != 0)
1451
                retVal = retVal + " | kDuplicate";
1452

    
1453
            return retVal == "" ? "kDefault" : retVal.Substring(3);
1454
        }
1455

    
1456
        void dump(Hatch pHatch, int indent)
1457
        {
1458
            writeLine(indent++, pHatch.GetRXClass().Name, pHatch.Handle);
1459
            writeLine(indent, "Hatch Style", pHatch.HatchStyle);
1460
            writeLine(indent, "Hatch Object Type", pHatch.HatchObjectType);
1461
            writeLine(indent, "Is Hatch", pHatch.IsHatch);
1462
            writeLine(indent, "Is Gradient", !pHatch.IsGradient);
1463
            if (pHatch.IsHatch)
1464
            {
1465
                /******************************************************************/
1466
                /* Dump Hatch Parameters                                          */
1467
                /******************************************************************/
1468
                writeLine(indent, "Pattern Type", pHatch.PatternType);
1469
                switch (pHatch.PatternType)
1470
                {
1471
                    case HatchPatternType.PreDefined:
1472
                    case HatchPatternType.CustomDefined:
1473
                        writeLine(indent, "Pattern Name", pHatch.PatternName);
1474
                        writeLine(indent, "Solid Fill", pHatch.IsSolidFill);
1475
                        if (!pHatch.IsSolidFill)
1476
                        {
1477
                            writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle));
1478
                            writeLine(indent, "Pattern Scale", pHatch.PatternScale);
1479
                        }
1480
                        break;
1481
                    case HatchPatternType.UserDefined:
1482
                        writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle));
1483
                        writeLine(indent, "Pattern Double", pHatch.PatternDouble);
1484
                        writeLine(indent, "Pattern Space", pHatch.PatternSpace);
1485
                        break;
1486
                }
1487
                DBObjectCollection entitySet = new DBObjectCollection();
1488
                Handle hhh = pHatch.Handle;
1489
                if (hhh.Value == 1692) //69C)
1490
                {
1491
                    pHatch.Explode(entitySet);
1492
                    return;
1493
                }
1494
                if (hhh.Value == 1693) //69D)
1495
                {
1496
                    try
1497
                    {
1498
                        pHatch.Explode(entitySet);
1499
                    }
1500
                    catch (System.Exception e)
1501
                    {
1502
                        if (e.Message == "eCannotExplodeEntity")
1503
                        {
1504
                            writeLine(indent, "Hatch " + e.Message + ": ", pHatch.Handle);
1505
                            return;
1506
                        }
1507
                    }
1508
                }
1509
            }
1510
            if (pHatch.IsGradient)
1511
            {
1512
                /******************************************************************/
1513
                /* Dump Gradient Parameters                                       */
1514
                /******************************************************************/
1515
                writeLine(indent, "Gradient Type", pHatch.GradientType);
1516
                writeLine(indent, "Gradient Name", pHatch.GradientName);
1517
                writeLine(indent, "Gradient Angle", toDegreeString(pHatch.GradientAngle));
1518
                writeLine(indent, "Gradient Shift", pHatch.GradientShift);
1519
                writeLine(indent, "Gradient One-Color Mode", pHatch.GradientOneColorMode);
1520
                if (pHatch.GradientOneColorMode)
1521
                {
1522
                    writeLine(indent, "ShadeTintValue", pHatch.ShadeTintValue);
1523
                }
1524
                GradientColor[] colors = pHatch.GetGradientColors();
1525
                for (int i = 0; i < colors.Length; i++)
1526
                {
1527
                    writeLine(indent, string.Format("Color         {0}", i), colors[i].get_Color());
1528
                    writeLine(indent, string.Format("Interpolation {0}", i), colors[i].get_Value());
1529
                }
1530
            }
1531

    
1532
            /********************************************************************/
1533
            /* Dump Associated Objects                                          */
1534
            /********************************************************************/
1535
            writeLine(indent, "Associated objects", pHatch.Associative);
1536
            foreach (ObjectId id in pHatch.GetAssociatedObjectIds())
1537
            {
1538
                writeLine(indent + 1, id.ObjectClass.Name, id.Handle);
1539
            }
1540

    
1541
            /********************************************************************/
1542
            /* Dump Loops                                                       */
1543
            /********************************************************************/
1544
            writeLine(indent, "Loops", pHatch.NumberOfLoops);
1545
            for (int i = 0; i < pHatch.NumberOfLoops; i++)
1546
            {
1547
                writeLine(indent + 1, "Loop " + i.ToString(), toLooptypeString(pHatch.LoopTypeAt(i)));
1548

    
1549
                /******************************************************************/
1550
                /* Dump Loop                                                      */
1551
                /******************************************************************/
1552
                if ((pHatch.LoopTypeAt(i) & HatchLoopTypes.Polyline) != 0)
1553
                {
1554
                    dumpPolylineType(i, pHatch, indent + 2);
1555
                }
1556
                else
1557
                {
1558
                    dumpEdgesType(i, pHatch, indent + 2);
1559
                }
1560
                /******************************************************************/
1561
                /* Dump Associated Objects                                        */
1562
                /******************************************************************/
1563
                if (pHatch.Associative)
1564
                {
1565
                    writeLine(indent + 2, "Associated objects");
1566
                    foreach (ObjectId id in pHatch.GetAssociatedObjectIdsAt(i))
1567
                    {
1568
                        writeLine(indent + 3, id.ObjectClass.Name, id.Handle);
1569
                    }
1570
                }
1571
            }
1572

    
1573
            writeLine(indent, "Elevation", pHatch.Elevation);
1574
            writeLine(indent, "Normal", pHatch.Normal);
1575
            dumpEntityData(pHatch, indent, Program.xml.DocumentElement);
1576
        }
1577

    
1578
        /************************************************************************/
1579
        /* Leader Dumper                                                          */
1580
        /************************************************************************/
1581
        void dump(Leader pLeader, int indent)
1582
        {
1583
            writeLine(indent++, pLeader.GetRXClass().Name, pLeader.Handle);
1584
            writeLine(indent, "Dimension Style", pLeader.DimensionStyleName);
1585

    
1586
            writeLine(indent, "Annotation");
1587
            if (!pLeader.Annotation.IsNull)
1588
            {
1589
                writeLine(indent++, pLeader.Annotation.ObjectClass.Name, pLeader.Annotation.Handle);
1590
            }
1591
            writeLine(indent + 1, "Type", pLeader.AnnoType);
1592
            writeLine(indent + 1, "Height", pLeader.AnnoHeight);
1593
            writeLine(indent + 1, "Width", pLeader.AnnoWidth);
1594
            writeLine(indent + 1, "Offset", pLeader.AnnotationOffset);
1595
            writeLine(indent, "Has Arrowhead", pLeader.HasArrowHead);
1596
            writeLine(indent, "Has Hook Line", pLeader.HasHookLine);
1597
            writeLine(indent, "Splined", pLeader.IsSplined);
1598

    
1599
            for (int i = 0; i < pLeader.NumVertices; i++)
1600
            {
1601
                writeLine(indent, string.Format("Vertex {0}", i), pLeader.VertexAt(i));
1602
            }
1603
            writeLine(indent, "Normal", pLeader.Normal);
1604
            dumpCurveData(pLeader, indent, Program.xml.DocumentElement);
1605
        }
1606

    
1607
        /************************************************************************/
1608
        /* Line Dumper                                                          */
1609
        /************************************************************************/
1610
        void dump(Line pLine, int indent, XmlNode node)
1611
        {
1612
            if (node != null && pLine != null && pLine.Length != 0)
1613
            {
1614
                XmlNode LineNode = Program.xml.CreateElement(pLine.GetRXClass().Name);
1615
                XmlAttribute LengthAttr = Program.xml.CreateAttribute("Length");
1616
                LengthAttr.Value = pLine.Length.ToString();
1617
                LineNode.Attributes.SetNamedItem(LengthAttr);
1618

    
1619
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1620
                HandleAttr.Value = pLine.Handle.ToString();
1621
                LineNode.Attributes.SetNamedItem(HandleAttr);
1622

    
1623
                XmlNode StartPointNode = Program.xml.CreateElement("Vertex");
1624
                {
1625
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1626
                    XAttr.Value = pLine.StartPoint.X.ToString();
1627
                    StartPointNode.Attributes.SetNamedItem(XAttr);
1628

    
1629
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1630
                    YAttr.Value = pLine.StartPoint.Y.ToString();
1631
                    StartPointNode.Attributes.SetNamedItem(YAttr);
1632

    
1633
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1634
                    ZAttr.Value = pLine.StartPoint.Z.ToString();
1635
                    StartPointNode.Attributes.SetNamedItem(ZAttr);
1636
                }
1637
                LineNode.AppendChild(StartPointNode);
1638

    
1639
                XmlNode EndPointNode = Program.xml.CreateElement("Vertex");
1640
                {
1641
                    XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1642
                    XAttr.Value = pLine.EndPoint.X.ToString();
1643
                    EndPointNode.Attributes.SetNamedItem(XAttr);
1644

    
1645
                    XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1646
                    YAttr.Value = pLine.EndPoint.Y.ToString();
1647
                    EndPointNode.Attributes.SetNamedItem(YAttr);
1648

    
1649
                    XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1650
                    ZAttr.Value = pLine.EndPoint.Z.ToString();
1651
                    EndPointNode.Attributes.SetNamedItem(ZAttr);
1652
                }
1653
                LineNode.AppendChild(EndPointNode);
1654

    
1655
                XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal");
1656
                NormalAttr.Value = pLine.Normal.ToString();
1657
                LineNode.Attributes.SetNamedItem(NormalAttr);
1658

    
1659
                XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness");
1660
                ThicknessAttr.Value = pLine.Thickness.ToString();
1661
                LineNode.Attributes.SetNamedItem(ThicknessAttr);
1662

    
1663
                dumpEntityData(pLine, indent, LineNode);
1664

    
1665
                node.AppendChild(LineNode);
1666
            }
1667
            else
1668
            {
1669
                int d = 0;
1670
            }
1671
        }
1672

    
1673
        /************************************************************************/
1674
        /* MInsertBlock Dumper                                                  */
1675
        /************************************************************************/
1676
        void dump(MInsertBlock pMInsert, int indent, XmlNode node)
1677
        {
1678
            writeLine(indent++, pMInsert.GetRXClass().Name, pMInsert.Handle);
1679

    
1680
            using (BlockTableRecord pRecord = (BlockTableRecord)pMInsert.BlockTableRecord.Open(OpenMode.ForRead))
1681
            {
1682
                writeLine(indent, "Name", pRecord.Name);
1683
                writeLine(indent, "Rows", pMInsert.Rows);
1684
                writeLine(indent, "Columns", pMInsert.Columns);
1685
                writeLine(indent, "Row Spacing", pMInsert.RowSpacing);
1686
                writeLine(indent, "Column Spacing", pMInsert.ColumnSpacing);
1687
                dumpBlockRefData(pMInsert, indent, node);
1688
            }
1689
        }
1690

    
1691
        /************************************************************************/
1692
        /* Mline Dumper                                                         */
1693
        /************************************************************************/
1694
        void dump(Mline pMline, int indent)
1695
        {
1696
            writeLine(indent++, pMline.GetRXClass().Name, pMline.Handle);
1697
            writeLine(indent, "Style", pMline.Style);
1698
            writeLine(indent, "Closed", pMline.IsClosed);
1699
            writeLine(indent, "Scale", pMline.Scale);
1700
            writeLine(indent, "Suppress Start Caps", pMline.SupressStartCaps);
1701
            writeLine(indent, "Suppress End Caps", pMline.SupressEndCaps);
1702
            writeLine(indent, "Normal", pMline.Normal);
1703

    
1704
            /********************************************************************/
1705
            /* Dump the segment data                                            */
1706
            /********************************************************************/
1707
            for (int i = 0; i < pMline.NumberOfVertices; i++)
1708
            {
1709
                writeLine(indent, "Segment", i);
1710
                writeLine(indent + 1, "Vertex", pMline.VertexAt(i));
1711
            }
1712
            dumpEntityData(pMline, indent, Program.xml.DocumentElement);
1713
        }
1714

    
1715
        /************************************************************************/
1716
        /* MText Dumper                                                         */
1717
        /************************************************************************/
1718
        /// <summary>
1719
        /// convert MText to normal Text
1720
        /// </summary>
1721
        /// <param name="pMText"></param>
1722
        /// <param name="indent"></param>
1723
        /// <param name="node"></param>
1724
        void dump(MText pMText, int indent, XmlNode node)
1725
        {
1726
            DBObjectCollection objColl = new DBObjectCollection();
1727
            pMText.Explode(objColl);
1728
            foreach (var obj in objColl)
1729
            {
1730
                dumpTextData(obj as DBText, indent, node);
1731
            }
1732
        }
1733

    
1734
        /************************************************************************/
1735
        /* Ordinate Dimension Dumper                                            */
1736
        /************************************************************************/
1737
        XmlNode dump(OrdinateDimension pDim, int indent, XmlNode node)
1738
        {
1739
            if (node != null)
1740
            {
1741
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
1742

    
1743
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1744
                HandleAttr.Value = pDim.Handle.ToString();
1745
                DimNode.Attributes.SetNamedItem(HandleAttr);
1746

    
1747
                XmlAttribute DefiningPointAttr = Program.xml.CreateAttribute("DefiningPoint");
1748
                DefiningPointAttr.Value = pDim.DefiningPoint.ToString();
1749
                DimNode.Attributes.SetNamedItem(DefiningPointAttr);
1750

    
1751
                XmlAttribute UsingXAxisAttr = Program.xml.CreateAttribute("UsingXAxis");
1752
                UsingXAxisAttr.Value = pDim.UsingXAxis.ToString();
1753
                DimNode.Attributes.SetNamedItem(UsingXAxisAttr);
1754

    
1755
                XmlAttribute UsingYAxisAttr = Program.xml.CreateAttribute("UsingYAxis");
1756
                UsingYAxisAttr.Value = pDim.UsingYAxis.ToString();
1757
                DimNode.Attributes.SetNamedItem(UsingYAxisAttr);
1758

    
1759
                XmlAttribute LeaderEndPointAttr = Program.xml.CreateAttribute("LeaderEndPoint");
1760
                LeaderEndPointAttr.Value = pDim.LeaderEndPoint.ToString();
1761
                DimNode.Attributes.SetNamedItem(LeaderEndPointAttr);
1762

    
1763
                XmlAttribute OriginAttr = Program.xml.CreateAttribute("Origin");
1764
                OriginAttr.Value = pDim.Origin.ToString();
1765
                DimNode.Attributes.SetNamedItem(OriginAttr);
1766

    
1767
                dumpDimData(pDim, indent, DimNode);
1768

    
1769
                return DimNode;
1770
            }
1771

    
1772
            return null;
1773
        }
1774

    
1775
        /************************************************************************/
1776
        /* PolyFaceMesh Dumper                                                  */
1777
        /************************************************************************/
1778
        XmlNode dump(PolyFaceMesh pPoly, int indent, XmlNode node)
1779
        {
1780
            if (node != null)
1781
            {
1782
                XmlElement PolyNode = Program.xml.CreateElement(pPoly.GetRXClass().Name);
1783

    
1784
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1785
                HandleAttr.Value = pPoly.Handle.ToString();
1786
                PolyNode.Attributes.SetNamedItem(HandleAttr);
1787

    
1788
                XmlAttribute NumVerticesAttr = Program.xml.CreateAttribute("NumVertices");
1789
                NumVerticesAttr.Value = pPoly.NumVertices.ToString();
1790
                PolyNode.Attributes.SetNamedItem(NumVerticesAttr);
1791

    
1792
                XmlAttribute NumFacesAttr = Program.xml.CreateAttribute("NumFaces");
1793
                NumFacesAttr.Value = pPoly.NumFaces.ToString();
1794
                PolyNode.Attributes.SetNamedItem(NumFacesAttr);
1795

    
1796
                /********************************************************************/
1797
                /* dump vertices and faces                                          */
1798
                /********************************************************************/
1799
                int vertexCount = 0;
1800
                int faceCount = 0;
1801
                foreach (ObjectId objId in pPoly)
1802
                {
1803
                    using (Entity ent = (Entity)objId.GetObject(OpenMode.ForRead))
1804
                    {
1805
                        if (ent is PolyFaceMeshVertex)
1806
                        {
1807
                            PolyFaceMeshVertex pVertex = (PolyFaceMeshVertex)ent;
1808

    
1809
                            XmlElement VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name);
1810

    
1811
                            XmlAttribute _HandleAttr = Program.xml.CreateAttribute("Handle");
1812
                            _HandleAttr.Value = pVertex.Handle.ToString();
1813
                            VertexNode.Attributes.SetNamedItem(_HandleAttr);
1814

    
1815
                            XmlAttribute PositionAttr = Program.xml.CreateAttribute("Position");
1816
                            PositionAttr.Value = pVertex.Position.ToString();
1817
                            VertexNode.Attributes.SetNamedItem(PositionAttr);
1818

    
1819
                            dumpEntityData(pVertex, indent + 1, VertexNode);
1820

    
1821
                            PolyNode.AppendChild(VertexNode);
1822
                        }
1823
                        else if (ent is FaceRecord)
1824
                        {
1825
                            FaceRecord pFace = (FaceRecord)ent;
1826
                            string face = "{";
1827
                            for (short i = 0; i < 4; i++)
1828
                            {
1829
                                if (i > 0)
1830
                                {
1831
                                    face = face + " ";
1832
                                }
1833
                                face = face + pFace.GetVertexAt(i).ToString();
1834
                            }
1835

    
1836
                            face += "}";
1837

    
1838
                            XmlElement FaceNode = Program.xml.CreateElement(pFace.GetRXClass().Name);
1839

    
1840
                            XmlAttribute _HandleAttr = Program.xml.CreateAttribute("Handle");
1841
                            _HandleAttr.Value = pFace.Handle.ToString();
1842
                            FaceNode.Attributes.SetNamedItem(_HandleAttr);
1843
                            FaceNode.InnerText = face;
1844

    
1845
                            dumpEntityData(pFace, indent + 1, FaceNode);
1846

    
1847
                            PolyNode.AppendChild(FaceNode);
1848
                        }
1849
                        else
1850
                        { // Unknown entity type
1851
                            writeLine(indent, "Unexpected Entity");
1852
                        }
1853
                    }
1854
                }
1855
                dumpEntityData(pPoly, indent, PolyNode);
1856

    
1857
                return PolyNode;
1858
            }
1859

    
1860
            return null;
1861
        }
1862

    
1863
        /************************************************************************/
1864
        /* Ole2Frame                                                            */
1865
        /************************************************************************/
1866
        void dump(Ole2Frame pOle, int indent)
1867
        {
1868
            writeLine(indent++, pOle.GetRXClass().Name, pOle.Handle);
1869

    
1870
            Rectangle3d pos = (Rectangle3d)pOle.Position3d;
1871
            writeLine(indent, "Lower Left", pos.LowerLeft);
1872
            writeLine(indent, "Lower Right", pos.LowerRight);
1873
            writeLine(indent, "Upper Left", pos.UpperLeft);
1874
            writeLine(indent, "Upper Right", pos.UpperRight);
1875
            writeLine(indent, "Type", pOle.Type);
1876
            writeLine(indent, "User Type", pOle.UserType);
1877
            if (pOle.Type == Ole2Frame.ItemType.Link)
1878
            {
1879
                writeLine(indent, "Link Name", pOle.LinkName);
1880
                writeLine(indent, "Link Path", pOle.LinkPath);
1881
            }
1882
            writeLine(indent, "Output Quality", pOle.OutputQuality);
1883
            dumpEntityData(pOle, indent, Program.xml.DocumentElement);
1884
        }
1885

    
1886
        /************************************************************************/
1887
        /* Point Dumper                                                         */
1888
        /************************************************************************/
1889
        void dump(DBPoint pPoint, int indent)
1890
        {
1891
            writeLine(indent++, pPoint.GetRXClass().Name, pPoint.Handle);
1892
            writeLine(indent, "Position", pPoint.Position);
1893
            writeLine(indent, "ECS Rotation", toDegreeString(pPoint.EcsRotation));
1894
            writeLine(indent, "Normal", pPoint.Normal);
1895
            writeLine(indent, "Thickness", pPoint.Thickness);
1896
            dumpEntityData(pPoint, indent, Program.xml.DocumentElement);
1897
        }
1898

    
1899
        /************************************************************************/
1900
        /* Polygon Mesh Dumper                                                  */
1901
        /************************************************************************/
1902
        void dump(PolygonMesh pPoly, int indent)
1903
        {
1904
            writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1905
            writeLine(indent, "m Size", pPoly.MSize);
1906
            writeLine(indent, "m-Closed", pPoly.IsMClosed);
1907
            writeLine(indent, "m Surface Density", pPoly.MSurfaceDensity);
1908
            writeLine(indent, "n Size", pPoly.NSize);
1909
            writeLine(indent, "n-Closed", pPoly.IsNClosed);
1910
            writeLine(indent, "n Surface Density", pPoly.NSurfaceDensity);
1911
            /********************************************************************/
1912
            /* dump vertices                                                    */
1913
            /********************************************************************/
1914
            int vertexCount = 0;
1915
            foreach (object o in pPoly)
1916
            {
1917
                PolygonMeshVertex pVertex = o as PolygonMeshVertex;
1918
                if (pVertex != null)
1919
                {
1920
                    writeLine(indent, pVertex.GetRXClass().Name, vertexCount++);
1921
                    writeLine(indent + 1, "Handle", pVertex.Handle);
1922
                    writeLine(indent + 1, "Position", pVertex.Position);
1923
                    writeLine(indent + 1, "Type", pVertex.VertexType);
1924
                }
1925
            }
1926
            dumpEntityData(pPoly, indent, Program.xml.DocumentElement);
1927
        }
1928

    
1929
        /************************************************************************/
1930
        /* Polyline Dumper                                                      */
1931
        /************************************************************************/
1932
        void dump(Teigha.DatabaseServices.Polyline pPoly, int indent, XmlNode node)
1933
        {
1934
            if (pPoly != null && pPoly.Length != 0)
1935
            {
1936
                writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1937
                writeLine(indent, "Has Width", pPoly.HasWidth);
1938
                if (!pPoly.HasWidth)
1939
                {
1940
                    writeLine(indent, "Constant Width", pPoly.ConstantWidth);
1941
                }
1942

    
1943
                /********************************************************************/
1944
                /* dump vertices                                                    */
1945
                /********************************************************************/
1946
                if (node != null)
1947
                {
1948
                    XmlNode PolylineNode = Program.xml.CreateElement(pPoly.GetRXClass().Name);
1949
                    XmlAttribute LengthAttr = Program.xml.CreateAttribute("Length");
1950
                    LengthAttr.Value = pPoly.Length.ToString();
1951
                    PolylineNode.Attributes.SetNamedItem(LengthAttr);
1952

    
1953
                    XmlAttribute CountAttr = Program.xml.CreateAttribute("Count");
1954
                    CountAttr.Value = pPoly.NumberOfVertices.ToString();
1955
                    PolylineNode.Attributes.SetNamedItem(CountAttr);
1956

    
1957
                    XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
1958
                    HandleAttr.Value = pPoly.Handle.ToString();
1959
                    PolylineNode.Attributes.SetNamedItem(HandleAttr);
1960

    
1961
                    XmlAttribute ClosedAttr = Program.xml.CreateAttribute("Closed");
1962
                    ClosedAttr.Value = pPoly.Closed.ToString();
1963
                    PolylineNode.Attributes.SetNamedItem(ClosedAttr);
1964

    
1965
                    for (int i = 0; i < pPoly.NumberOfVertices; i++)
1966
                    {
1967
                        XmlNode VertexNode = Program.xml.CreateElement("Vertex");
1968

    
1969
                        XmlAttribute SegmentTypeAttr = Program.xml.CreateAttribute("SegmentType");
1970
                        SegmentTypeAttr.Value = pPoly.GetSegmentType(i).ToString();
1971

    
1972
                        Point3d pt = pPoly.GetPoint3dAt(i);
1973
                        XmlAttribute XAttr = Program.xml.CreateAttribute("X");
1974
                        XAttr.Value = pt.X.ToString();
1975
                        VertexNode.Attributes.SetNamedItem(XAttr);
1976

    
1977
                        XmlAttribute YAttr = Program.xml.CreateAttribute("Y");
1978
                        YAttr.Value = pt.Y.ToString();
1979
                        VertexNode.Attributes.SetNamedItem(YAttr);
1980

    
1981
                        XmlAttribute ZAttr = Program.xml.CreateAttribute("Z");
1982
                        ZAttr.Value = pt.Z.ToString();
1983
                        VertexNode.Attributes.SetNamedItem(ZAttr);
1984

    
1985
                        if (pPoly.HasWidth)
1986
                        {
1987
                            XmlAttribute StartWidthAttr = Program.xml.CreateAttribute("StartWidth");
1988
                            StartWidthAttr.Value = pPoly.GetStartWidthAt(i).ToString();
1989
                            VertexNode.Attributes.SetNamedItem(StartWidthAttr);
1990

    
1991
                            XmlAttribute EndWidthAttr = Program.xml.CreateAttribute("EndWidth");
1992
                            EndWidthAttr.Value = pPoly.GetEndWidthAt(i).ToString();
1993
                            VertexNode.Attributes.SetNamedItem(EndWidthAttr);
1994
                        }
1995
                        if (pPoly.HasBulges)
1996
                        {
1997
                            XmlAttribute BulgeAttr = Program.xml.CreateAttribute("Bulge");
1998
                            BulgeAttr.Value = pPoly.GetBulgeAt(i).ToString();
1999
                            VertexNode.Attributes.SetNamedItem(BulgeAttr);
2000

    
2001
                            if (pPoly.GetSegmentType(i) == SegmentType.Arc)
2002
                            {
2003
                                XmlAttribute BulgeAngleAttr = Program.xml.CreateAttribute("BulgeAngle");
2004
                                BulgeAngleAttr.Value = pPoly.GetBulgeAt(i).ToString();
2005
                                VertexNode.Attributes.SetNamedItem(BulgeAngleAttr);
2006
                            }
2007
                        }
2008

    
2009
                        PolylineNode.AppendChild(VertexNode);
2010
                    }
2011

    
2012
                    dumpEntityData(pPoly, indent, PolylineNode);
2013
                    node.AppendChild(PolylineNode);
2014
                }
2015
            }
2016
            else
2017
            {
2018
                int d = 0;
2019
            }
2020
        }
2021

    
2022
        class DrawContextDumper : Context
2023
        {
2024
            Database _db;
2025
            public DrawContextDumper(Database db)
2026
            {
2027
                _db = db;
2028
            }
2029
            public override Database Database
2030
            {
2031
                get { return _db; }
2032
            }
2033
            public override bool IsBoundaryClipping
2034
            {
2035
                get { return false; }
2036
            }
2037
            public override bool IsPlotGeneration
2038
            {
2039
                get { return false; }
2040
            }
2041
            public override bool IsPostScriptOut
2042
            {
2043
                get { return false; }
2044
            }
2045
        }
2046
        class SubEntityTraitsDumper : SubEntityTraits
2047
        {
2048
            short _color;
2049
            int _drawFlags;
2050
            FillType _ft;
2051
            ObjectId _layer;
2052
            ObjectId _linetype;
2053
            LineWeight _lineWeight;
2054
            Mapper _mapper;
2055
            double _lineTypeScale;
2056
            ObjectId _material;
2057
            PlotStyleDescriptor _plotStyleDescriptor;
2058
            bool _sectionable;
2059
            bool _selectionOnlyGeometry;
2060
            ShadowFlags _shadowFlags;
2061
            double _thickness;
2062
            EntityColor _trueColor;
2063
            Transparency _transparency;
2064
            ObjectId _visualStyle;
2065
            public SubEntityTraitsDumper(Database db)
2066
            {
2067
                _drawFlags = 0; // kNoDrawFlags 
2068
                _color = 0;
2069
                _ft = FillType.FillAlways;
2070
                _layer = db.Clayer;
2071
                _linetype = db.Celtype;
2072
                _lineWeight = db.Celweight;
2073
                _lineTypeScale = db.Celtscale;
2074
                _material = db.Cmaterial;
2075
                _shadowFlags = ShadowFlags.ShadowsIgnore;
2076
                _thickness = 0;
2077
                _trueColor = new EntityColor(ColorMethod.None);
2078
                _transparency = new Transparency();
2079
            }
2080

    
2081
            protected override void SetLayerFlags(LayerFlags flags)
2082
            {
2083
                writeLine(0, string.Format("SubEntityTraitsDumper.SetLayerFlags(flags = {0})", flags));
2084
            }
2085
            public override void AddLight(ObjectId lightId)
2086
            {
2087
                writeLine(0, string.Format("SubEntityTraitsDumper.AddLight(lightId = {0})", lightId.ToString()));
2088
            }
2089
            public override void SetupForEntity(Entity entity)
2090
            {
2091
                writeLine(0, string.Format("SubEntityTraitsDumper.SetupForEntity(entity = {0})", entity.ToString()));
2092
            }
2093

    
2094
            public override short Color
2095
            {
2096
                get { return _color; }
2097
                set { _color = value; }
2098
            }
2099
            public override int DrawFlags
2100
            {
2101
                get { return _drawFlags; }
2102
                set { _drawFlags = value; }
2103
            }
2104
            public override FillType FillType
2105
            {
2106
                get { return _ft; }
2107
                set { _ft = value; }
2108
            }
2109
            public override ObjectId Layer
2110
            {
2111
                get { return _layer; }
2112
                set { _layer = value; }
2113
            }
2114
            public override ObjectId LineType
2115
            {
2116
                get { return _linetype; }
2117
                set { _linetype = value; }
2118
            }
2119
            public override double LineTypeScale
2120
            {
2121
                get { return _lineTypeScale; }
2122
                set { _lineTypeScale = value; }
2123
            }
2124
            public override LineWeight LineWeight
2125
            {
2126
                get { return _lineWeight; }
2127
                set { _lineWeight = value; }
2128
            }
2129
            public override Mapper Mapper
2130
            {
2131
                get { return _mapper; }
2132
                set { _mapper = value; }
2133
            }
2134
            public override ObjectId Material
2135
            {
2136
                get { return _material; }
2137
                set { _material = value; }
2138
            }
2139
            public override PlotStyleDescriptor PlotStyleDescriptor
2140
            {
2141
                get { return _plotStyleDescriptor; }
2142
                set { _plotStyleDescriptor = value; }
2143
            }
2144
            public override bool Sectionable
2145
            {
2146
                get { return _sectionable; }
2147
                set { _sectionable = value; }
2148
            }
2149
            public override bool SelectionOnlyGeometry
2150
            {
2151
                get { return _selectionOnlyGeometry; }
2152
                set { _selectionOnlyGeometry = value; }
2153
            }
2154
            public override ShadowFlags ShadowFlags
2155
            {
2156
                get { return _shadowFlags; }
2157
                set { _shadowFlags = value; }
2158
            }
2159
            public override double Thickness
2160
            {
2161
                get { return _thickness; }
2162
                set { _thickness = value; }
2163
            }
2164
            public override EntityColor TrueColor
2165
            {
2166
                get { return _trueColor; }
2167
                set { _trueColor = value; }
2168
            }
2169
            public override Transparency Transparency
2170
            {
2171
                get { return _transparency; }
2172
                set { _transparency = value; }
2173
            }
2174
            public override ObjectId VisualStyle
2175
            {
2176
                get { return _visualStyle; }
2177
                set { _visualStyle = value; }
2178
            }
2179
            public override void SetSelectionMarker(IntPtr sm)
2180
            {
2181
            }
2182
        }
2183
        class WorldGeometryDumper : WorldGeometry
2184
        {
2185
            Stack<Matrix3d> modelMatrix;
2186
            Stack<ClipBoundary> clips;
2187
            int indent;
2188
            public WorldGeometryDumper(int indent)
2189
              : base()
2190
            {
2191
                this.indent = indent;
2192
                modelMatrix = new Stack<Matrix3d>();
2193
                clips = new Stack<ClipBoundary>();
2194
                modelMatrix.Push(Matrix3d.Identity);
2195
            }
2196
            public override Matrix3d ModelToWorldTransform
2197
            {
2198
                get { return modelMatrix.Peek(); }
2199
            }
2200
            public override Matrix3d WorldToModelTransform
2201
            {
2202
                get { return modelMatrix.Peek().Inverse(); }
2203
            }
2204

    
2205
            public override Matrix3d PushOrientationTransform(OrientationBehavior behavior)
2206
            {
2207
                writeLine(indent, string.Format("WorldGeometry.PushOrientationTransform(behavior = {0})", behavior));
2208
                return new Matrix3d();
2209
            }
2210
            public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point2d offset)
2211
            {
2212
                writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset));
2213
                return new Matrix3d();
2214
            }
2215
            public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point3d offset)
2216
            {
2217
                writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset));
2218
                return new Matrix3d();
2219
            }
2220
            public override bool OwnerDraw(GdiDrawObject gdiDrawObject, Point3d position, Vector3d u, Vector3d v)
2221
            {
2222
                writeLine(indent, string.Format("WorldGeometry.OwnerDraw(gdiDrawObject = {0}, position = {1}, u = {2}, v = {3})", gdiDrawObject, position, u, v));
2223
                return false;
2224
            }
2225
            public override bool Polyline(Teigha.GraphicsInterface.Polyline polylineObj)
2226
            {
2227
                writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}", polylineObj));
2228
                return false;
2229
            }
2230
            public override bool Polypoint(Point3dCollection points, Vector3dCollection normals, IntPtrCollection subentityMarkers)
2231
            {
2232
                writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, normals = {1}, subentityMarkers = {2}", points, normals, subentityMarkers));
2233
                return false;
2234
            }
2235
            public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, Vector3dCollection normals, IntPtrCollection subentityMarkers)
2236
            {
2237
                writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, normals = {2}, subentityMarkers = {3}", points, colors, normals, subentityMarkers));
2238
                return false;
2239
            }
2240
            public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, TransparencyCollection transparency, Vector3dCollection normals, IntPtrCollection subentityMarkers, int pointSize)
2241
            {
2242
                writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, transparency = {2}, normals = {3}, subentityMarkers = {4}, pointSize = {5}", points, colors, transparency, normals, subentityMarkers, pointSize));
2243
                return false;
2244
            }
2245
            public override bool PolyPolyline(Teigha.GraphicsInterface.PolylineCollection polylineCollection)
2246
            {
2247
                writeLine(indent, string.Format("WorldGeometry.PolyPolyline(polylineCollection = {0}", polylineCollection));
2248
                return false;
2249
            }
2250
            public override bool PolyPolygon(UInt32Collection numPolygonPositions, Point3dCollection polygonPositions, UInt32Collection numPolygonPoints, Point3dCollection polygonPoints, EntityColorCollection outlineColors, LinetypeCollection outlineTypes, EntityColorCollection fillColors, Teigha.Colors.TransparencyCollection fillOpacities)
2251
            {
2252
                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));
2253
                return false;
2254
            }
2255
            public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point2d extents)
2256
            {
2257
                writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents));
2258
                return new Matrix3d();
2259
            }
2260
            public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point3d extents)
2261
            {
2262
                writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents));
2263
                return new Matrix3d();
2264
            }
2265
            public override bool EllipticalArc(Point3d center, Vector3d normal, double majorAxisLength, double minorAxisLength, double startDegreeInRads, double endDegreeInRads, double tiltDegreeInRads, ArcType arType)
2266
            {
2267
                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));
2268
                return false;
2269
            }
2270
            public override bool Circle(Point3d center, double radius, Vector3d normal)
2271
            {
2272
                writeLine(indent, string.Format("WorldGeometry.Circle(center = {0}, radius = {1}, normal = {2})", center, radius, normal));
2273
                return false;
2274
            }
2275
            public override bool Circle(Point3d firstPoint, Point3d secondPoint, Point3d thirdPoint)
2276
            {
2277
                writeLine(indent, string.Format("WorldGeometry.Circle(firstPoint = {0}, secondPoint = {1}, thirdPoint = {2})", firstPoint, secondPoint, thirdPoint));
2278
                return false;
2279
            }
2280
            public override bool CircularArc(Point3d start, Point3d point, Point3d endingPoint, ArcType arcType)
2281
            {
2282
                writeLine(indent, string.Format("WorldGeometry.CircularArc(start = {0}, point = {1}, endingPoint = {2}, arcType = {3})", start, point, endingPoint, arcType));
2283
                return false;
2284
            }
2285
            public override bool CircularArc(Point3d center, double radius, Vector3d normal, Vector3d startVector, double sweepAngle, ArcType arcType)
2286
            {
2287
                writeLine(indent, string.Format("WorldGeometry.CircularArc(center = {0}, radius = {1}, normal = {2}, startVector = {3}, sweepAngle = {4}, arcType = {5}", center, radius, normal, startVector, sweepAngle, arcType));
2288
                return false;
2289
            }
2290
            public override bool Draw(Drawable value)
2291
            {
2292
                writeLine(indent, string.Format("WorldGeometry.Draw(value = {0}", value));
2293
                return false;
2294
            }
2295
            public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v)
2296
            {
2297
                writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}", position, u, v));
2298
                return false;
2299
            }
2300
            public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v, TransparencyMode transparencyMode)
2301
            {
2302
                writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}, transparencyMode = {4}", position, u, v, transparencyMode));
2303
                return false;
2304
            }
2305
            public override bool Mesh(int rows, int columns, Point3dCollection points, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals)
2306
            {
2307
                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));
2308
                return false;
2309
            }
2310
            public override bool Polygon(Point3dCollection points)
2311
            {
2312
                writeLine(indent, string.Format("WorldGeometry.Polygon(points = {0})", points));
2313
                return false;
2314
            }
2315
            public override bool Polyline(Teigha.DatabaseServices.Polyline value, int fromIndex, int segments)
2316
            {
2317
                writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}, fromIndex = {1}, segments = {2})", value, fromIndex, segments));
2318
                return false;
2319
            }
2320
            public override bool Polyline(Point3dCollection points, Vector3d normal, IntPtr subEntityMarker)
2321
            {
2322
                writeLine(indent, string.Format("WorldGeometry.Polyline(points = {0}, normal = {1}, subEntityMarker = {2})", points, normal, subEntityMarker));
2323
                return false;
2324
            }
2325
            public override void PopClipBoundary()
2326
            {
2327
                writeLine(indent, string.Format("WorldGeometry.PopClipBoundary"));
2328
                clips.Pop();
2329
            }
2330
            public override bool PopModelTransform()
2331
            {
2332
                return true;
2333
            }
2334
            public override bool PushClipBoundary(ClipBoundary boundary)
2335
            {
2336
                writeLine(indent, string.Format("WorldGeometry.PushClipBoundary"));
2337
                clips.Push(boundary);
2338
                return true;
2339
            }
2340
            public override bool PushModelTransform(Matrix3d matrix)
2341
            {
2342
                writeLine(indent, "WorldGeometry.PushModelTransform(Matrix3d)");
2343
                Matrix3d m = modelMatrix.Peek();
2344
                modelMatrix.Push(m * matrix);
2345
                return true;
2346
            }
2347
            public override bool PushModelTransform(Vector3d normal)
2348
            {
2349
                writeLine(indent, "WorldGeometry.PushModelTransform(Vector3d)");
2350
                PushModelTransform(Matrix3d.PlaneToWorld(normal));
2351
                return true;
2352
            }
2353
            public override bool RowOfDots(int count, Point3d start, Vector3d step)
2354
            {
2355
                writeLine(indent, string.Format("ViewportGeometry.RowOfDots(count = {0}, start = {1}, step = {1})", count, start, step));
2356
                return false;
2357
            }
2358
            public override bool Ray(Point3d point1, Point3d point2)
2359
            {
2360
                writeLine(indent, string.Format("WorldGeometry.Ray(point1 = {0}, point2 = {1})", point1, point2));
2361
                return false;
2362
            }
2363
            public override bool Shell(Point3dCollection points, IntegerCollection faces, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals)
2364
            {
2365
                writeLine(indent, string.Format("WorldGeometry.Shell(points = {0}, faces = {1}, edgeData = {2}, faceData = {3}, vertexData = {4}, bAutoGenerateNormals = {5})", points, faces, edgeData, faceData, vertexData, bAutoGenerateNormals));
2366
                return false;
2367
            }
2368
            public override bool Text(Point3d position, Vector3d normal, Vector3d direction, string message, bool raw, TextStyle textStyle)
2369
            {
2370
                writeLine(indent, string.Format("WorldGeometry.Text(position = {0}, normal = {1}, direction = {2}, message = {3}, raw = {4}, textStyle = {5})", position, normal, direction, message, raw, textStyle));
2371
                return false;
2372
            }
2373
            public override bool Text(Point3d position, Vector3d normal, Vector3d direction, double height, double width, double oblique, string message)
2374
            {
2375
                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));
2376
                return false;
2377
            }
2378
            public override bool WorldLine(Point3d startPoint, Point3d endPoint)
2379
            {
2380
                writeLine(indent, string.Format("WorldGeometry.WorldLine(startPoint = {0}, endPoint = {1})", startPoint, endPoint));
2381
                return false;
2382
            }
2383
            public override bool Xline(Point3d point1, Point3d point2)
2384
            {
2385
                writeLine(indent, string.Format("WorldGeometry.Xline(point1 = {0}, point2 = {1})", point1, point2));
2386
                return false;
2387
            }
2388

    
2389
            public override void SetExtents(Extents3d extents)
2390
            {
2391
                writeLine(indent, "WorldGeometry.SetExtents({0}) ", extents);
2392
            }
2393
            public override void StartAttributesSegment()
2394
            {
2395
                writeLine(indent, "WorldGeometry.StartAttributesSegment called");
2396
            }
2397
        }
2398

    
2399
        class WorldDrawDumper : WorldDraw
2400
        {
2401
            WorldGeometryDumper _geom;
2402
            DrawContextDumper _ctx;
2403
            SubEntityTraits _subents;
2404
            RegenType _regenType;
2405
            int indent;
2406
            public WorldDrawDumper(Database db, int indent)
2407
              : base()
2408
            {
2409
                _regenType = RegenType;
2410
                this.indent = indent;
2411
                _geom = new WorldGeometryDumper(indent);
2412
                _ctx = new DrawContextDumper(db);
2413
                _subents = new SubEntityTraitsDumper(db);
2414
            }
2415
            public override double Deviation(DeviationType deviationType, Point3d pointOnCurve)
2416
            {
2417
                return 1e-9;
2418
            }
2419
            public override WorldGeometry Geometry
2420
            {
2421
                get
2422
                {
2423
                    return _geom;
2424
                }
2425
            }
2426
            public override bool IsDragging
2427
            {
2428
                get
2429
                {
2430
                    return false;
2431
                }
2432
            }
2433
            public override Int32 NumberOfIsolines
2434
            {
2435
                get
2436
                {
2437
                    return 10;
2438
                }
2439
            }
2440
            public override Geometry RawGeometry
2441
            {
2442
                get
2443
                {
2444
                    return _geom;
2445
                }
2446
            }
2447
            public override bool RegenAbort
2448
            {
2449
                get
2450
                {
2451
                    return false;
2452
                }
2453
            }
2454
            public override RegenType RegenType
2455
            {
2456
                get
2457
                {
2458
                    writeLine(indent, "RegenType is asked");
2459
                    return _regenType;
2460
                }
2461
            }
2462
            public override SubEntityTraits SubEntityTraits
2463
            {
2464
                get
2465
                {
2466
                    return _subents;
2467
                }
2468
            }
2469
            public override Context Context
2470
            {
2471
                get
2472
                {
2473
                    return _ctx;
2474
                }
2475
            }
2476
        }
2477

    
2478
        /************************************************************************/
2479
        /* Dump the common data and WorldDraw information for all               */
2480
        /* entities without explicit dumpers                                    */
2481
        /************************************************************************/
2482
        XmlNode dump(Entity pEnt, int indent, XmlNode node)
2483
        {
2484
            if (node != null)
2485
            {
2486
                XmlElement EntNode = Program.xml.CreateElement(pEnt.GetRXClass().Name);
2487

    
2488
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2489
                HandleAttr.Value = pEnt.Handle.ToString();
2490
                EntNode.Attributes.SetNamedItem(HandleAttr);
2491

    
2492
                dumpEntityData(pEnt, indent, EntNode);
2493
                using (Database db = pEnt.Database)
2494
                {
2495
                    /**********************************************************************/
2496
                    /* Create an OdGiWorldDraw instance for the vectorization             */
2497
                    /**********************************************************************/
2498
                    WorldDrawDumper wd = new WorldDrawDumper(db, indent + 1);
2499
                    /**********************************************************************/
2500
                    /* Call worldDraw()                                                   */
2501
                    /**********************************************************************/
2502
                    pEnt.WorldDraw(wd);
2503
                }
2504

    
2505
                node.AppendChild(EntNode);
2506

    
2507
                return EntNode;
2508
            }
2509

    
2510
            return null;
2511
        }
2512

    
2513
        /************************************************************************/
2514
        /* Proxy Entity Dumper                                                  */
2515
        /************************************************************************/
2516
        XmlNode dump(ProxyEntity pProxy, int indent, XmlNode node)
2517
        {
2518
            if (node != null)
2519
            {
2520
                XmlElement ProxyNode = Program.xml.CreateElement(pProxy.GetRXClass().Name);
2521

    
2522
                XmlAttribute OriginalClassNameAttr = Program.xml.CreateAttribute("OriginalClassName");
2523
                OriginalClassNameAttr.Value = pProxy.OriginalClassName.ToString();
2524
                ProxyNode.Attributes.SetNamedItem(OriginalClassNameAttr);
2525

    
2526
                // this will dump proxy entity graphics
2527
                dump((Entity)pProxy, indent, node);
2528

    
2529
                DBObjectCollection collection = new DBObjectCollection(); ;
2530
                try
2531
                {
2532
                    pProxy.ExplodeGeometry(collection);
2533
                }
2534
                catch (System.Exception)
2535
                {
2536
                    return null;
2537
                }
2538

    
2539
                foreach (Entity ent in collection)
2540
                {
2541
                    if (ent is Polyline2d)
2542
                    {
2543
                        Polyline2d pline2d = (Polyline2d)ent;
2544
                        int i = 0;
2545

    
2546
                        try
2547
                        {
2548
                            foreach (Entity ent1 in pline2d)
2549
                            {
2550
                                if (ent1 is Vertex2d)
2551
                                {
2552
                                    Vertex2d vtx2d = (Vertex2d)ent1;
2553
                                    dump2dVertex(indent, vtx2d, i++, ProxyNode);
2554
                                }
2555
                            }
2556
                        }
2557
                        catch (System.Exception)
2558
                        {
2559
                            return null;
2560
                        }
2561
                    }
2562
                }
2563

    
2564
                node.AppendChild(ProxyNode);
2565
                return ProxyNode;
2566
            }
2567

    
2568
            return null;
2569
        }
2570

    
2571
        /************************************************************************/
2572
        /* Radial Dimension Dumper                                              */
2573
        /************************************************************************/
2574
        XmlNode dump(RadialDimension pDim, int indent, XmlNode node)
2575
        {
2576
            if (node != null)
2577
            {
2578
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
2579

    
2580
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2581
                HandleAttr.Value = pDim.Handle.ToString();
2582
                DimNode.Attributes.SetNamedItem(HandleAttr);
2583

    
2584
                XmlAttribute CenterAttr = Program.xml.CreateAttribute("Center");
2585
                CenterAttr.Value = pDim.Center.ToString();
2586
                DimNode.Attributes.SetNamedItem(CenterAttr);
2587

    
2588
                XmlAttribute ChordPointAttr = Program.xml.CreateAttribute("ChordPoint");
2589
                ChordPointAttr.Value = pDim.ChordPoint.ToString();
2590
                DimNode.Attributes.SetNamedItem(ChordPointAttr);
2591

    
2592
                XmlAttribute LeaderLengthAttr = Program.xml.CreateAttribute("LeaderLength");
2593
                LeaderLengthAttr.Value = pDim.LeaderLength.ToString();
2594
                DimNode.Attributes.SetNamedItem(LeaderLengthAttr);
2595

    
2596
                dumpDimData(pDim, indent, DimNode);
2597

    
2598
                node.AppendChild(DimNode);
2599

    
2600
                return DimNode;
2601
            }
2602

    
2603
            return null;
2604
        }
2605

    
2606
        /************************************************************************/
2607
        /* Dump Raster Image Def                                               */
2608
        /************************************************************************/
2609
        void dumpRasterImageDef(ObjectId id, int indent)
2610
        {
2611
            if (!id.IsValid)
2612
                return;
2613
            using (RasterImageDef pDef = (RasterImageDef)id.Open(OpenMode.ForRead))
2614
            {
2615
                writeLine(indent++, pDef.GetRXClass().Name, pDef.Handle);
2616
                writeLine(indent, "Source Filename", shortenPath(pDef.SourceFileName));
2617
                writeLine(indent, "Loaded", pDef.IsLoaded);
2618
                writeLine(indent, "mm per Pixel", pDef.ResolutionMMPerPixel);
2619
                writeLine(indent, "Loaded", pDef.IsLoaded);
2620
                writeLine(indent, "Resolution Units", pDef.ResolutionUnits);
2621
                writeLine(indent, "Size", pDef.Size);
2622
            }
2623
        }
2624
        /************************************************************************/
2625
        /* Dump Raster Image Data                                               */
2626
        /************************************************************************/
2627
        void dumpRasterImageData(RasterImage pImage, int indent)
2628
        {
2629
            writeLine(indent, "Brightness", pImage.Brightness);
2630
            writeLine(indent, "Clipped", pImage.IsClipped);
2631
            writeLine(indent, "Contrast", pImage.Contrast);
2632
            writeLine(indent, "Fade", pImage.Fade);
2633
            writeLine(indent, "kClip", pImage.DisplayOptions & ImageDisplayOptions.Clip);
2634
            writeLine(indent, "kShow", pImage.DisplayOptions & ImageDisplayOptions.Show);
2635
            writeLine(indent, "kShowUnAligned", pImage.DisplayOptions & ImageDisplayOptions.ShowUnaligned);
2636
            writeLine(indent, "kTransparent", pImage.DisplayOptions & ImageDisplayOptions.Transparent);
2637
            writeLine(indent, "Scale", pImage.Scale);
2638

    
2639
            /********************************************************************/
2640
            /* Dump clip boundary                                               */
2641
            /********************************************************************/
2642
            if (pImage.IsClipped)
2643
            {
2644
                writeLine(indent, "Clip Boundary Type", pImage.ClipBoundaryType);
2645
                if (pImage.ClipBoundaryType != ClipBoundaryType.Invalid)
2646
                {
2647
                    Point2dCollection pt = pImage.GetClipBoundary();
2648
                    for (int i = 0; i < pt.Count; i++)
2649
                    {
2650
                        writeLine(indent, string.Format("Clip Point {0}", i), pt[i]);
2651
                    }
2652
                }
2653
            }
2654

    
2655
            /********************************************************************/
2656
            /* Dump frame                                                       */
2657
            /********************************************************************/
2658
            Point3dCollection vertices = pImage.GetVertices();
2659
            for (int i = 0; i < vertices.Count; i++)
2660
            {
2661
                writeLine(indent, "Frame Vertex " + i.ToString(), vertices[i]);
2662
            }
2663

    
2664
            /********************************************************************/
2665
            /* Dump orientation                                                 */
2666
            /********************************************************************/
2667
            writeLine(indent, "Orientation");
2668
            writeLine(indent + 1, "Origin", pImage.Orientation.Origin);
2669
            writeLine(indent + 1, "uVector", pImage.Orientation.Xaxis);
2670
            writeLine(indent + 1, "vVector", pImage.Orientation.Yaxis);
2671
            dumpRasterImageDef(pImage.ImageDefId, indent);
2672
            dumpEntityData(pImage, indent, Program.xml.DocumentElement);
2673
        }
2674

    
2675
        /************************************************************************/
2676
        /* Raster Image Dumper                                                  */
2677
        /************************************************************************/
2678
        void dump(RasterImage pImage, int indent)
2679
        {
2680
            writeLine(indent++, pImage.GetRXClass().Name, pImage.Handle);
2681
            writeLine(indent, "Image size", pImage.ImageSize(true));
2682
            dumpRasterImageData(pImage, indent);
2683
        }
2684

    
2685
        /************************************************************************/
2686
        /* Ray Dumper                                                          */
2687
        /************************************************************************/
2688
        void dump(Ray pRay, int indent)
2689
        {
2690
            writeLine(indent++, pRay.GetRXClass().Name, pRay.Handle);
2691
            writeLine(indent, "Base Point", pRay.BasePoint);
2692
            writeLine(indent, "Unit Direction", pRay.UnitDir);
2693
            dumpCurveData(pRay, indent, Program.xml.DocumentElement);
2694
        }
2695

    
2696
        /************************************************************************/
2697
        /* Region Dumper                                                        */
2698
        /************************************************************************/
2699
        void dump(Region pRegion, int indent)
2700
        {
2701
            writeLine(indent++, pRegion.GetRXClass().Name, pRegion.Handle);
2702
            dumpEntityData(pRegion, indent, Program.xml.DocumentElement);
2703
        }
2704

    
2705
        /************************************************************************/
2706
        /* Rotated Dimension Dumper                                             */
2707
        /************************************************************************/
2708
        XmlNode dump(RotatedDimension pDim, int indent, XmlNode node)
2709
        {
2710
            if (node != null)
2711
            {
2712
                XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name);
2713

    
2714
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2715
                HandleAttr.Value = pDim.Handle.ToString();
2716
                DimNode.Attributes.SetNamedItem(HandleAttr);
2717

    
2718
                XmlAttribute DimLinePointAttr = Program.xml.CreateAttribute("DimLinePoint");
2719
                DimLinePointAttr.Value = pDim.DimLinePoint.ToString();
2720
                DimNode.Attributes.SetNamedItem(DimLinePointAttr);
2721

    
2722
                XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique");
2723
                ObliqueAttr.Value = pDim.Oblique.ToString();
2724
                DimNode.Attributes.SetNamedItem(ObliqueAttr);
2725

    
2726
                XmlAttribute RotationAttr = Program.xml.CreateAttribute("Rotation");
2727
                RotationAttr.Value = pDim.Rotation.ToString();
2728
                DimNode.Attributes.SetNamedItem(RotationAttr);
2729

    
2730
                XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point");
2731
                XLine1PointAttr.Value = pDim.XLine1Point.ToString();
2732
                DimNode.Attributes.SetNamedItem(XLine1PointAttr);
2733

    
2734
                XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point");
2735
                XLine2PointAttr.Value = pDim.XLine2Point.ToString();
2736
                DimNode.Attributes.SetNamedItem(XLine2PointAttr);
2737

    
2738
                dumpDimData(pDim, indent, DimNode);
2739
                node.AppendChild(DimNode);
2740

    
2741
                return DimNode;
2742
            }
2743

    
2744
            return null;
2745
        }
2746

    
2747
        /************************************************************************/
2748
        /* Shape Dumper                                                          */
2749
        /************************************************************************/
2750
        void dump(Shape pShape, int indent)
2751
        {
2752
            writeLine(indent++, pShape.GetRXClass().Name, pShape.Handle);
2753

    
2754
            if (!pShape.StyleId.IsNull)
2755
            {
2756
                using (TextStyleTableRecord pStyle = (TextStyleTableRecord)pShape.StyleId.Open(OpenMode.ForRead))
2757
                    writeLine(indent, "Filename", shortenPath(pStyle.FileName));
2758
            }
2759

    
2760
            writeLine(indent, "Shape Number", pShape.ShapeNumber);
2761
            writeLine(indent, "Shape Name", pShape.Name);
2762
            writeLine(indent, "Position", pShape.Position);
2763
            writeLine(indent, "Size", pShape.Size);
2764
            writeLine(indent, "Rotation", toDegreeString(pShape.Rotation));
2765
            writeLine(indent, "Oblique", toDegreeString(pShape.Oblique));
2766
            writeLine(indent, "Normal", pShape.Normal);
2767
            writeLine(indent, "Thickness", pShape.Thickness);
2768
            dumpEntityData(pShape, indent, Program.xml.DocumentElement);
2769
        }
2770

    
2771
        /************************************************************************/
2772
        /* Solid Dumper                                                         */
2773
        /************************************************************************/
2774
        // TODO:
2775
        /*  void dump(Solid pSolid, int indent)
2776
      {
2777
        writeLine(indent++, pSolid.GetRXClass().Name, pSolid.Handle);
2778

    
2779
        for (int i = 0; i < 4; i++)
2780
        {
2781
          writeLine(indent, "Point " + i.ToString(),  pSolid .GetPointAt(i));
2782
        }
2783
        dumpEntityData(pSolid, indent);
2784
      }
2785
    */
2786
        /************************************************************************/
2787
        /* Spline Dumper                                                        */
2788
        /************************************************************************/
2789
        void dump(Spline pSpline, int indent)
2790
        {
2791
            writeLine(indent++, pSpline.GetRXClass().Name, pSpline.Handle);
2792

    
2793
            NurbsData data = pSpline.NurbsData;
2794
            writeLine(indent, "Degree", data.Degree);
2795
            writeLine(indent, "Rational", data.Rational);
2796
            writeLine(indent, "Periodic", data.Periodic);
2797
            writeLine(indent, "Control Point Tolerance", data.ControlPointTolerance);
2798
            writeLine(indent, "Knot Tolerance", data.KnotTolerance);
2799

    
2800
            writeLine(indent, "Number of control points", data.GetControlPoints().Count);
2801
            for (int i = 0; i < data.GetControlPoints().Count; i++)
2802
            {
2803
                writeLine(indent, "Control Point " + i.ToString(), data.GetControlPoints()[i]);
2804
            }
2805

    
2806
            writeLine(indent, "Number of Knots", data.GetKnots().Count);
2807
            for (int i = 0; i < data.GetKnots().Count; i++)
2808
            {
2809
                writeLine(indent, "Knot " + i.ToString(), data.GetKnots()[i]);
2810
            }
2811

    
2812
            if (data.Rational)
2813
            {
2814
                writeLine(indent, "Number of Weights", data.GetWeights().Count);
2815
                for (int i = 0; i < data.GetWeights().Count; i++)
2816
                {
2817
                    writeLine(indent, "Weight " + i.ToString(), data.GetWeights()[i]);
2818
                }
2819
            }
2820
            dumpCurveData(pSpline, indent, Program.xml.DocumentElement);
2821
        }
2822
        /************************************************************************/
2823
        /* Table Dumper                                                         */
2824
        /************************************************************************/
2825
        void dump(Table pTable, int indent)
2826
        {
2827
            writeLine(indent++, pTable.GetRXClass().Name, pTable.Handle);
2828
            writeLine(indent, "Position", pTable.Position);
2829
            writeLine(indent, "X-Direction", pTable.Direction);
2830
            writeLine(indent, "Normal", pTable.Normal);
2831
            writeLine(indent, "Height", (int)pTable.Height);
2832
            writeLine(indent, "Width", (int)pTable.Width);
2833
            writeLine(indent, "Rows", (int)pTable.NumRows);
2834
            writeLine(indent, "Columns", (int)pTable.NumColumns);
2835

    
2836
            // TODO:
2837
            //TableStyle pStyle = (TableStyle)pTable.TableStyle.Open(OpenMode.ForRead);
2838
            //writeLine(indent, "Table Style",               pStyle.Name);
2839
            dumpEntityData(pTable, indent, Program.xml.DocumentElement);
2840
        }
2841

    
2842
        /************************************************************************/
2843
        /* Text Dumper                                                          */
2844
        /************************************************************************/
2845
        static void dump(DBText pText, int indent, XmlNode node)
2846
        {
2847
            if (node != null)
2848
            {
2849
                dumpTextData(pText, indent, node);
2850
            }
2851
        }
2852
        /************************************************************************/
2853
        /* Trace Dumper                                                         */
2854
        /************************************************************************/
2855
        void dump(Trace pTrace, int indent)
2856
        {
2857
            writeLine(indent++, pTrace.GetRXClass().Name, pTrace.Handle);
2858

    
2859
            for (short i = 0; i < 4; i++)
2860
            {
2861
                writeLine(indent, "Point " + i.ToString(), pTrace.GetPointAt(i));
2862
            }
2863
            dumpEntityData(pTrace, indent, Program.xml.DocumentElement);
2864
        }
2865

    
2866
        /************************************************************************/
2867
        /* Trace UnderlayReference                                                         */
2868
        /************************************************************************/
2869
        void dump(UnderlayReference pEnt, int indent)
2870
        {
2871
            writeLine(indent++, pEnt.GetRXClass().Name, pEnt.Handle);
2872
            writeLine(indent, "UnderlayReference Path ", pEnt.Path);
2873
            writeLine(indent, "UnderlayReference Position ", pEnt.Position);
2874
        }
2875

    
2876
        /************************************************************************/
2877
        /* Viewport Dumper                                                       */
2878
        /************************************************************************/
2879
        XmlNode dump(Teigha.DatabaseServices.Viewport pVport, int indent, XmlNode node)
2880
        {
2881
            if (node != null)
2882
            {
2883
                XmlElement VportNode = Program.xml.CreateElement(pVport.GetRXClass().Name);
2884

    
2885
                XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle");
2886
                HandleAttr.Value = pVport.Handle.ToString();
2887
                VportNode.Attributes.SetNamedItem(HandleAttr);
2888

    
2889
                writeLine(indent, "Back Clip Distance", pVport.BackClipDistance);
2890
                writeLine(indent, "Back Clip On", pVport.BackClipOn);
2891
                writeLine(indent, "Center Point", pVport.CenterPoint);
2892
                writeLine(indent, "Circle sides", pVport.CircleSides);
2893
                writeLine(indent, "Custom Scale", pVport.CustomScale);
2894
                writeLine(indent, "Elevation", pVport.Elevation);
2895
                writeLine(indent, "Front Clip at Eye", pVport.FrontClipAtEyeOn);
2896
                writeLine(indent, "Front Clip Distance", pVport.FrontClipDistance);
2897
                writeLine(indent, "Front Clip On", pVport.FrontClipOn);
2898
                writeLine(indent, "Plot style sheet", pVport.EffectivePlotStyleSheet);
2899

    
2900
                ObjectIdCollection layerIds = pVport.GetFrozenLayers();
2901
                if (layerIds.Count > 0)
2902
                {
2903
                    writeLine(indent, "Frozen Layers:");
2904
                    for (int i = 0; i < layerIds.Count; i++)
2905
                    {
2906
                        writeLine(indent + 1, i, layerIds[i]);
2907
                    }
2908
                }
2909
                else
2910
                {
2911
                    writeLine(indent, "Frozen Layers", "None");
2912
                }
2913

    
2914
                Point3d origin = new Point3d();
2915
                Vector3d xAxis = new Vector3d();
2916
                Vector3d yAxis = new Vector3d();
2917
                pVport.GetUcs(ref origin, ref xAxis, ref yAxis);
2918
                writeLine(indent, "UCS origin", origin);
2919
                writeLine(indent, "UCS x-Axis", xAxis);
2920
                writeLine(indent, "UCS y-Axis", yAxis);
2921
                writeLine(indent, "Grid Increment", pVport.GridIncrement);
2922
                writeLine(indent, "Grid On", pVport.GridOn);
2923
                writeLine(indent, "Height", pVport.Height);
2924
                writeLine(indent, "Lens Length", pVport.LensLength);
2925
                writeLine(indent, "Locked", pVport.Locked);
2926
                writeLine(indent, "Non-Rectangular Clip", pVport.NonRectClipOn);
2927

    
2928
                if (!pVport.NonRectClipEntityId.IsNull)
2929
                {
2930
                    writeLine(indent, "Non-rectangular Clipper", pVport.NonRectClipEntityId.Handle);
2931
                }
2932
                writeLine(indent, "Render Mode", pVport.RenderMode);
2933
                writeLine(indent, "Remove Hidden Lines", pVport.HiddenLinesRemoved);
2934
                writeLine(indent, "Shade Plot", pVport.ShadePlot);
2935
                writeLine(indent, "Snap Isometric", pVport.SnapIsometric);
2936
                writeLine(indent, "Snap On", pVport.SnapOn);
2937
                writeLine(indent, "Transparent", pVport.Transparent);
2938
                writeLine(indent, "UCS Follow", pVport.UcsFollowModeOn);
2939
                writeLine(indent, "UCS Icon at Origin", pVport.UcsIconAtOrigin);
2940

    
2941
                writeLine(indent, "UCS Orthographic", pVport.UcsOrthographic);
2942
                writeLine(indent, "UCS Saved with VP", pVport.UcsPerViewport);
2943

    
2944
                if (!pVport.UcsName.IsNull)
2945
                {
2946
                    using (UcsTableRecord pUCS = (UcsTableRecord)pVport.UcsName.Open(OpenMode.ForRead))
2947
                        writeLine(indent, "UCS Name", pUCS.Name);
2948
                }
2949
                else
2950
                {
2951
                    writeLine(indent, "UCS Name", "Null");
2952
                }
2953

    
2954
                writeLine(indent, "View Center", pVport.ViewCenter);
2955
                writeLine(indent, "View Height", pVport.ViewHeight);
2956
                writeLine(indent, "View Target", pVport.ViewTarget);
2957
                writeLine(indent, "Width", pVport.Width);
2958
                dumpEntityData(pVport, indent, Program.xml.DocumentElement);
2959

    
2960
                {
2961
                    using (DBObjectCollection collection = new DBObjectCollection())
2962
                    {
2963
                        try
2964
                        {
2965
                            pVport.ExplodeGeometry(collection);
2966

    
2967
                            foreach (Entity ent in collection)
2968
                            {
2969
                                if (ent is Polyline2d)
2970
                                {
2971
                                    Polyline2d pline2d = (Polyline2d)ent;
2972
                                    int i = 0;
2973
                                    foreach (Entity ent1 in pline2d)
2974
                                    {
2975
                                        if (ent1 is Vertex2d)
2976
                                        {
2977
                                            Vertex2d vtx2d = (Vertex2d)ent1;
2978
                                            dump2dVertex(indent, vtx2d, i++, VportNode);
2979
                                        }
2980
                                    }
2981
                                }
2982
                            }
2983
                        }
2984
                        catch (System.Exception)
2985
                        {
2986
                        }
2987
                    }
2988
                }
2989

    
2990
                node.AppendChild(VportNode);
2991
                return VportNode;
2992
            }
2993

    
2994
            return null;
2995
        }
2996

    
2997
        /************************************************************************/
2998
        /* Wipeout Dumper                                                  */
2999
        /************************************************************************/
3000
        void dump(Wipeout pWipeout, int indent)
3001
        {
3002
            writeLine(indent++, pWipeout.GetRXClass().Name, pWipeout.Handle);
3003
            dumpRasterImageData(pWipeout, indent);
3004
        }
3005

    
3006
        /************************************************************************/
3007
        /* Xline Dumper                                                         */
3008
        /************************************************************************/
3009
        void dump(Xline pXline, int indent)
3010
        {
3011
            writeLine(indent++, pXline.GetRXClass().Name, pXline.Handle);
3012
            writeLine(indent, "Base Point", pXline.BasePoint);
3013
            writeLine(indent, "Unit Direction", pXline.UnitDir);
3014
            dumpCurveData(pXline, indent, Program.xml.DocumentElement);
3015
        }
3016

    
3017
        public void dump(Database pDb, int indent, XmlNode node)
3018
        {
3019
            using (BlockTableRecord btr = (BlockTableRecord)pDb.CurrentSpaceId.GetObject(OpenMode.ForRead))
3020
            {
3021
                using (Layout pLayout = (Layout)btr.LayoutId.GetObject(OpenMode.ForRead))
3022
                {
3023
                    string layoutName = "";
3024
                    layoutName = pLayout.LayoutName;
3025

    
3026
                    XmlAttribute LayoutNameAttr = Program.xml.CreateAttribute("LayoutName");
3027
                    LayoutNameAttr.Value = layoutName;
3028
                    node.Attributes.SetNamedItem(LayoutNameAttr);
3029
                }
3030
            }
3031

    
3032
            dumpHeader(pDb, indent, node);
3033
            dumpLayers(pDb, indent, node);
3034
            dumpLinetypes(pDb, indent, node);
3035
            dumpTextStyles(pDb, indent, node);
3036
            dumpDimStyles(pDb, indent, node);
3037
            dumpRegApps(pDb, indent);
3038
            dumpViewports(pDb, indent, node);
3039
            dumpViews(pDb, indent, node);
3040
            dumpMLineStyles(pDb, indent);
3041
            dumpUCSTable(pDb, indent, node);
3042
            dumpObject(pDb.NamedObjectsDictionaryId, "Named Objects Dictionary", indent);
3043

    
3044
            dumpBlocks(pDb, indent, node);
3045
        }
3046

    
3047
        /************************************************************************/
3048
        /* Export DWG to PDF                                                    */
3049
        /************************************************************************/
3050
        public void ExportPDF(Database pDb, string filePath)
3051
        {
3052
            DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(filePath));
3053
            string dirPath = di.Parent != null ? di.Parent.FullName : di.FullName;
3054
            string pdfPath = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(filePath) + ".pdf");
3055

    
3056
            using (mPDFExportParams param = new mPDFExportParams())
3057
            {
3058
                param.Database = pDb;
3059

    
3060
                TransactionManager tm = pDb.TransactionManager;
3061
                using (Transaction ta = tm.StartTransaction())
3062
                {
3063
                    using (FileStreamBuf fileStrem = new FileStreamBuf(pdfPath, false, FileShareMode.DenyNo, FileCreationDisposition.CreateAlways))
3064
                    {
3065
                        param.OutputStream = fileStrem;
3066

    
3067
                        bool embededTTF = false;
3068
                        bool shxTextAsGeometry = true;
3069
                        bool ttfGeometry = true;
3070
                        bool simpleGeomOptimization = false;
3071
                        bool zoomToExtentsMode = true;
3072
                        bool enableLayers = false;
3073
                        bool includeOffLayers = false;
3074
                        bool enablePrcMode = true;
3075
                        bool monochrome = true;
3076
                        bool allLayout = false;
3077
                        double paperWidth = 841;
3078
                        double paperHeight = 594;
3079

    
3080
                        param.Flags = (embededTTF ? PDFExportFlags.EmbededTTF : 0) |
3081
                                      (shxTextAsGeometry ? PDFExportFlags.SHXTextAsGeometry : 0) |
3082
                                      (ttfGeometry ? PDFExportFlags.TTFTextAsGeometry : 0) |
3083
                                      (simpleGeomOptimization ? PDFExportFlags.SimpleGeomOptimization : 0) |
3084
                                      (zoomToExtentsMode ? PDFExportFlags.ZoomToExtentsMode : 0) |
3085
                                      (enableLayers ? PDFExportFlags.EnableLayers : 0) |
3086
                                      (includeOffLayers ? PDFExportFlags.IncludeOffLayers : 0);
3087

    
3088
                        param.Title = "";
3089
                        param.Author = "";
3090
                        param.Subject = "";
3091
                        param.Keywords = "";
3092
                        param.Creator = "";
3093
                        param.Producer = "";
3094
                        param.UseHLR = !enablePrcMode;
3095
                        param.FlateCompression = true;
3096
                        param.ASCIIHEXEncodeStream = true;
3097
                        param.hatchDPI = 720;
3098

    
3099
                        bool bV15 = enableLayers || includeOffLayers;
3100
                        param.Versions = bV15 ? PDFExportVersions.PDFv1_5 : PDFExportVersions.PDFv1_4;
3101

    
3102
                        if (enablePrcMode)
3103
                        {
3104
                            Module pModule = SystemObjects.DynamicLinker.LoadApp("OdPrcModule", false, false);
3105
                            if (pModule != null)
3106
                            {
3107
                                pModule = SystemObjects.DynamicLinker.LoadApp("OdPrcExport", false, false);
3108
                            }
3109
                            if (pModule != null)
3110
                            {
3111
                                RXObject pObj = null;
3112
                                bool bUsePRCSingleViewMode = true; // provide a corresponding checkbox in Export to PDF dialog similar to one in OdaMfcApp
3113
                                if (bUsePRCSingleViewMode)
3114
                                {
3115
                                    pObj = SystemObjects.ClassDictionary.At("OdPrcContextForPdfExport_AllInSingleView");
3116
                                }
3117
                                else
3118
                                {
3119
                                    pObj = SystemObjects.ClassDictionary.At("OdPrcContextForPdfExport_Default");
3120
                                }
3121
                                if (pObj != null)
3122
                                {
3123
                                    RXClass pCls = (RXClass)pObj;
3124
                                    if (pCls != null)
3125
                                    {
3126
                                        param.PRCContext = pCls.Create();
3127
                                        param.PRCMode = PRCSupport.AsBrep; //(bUsePRCAsBRep == TRUE ? PRCSupport.AsBrep : PRCSupport.AsMesh);
3128
                                    }
3129
                                    else
3130
                                    {
3131
                                        Console.WriteLine("PDF Export, PRC support - RXClass failed");
3132
                                    }
3133
                                }
3134
                                else
3135
                                {
3136
                                    Console.WriteLine("PDF Export, PRC support - context failed");
3137
                                }
3138
                            }
3139
                            else
3140
                            {
3141
                                Console.WriteLine("PRC module was not loaded", "Error");
3142
                            }
3143
                        }
3144

    
3145
                        PlotSettingsValidator plotSettingVal = PlotSettingsValidator.Current;
3146

    
3147
                        StringCollection styleCol = plotSettingVal.GetPlotStyleSheetList();
3148
                        int iIndexStyle = monochrome ? styleCol.IndexOf(String.Format("monochrome.ctb")) : -1;
3149

    
3150
                        StringCollection strColl = new StringCollection();
3151
                        if (allLayout)
3152
                        {
3153
                            using (DBDictionary layouts = (DBDictionary)pDb.LayoutDictionaryId.GetObject(OpenMode.ForRead))
3154
                            {
3155
                                foreach (DBDictionaryEntry entry in layouts)
3156
                                {
3157
                                    if ("Model" == entry.Key)
3158
                                        strColl.Insert(0, entry.Key);
3159
                                    else
3160
                                        strColl.Add(entry.Key);
3161
                                    if (-1 != iIndexStyle)
3162
                                    {
3163
                                        PlotSettings ps = (PlotSettings)ta.GetObject(entry.Value, OpenMode.ForWrite);
3164
                                        plotSettingVal.SetCurrentStyleSheet(ps, styleCol[iIndexStyle]);
3165
                                    }
3166
                                }
3167
                            }
3168
                        }
3169
                        else if (-1 != iIndexStyle)
3170
                        {
3171
                            using (BlockTableRecord paperBTR = (BlockTableRecord)pDb.CurrentSpaceId.GetObject(OpenMode.ForRead))
3172
                            {
3173
                                using (PlotSettings pLayout = (PlotSettings)paperBTR.LayoutId.GetObject(OpenMode.ForWrite))
3174
                                {
3175
                                    plotSettingVal.SetCurrentStyleSheet(pLayout, styleCol[iIndexStyle]);
3176
                                }
3177
                            }
3178
                        }
3179
                        param.Layouts = strColl;
3180

    
3181
                        int nPages = Math.Max(1, strColl.Count);
3182
                        PageParamsCollection pParCol = new PageParamsCollection();
3183
                        for (int i = 0; i < nPages; ++i)
3184
                        {
3185
                            PageParams pp = new PageParams();
3186
                            pp.setParams(paperWidth, paperHeight);
3187
                            pParCol.Add(pp);
3188
                        }
3189
                        param.PageParams = pParCol;
3190
                        Export_Import.ExportPDF(param);
3191
                    }
3192
                    ta.Abort();
3193
                }
3194
            }
3195
        }
3196

    
3197
        /************************************************************************/
3198
        /* Export DWG to PNG                                                    */
3199
        /************************************************************************/
3200
        public void ExportPNG(Database pDb, string filePath)
3201
        {
3202
            chageColorAllObjects(pDb);
3203

    
3204
            string gdPath = "WinOpenGL_20.5_15.txv";
3205

    
3206
            DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(filePath));
3207
            string dirPath = di.Parent != null ? di.Parent.FullName : di.FullName;
3208
            string bmpPath = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(filePath) + ".bmp");
3209
            string pngPath = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(filePath) + ".png");
3210

    
3211
            using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule(gdPath, false, true))
3212
            {
3213
                if (gsModule == null)
3214
                {
3215
                    Console.WriteLine("\nCould not load graphics module {0} \nExport cancelled.", gdPath);
3216
                    return;
3217
                }
3218

    
3219
                // create graphics device
3220
                using (Teigha.GraphicsSystem.Device dev = gsModule.CreateBitmapDevice())
3221
                {
3222
                    // setup device properties
3223
                    using (Dictionary props = dev.Properties)
3224
                    {
3225
                        props.AtPut("BitPerPixel", new RxVariant(32));
3226
                    }
3227
                    using (ContextForDbDatabase ctx = new ContextForDbDatabase(pDb))
3228
                    {
3229
                        ctx.PaletteBackground = System.Drawing.Color.White;
3230
                        ctx.SetPlotGeneration(true);
3231

    
3232
                        using (LayoutHelperDevice helperDevice = LayoutHelperDevice.SetupActiveLayoutViews(dev, ctx))
3233
                        {
3234
                            helperDevice.SetLogicalPalette(Device.LightPalette); // Drark palette
3235
                            int width = 9600;
3236
                            int height = 6787;
3237
                            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
3238
                            helperDevice.OnSize(rect);
3239

    
3240
                            if (ctx.IsPlotGeneration)
3241
                                helperDevice.BackgroundColor = System.Drawing.Color.White;
3242
                            else
3243
                                helperDevice.BackgroundColor = System.Drawing.Color.FromArgb(0, 173, 174, 173);
3244

    
3245
                            helperDevice.ActiveView.ZoomExtents(pDb.Extmin, pDb.Extmax);
3246
                            helperDevice.ActiveView.Zoom(0.99);
3247
                            helperDevice.Update();
3248

    
3249
                            Export_Import.ExportBitmap(helperDevice, bmpPath);
3250
                        }
3251
                    }
3252
                }
3253
            }
3254

    
3255
            if (File.Exists(bmpPath))
3256
            {
3257
                if (File.Exists(pngPath))
3258
                {
3259
                    File.Delete(pngPath);
3260
                }
3261

    
3262
                ////bmp => grayscale bmp => png
3263
                //using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bmpPath))
3264
                //{
3265
                //    System.Drawing.Bitmap newBmp = new System.Drawing.Bitmap(bmp.Width, bmp.Height);
3266
                //    //get a graphics object from the new image
3267
                //    using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newBmp))
3268
                //    {
3269
                //        //create the grayscale ColorMatrix
3270
                //        System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(new float[][]
3271
                //        {
3272
                //            new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
3273
                //            new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
3274
                //            new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
3275
                //            new float[] { 0,      0,      0,      1, 0 },
3276
                //            new float[] { 0,      0,      0,      0, 1 }
3277
                //        });
3278

    
3279
                //        //create some image attributes
3280
                //        using (System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes())
3281
                //        {
3282
                //            //set the color matrix attribute
3283
                //            attributes.SetColorMatrix(colorMatrix);
3284
                //            //attributes.SetThreshold(0.8F);
3285

    
3286
                //            //draw the original image on the new image
3287
                //            //using the grayscale color matrix
3288
                //            g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
3289
                //                        0, 0, bmp.Width, bmp.Height, System.Drawing.GraphicsUnit.Pixel, attributes);
3290
                //        }
3291

    
3292
                //    }
3293
                //    newBmp.Save(pngPath, System.Drawing.Imaging.ImageFormat.Png);
3294
                //}
3295

    
3296
                using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bmpPath))
3297
                {
3298
                    bmp.Save(pngPath, System.Drawing.Imaging.ImageFormat.Png);
3299
                }
3300
                if (File.Exists(bmpPath))
3301
                {
3302
                    File.Delete(bmpPath);
3303
                }
3304
            }
3305
        }
3306

    
3307
        /************************************************************************/
3308
        /* Change the color of all objects                                      */
3309
        /************************************************************************/
3310
        private void chageColorAllObjects(Database pDb)
3311
        {
3312
            using (Transaction tr = pDb.TransactionManager.StartTransaction())
3313
            {
3314
                BlockTable bt = (BlockTable)tr.GetObject(pDb.BlockTableId, OpenMode.ForRead);
3315
                BlockTableRecord btrModelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
3316

    
3317
                foreach (ObjectId id in btrModelSpace)
3318
                {
3319
                    Entity ent = tr.GetObject(id, OpenMode.ForWrite, false, true) as Entity;
3320
                    if (ent == null) continue;
3321

    
3322
                    ent.ColorIndex = 7;
3323

    
3324
                    if (ent is BlockReference)
3325
                    {
3326
                        changeColorBlocks(tr, (BlockReference)ent);
3327
                    }
3328
                }
3329

    
3330
                DBDictionary dbdic = (DBDictionary)tr.GetObject(pDb.GroupDictionaryId, OpenMode.ForRead);
3331
                foreach (DBDictionaryEntry entry in dbdic)
3332
                {
3333
                    Group group = tr.GetObject(entry.Value, OpenMode.ForRead) as Group;
3334
                    if (group == null) continue;
3335

    
3336
                    ObjectId[] idarrTags = group.GetAllEntityIds();
3337
                    if (idarrTags == null) continue;
3338

    
3339
                    foreach (ObjectId id in idarrTags)
3340
                    {
3341
                        Entity ent = tr.GetObject(id, OpenMode.ForWrite, false, true) as Entity;
3342
                        if (ent == null) continue;
3343

    
3344
                        ent.ColorIndex = 7;
3345
                    }
3346
                }
3347

    
3348
                foreach (ObjectId btrId in bt)
3349
                {
3350
                    BlockTableRecord btr = tr.GetObject(btrId, OpenMode.ForRead) as BlockTableRecord;
3351
                    if (btr == null) continue;
3352
                    if (btr.Name.StartsWith("*")) continue;
3353

    
3354
                    foreach (ObjectId entId in btr)
3355
                    {
3356
                        Entity ent = tr.GetObject(entId, OpenMode.ForWrite, false, true) as Entity;
3357
                        if (ent == null) continue;
3358
                        ent.ColorIndex = 0;//ByBlock
3359
                    }
3360
                }
3361

    
3362
                tr.Commit();
3363
            }
3364
        }
3365

    
3366
        /************************************************************************/
3367
        /* Change the color of blocks                                           */
3368
        /************************************************************************/
3369
        private void changeColorBlocks(Transaction tr, BlockReference blkRef)
3370
        {
3371
            if (blkRef == null) return;
3372

    
3373
            if (blkRef.AttributeCollection != null && blkRef.AttributeCollection.Count > 0)
3374
            {
3375
                foreach (ObjectId objectId in blkRef.AttributeCollection)
3376
                {
3377
                    AttributeReference attRef = tr.GetObject(objectId, OpenMode.ForWrite, false, true) as AttributeReference;
3378
                    attRef.ColorIndex = 7;
3379
                }
3380
            }
3381

    
3382
            BlockTableRecord btrBlock = tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
3383
            if (btrBlock == null) return;
3384

    
3385
            foreach (ObjectId oid in btrBlock)
3386
            {
3387
                Entity ent = tr.GetObject(oid, OpenMode.ForWrite, false, true) as Entity;
3388
                if (ent == null) continue;
3389

    
3390
                ent.ColorIndex = 7;
3391

    
3392
                if (ent is BlockReference)
3393
                {
3394
                    changeColorBlocks(tr, (BlockReference)ent);
3395
                }
3396
            }
3397
        }
3398

    
3399
        /************************************************************************/
3400
        /* Nested block Explode & Purge                                         */
3401
        /************************************************************************/
3402
        public void ExplodeAndPurgeNestedBlocks(Database pDb)
3403
        {
3404
            HashSet<string> blockNameList = new HashSet<string>();
3405
            // Explode ModelSpace Nested Block
3406
            blockNameList = explodeNestedBlocks(pDb);
3407

    
3408
            // Prepare Block Purge
3409
            preparePurgeBlocks(pDb, blockNameList);
3410

    
3411
            // Block Purge
3412
            ObjectIdCollection oids = new ObjectIdCollection();
3413
            using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead))
3414
            {
3415
                foreach (ObjectId id in pTable)
3416
                {
3417
                    BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead, false, true);
3418
                    oids.Add(id);
3419
                }
3420
            }
3421
            pDb.Purge(oids);
3422

    
3423
            foreach (ObjectId oid in oids)
3424
            {
3425
                using (BlockTableRecord btr = (BlockTableRecord)oid.Open(OpenMode.ForWrite, false, true))
3426
                {
3427
                    btr.Erase(true);
3428
                }
3429
            }
3430
        }
3431

    
3432
        private HashSet<string> explodeNestedBlocks(Database pDb)
3433
        {
3434
            HashSet<string> blockNameList = new HashSet<string>();
3435
            HashSet<ObjectId> oidSet = new HashSet<ObjectId>();
3436

    
3437
            using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead))
3438
            {
3439
                using (BlockTableRecord pBlock = (BlockTableRecord)pTable[BlockTableRecord.ModelSpace].Open(OpenMode.ForRead, false, true))
3440
                {
3441
                    foreach (ObjectId entid in pBlock)
3442
                    {
3443
                        using (Entity pEnt = (Entity)entid.Open(OpenMode.ForRead, false, true))
3444
                        {
3445
                            if (pEnt.GetRXClass().Name != "AcDbBlockReference") continue;
3446
                            BlockReference blockRef = (BlockReference)pEnt;
3447

    
3448
                            using (BlockTableRecord pBtr = (BlockTableRecord)blockRef.BlockTableRecord.Open(OpenMode.ForRead, false, true))
3449
                            {
3450
                                bool isNestedBlock = false;
3451
                                foreach (ObjectId blkid in pBtr)
3452
                                {
3453
                                    using (Entity pBlkEnt = (Entity)blkid.Open(OpenMode.ForRead, false, true))
3454
                                    {
3455
                                        if (pBlkEnt.GetRXClass().Name == "AcDbBlockReference")
3456
                                        {
3457
                                            oidSet.Add(entid);
3458
                                            isNestedBlock = true;                                            
3459
                                        }
3460
                                    }
3461
                                }
3462
                                if (!isNestedBlock)
3463
                                {
3464
                                    blockNameList.Add(blockRef.Name);
3465
                                }
3466
                            }
3467
                        }
3468
                    }
3469
                }
3470
            }
3471

    
3472
            if (oidSet.Count > 0)
3473
            {
3474
                explodeBlocks(oidSet);
3475
                blockNameList = explodeNestedBlocks(pDb);
3476
            }
3477

    
3478
            return blockNameList;
3479
        }
3480

    
3481
        private void preparePurgeBlocks(Database pDb, HashSet<string> blockNameList)
3482
        {
3483
            HashSet<ObjectId> oidSet = new HashSet<ObjectId>();
3484

    
3485
            using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead))
3486
            {
3487
                foreach (ObjectId id in pTable)
3488
                {
3489
                    using (BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead, false, true))
3490
                    {
3491
                        if (pBlock.IsLayout) continue;
3492
                        if (blockNameList.Contains(pBlock.Name)) continue;
3493

    
3494
                        foreach (ObjectId entid in pBlock)
3495
                        {
3496
                            using (Entity pEnt = (Entity)entid.Open(OpenMode.ForRead, false, true))
3497
                            {
3498
                                if (pEnt.GetRXClass().Name != "AcDbBlockReference") continue;
3499

    
3500
                                oidSet.Add(entid);
3501
                            }
3502
                        }
3503
                    }
3504
                }
3505
            }
3506

    
3507
            if (oidSet.Count > 0)
3508
            {
3509
                explodeBlocks(oidSet);
3510
                preparePurgeBlocks(pDb, blockNameList);
3511
            }
3512

    
3513
            return;
3514
        }
3515
        private void explodeBlocks(HashSet<ObjectId> oidSet)
3516
        {
3517
            foreach (ObjectId blkId in oidSet)
3518
            {
3519
                BlockReference blkRef = (BlockReference)blkId.Open(OpenMode.ForWrite, false, true);
3520
                blkRef.ExplodeGeometryToOwnerSpace();
3521
                blkRef.Erase();
3522
            }
3523
        }
3524

    
3525
        /************************************************************************/
3526
        /* Dump the BlockTable                                                  */
3527
        /************************************************************************/
3528
        public void dumpBlocks(Database pDb, int indent, XmlNode node)
3529
        {
3530
            /**********************************************************************/
3531
            /* Get a pointer to the BlockTable                               */
3532
            /**********************************************************************/
3533
            using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead))
3534
            {
3535
                /**********************************************************************/
3536
                /* Dump the Description                                               */
3537
                /**********************************************************************/
3538
                XmlElement BlocksNode = Program.xml.CreateElement(pTable.GetRXClass().Name);
3539

    
3540
                /**********************************************************************/
3541
                /* Step through the BlockTable                                        */
3542
                /**********************************************************************/
3543
                foreach (ObjectId id in pTable)
3544
                {
3545
                    /********************************************************************/
3546
                    /* Open the BlockTableRecord for Reading                            */
3547
                    /********************************************************************/
3548
                    using (BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead))
3549
                    {
3550
                        /********************************************************************/
3551
                        /* Dump the BlockTableRecord                                        */
3552
                        /********************************************************************/
3553
                        XmlElement BlockNode = Program.xml.CreateElement(pBlock.GetRXClass().Name);
3554

    
3555
                        XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
3556
                        NameAttr.Value = pBlock.Name;
3557
                        BlockNode.Attributes.SetNamedItem(NameAttr);
3558

    
3559
                        XmlAttribute CommentsAttr = Program.xml.CreateAttribute("Comments");
3560
                        CommentsAttr.Value = pBlock.Comments;
3561
                        BlockNode.Attributes.SetNamedItem(CommentsAttr);
3562

    
3563
                        XmlAttribute OriginAttr = Program.xml.CreateAttribute("Origin");
3564
                        OriginAttr.Value = pBlock.Origin.ToString();
3565
                        BlockNode.Attributes.SetNamedItem(OriginAttr);
3566

    
3567
                        writeLine(indent, pBlock.GetRXClass().Name);
3568
                        writeLine(indent + 1, "Anonymous", pBlock.IsAnonymous);
3569
                        writeLine(indent + 1, "Block Insert Units", pBlock.Units);
3570
                        writeLine(indent + 1, "Block Scaling", pBlock.BlockScaling);
3571
                        writeLine(indent + 1, "Explodable", pBlock.Explodable);
3572
                        writeLine(indent + 1, "IsDynamicBlock", pBlock.IsDynamicBlock);
3573

    
3574
                        try
3575
                        {
3576
                            Extents3d extents = new Extents3d(new Point3d(1E+20, 1E+20, 1E+20), new Point3d(1E-20, 1E-20, 1E-20));
3577
                            extents.AddBlockExtents(pBlock);
3578

    
3579
                            XmlAttribute MinExtentsAttr = Program.xml.CreateAttribute("MinExtents");
3580
                            MinExtentsAttr.Value = extents.MinPoint.ToString();
3581
                            BlockNode.Attributes.SetNamedItem(MinExtentsAttr);
3582

    
3583
                            XmlAttribute MaxExtentsAttr = Program.xml.CreateAttribute("MaxExtents");
3584
                            MaxExtentsAttr.Value = extents.MaxPoint.ToString();
3585
                            BlockNode.Attributes.SetNamedItem(MaxExtentsAttr);
3586
                        }
3587
                        catch (System.Exception)
3588
                        {
3589
                        }
3590

    
3591
                        writeLine(indent + 1, "Layout", pBlock.IsLayout);
3592
                        writeLine(indent + 1, "Has Attribute Definitions", pBlock.HasAttributeDefinitions);
3593
                        writeLine(indent + 1, "Xref Status", pBlock.XrefStatus);
3594
                        if (pBlock.XrefStatus != XrefStatus.NotAnXref)
3595
                        {
3596
                            writeLine(indent + 1, "Xref Path", pBlock.PathName);
3597
                            writeLine(indent + 1, "From Xref Attach", pBlock.IsFromExternalReference);
3598
                            writeLine(indent + 1, "From Xref Overlay", pBlock.IsFromOverlayReference);
3599
                            writeLine(indent + 1, "Xref Unloaded", pBlock.IsUnloaded);
3600
                        }
3601

    
3602
                        /********************************************************************/
3603
                        /* Step through the BlockTableRecord                                */
3604
                        /********************************************************************/
3605
                        foreach (ObjectId entid in pBlock)
3606
                        {
3607
                            /********************************************************************/
3608
                            /* Dump the Entity                                                  */
3609
                            /********************************************************************/
3610
                            dumpEntity(entid, indent + 1, BlockNode);
3611
                        }
3612

    
3613
                        BlocksNode.AppendChild(BlockNode);
3614
                    }
3615
                }
3616

    
3617
                node.AppendChild(BlocksNode);
3618
            }
3619
        }
3620

    
3621
        public void dumpDimStyles(Database pDb, int indent, XmlNode node)
3622
        {
3623
            /**********************************************************************/
3624
            /* Get a SmartPointer to the DimStyleTable                            */
3625
            /**********************************************************************/
3626
            using (DimStyleTable pTable = (DimStyleTable)pDb.DimStyleTableId.Open(OpenMode.ForRead))
3627
            {
3628
                /**********************************************************************/
3629
                /* Dump the Description                                               */
3630
                /**********************************************************************/
3631
                writeLine();
3632
                writeLine(indent++, pTable.GetRXClass().Name);
3633

    
3634
                /**********************************************************************/
3635
                /* Step through the DimStyleTable                                    */
3636
                /**********************************************************************/
3637
                foreach (ObjectId id in pTable)
3638
                {
3639
                    /*********************************************************************/
3640
                    /* Open the DimStyleTableRecord for Reading                         */
3641
                    /*********************************************************************/
3642
                    using (DimStyleTableRecord pRecord = (DimStyleTableRecord)id.Open(OpenMode.ForRead))
3643
                    {
3644
                        /*********************************************************************/
3645
                        /* Dump the DimStyleTableRecord                                      */
3646
                        /*********************************************************************/
3647
                        writeLine();
3648
                        writeLine(indent, pRecord.GetRXClass().Name);
3649
                        writeLine(indent, "Name", pRecord.Name);
3650
                        writeLine(indent, "Arc Symbol", toArcSymbolTypeString(pRecord.Dimarcsym));
3651

    
3652
                        writeLine(indent, "Background Text Color", pRecord.Dimtfillclr);
3653
                        writeLine(indent, "BackgroundText Flags", pRecord.Dimtfill);
3654
                        writeLine(indent, "Extension Line 1 Linetype", pRecord.Dimltex1);
3655
                        writeLine(indent, "Extension Line 2 Linetype", pRecord.Dimltex2);
3656
                        writeLine(indent, "Dimension Line Linetype", pRecord.Dimltype);
3657
                        writeLine(indent, "Extension Line Fixed Len", pRecord.Dimfxlen);
3658
                        writeLine(indent, "Extension Line Fixed Len Enable", pRecord.DimfxlenOn);
3659
                        writeLine(indent, "Jog Angle", toDegreeString(pRecord.Dimjogang));
3660
                        writeLine(indent, "Modified For Recompute", pRecord.IsModifiedForRecompute);
3661
                        writeLine(indent, "DIMADEC", pRecord.Dimadec);
3662
                        writeLine(indent, "DIMALT", pRecord.Dimalt);
3663
                        writeLine(indent, "DIMALTD", pRecord.Dimaltd);
3664
                        writeLine(indent, "DIMALTF", pRecord.Dimaltf);
3665
                        writeLine(indent, "DIMALTRND", pRecord.Dimaltrnd);
3666
                        writeLine(indent, "DIMALTTD", pRecord.Dimalttd);
3667
                        writeLine(indent, "DIMALTTZ", pRecord.Dimalttz);
3668
                        writeLine(indent, "DIMALTU", pRecord.Dimaltu);
3669
                        writeLine(indent, "DIMALTZ", pRecord.Dimaltz);
3670
                        writeLine(indent, "DIMAPOST", pRecord.Dimapost);
3671
                        writeLine(indent, "DIMASZ", pRecord.Dimasz);
3672
                        writeLine(indent, "DIMATFIT", pRecord.Dimatfit);
3673
                        writeLine(indent, "DIMAUNIT", pRecord.Dimaunit);
3674
                        writeLine(indent, "DIMAZIN", pRecord.Dimazin);
3675
                        writeLine(indent, "DIMBLK", pRecord.Dimblk);
3676
                        writeLine(indent, "DIMBLK1", pRecord.Dimblk1);
3677
                        writeLine(indent, "DIMBLK2", pRecord.Dimblk2);
3678
                        writeLine(indent, "DIMCEN", pRecord.Dimcen);
3679
                        writeLine(indent, "DIMCLRD", pRecord.Dimclrd);
3680
                        writeLine(indent, "DIMCLRE", pRecord.Dimclre);
3681
                        writeLine(indent, "DIMCLRT", pRecord.Dimclrt);
3682
                        writeLine(indent, "DIMDEC", pRecord.Dimdec);
3683
                        writeLine(indent, "DIMDLE", pRecord.Dimdle);
3684
                        writeLine(indent, "DIMDLI", pRecord.Dimdli);
3685
                        writeLine(indent, "DIMDSEP", pRecord.Dimdsep);
3686
                        writeLine(indent, "DIMEXE", pRecord.Dimexe);
3687
                        writeLine(indent, "DIMEXO", pRecord.Dimexo);
3688
                        writeLine(indent, "DIMFRAC", pRecord.Dimfrac);
3689
                        writeLine(indent, "DIMGAP", pRecord.Dimgap);
3690
                        writeLine(indent, "DIMJUST", pRecord.Dimjust);
3691
                        writeLine(indent, "DIMLDRBLK", pRecord.Dimldrblk);
3692
                        writeLine(indent, "DIMLFAC", pRecord.Dimlfac);
3693
                        writeLine(indent, "DIMLIM", pRecord.Dimlim);
3694
                        writeLine(indent, "DIMLUNIT", pRecord.Dimlunit);
3695
                        writeLine(indent, "DIMLWD", pRecord.Dimlwd);
3696
                        writeLine(indent, "DIMLWE", pRecord.Dimlwe);
3697
                        writeLine(indent, "DIMPOST", pRecord.Dimpost);
3698
                        writeLine(indent, "DIMRND", pRecord.Dimrnd);
3699
                        writeLine(indent, "DIMSAH", pRecord.Dimsah);
3700
                        writeLine(indent, "DIMSCALE", pRecord.Dimscale);
3701
                        writeLine(indent, "DIMSD1", pRecord.Dimsd1);
3702
                        writeLine(indent, "DIMSD2", pRecord.Dimsd2);
3703
                        writeLine(indent, "DIMSE1", pRecord.Dimse1);
3704
                        writeLine(indent, "DIMSE2", pRecord.Dimse2);
3705
                        writeLine(indent, "DIMSOXD", pRecord.Dimsoxd);
3706
                        writeLine(indent, "DIMTAD", pRecord.Dimtad);
3707
                        writeLine(indent, "DIMTDEC", pRecord.Dimtdec);
3708
                        writeLine(indent, "DIMTFAC", pRecord.Dimtfac);
3709
                        writeLine(indent, "DIMTIH", pRecord.Dimtih);
3710
                        writeLine(indent, "DIMTIX", pRecord.Dimtix);
3711
                        writeLine(indent, "DIMTM", pRecord.Dimtm);
3712
                        writeLine(indent, "DIMTOFL", pRecord.Dimtofl);
3713
                        writeLine(indent, "DIMTOH", pRecord.Dimtoh);
3714
                        writeLine(indent, "DIMTOL", pRecord.Dimtol);
3715
                        writeLine(indent, "DIMTOLJ", pRecord.Dimtolj);
3716
                        writeLine(indent, "DIMTP", pRecord.Dimtp);
3717
                        writeLine(indent, "DIMTSZ", pRecord.Dimtsz);
3718
                        writeLine(indent, "DIMTVP", pRecord.Dimtvp);
3719
                        writeLine(indent, "DIMTXSTY", pRecord.Dimtxsty);
3720
                        writeLine(indent, "DIMTXT", pRecord.Dimtxt);
3721
                        writeLine(indent, "DIMTZIN", pRecord.Dimtzin);
3722
                        writeLine(indent, "DIMUPT", pRecord.Dimupt);
3723
                        writeLine(indent, "DIMZIN", pRecord.Dimzin);
3724

    
3725
                        dumpSymbolTableRecord(pRecord, indent, node);
3726
                    }
3727
                }
3728
            }
3729
        }
3730

    
3731
        /// <summary>
3732
        /// extract information from entity has given id
3733
        /// </summary>
3734
        /// <param name="id"></param>
3735
        /// <param name="indent"></param>
3736
        /// <param name="node">XmlNode</param>
3737
        public void dumpEntity(ObjectId id, int indent, XmlNode node)
3738
        {
3739
            /**********************************************************************/
3740
            /* Get a pointer to the Entity                                   */
3741
            /**********************************************************************/
3742
            try
3743
            {
3744
                using (Entity pEnt = (Entity)id.Open(OpenMode.ForRead, false, true))
3745
                {
3746
                    /**********************************************************************/
3747
                    /* Dump the entity                                                    */
3748
                    /**********************************************************************/
3749
                    writeLine();
3750
                    // Protocol extensions are not supported in DD.NET (as well as in ARX.NET)
3751
                    // so we just switch by entity type here
3752
                    // (maybe it makes sense to make a map: type -> delegate)
3753
                    switch (pEnt.GetRXClass().Name)
3754
                    {
3755
                        case "AcDbAlignedDimension":
3756
                            dump((AlignedDimension)pEnt, indent, node);
3757
                            break;
3758
                        case "AcDbArc":
3759
                            dump((Arc)pEnt, indent, node);
3760
                            break;
3761
                        case "AcDbArcDimension":
3762
                            dump((ArcDimension)pEnt, indent, node);
3763
                            break;
3764
                        case "AcDbBlockReference":
3765
                            dump((BlockReference)pEnt, indent, node);
3766
                            break;
3767
                        case "AcDbBody":
3768
                            dump((Body)pEnt, indent, node);
3769
                            break;
3770
                        case "AcDbCircle":
3771
                            dump((Circle)pEnt, indent, node);
3772
                            break;
3773
                        case "AcDbPoint":
3774
                            dump((DBPoint)pEnt, indent);
3775
                            break;
3776
                        case "AcDbText":
3777
                            dump((DBText)pEnt, indent, node);
3778
                            break;
3779
                        case "AcDbDiametricDimension":
3780
                            dump((DiametricDimension)pEnt, indent, node);
3781
                            break;
3782
                        case "AcDbViewport":
3783
                            dump((Teigha.DatabaseServices.Viewport)pEnt, indent, node);
3784
                            break;
3785
                        case "AcDbEllipse":
3786
                            dump((Ellipse)pEnt, indent, node);
3787
                            break;
3788
                        case "AcDbFace":
3789
                            dump((Face)pEnt, indent, node);
3790
                            break;
3791
                        case "AcDbFcf":
3792
                            dump((FeatureControlFrame)pEnt, indent);
3793
                            break;
3794
                        case "AcDbHatch":
3795
                            dump((Hatch)pEnt, indent);
3796
                            break;
3797
                        case "AcDbLeader":
3798
                            dump((Leader)pEnt, indent);
3799
                            break;
3800
                        case "AcDbLine":
3801
                            dump((Line)pEnt, indent, node);
3802
                            break;
3803
                        case "AcDb2LineAngularDimension":
3804
                            dump((LineAngularDimension2)pEnt, indent, node);
3805
                            break;
3806
                        case "AcDbMInsertBlock":
3807
                            dump((MInsertBlock)pEnt, indent, node);
3808
                            break;
3809
                        case "AcDbMline":
3810
                            dump((Mline)pEnt, indent);
3811
                            break;
3812
                        case "AcDbMText":
3813
                            dump((MText)pEnt, indent, node);
3814
                            break;
3815
                        case "AcDbOle2Frame":
3816
                            dump((Ole2Frame)pEnt, indent);
3817
                            break;
3818
                        case "AcDbOrdinateDimension":
3819
                            dump((OrdinateDimension)pEnt, indent, node);
3820
                            break;
3821
                        case "AcDb3PointAngularDimension":
3822
                            dump((Point3AngularDimension)pEnt, indent, node);
3823
                            break;
3824
                        case "AcDbPolyFaceMesh":
3825
                            dump((PolyFaceMesh)pEnt, indent, node);
3826
                            break;
3827
                        case "AcDbPolygonMesh":
3828
                            dump((PolygonMesh)pEnt, indent);
3829
                            break;
3830
                        case "AcDbPolyline":
3831
                            dump((Teigha.DatabaseServices.Polyline)pEnt, indent, node);
3832
                            break;
3833
                        case "AcDb2dPolyline":
3834
                            dump((Polyline2d)pEnt, indent, node);
3835
                            break;
3836
                        case "AcDb3dPolyline":
3837
                            dump((Polyline3d)pEnt, indent, node);
3838
                            break;
3839
                        case "AcDbProxyEntity":
3840
                            dump((ProxyEntity)pEnt, indent, node);
3841
                            break;
3842
                        case "AcDbRadialDimension":
3843
                            dump((RadialDimension)pEnt, indent, node);
3844
                            break;
3845
                        case "AcDbRasterImage":
3846
                            dump((RasterImage)pEnt, indent);
3847
                            break;
3848
                        case "AcDbRay":
3849
                            dump((Ray)pEnt, indent);
3850
                            break;
3851
                        case "AcDbRegion":
3852
                            dump((Region)pEnt, indent);
3853
                            break;
3854
                        case "AcDbRotatedDimension":
3855
                            dump((RotatedDimension)pEnt, indent, node);
3856
                            break;
3857
                        case "AcDbShape":
3858
                            dump((Shape)pEnt, indent);
3859
                            break;
3860
                        case "AcDb3dSolid":
3861
                            dump((Solid3d)pEnt, indent, node);
3862
                            break;
3863
                        case "AcDbSpline":
3864
                            dump((Spline)pEnt, indent);
3865
                            break;
3866
                        case "AcDbTable":
3867
                            dump((Table)pEnt, indent);
3868
                            break;
3869
                        case "AcDbTrace":
3870
                            dump((Trace)pEnt, indent);
3871
                            break;
3872
                        case "AcDbWipeout":
3873
                            dump((Wipeout)pEnt, indent);
3874
                            break;
3875
                        case "AcDbXline":
3876
                            dump((Xline)pEnt, indent);
3877
                            break;
3878
                        case "AcDbPdfReference":
3879
                        case "AcDbDwfReference":
3880
                        case "AcDbDgnReference":
3881
                            dump((UnderlayReference)pEnt, indent);
3882
                            break;
3883
                        default:
3884
                            dump(pEnt, indent, node);
3885
                            break;
3886
                    }
3887
                    /* Dump the Xdata                                                     */
3888
                    /**********************************************************************/
3889
                    dumpXdata(pEnt.XData, indent);
3890

    
3891
                    /**********************************************************************/
3892
                    /* Dump the Extension Dictionary                                      */
3893
                    /**********************************************************************/
3894
                    if (!pEnt.ExtensionDictionary.IsNull)
3895
                    {
3896
                        dumpObject(pEnt.ExtensionDictionary, "ACAD_XDICTIONARY", indent);
3897
                    }
3898
                }
3899
            }
3900
            catch (System.Exception ex)
3901
            {
3902
                writeLine(indent, $"OID = {id.ToString()}, Error = {ex.Message}");
3903
            }
3904
        }
3905
        public void dumpHeader(Database pDb, int indent, XmlNode node)
3906
        {
3907
            if (node != null)
3908
            {
3909
                XmlAttribute FileNameAttr = Program.xml.CreateAttribute("FileName");
3910
                FileNameAttr.Value = shortenPath(pDb.Filename);
3911
                node.Attributes.SetNamedItem(FileNameAttr);
3912

    
3913
                XmlAttribute OriginalFileVersionAttr = Program.xml.CreateAttribute("OriginalFileVersion");
3914
                OriginalFileVersionAttr.Value = pDb.OriginalFileVersion.ToString();
3915
                node.Attributes.SetNamedItem(OriginalFileVersionAttr);
3916

    
3917
                writeLine();
3918
                writeLine(indent++, "Header Variables:");
3919

    
3920
                //writeLine();
3921
                //writeLine(indent, "TDCREATE:", pDb.TDCREATE);
3922
                //writeLine(indent, "TDUPDATE:", pDb.TDUPDATE);
3923

    
3924
                writeLine();
3925
                writeLine(indent, "ANGBASE", pDb.Angbase);
3926
                writeLine(indent, "ANGDIR", pDb.Angdir);
3927
                writeLine(indent, "ATTMODE", pDb.Attmode);
3928
                writeLine(indent, "AUNITS", pDb.Aunits);
3929
                writeLine(indent, "AUPREC", pDb.Auprec);
3930
                writeLine(indent, "CECOLOR", pDb.Cecolor);
3931
                writeLine(indent, "CELTSCALE", pDb.Celtscale);
3932
                writeLine(indent, "CHAMFERA", pDb.Chamfera);
3933
                writeLine(indent, "CHAMFERB", pDb.Chamferb);
3934
                writeLine(indent, "CHAMFERC", pDb.Chamferc);
3935
                writeLine(indent, "CHAMFERD", pDb.Chamferd);
3936
                writeLine(indent, "CMLJUST", pDb.Cmljust);
3937
                writeLine(indent, "CMLSCALE", pDb.Cmljust);
3938
                writeLine(indent, "DIMADEC", pDb.Dimadec);
3939
                writeLine(indent, "DIMALT", pDb.Dimalt);
3940
                writeLine(indent, "DIMALTD", pDb.Dimaltd);
3941
                writeLine(indent, "DIMALTF", pDb.Dimaltf);
3942
                writeLine(indent, "DIMALTRND", pDb.Dimaltrnd);
3943
                writeLine(indent, "DIMALTTD", pDb.Dimalttd);
3944
                writeLine(indent, "DIMALTTZ", pDb.Dimalttz);
3945
                writeLine(indent, "DIMALTU", pDb.Dimaltu);
3946
                writeLine(indent, "DIMALTZ", pDb.Dimaltz);
3947
                writeLine(indent, "DIMAPOST", pDb.Dimapost);
3948
                writeLine(indent, "DIMASZ", pDb.Dimasz);
3949
                writeLine(indent, "DIMATFIT", pDb.Dimatfit);
3950
                writeLine(indent, "DIMAUNIT", pDb.Dimaunit);
3951
                writeLine(indent, "DIMAZIN", pDb.Dimazin);
3952
                writeLine(indent, "DIMBLK", pDb.Dimblk);
3953
                writeLine(indent, "DIMBLK1", pDb.Dimblk1);
3954
                writeLine(indent, "DIMBLK2", pDb.Dimblk2);
3955
                writeLine(indent, "DIMCEN", pDb.Dimcen);
3956
                writeLine(indent, "DIMCLRD", pDb.Dimclrd);
3957
                writeLine(indent, "DIMCLRE", pDb.Dimclre);
3958
                writeLine(indent, "DIMCLRT", pDb.Dimclrt);
3959
                writeLine(indent, "DIMDEC", pDb.Dimdec);
3960
                writeLine(indent, "DIMDLE", pDb.Dimdle);
3961
                writeLine(indent, "DIMDLI", pDb.Dimdli);
3962
                writeLine(indent, "DIMDSEP", pDb.Dimdsep);
3963
                writeLine(indent, "DIMEXE", pDb.Dimexe);
3964
                writeLine(indent, "DIMEXO", pDb.Dimexo);
3965
                writeLine(indent, "DIMFRAC", pDb.Dimfrac);
3966
                writeLine(indent, "DIMGAP", pDb.Dimgap);
3967
                writeLine(indent, "DIMJUST", pDb.Dimjust);
3968
                writeLine(indent, "DIMLDRBLK", pDb.Dimldrblk);
3969
                writeLine(indent, "DIMLFAC", pDb.Dimlfac);
3970
                writeLine(indent, "DIMLIM", pDb.Dimlim);
3971
                writeLine(indent, "DIMLUNIT", pDb.Dimlunit);
3972
                writeLine(indent, "DIMLWD", pDb.Dimlwd);
3973
                writeLine(indent, "DIMLWE", pDb.Dimlwe);
3974
                writeLine(indent, "DIMPOST", pDb.Dimpost);
3975
                writeLine(indent, "DIMRND", pDb.Dimrnd);
3976
                writeLine(indent, "DIMSAH", pDb.Dimsah);
3977
                writeLine(indent, "DIMSCALE", pDb.Dimscale);
3978
                writeLine(indent, "DIMSD1", pDb.Dimsd1);
3979
                writeLine(indent, "DIMSD2", pDb.Dimsd2);
3980
                writeLine(indent, "DIMSE1", pDb.Dimse1);
3981
                writeLine(indent, "DIMSE2", pDb.Dimse2);
3982
                writeLine(indent, "DIMSOXD", pDb.Dimsoxd);
3983
                writeLine(indent, "DIMTAD", pDb.Dimtad);
3984
                writeLine(indent, "DIMTDEC", pDb.Dimtdec);
3985
                writeLine(indent, "DIMTFAC", pDb.Dimtfac);
3986
                writeLine(indent, "DIMTIH", pDb.Dimtih);
3987
                writeLine(indent, "DIMTIX", pDb.Dimtix);
3988
                writeLine(indent, "DIMTM", pDb.Dimtm);
3989
                writeLine(indent, "DIMTOFL", pDb.Dimtofl);
3990
                writeLine(indent, "DIMTOH", pDb.Dimtoh);
3991
                writeLine(indent, "DIMTOL", pDb.Dimtol);
3992
                writeLine(indent, "DIMTOLJ", pDb.Dimtolj);
3993
                writeLine(indent, "DIMTP", pDb.Dimtp);
3994
                writeLine(indent, "DIMTSZ", pDb.Dimtsz);
3995
                writeLine(indent, "DIMTVP", pDb.Dimtvp);
3996
                writeLine(indent, "DIMTXSTY", pDb.Dimtxsty);
3997
                writeLine(indent, "DIMTXT", pDb.Dimtxt);
3998
                writeLine(indent, "DIMTZIN", pDb.Dimtzin);
3999
                writeLine(indent, "DIMUPT", pDb.Dimupt);
4000
                writeLine(indent, "DIMZIN", pDb.Dimzin);
4001
                writeLine(indent, "DISPSILH", pDb.DispSilh);
4002
                writeLine(indent, "DRAWORDERCTL", pDb.DrawOrderCtl);
4003
                writeLine(indent, "ELEVATION", pDb.Elevation);
4004
                writeLine(indent, "EXTMAX", pDb.Extmax);
4005
                writeLine(indent, "EXTMIN", pDb.Extmin);
4006
                writeLine(indent, "FACETRES", pDb.Facetres);
4007
                writeLine(indent, "FILLETRAD", pDb.Filletrad);
4008
                writeLine(indent, "FILLMODE", pDb.Fillmode);
4009
                writeLine(indent, "INSBASE", pDb.Insbase);
4010
                writeLine(indent, "ISOLINES", pDb.Isolines);
4011
                writeLine(indent, "LIMCHECK", pDb.Limcheck);
4012
                writeLine(indent, "LIMMAX", pDb.Limmax);
4013
                writeLine(indent, "LIMMIN", pDb.Limmin);
4014
                writeLine(indent, "LTSCALE", pDb.Ltscale);
4015
                writeLine(indent, "LUNITS", pDb.Lunits);
4016
                writeLine(indent, "LUPREC", pDb.Luprec);
4017
                writeLine(indent, "MAXACTVP", pDb.Maxactvp);
4018
                writeLine(indent, "MIRRTEXT", pDb.Mirrtext);
4019
                writeLine(indent, "ORTHOMODE", pDb.Orthomode);
4020
                writeLine(indent, "PDMODE", pDb.Pdmode);
4021
                writeLine(indent, "PDSIZE", pDb.Pdsize);
4022
                writeLine(indent, "PELEVATION", pDb.Pelevation);
4023
                writeLine(indent, "PELLIPSE", pDb.PlineEllipse);
4024
                writeLine(indent, "PEXTMAX", pDb.Pextmax);
4025
                writeLine(indent, "PEXTMIN", pDb.Pextmin);
4026
                writeLine(indent, "PINSBASE", pDb.Pinsbase);
4027
                writeLine(indent, "PLIMCHECK", pDb.Plimcheck);
4028
                writeLine(indent, "PLIMMAX", pDb.Plimmax);
4029
                writeLine(indent, "PLIMMIN", pDb.Plimmin);
4030
                writeLine(indent, "PLINEGEN", pDb.Plinegen);
4031
                writeLine(indent, "PLINEWID", pDb.Plinewid);
4032
                writeLine(indent, "PROXYGRAPHICS", pDb.Saveproxygraphics);
4033
                writeLine(indent, "PSLTSCALE", pDb.Psltscale);
4034
                writeLine(indent, "PUCSNAME", pDb.Pucsname);
4035
                writeLine(indent, "PUCSORG", pDb.Pucsorg);
4036
                writeLine(indent, "PUCSXDIR", pDb.Pucsxdir);
4037
                writeLine(indent, "PUCSYDIR", pDb.Pucsydir);
4038
                writeLine(indent, "QTEXTMODE", pDb.Qtextmode);
4039
                writeLine(indent, "REGENMODE", pDb.Regenmode);
4040
                writeLine(indent, "SHADEDGE", pDb.Shadedge);
4041
                writeLine(indent, "SHADEDIF", pDb.Shadedif);
4042
                writeLine(indent, "SKETCHINC", pDb.Sketchinc);
4043
                writeLine(indent, "SKPOLY", pDb.Skpoly);
4044
                writeLine(indent, "SPLFRAME", pDb.Splframe);
4045
                writeLine(indent, "SPLINESEGS", pDb.Splinesegs);
4046
                writeLine(indent, "SPLINETYPE", pDb.Splinetype);
4047
                writeLine(indent, "SURFTAB1", pDb.Surftab1);
4048
                writeLine(indent, "SURFTAB2", pDb.Surftab2);
4049
                writeLine(indent, "SURFTYPE", pDb.Surftype);
4050
                writeLine(indent, "SURFU", pDb.Surfu);
4051
                writeLine(indent, "SURFV", pDb.Surfv);
4052
                //writeLine(indent, "TEXTQLTY", pDb.TEXTQLTY);
4053
                writeLine(indent, "TEXTSIZE", pDb.Textsize);
4054
                writeLine(indent, "THICKNESS", pDb.Thickness);
4055
                writeLine(indent, "TILEMODE", pDb.TileMode);
4056
                writeLine(indent, "TRACEWID", pDb.Tracewid);
4057
                writeLine(indent, "TREEDEPTH", pDb.Treedepth);
4058
                writeLine(indent, "UCSNAME", pDb.Ucsname);
4059
                writeLine(indent, "UCSORG", pDb.Ucsorg);
4060
                writeLine(indent, "UCSXDIR", pDb.Ucsxdir);
4061
                writeLine(indent, "UCSYDIR", pDb.Ucsydir);
4062
                writeLine(indent, "UNITMODE", pDb.Unitmode);
4063
                writeLine(indent, "USERI1", pDb.Useri1);
4064
                writeLine(indent, "USERI2", pDb.Useri2);
4065
                writeLine(indent, "USERI3", pDb.Useri3);
4066
                writeLine(indent, "USERI4", pDb.Useri4);
4067
                writeLine(indent, "USERI5", pDb.Useri5);
4068
                writeLine(indent, "USERR1", pDb.Userr1);
4069
                writeLine(indent, "USERR2", pDb.Userr2);
4070
                writeLine(indent, "USERR3", pDb.Userr3);
4071
                writeLine(indent, "USERR4", pDb.Userr4);
4072
                writeLine(indent, "USERR5", pDb.Userr5);
4073
                writeLine(indent, "USRTIMER", pDb.Usrtimer);
4074
                writeLine(indent, "VISRETAIN", pDb.Visretain);
4075
                writeLine(indent, "WORLDVIEW", pDb.Worldview);
4076
            }
4077
        }
4078

    
4079
        public void dumpLayers(Database pDb, int indent, XmlNode node)
4080
        {
4081
            if (node != null)
4082
            {
4083
                /**********************************************************************/
4084
                /* Get a SmartPointer to the LayerTable                               */
4085
                /**********************************************************************/
4086
                using (LayerTable pTable = (LayerTable)pDb.LayerTableId.Open(OpenMode.ForRead))
4087
                {
4088
                    /**********************************************************************/
4089
                    /* Dump the Description                                               */
4090
                    /**********************************************************************/
4091
                    XmlElement LayerNode = Program.xml.CreateElement(pTable.GetRXClass().Name);
4092

    
4093
                    /**********************************************************************/
4094
                    /* Get a SmartPointer to a new SymbolTableIterator                    */
4095
                    /**********************************************************************/
4096

    
4097
                    /**********************************************************************/
4098
                    /* Step through the LayerTable                                        */
4099
                    /**********************************************************************/
4100
                    foreach (ObjectId id in pTable)
4101
                    {
4102
                        /********************************************************************/
4103
                        /* Open the LayerTableRecord for Reading                            */
4104
                        /********************************************************************/
4105
                        using (LayerTableRecord pRecord = (LayerTableRecord)id.Open(OpenMode.ForRead))
4106
                        {
4107
                            /********************************************************************/
4108
                            /* Dump the LayerTableRecord                                        */
4109
                            /********************************************************************/
4110
                            XmlElement RecordNode = Program.xml.CreateElement(pRecord.GetRXClass().Name);
4111

    
4112
                            XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
4113
                            NameAttr.Value = pRecord.Name.ToString();
4114
                            RecordNode.Attributes.SetNamedItem(NameAttr);
4115

    
4116
                            XmlAttribute IsUsedAttr = Program.xml.CreateAttribute("IsUsed");
4117
                            IsUsedAttr.Value = pRecord.IsUsed.ToString();
4118
                            RecordNode.Attributes.SetNamedItem(IsUsedAttr);
4119

    
4120
                            XmlAttribute IsOffAttr = Program.xml.CreateAttribute("IsOff");
4121
                            IsOffAttr.Value = pRecord.IsOff.ToString();
4122
                            RecordNode.Attributes.SetNamedItem(IsOffAttr);
4123

    
4124
                            XmlAttribute IsFrozenAttr = Program.xml.CreateAttribute("IsFrozen");
4125
                            IsFrozenAttr.Value = pRecord.IsFrozen.ToString();
4126
                            RecordNode.Attributes.SetNamedItem(IsFrozenAttr);
4127

    
4128
                            XmlAttribute IsLockedAttr = Program.xml.CreateAttribute("IsLocked");
4129
                            IsLockedAttr.Value = pRecord.IsLocked.ToString();
4130
                            RecordNode.Attributes.SetNamedItem(IsLockedAttr);
4131

    
4132
                            XmlAttribute ColorAttr = Program.xml.CreateAttribute("Color");
4133
                            ColorAttr.Value = pRecord.Color.ToString();
4134
                            RecordNode.Attributes.SetNamedItem(ColorAttr);
4135

    
4136
                            XmlAttribute LinetypeObjectIdAttr = Program.xml.CreateAttribute("LinetypeObjectId");
4137
                            LinetypeObjectIdAttr.Value = pRecord.LinetypeObjectId.ToString();
4138
                            RecordNode.Attributes.SetNamedItem(LinetypeObjectIdAttr);
4139

    
4140
                            XmlAttribute LineWeightAttr = Program.xml.CreateAttribute("LineWeight");
4141
                            LineWeightAttr.Value = pRecord.LineWeight.ToString();
4142
                            RecordNode.Attributes.SetNamedItem(LineWeightAttr);
4143

    
4144
                            XmlAttribute PlotStyleNameAttr = Program.xml.CreateAttribute("PlotStyleName");
4145
                            PlotStyleNameAttr.Value = pRecord.PlotStyleName.ToString();
4146
                            RecordNode.Attributes.SetNamedItem(PlotStyleNameAttr);
4147

    
4148
                            XmlAttribute IsPlottableAttr = Program.xml.CreateAttribute("IsPlottable");
4149
                            IsPlottableAttr.Value = pRecord.IsPlottable.ToString();
4150
                            RecordNode.Attributes.SetNamedItem(IsPlottableAttr);
4151

    
4152
                            XmlAttribute ViewportVisibilityDefaultAttr = Program.xml.CreateAttribute("ViewportVisibilityDefault");
4153
                            ViewportVisibilityDefaultAttr.Value = pRecord.ViewportVisibilityDefault.ToString();
4154
                            RecordNode.Attributes.SetNamedItem(ViewportVisibilityDefaultAttr);
4155

    
4156
                            dumpSymbolTableRecord(pRecord, indent, RecordNode);
4157
                            LayerNode.AppendChild(RecordNode);
4158
                        }
4159
                    }
4160

    
4161
                    node.AppendChild(LayerNode);
4162
                }
4163
            }
4164
        }
4165

    
4166
        public void dumpLinetypes(Database pDb, int indent, XmlNode node)
4167
        {
4168
            if (node != null)
4169
            {
4170
                /**********************************************************************/
4171
                /* Get a pointer to the LinetypeTable                            */
4172
                /**********************************************************************/
4173
                using (LinetypeTable pTable = (LinetypeTable)pDb.LinetypeTableId.Open(OpenMode.ForRead))
4174
                {
4175
                    XmlElement LinetypeNode = Program.xml.CreateElement(pTable.GetRXClass().Name);
4176

    
4177
                    /**********************************************************************/
4178
                    /* Step through the LinetypeTable                                     */
4179
                    /**********************************************************************/
4180
                    foreach (ObjectId id in pTable)
4181
                    {
4182
                        /*********************************************************************/
4183
                        /* Open the LinetypeTableRecord for Reading                          */
4184
                        /*********************************************************************/
4185
                        using (LinetypeTableRecord pRecord = (LinetypeTableRecord)id.Open(OpenMode.ForRead))
4186
                        {
4187
                            XmlElement RecordNode = Program.xml.CreateElement(pRecord.GetRXClass().Name);
4188

    
4189
                            XmlAttribute ObjectIdAttr = Program.xml.CreateAttribute("ObjectId");
4190
                            ObjectIdAttr.Value = pRecord.ObjectId.ToString();
4191
                            RecordNode.Attributes.SetNamedItem(ObjectIdAttr);
4192

    
4193
                            XmlAttribute NameAttr = Program.xml.CreateAttribute("Name");
4194
                            NameAttr.Value = pRecord.Name;
4195
                            RecordNode.Attributes.SetNamedItem(NameAttr);
4196

    
4197
                            XmlAttribute CommentsAttr = Program.xml.CreateAttribute("Comments");
4198
                            CommentsAttr.Value = pRecord.Comments;
4199
                            RecordNode.Attributes.SetNamedItem(CommentsAttr);
4200

    
4201
                            /********************************************************************/
4202
                            /* Dump the first line of record as in ACAD.LIN                     */
4203
                            /********************************************************************/
4204
                            string buffer = "*" + pRecord.Name;
4205
                            if (pRecord.Comments != "")
4206
                            {
4207
                                buffer = buffer + "," + pRecord.Comments;
4208
                            }
4209
                            writeLine(indent, buffer);
4210

    
4211
                            /********************************************************************/
4212
                            /* Dump the second line of record as in ACAD.LIN                    */
4213
                            /********************************************************************/
4214
                            if (pRecord.NumDashes > 0)
4215
                            {
4216
                                buffer = pRecord.IsScaledToFit ? "S" : "A";
4217
                                for (int i = 0; i < pRecord.NumDashes; i++)
4218
                                {
4219
                                    buffer = buffer + "," + pRecord.DashLengthAt(i);
4220
                                    int shapeNumber = pRecord.ShapeNumberAt(i);
4221
                                    string text = pRecord.TextAt(i);
4222

    
4223
                                    /**************************************************************/
4224
                                    /* Dump the Complex Line                                      */
4225
                                    /**************************************************************/
4226
                                    if (shapeNumber != 0 || text != "")
4227
                                    {
4228
                                        using (TextStyleTableRecord pTextStyle = (TextStyleTableRecord)(pRecord.ShapeStyleAt(i) == ObjectId.Null ? null : pRecord.ShapeStyleAt(i).Open(OpenMode.ForRead)))
4229
                                        {
4230
                                            if (shapeNumber != 0)
4231
                                            {
4232
                                                buffer = buffer + ",[" + shapeNumber + ",";
4233
                                                if (pTextStyle != null)
4234
                                                    buffer = buffer + pTextStyle.FileName;
4235
                                                else
4236
                                                    buffer = buffer + "NULL style";
4237
                                            }
4238
                                            else
4239
                                            {
4240
                                                buffer = buffer + ",[" + text + ",";
4241
                                                if (pTextStyle != null)
4242
                                                    buffer = buffer + pTextStyle.Name;
4243
                                                else
4244
                                                    buffer = buffer + "NULL style";
4245
                                            }
4246
                                        }
4247

    
4248
                                        if (pRecord.ShapeScaleAt(i) != 0.0)
4249
                                        {
4250
                                            buffer = buffer + ",S" + pRecord.ShapeScaleAt(i);
4251
                                        }
4252
                                        if (pRecord.ShapeRotationAt(i) != 0)
4253
                                        {
4254
                                            buffer = buffer + ",R" + toDegreeString(pRecord.ShapeRotationAt(i));
4255
                                        }
4256
                                        if (pRecord.ShapeOffsetAt(i).X != 0)
4257
                                        {
4258
                                            buffer = buffer + ",X" + pRecord.ShapeOffsetAt(i).X;
4259
                                        }
4260
                                        if (pRecord.ShapeOffsetAt(i).Y != 0)
4261
                                        {
4262
                                            buffer = buffer + ",Y" + pRecord.ShapeOffsetAt(i).Y;
4263
                                        }
4264
                                        buffer = buffer + "]";
4265
                                    }
4266
                                }
4267
                                writeLine(indent, buffer);
4268
                            }
4269
                            dumpSymbolTableRecord(pRecord, indent, node);
4270
                            LinetypeNode.AppendChild(RecordNode);
4271
                        }
4272
                    }
4273

    
4274
                    node.AppendChild(LinetypeNode);
4275
                }
4276
            }
4277
        }
4278

    
4279
        public void dumpRegApps(Database pDb, int indent)
4280
        {
4281
            /**********************************************************************/
4282
            /* Get a pointer to the RegAppTable                            */
4283
            /**********************************************************************/
4284
            using (RegAppTable pTable = (RegAppTable)pDb.RegAppTableId.Open(OpenMode.ForRead))
4285
            {
4286
                /**********************************************************************/
4287
                /* Dump the Description                                               */
4288
                /**********************************************************************/
4289
                writeLine();
4290
                writeLine(indent++, pTable.GetRXClass().Name);
4291

    
4292
                /**********************************************************************/
4293
                /* Step through the RegAppTable                                    */
4294
                /**********************************************************************/
4295
                foreach (ObjectId id in pTable)
4296
                {
4297
                    /*********************************************************************/
4298
                    /* Open the RegAppTableRecord for Reading                         */
4299
                    /*********************************************************************/
4300
                    using (RegAppTableRecord pRecord = (RegAppTableRecord)id.Open(OpenMode.ForRead))
4301
                    {
4302
                        /*********************************************************************/
4303
                        /* Dump the RegAppTableRecord                                      */
4304
                        /*********************************************************************/
4305
                        writeLine();
4306
                        writeLine(indent, pRecord.GetRXClass().Name);
4307
                        writeLine(indent, "Name", pRecord.Name);
4308
                    }
4309
                }
4310
            }
4311
        }
4312

    
4313
        public void dumpSymbolTableRecord(SymbolTableRecord pRecord, int indent, XmlNode node)
4314
        {
4315
            writeLine(indent, "Xref dependent", pRecord.IsDependent);
4316
            if (pRecord.IsDependent)
4317
            {
4318
                writeLine(indent, "Resolved", pRecord.IsResolved);
4319
            }
4320
        }
4321

    
4322
        public void dumpTextStyles(Database pDb, int indent, XmlNode node)
4323
        {
4324
            /**********************************************************************/
4325
            /* Get a SmartPointer to the TextStyleTable                            */
4326
            /**********************************************************************/
4327
            using (TextStyleTable pTable = (TextStyleTable)pDb.TextStyleTableId.Open(OpenMode.ForRead))
4328
            {
4329
                /**********************************************************************/
4330
                /* Dump the Description                                               */
4331
                /**********************************************************************/
4332
                writeLine();
4333
                writeLine(indent++, pTable.GetRXClass().Name);
4334

    
4335
                /**********************************************************************/
4336
                /* Step through the TextStyleTable                                    */
4337
                /**********************************************************************/
4338
                foreach (ObjectId id in pTable)
4339
                {
4340
                    /*********************************************************************/
4341
                    /* Open the TextStyleTableRecord for Reading                         */
4342
                    /*********************************************************************/
4343
                    using (TextStyleTableRecord pRecord = (TextStyleTableRecord)id.Open(OpenMode.ForRead))
4344
                    {
4345
                        /*********************************************************************/
4346
                        /* Dump the TextStyleTableRecord                                      */
4347
                        /*********************************************************************/
4348
                        writeLine();
4349
                        writeLine(indent, pRecord.GetRXClass().Name);
4350
                        writeLine(indent, "Name", pRecord.Name);
4351
                        writeLine(indent, "Shape File", pRecord.IsShapeFile);
4352
                        writeLine(indent, "Text Height", pRecord.TextSize);
4353
                        writeLine(indent, "Width Factor", pRecord.XScale);
4354
                        writeLine(indent, "Obliquing Angle", toDegreeString(pRecord.ObliquingAngle));
4355
                        writeLine(indent, "Backwards", (pRecord.FlagBits & 2));
4356
                        writeLine(indent, "Vertical", pRecord.IsVertical);
4357
                        writeLine(indent, "Upside Down", (pRecord.FlagBits & 4));
4358
                        writeLine(indent, "Filename", shortenPath(pRecord.FileName));
4359
                        writeLine(indent, "BigFont Filename", shortenPath(pRecord.BigFontFileName));
4360

    
4361
                        FontDescriptor fd = pRecord.Font;
4362
                        writeLine(indent, "Typeface", fd.TypeFace);
4363
                        writeLine(indent, "Character Set", fd.CharacterSet);
4364
                        writeLine(indent, "Bold", fd.Bold);
4365
                        writeLine(indent, "Italic", fd.Italic);
4366
                        writeLine(indent, "Font Pitch & Family", toHexString(fd.PitchAndFamily));
4367
                        dumpSymbolTableRecord(pRecord, indent, node);
4368
                    }
4369
                }
4370
            }
4371
        }
4372
        public void dumpAbstractViewTableRecord(AbstractViewTableRecord pView, int indent, XmlNode node)
4373
        {
4374
            /*********************************************************************/
4375
            /* Dump the AbstractViewTableRecord                                  */
4376
            /*********************************************************************/
4377
            writeLine(indent, "Back Clip Dist", pView.BackClipDistance);
4378
            writeLine(indent, "Back Clip Enabled", pView.BackClipEnabled);
4379
            writeLine(indent, "Front Clip Dist", pView.FrontClipDistance);
4380
            writeLine(indent, "Front Clip Enabled", pView.FrontClipEnabled);
4381
            writeLine(indent, "Front Clip at Eye", pView.FrontClipAtEye);
4382
            writeLine(indent, "Elevation", pView.Elevation);
4383
            writeLine(indent, "Height", pView.Height);
4384
            writeLine(indent, "Width", pView.Width);
4385
            writeLine(indent, "Lens Length", pView.LensLength);
4386
            writeLine(indent, "Render Mode", pView.RenderMode);
4387
            writeLine(indent, "Perspective", pView.PerspectiveEnabled);
4388
            writeLine(indent, "UCS Name", pView.UcsName);
4389

    
4390
            //writeLine(indent, "UCS Orthographic", pView.IsUcsOrthographic(orthoUCS));
4391
            //writeLine(indent, "Orthographic UCS", orthoUCS);
4392

    
4393
            if (pView.UcsOrthographic != OrthographicView.NonOrthoView)
4394
            {
4395
                writeLine(indent, "UCS Origin", pView.Ucs.Origin);
4396
                writeLine(indent, "UCS x-Axis", pView.Ucs.Xaxis);
4397
                writeLine(indent, "UCS y-Axis", pView.Ucs.Yaxis);
4398
            }
4399

    
4400
            writeLine(indent, "Target", pView.Target);
4401
            writeLine(indent, "View Direction", pView.ViewDirection);
4402
            writeLine(indent, "Twist Angle", toDegreeString(pView.ViewTwist));
4403
            dumpSymbolTableRecord(pView, indent, node);
4404
        }
4405
        public void dumpDimAssoc(DBObject pObject, int indent)
4406
        {
4407

    
4408
        }
4409
        public void dumpMLineStyles(Database pDb, int indent)
4410
        {
4411
            using (DBDictionary pDictionary = (DBDictionary)pDb.MLStyleDictionaryId.Open(OpenMode.ForRead))
4412
            {
4413
                /**********************************************************************/
4414
                /* Dump the Description                                               */
4415
                /**********************************************************************/
4416
                writeLine();
4417
                writeLine(indent++, pDictionary.GetRXClass().Name);
4418

    
4419
                /**********************************************************************/
4420
                /* Step through the MlineStyle dictionary                             */
4421
                /**********************************************************************/
4422
                DbDictionaryEnumerator e = pDictionary.GetEnumerator();
4423
                while (e.MoveNext())
4424
                {
4425
                    try
4426
                    {
4427
                        using (MlineStyle pEntry = (MlineStyle)e.Value.Open(OpenMode.ForRead))
4428
                        {
4429
                            /*********************************************************************/
4430
                            /* Dump the MLineStyle dictionary entry                              */
4431
                            /*********************************************************************/
4432
                            writeLine();
4433
                            writeLine(indent, pEntry.GetRXClass().Name);
4434
                            writeLine(indent, "Name", pEntry.Name);
4435
                            writeLine(indent, "Description", pEntry.Description);
4436
                            writeLine(indent, "Start Angle", toDegreeString(pEntry.StartAngle));
4437
                            writeLine(indent, "End Angle", toDegreeString(pEntry.EndAngle));
4438
                            writeLine(indent, "Start Inner Arcs", pEntry.StartInnerArcs);
4439
                            writeLine(indent, "End Inner Arcs", pEntry.EndInnerArcs);
4440
                            writeLine(indent, "Start Round Cap", pEntry.StartRoundCap);
4441
                            writeLine(indent, "End Round Cap", pEntry.EndRoundCap);
4442
                            writeLine(indent, "Start Square Cap", pEntry.StartRoundCap);
4443
                            writeLine(indent, "End Square Cap", pEntry.EndRoundCap);
4444
                            writeLine(indent, "Show Miters", pEntry.ShowMiters);
4445
                            /*********************************************************************/
4446
                            /* Dump the elements                                                 */
4447
                            /*********************************************************************/
4448
                            if (pEntry.Elements.Count > 0)
4449
                            {
4450
                                writeLine(indent, "Elements:");
4451
                            }
4452
                            int i = 0;
4453
                            foreach (MlineStyleElement el in pEntry.Elements)
4454
                            {
4455
                                writeLine(indent, "Index", (i++));
4456
                                writeLine(indent + 1, "Offset", el.Offset);
4457
                                writeLine(indent + 1, "Color", el.Color);
4458
                                writeLine(indent + 1, "Linetype", el.LinetypeId);
4459
                            }
4460
                        }
4461
                    }
4462
                    catch (System.Exception)
4463
                    {
4464
                    }
4465
                }
4466
            }
4467
        }
4468
        public void dumpObject(ObjectId id, string itemName, int indent)
4469
        {
4470
            using (DBObject pObject = id.Open(OpenMode.ForRead))
4471
            {
4472
                /**********************************************************************/
4473
                /* Dump the item name and class name                                  */
4474
                /**********************************************************************/
4475
                if (pObject is DBDictionary)
4476
                {
4477
                    writeLine();
4478
                }
4479
                writeLine(indent++, itemName, pObject.GetRXClass().Name);
4480

    
4481
                /**********************************************************************/
4482
                /* Dispatch                                                           */
4483
                /**********************************************************************/
4484
                if (pObject is DBDictionary)
4485
                {
4486
                    /********************************************************************/
4487
                    /* Dump the dictionary                                               */
4488
                    /********************************************************************/
4489
                    DBDictionary pDic = (DBDictionary)pObject;
4490

    
4491
                    /********************************************************************/
4492
                    /* Get a pointer to a new DictionaryIterator                   */
4493
                    /********************************************************************/
4494
                    DbDictionaryEnumerator pIter = pDic.GetEnumerator();
4495

    
4496
                    /********************************************************************/
4497
                    /* Step through the Dictionary                                      */
4498
                    /********************************************************************/
4499
                    while (pIter.MoveNext())
4500
                    {
4501
                        /******************************************************************/
4502
                        /* Dump the Dictionary object                                     */
4503
                        /******************************************************************/
4504
                        dumpObject(pIter.Value, pIter.Key, indent);
4505
                    }
4506
                }
4507
                else if (pObject is Xrecord)
4508
                {
4509
                    /********************************************************************/
4510
                    /* Dump an Xrecord                                                  */
4511
                    /********************************************************************/
4512
                    Xrecord pXRec = (Xrecord)pObject;
4513
                    dumpXdata(pXRec.Data, indent);
4514
                }
4515
            }
4516
        }
4517

    
4518
        public void dumpUCSTable(Database pDb, int indent, XmlNode node)
4519
        {
4520
            /**********************************************************************/
4521
            /* Get a pointer to the UCSTable                               */
4522
            /**********************************************************************/
4523
            using (UcsTable pTable = (UcsTable)pDb.UcsTableId.Open(OpenMode.ForRead))
4524
            {
4525
                /**********************************************************************/
4526
                /* Dump the Description                                               */
4527
                /**********************************************************************/
4528
                writeLine();
4529
                writeLine(indent++, pTable.GetRXClass().Name);
4530

    
4531
                /**********************************************************************/
4532
                /* Step through the UCSTable                                          */
4533
                /**********************************************************************/
4534
                foreach (ObjectId id in pTable)
4535
                {
4536
                    /********************************************************************/
4537
                    /* Open the UCSTableRecord for Reading                            */
4538
                    /********************************************************************/
4539
                    using (UcsTableRecord pRecord = (UcsTableRecord)id.Open(OpenMode.ForRead))
4540
                    {
4541
                        /********************************************************************/
4542
                        /* Dump the UCSTableRecord                                        */
4543
                        /********************************************************************/
4544
                        writeLine();
4545
                        writeLine(indent, pRecord.GetRXClass().Name);
4546
                        writeLine(indent, "Name", pRecord.Name);
4547
                        writeLine(indent, "UCS Origin", pRecord.Origin);
4548
                        writeLine(indent, "UCS x-Axis", pRecord.XAxis);
4549
                        writeLine(indent, "UCS y-Axis", pRecord.YAxis);
4550
                        dumpSymbolTableRecord(pRecord, indent, node);
4551
                    }
4552
                }
4553
            }
4554
        }
4555
        public void dumpViewports(Database pDb, int indent, XmlNode node)
4556
        {
4557
            /**********************************************************************/
4558
            /* Get a pointer to the ViewportTable                            */
4559
            /**********************************************************************/
4560
            using (ViewportTable pTable = (ViewportTable)pDb.ViewportTableId.Open(OpenMode.ForRead))
4561
            {
4562
                /**********************************************************************/
4563
                /* Dump the Description                                               */
4564
                /**********************************************************************/
4565
                writeLine();
4566
                writeLine(indent++, pTable.GetRXClass().Name);
4567

    
4568
                /**********************************************************************/
4569
                /* Step through the ViewportTable                                    */
4570
                /**********************************************************************/
4571
                foreach (ObjectId id in pTable)
4572
                {
4573
                    /*********************************************************************/
4574
                    /* Open the ViewportTableRecord for Reading                          */
4575
                    /*********************************************************************/
4576
                    using (ViewportTableRecord pRecord = (ViewportTableRecord)id.Open(OpenMode.ForRead))
4577
                    {
4578
                        /*********************************************************************/
4579
                        /* Dump the ViewportTableRecord                                      */
4580
                        /*********************************************************************/
4581
                        writeLine();
4582
                        writeLine(indent, pRecord.GetRXClass().Name);
4583
                        writeLine(indent, "Name", pRecord.Name);
4584
                        writeLine(indent, "Circle Sides", pRecord.CircleSides);
4585
                        writeLine(indent, "Fast Zooms Enabled", pRecord.FastZoomsEnabled);
4586
                        writeLine(indent, "Grid Enabled", pRecord.GridEnabled);
4587
                        writeLine(indent, "Grid Increments", pRecord.GridIncrements);
4588
                        writeLine(indent, "Icon at Origin", pRecord.IconAtOrigin);
4589
                        writeLine(indent, "Icon Enabled", pRecord.IconEnabled);
4590
                        writeLine(indent, "Iso snap Enabled", pRecord.IsometricSnapEnabled);
4591
                        writeLine(indent, "Iso Snap Pair", pRecord.SnapPair);
4592
                        writeLine(indent, "UCS Saved w/Vport", pRecord.UcsSavedWithViewport);
4593
                        writeLine(indent, "UCS follow", pRecord.UcsFollowMode);
4594
                        writeLine(indent, "Lower-Left Corner", pRecord.LowerLeftCorner);
4595
                        writeLine(indent, "Upper-Right Corner", pRecord.UpperRightCorner);
4596
                        writeLine(indent, "Snap Angle", toDegreeString(pRecord.SnapAngle));
4597
                        writeLine(indent, "Snap Base", pRecord.SnapBase);
4598
                        writeLine(indent, "Snap Enabled", pRecord.SnapEnabled);
4599
                        writeLine(indent, "Snap Increments", pRecord.SnapIncrements);
4600
                        dumpAbstractViewTableRecord(pRecord, indent, node);
4601
                    }
4602
                }
4603
            }
4604
        }
4605

    
4606
        /************************************************************************/
4607
        /* Dump the ViewTable                                                   */
4608
        /************************************************************************/
4609
        public void dumpViews(Database pDb, int indent, XmlNode node)
4610
        {
4611
            /**********************************************************************/
4612
            /* Get a pointer to the ViewTable                                */
4613
            /**********************************************************************/
4614
            using (ViewTable pTable = (ViewTable)pDb.ViewTableId.Open(OpenMode.ForRead))
4615
            {
4616
                /**********************************************************************/
4617
                /* Dump the Description                                               */
4618
                /**********************************************************************/
4619
                writeLine();
4620
                writeLine(indent++, pTable.GetRXClass().Name);
4621

    
4622
                /**********************************************************************/
4623
                /* Step through the ViewTable                                         */
4624
                /**********************************************************************/
4625
                foreach (ObjectId id in pTable)
4626
                {
4627
                    /*********************************************************************/
4628
                    /* Open the ViewTableRecord for Reading                              */
4629
                    /*********************************************************************/
4630
                    using (ViewTableRecord pRecord = (ViewTableRecord)id.Open(OpenMode.ForRead))
4631
                    {
4632
                        /*********************************************************************/
4633
                        /* Dump the ViewTableRecord                                          */
4634
                        /*********************************************************************/
4635
                        writeLine();
4636
                        writeLine(indent, pRecord.GetRXClass().Name);
4637
                        writeLine(indent, "Name", pRecord.Name);
4638
                        writeLine(indent, "Category Name", pRecord.CategoryName);
4639
                        writeLine(indent, "Layer State", pRecord.LayerState);
4640

    
4641
                        string layoutName = "";
4642
                        if (!pRecord.Layout.IsNull)
4643
                        {
4644
                            using (Layout pLayout = (Layout)pRecord.Layout.Open(OpenMode.ForRead))
4645
                                layoutName = pLayout.LayoutName;
4646
                        }
4647
                        writeLine(indent, "Layout Name", layoutName);
4648
                        writeLine(indent, "PaperSpace View", pRecord.IsPaperspaceView);
4649
                        writeLine(indent, "Associated UCS", pRecord.IsUcsAssociatedToView);
4650
                        writeLine(indent, "PaperSpace View", pRecord.ViewAssociatedToViewport);
4651
                        dumpAbstractViewTableRecord(pRecord, indent, node);
4652
                    }
4653
                }
4654
            }
4655
        }
4656
        /************************************************************************/
4657
        /* Dump Xdata                                                           */
4658
        /************************************************************************/
4659
        public void dumpXdata(ResultBuffer xIter, int indent)
4660
        {
4661
            if (xIter == null)
4662
                return;
4663
            writeLine(indent++, "Xdata:");
4664
            /**********************************************************************/
4665
            /* Step through the ResBuf chain                                      */
4666
            /**********************************************************************/
4667
            foreach (TypedValue resbuf in xIter)
4668
            {
4669
                writeLine(indent, resbuf);
4670
            }
4671
        }
4672
    }
4673
    class ExProtocolExtension
4674
    {
4675
    }
4676

    
4677
    class Program
4678
    {
4679
        public static XmlDocument xml = null;
4680
        public static double OffsetX = 0;
4681
        public static double OffsetY = 0;
4682
        public static double Scale = 0;
4683
        public static double getDrawing = 0;
4684
        public static List<string> Layers = new List<string>() { "MINOR", "INSTR", "ELECT", "INSTRUMENT", "LINES" };
4685

    
4686
        static void Main(string[] args)
4687
        {
4688
            /********************************************************************/
4689
            /* Initialize Drawings.NET.                                         */
4690
            /********************************************************************/
4691
            bool bSuccess = true;
4692
            Teigha.Runtime.Services.odActivate(ActivationData.userInfo, ActivationData.userSignature);
4693
            using (Teigha.Runtime.Services srv = new Teigha.Runtime.Services())
4694
            {
4695
                try
4696
                {
4697
                    HostApplicationServices.Current = new OdaMgdMViewApp.HostAppServ();
4698
                    /**********************************************************************/
4699
                    /* Display the Product and Version that created the executable        */
4700
                    /**********************************************************************/
4701
                    Console.WriteLine("\nReadExMgd developed using {0} ver {1}", HostApplicationServices.Current.Product, HostApplicationServices.Current.VersionString);
4702

    
4703
                    if (args.Length != 5)
4704
                    {
4705
                        Console.WriteLine("\n\n\tusage: OdReadExMgd <filename> <OffsetX> <OffsetY> <Scale> <GenDrawing>");
4706
                        Console.WriteLine("\nPress ENTER to continue...\n");
4707
                        Console.ReadLine();
4708
                        bSuccess = false;
4709
                    }
4710
                    else
4711
                    {
4712
                        Console.WriteLine("\n File Name = " + args[0]);
4713

    
4714
                        double.TryParse(args[1], out Program.OffsetX);
4715
                        double.TryParse(args[2], out Program.OffsetY);
4716
                        double.TryParse(args[3], out Program.Scale);
4717
                        double.TryParse(args[4], out Program.getDrawing);
4718
                        Program.xml = new XmlDocument();
4719
                        {
4720
                            XmlNode root = xml.CreateElement("ID2");
4721
                            Program.xml.AppendChild(root);
4722

    
4723
                            /******************************************************************/
4724
                            /* Create a database and load the drawing into it.                
4725
                            /* first parameter means - do not initialize database- it will be read from file
4726
                             * second parameter is not used by Teigha.NET Classic - it is left for ARX compatibility.
4727
                             * Note the 'using' clause - generally, wrappers should disposed after use, 
4728
                             * to close underlying database objects
4729
                            /******************************************************************/
4730
                            using (Database pDb = new Database(false, false))
4731
                            {
4732
                                pDb.ReadDwgFile(args[0], FileShare.Read, true, "");
4733
                                HostApplicationServices.WorkingDatabase = pDb;
4734
                                /****************************************************************/
4735
                                /* Display the File Version                                     */
4736
                                /****************************************************************/
4737
                                Console.WriteLine("File Version: {0}", pDb.OriginalFileVersion);
4738
                                /****************************************************************/
4739
                                /* Dump the database                                            */
4740
                                /****************************************************************/
4741
                                DbDumper dumper = new DbDumper();
4742
                                dumper.ExplodeAndPurgeNestedBlocks(pDb);
4743
                                if (Program.getDrawing == 1)
4744
                                {
4745
                                    dumper.ExportPNG(pDb, args[0]);
4746
                                    dumper.ExportPDF(pDb, args[0]);
4747
                                }
4748

    
4749
                                dumper.dump(pDb, 0, Program.xml.DocumentElement);
4750
                            }
4751
                            Program.xml.Save(Path.Combine(Path.GetDirectoryName(args[0]), Path.GetFileNameWithoutExtension(args[0]) + ".xml"));
4752
                        }
4753
                    }
4754
                }
4755
                /********************************************************************/
4756
                /* Display the error                                                */
4757
                /********************************************************************/
4758
                catch (System.Exception e)
4759
                {
4760
                    bSuccess = false;
4761
                    Console.WriteLine("Teigha?NET for .dwg files Error: " + e.Message);
4762
                }
4763

    
4764
                if (bSuccess)
4765
                    Console.WriteLine("OdReadExMgd Finished Successfully");
4766
            }
4767
        }
4768
    }
4769
}
클립보드 이미지 추가 (최대 크기: 500 MB)