프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / OdReadExMgd / OdReadExMgd-.cs @ db995e28

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

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

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

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

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

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

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

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

    
120
      const int tabSize = 2;
121

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

    
127
      /**********************************************************************/
128
      /* If rightString is not specified, just output the indented          */
129
      /* leftString. Otherwise, fill the space between leftString and       */
130
      /* rightString with leader characters.                                */
131
      /**********************************************************************/
132
      if (rightString == null || ((rightString is string) && ((string)rightString) == ""))
133
      {
134
        Console.WriteLine(newleftString);
135
      }
136
      else
137
      {
138
        int leaders = colWidth - newleftString.Length;
139
        if (leaders > 0)
140
        {
141
          Console.WriteLine(newleftString + leader.Substring(newleftString.Length, leaders) + rightString.ToString());
142
        }
143
        else
144
        {
145
          Console.WriteLine(newleftString + ' ' + rightString.ToString());
146
        }
147
      }
148
    }
149
    static void writeLine(int indent, object leftString, object rightString)
150
    {
151
      writeLine(indent, leftString, rightString, 38);
152
    }
153
    static void writeLine(int indent, object leftString)
154
    {
155
      writeLine(indent, leftString, null, 38);
156
    }
157
    static void writeLine()
158
    {
159
      Console.WriteLine();
160
    }
161
    static void dumpEntityData(Entity pEnt, int indent)
162
    {
163
      try
164
      {
165
        Extents3d ext = pEnt.GeometricExtents;
166
        writeLine(indent, "Min Extents", ext.MinPoint);
167
        writeLine(indent, "Max Extents", ext.MaxPoint);
168
      }
169
      catch (System.Exception)
170
      {
171
      }
172
      writeLine(indent, "Layer", pEnt.Layer);
173
      writeLine(indent, "Color Index", pEnt.ColorIndex);
174
      writeLine(indent, "Color", pEnt.Color);
175
      writeLine(indent, "Linetype", pEnt.Linetype);
176
      writeLine(indent, "LTscale", pEnt.LinetypeScale);
177
      writeLine(indent, "Lineweight", pEnt.LineWeight);
178
      writeLine(indent, "Plot Style", pEnt.PlotStyleName);
179
      writeLine(indent, "Transparency Method", pEnt.Transparency);
180
      writeLine(indent, "Visibility", pEnt.Visible);
181
      writeLine(indent, "Planar", pEnt.IsPlanar);
182

    
183
      if (pEnt.IsPlanar)
184
      {
185
        try
186
        {
187
          CoordinateSystem3d cs = (CoordinateSystem3d)pEnt.GetPlane().GetCoordinateSystem();
188
          writeLine(indent + 1, "Origin", cs.Origin);
189
          writeLine(indent + 1, "u-Axis", cs.Xaxis);
190
          writeLine(indent + 1, "v-Axis", cs.Yaxis);
191
        }
192
        catch (System.Exception ex)
193
        {
194
          writeLine(indent + 1, "pEnt.GetPlane().GetCoordinateSystem() failed", ex.Message);
195
        }
196
      }
197
    }
198

    
199
    /************************************************************************/
200
    /* Dump Text data                                                       */
201
    /************************************************************************/
202
    static void dumpTextData(DBText pText, int indent)
203
    {
204
      writeLine(indent, "Text String", pText.TextString);
205
      writeLine(indent, "Text Position", pText.Position);
206
      writeLine(indent, "Default Alignment", pText.IsDefaultAlignment);
207
      writeLine(indent, "Alignment Point", pText.AlignmentPoint);
208
      writeLine(indent, "Height", pText.Height);
209
      writeLine(indent, "Rotation", toDegreeString(pText.Rotation));
210
      writeLine(indent, "Horizontal Mode", pText.HorizontalMode);
211
      writeLine(indent, "Vertical Mode", pText.VerticalMode);
212
      writeLine(indent, "Mirrored in X", pText.IsMirroredInX);
213
      writeLine(indent, "Mirrored in Y", pText.IsMirroredInY);
214
      writeLine(indent, "Oblique", toDegreeString(pText.Oblique));
215
      writeLine(indent, "Text Style", pText.TextStyleName);
216
      writeLine(indent, "Width Factor", pText.WidthFactor);
217

    
218
      writeLine(indent, "Normal", pText.Normal);
219
      writeLine(indent, "Thickness", pText.Thickness);
220
      dumpEntityData(pText, indent);
221

    
222
            /// write text information to xml file
223
        if(Program.xml != null)
224
        {
225
            XmlNode text = Program.xml.CreateElement("Text");
226
                XmlNode loc = Program.xml.CreateElement("Location");
227
                loc.InnerText = string.Format("{0},{1}", pText.Position.X * Program.Scale + Program.OffsetX, pText.Position.Y * Program.Scale + Program.OffsetY + pText.Height * Program.Scale);
228
                text.AppendChild(loc);
229
                XmlNode value = Program.xml.CreateElement("Value");
230
                value.InnerText = pText.TextString.Replace("%%U", "");
231
                text.AppendChild(value);
232
                XmlNode angle = Program.xml.CreateElement("Angle");
233
                angle.InnerText = pText.Rotation.ToString();
234
                text.AppendChild(angle);
235
                XmlNode width = Program.xml.CreateElement("Width");
236
                width.InnerText = String.Format("{0}", pText.WidthFactor * pText.Height * pText.TextString.Length * Program.Scale);
237
                text.AppendChild(width);
238
                XmlNode height = Program.xml.CreateElement("Height");
239
                height.InnerText = (pText.Height * Program.Scale).ToString();
240
                text.AppendChild(height);
241
            Program.xml.DocumentElement.AppendChild(text);
242
        }
243
    }
244

    
245
    /************************************************************************/
246
    /* Dump Attribute data                                                  */
247
    /************************************************************************/
248
    static void dumpAttributeData(int indent, AttributeReference pAttr, int i)
249
    {
250
      writeLine(indent++, pAttr.GetRXClass().Name, i);
251
      writeLine(indent, "Handle", pAttr.Handle);
252
      writeLine(indent, "Tag", pAttr.Tag);
253
      writeLine(indent, "Field Length", pAttr.FieldLength);
254
      writeLine(indent, "Invisible", pAttr.Invisible);
255
      writeLine(indent, "Preset", pAttr.IsPreset);
256
      writeLine(indent, "Verifiable", pAttr.IsVerifiable);
257
      writeLine(indent, "Locked in Position", pAttr.LockPositionInBlock);
258
      writeLine(indent, "Constant", pAttr.IsConstant);
259
      dumpTextData(pAttr, indent);
260
    }
261

    
262
    /************************************************************************/
263
    /* Dump Block Reference Data                                             */
264
    /************************************************************************/
265
    static void dumpBlockRefData(BlockReference pBlkRef, int indent)
266
    {
267
      writeLine(indent, "Position", pBlkRef.Position);
268
      writeLine(indent, "Rotation", toDegreeString(pBlkRef.Rotation));
269
      writeLine(indent, "Scale Factors", pBlkRef.ScaleFactors);
270
      writeLine(indent, "Normal", pBlkRef.Normal);
271
      writeLine(indent, "Name", pBlkRef.Name);
272

    
273
      Matrix3d blockTransform = pBlkRef.BlockTransform;
274
      CoordinateSystem3d cs = blockTransform.CoordinateSystem3d;
275
      writeLine(indent + 1, "Origin", cs.Origin);
276
      writeLine(indent + 1, "u-Axis", cs.Xaxis);
277
      writeLine(indent + 1, "v-Axis", cs.Yaxis);
278
      writeLine(indent + 1, "z-Axis", cs.Zaxis);
279

    
280
      dumpEntityData(pBlkRef, indent);
281

    
282
      /**********************************************************************/
283
      /* Dump the attributes                                                */
284
      /**********************************************************************/
285
      int i = 0;
286
      AttributeCollection attCol = pBlkRef.AttributeCollection;
287
      foreach (ObjectId id in attCol)
288
      {
289
        try
290
        {
291
          using (AttributeReference pAttr = (AttributeReference)id.Open(OpenMode.ForRead))
292
            dumpAttributeData(indent, pAttr, i++);
293
        }
294
        catch (System.Exception)
295
        {
296

    
297
        }
298
      }
299
    }
300
    /************************************************************************/
301
    /* Dump data common to all OdDbCurves                                   */
302
    /************************************************************************/
303
    static void dumpCurveData(Entity pEnt, int indent)
304
    {
305
      Curve pEntity = (Curve)pEnt;
306
      try
307
      {
308
        writeLine(indent, "Start Point", pEntity.StartPoint);
309
        writeLine(indent, "End Point", pEntity.EndPoint);
310
      }
311
      catch (System.Exception)
312
      {
313
      }
314
      writeLine(indent, "Closed", pEntity.Closed);
315
      writeLine(indent, "Periodic", pEntity.IsPeriodic);
316

    
317
      try
318
      {
319
        writeLine(indent, "Area", pEntity.Area);
320
      }
321
      catch (System.Exception)
322
      {
323
      }
324
      dumpEntityData(pEntity, indent);
325
    }
326
    /************************************************************************/
327
    /* Dump Dimension data                                                  */
328
    /************************************************************************/
329
    static void dumpDimData(Dimension pDim, int indent)
330
    {
331
      writeLine(indent, "Measurement", pDim.CurrentMeasurement);
332
      writeLine(indent, "Dimension Text", pDim.DimensionText);
333

    
334
      if (pDim.CurrentMeasurement >= 0.0)
335
      {
336
        writeLine(indent, "Formatted Measurement", pDim.FormatMeasurement(pDim.CurrentMeasurement, pDim.DimensionText));
337
      }
338
      if (pDim.DimBlockId.IsNull)
339
      {
340
        writeLine(indent, "Dimension Block NULL");
341
      }
342
      else
343
      {
344
        using (BlockTableRecord btr = (BlockTableRecord)pDim.DimBlockId.Open(OpenMode.ForRead))
345
          writeLine(indent, "Dimension Block Name", btr.Name);
346
      }
347
      writeLine(indent + 1, "Position", pDim.DimBlockPosition);
348
      writeLine(indent, "Text Position", pDim.TextPosition);
349
      writeLine(indent, "Text Rotation", toDegreeString(pDim.TextRotation));
350
      writeLine(indent, "Dimension Style", pDim.DimensionStyleName);
351
      writeLine(indent, "Background Text Color", pDim.Dimtfillclr);
352
      writeLine(indent, "BackgroundText Flags", pDim.Dimtfill);
353
      writeLine(indent, "Extension Line 1 Linetype", pDim.Dimltex1);
354
      writeLine(indent, "Extension Line 2 Linetype", pDim.Dimltex2);
355
      writeLine(indent, "Dimension Line Linetype", pDim.Dimltype);
356
      writeLine(indent, "Horizontal Rotation", toDegreeString(pDim.HorizontalRotation));
357
      writeLine(indent, "Elevation", pDim.Elevation);
358
      writeLine(indent, "Normal", pDim.Normal);
359
      dumpEntityData(pDim, indent);
360
    }
361
    /************************************************************************/
362
    /* 2 Line Angular Dimension Dumper                                      */
363
    /************************************************************************/
364
    static void dump(LineAngularDimension2 pDim, int indent)
365
    {
366
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
367
      writeLine(indent, "Arc Point", pDim.ArcPoint);
368
      writeLine(indent, "Extension Line 1 Start", pDim.XLine1Start);
369
      writeLine(indent, "Extension Line 1 End", pDim.XLine1End);
370
      writeLine(indent, "Extension Line 2 Start", pDim.XLine2Start);
371
      writeLine(indent, "Extension Line 2 End", pDim.XLine2End);
372
      dumpDimData(pDim, indent);
373
    }
374
    /************************************************************************/
375
    /* Dump 2D Vertex data                                                  */
376
    /************************************************************************/
377
    static void dump2dVertex(int indent, Vertex2d pVertex, int i)
378
    {
379
      writeLine(indent++, pVertex.GetRXClass().Name, i);
380
      writeLine(indent, "Handle", pVertex.Handle);
381
      writeLine(indent, "Vertex Type", pVertex.VertexType);
382
      writeLine(indent, "Position", pVertex.Position);
383
      writeLine(indent, "Start Width", pVertex.StartWidth);
384
      writeLine(indent, "End Width", pVertex.EndWidth);
385
      writeLine(indent, "Bulge", pVertex.Bulge);
386

    
387
      if (pVertex.Bulge != 0)
388
      {
389
        writeLine(indent, "Bulge Angle", toDegreeString(4 * Math.Atan(pVertex.Bulge)));
390
      }
391

    
392
      writeLine(indent, "Tangent Used", pVertex.TangentUsed);
393
      if (pVertex.TangentUsed)
394
      {
395
        writeLine(indent, "Tangent", pVertex.Tangent);
396
      }
397
    }
398
    /************************************************************************/
399
    /* 2D Polyline Dumper                                                   */
400
    /************************************************************************/
401
    static void dump(Polyline2d pPolyline, int indent)
402
    {
403
      writeLine(indent++, pPolyline.GetRXClass().Name, pPolyline.Handle);
404
      writeLine(indent, "Elevation", pPolyline.Elevation);
405
      writeLine(indent, "Normal", pPolyline.Normal);
406
      writeLine(indent, "Thickness", pPolyline.Thickness);
407
      /********************************************************************/
408
      /* Dump the vertices                                                */
409
      /********************************************************************/
410
      int i = 0;
411
      foreach (ObjectId obj in pPolyline)
412
      {
413
        using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead))
414
        {
415
          if (dbObj is Vertex2d)
416
          {
417
            dump2dVertex(indent, (Vertex2d)dbObj, i++);
418
          }
419
        }
420
      }
421
      dumpCurveData(pPolyline, indent);
422
    }
423

    
424

    
425
    /************************************************************************/
426
    /* Dump 3D Polyline Vertex data                                         */
427
    /************************************************************************/
428
    void dump3dPolylineVertex(int indent, PolylineVertex3d pVertex, int i)
429
    {
430
      writeLine(indent++, pVertex.GetRXClass().Name, i);
431
      writeLine(indent, "Handle", pVertex.Handle);
432
      writeLine(indent, "Type", pVertex.VertexType);
433
      writeLine(indent, "Position", pVertex.Position);
434
    }
435

    
436
    /************************************************************************/
437
    /* 3D Polyline Dumper                                                   */
438
    /************************************************************************/
439
    void dump(Polyline3d pPolyline, int indent)
440
    {
441
      writeLine(indent++, pPolyline.GetRXClass().Name, pPolyline.Handle);
442
      /********************************************************************/
443
      /* Dump the vertices                                                */
444
      /********************************************************************/
445
      int i = 0;
446
      foreach (ObjectId obj in pPolyline)
447
      {
448
        using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead))
449
        {
450
          if (dbObj is PolylineVertex3d)
451
          {
452
            dump3dPolylineVertex(indent, (PolylineVertex3d)dbObj, i++);
453
          }
454
        }
455
      }
456
      dumpCurveData(pPolyline, indent);
457
    }
458

    
459

    
460
    /************************************************************************/
461
    /* 3DSolid Dumper                                                       */
462
    /************************************************************************/
463
    void dump(Solid3d pSolid, int indent)
464
    {
465
      writeLine(indent++, pSolid.GetRXClass().Name, pSolid.Handle);
466
      dumpEntityData(pSolid, indent);
467
    }
468

    
469

    
470
    /************************************************************************/
471
    /* 3 Point Angular Dimension Dumper                                     */
472
    /************************************************************************/
473
    void dump(Point3AngularDimension pDim, int indent)
474
    {
475
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
476
      writeLine(indent, "Arc Point", pDim.ArcPoint);
477
      writeLine(indent, "Center Point", pDim.CenterPoint);
478
      writeLine(indent, "Extension Line 1 Point", pDim.XLine1Point);
479
      writeLine(indent, "Extension Line 2 Point", pDim.XLine2Point);
480
      dumpDimData(pDim, indent);
481
    }
482

    
483
    /************************************************************************/
484
    /* Aligned Dimension Dumper                                             */
485
    /************************************************************************/
486
    void dump(AlignedDimension pDim, int indent)
487
    {
488
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
489
      writeLine(indent, "Dimension line Point", pDim.DimLinePoint);
490
      writeLine(indent, "Oblique", toDegreeString(pDim.Oblique));
491
      writeLine(indent, "Extension Line 1 Point", pDim.XLine1Point);
492
      writeLine(indent, "Extension Line 2 Point", pDim.XLine2Point);
493
      dumpDimData(pDim, indent);
494
    }
495

    
496
    /************************************************************************/
497
    /* Arc Dumper                                                           */
498
    /************************************************************************/
499
    void dump(Arc pArc, int indent)
500
    {
501
      writeLine(indent++, pArc.GetRXClass().Name, pArc.Handle);
502
      writeLine(indent, "Center", pArc.Center);
503
      writeLine(indent, "Radius", pArc.Radius);
504
      writeLine(indent, "Start Angle", toDegreeString(pArc.StartAngle));
505
      writeLine(indent, "End Angle", toDegreeString(pArc.EndAngle));
506
      writeLine(indent, "Normal", pArc.Normal);
507
      writeLine(indent, "Thickness", pArc.Thickness);
508
      dumpCurveData(pArc, indent);
509
    }
510

    
511
    /************************************************************************/
512
    /* Arc Dimension Dumper                                                 */
513
    /************************************************************************/
514
    void dump(ArcDimension pDim, int indent)
515
    {
516
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
517
      writeLine(indent, "Arc Point", pDim.ArcPoint);
518
      writeLine(indent, "Center Point", pDim.CenterPoint);
519
      writeLine(indent, "Arc symbol", toArcSymbolTypeString(pDim.ArcSymbolType));
520
      writeLine(indent, "Partial", pDim.IsPartial);
521
      writeLine(indent, "Has leader", pDim.HasLeader);
522

    
523
      if (pDim.HasLeader)
524
      {
525
        writeLine(indent, "Leader 1 Point", pDim.Leader1Point);
526
        writeLine(indent, "Leader 2 Point", pDim.Leader2Point);
527
      }
528
      writeLine(indent, "Extension Line 1 Point", pDim.XLine1Point);
529
      writeLine(indent, "Extension Line 2 Point", pDim.XLine2Point);
530
      dumpDimData(pDim, indent);
531
    }
532

    
533

    
534
    /************************************************************************/
535
    /* Block Reference Dumper                                                */
536
    /************************************************************************/
537
    void dump(BlockReference pBlkRef, int indent)
538
    {
539
      writeLine(indent++, pBlkRef.GetRXClass().Name, pBlkRef.Handle);
540

    
541
      using (BlockTableRecord pRecord = (BlockTableRecord)pBlkRef.BlockTableRecord.Open(OpenMode.ForRead))
542
      {
543
        writeLine(indent, "Name", pRecord.Name);
544
        dumpBlockRefData(pBlkRef, indent);
545
        /********************************************************************/
546
        /* Dump the Spatial Filter  (Xref Clip)                             */
547
        /********************************************************************/
548
        // TODO:
549
        /*
550
        Filters.SpatialFilter pFilt = 
551
        {
552
          writeLine(indent++, pFilt.GetRXClass().Name,   pFilt.Handle);
553
          writeLine(indent, "Normal",                    pFilt.Definition.Normal);
554
          writeLine(indent, "Elevation",                 pFilt.Definition.Elevation);
555
          writeLine(indent, "Front Clip Distance",       pFilt.Definition.FrontClip);
556
          writeLine(indent, "Back Clip Distance",        pFilt.Definition.BackClip);
557
          writeLine(indent, "Enabled",                   pFilt.Definition.Enabled);
558
          foreach (Point2d p in pFilt.Definition.GetPoints())
559
          {
560
            writeLine(indent, string.Format("Clip point %d",i), p);
561
          }
562
        }
563
         */
564
      }
565
    }
566

    
567
    /************************************************************************/
568
    /* Body Dumper                                                          */
569
    /************************************************************************/
570
    void dump(Body pBody, int indent)
571
    {
572
      writeLine(indent++, pBody.GetRXClass().Name, pBody.Handle);
573
      dumpEntityData(pBody, indent);
574
    }
575

    
576

    
577
    /************************************************************************/
578
    /* Circle Dumper                                                        */
579
    /************************************************************************/
580
    void dump(Circle pCircle, int indent)
581
    {
582
      writeLine(indent++, pCircle.GetRXClass().Name, pCircle.Handle);
583
      writeLine(indent, "Center", pCircle.Center);
584
      writeLine(indent, "Radius", pCircle.Radius);
585
      writeLine(indent, "Normal", pCircle.Normal);
586
      writeLine(indent, "Thickness", pCircle.Thickness);
587
      dumpCurveData(pCircle, indent);
588
    }
589

    
590
    /************************************************************************/
591
    /* Diametric Dimension Dumper                                           */
592
    /************************************************************************/
593
    void dump(DiametricDimension pDim, int indent)
594
    {
595
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
596
      writeLine(indent, "Chord Point", pDim.ChordPoint);
597
      writeLine(indent, "Far chord Point", pDim.FarChordPoint);
598
      writeLine(indent, "Leader Length", pDim.LeaderLength);
599
      dumpDimData(pDim, indent);
600
    }
601

    
602
    /************************************************************************/
603
    /* Ellipse Dumper                                                       */
604
    /************************************************************************/
605
    void dump(Ellipse pEllipse, int indent)
606
    {
607
      writeLine(indent++, pEllipse.GetRXClass().Name, pEllipse.Handle);
608
      writeLine(indent, "Center", pEllipse.Center);
609
      writeLine(indent, "Major Axis", pEllipse.MajorAxis);
610
      writeLine(indent, "Minor Axis", pEllipse.MinorAxis);
611
      writeLine(indent, "Major Radius", pEllipse.MajorAxis.Length);
612
      writeLine(indent, "Minor Radius", pEllipse.MinorAxis.Length);
613
      writeLine(indent, "Radius Ratio", pEllipse.RadiusRatio);
614
      writeLine(indent, "Start Angle", toDegreeString(pEllipse.StartAngle));
615
      writeLine(indent, "End Angle", toDegreeString(pEllipse.EndAngle));
616
      writeLine(indent, "Normal", pEllipse.Normal);
617
      dumpCurveData(pEllipse, indent);
618
    }
619
    /************************************************************************/
620
    /* Face Dumper                                                       */
621
    /************************************************************************/
622
    void dump(Face pFace, int indent)
623
    {
624
      writeLine(indent++, pFace.GetRXClass().Name, pFace.Handle);
625
      for (short i = 0; i < 4; i++)
626
      {
627
        writeLine(indent, string.Format("Vertex {0} ", i), pFace.GetVertexAt(i));
628
      }
629
      for (short i = 0; i < 4; i++)
630
      {
631
        writeLine(indent, string.Format("Edge {0} visible", i), pFace.IsEdgeVisibleAt(i));
632
      }
633
      dumpEntityData(pFace, indent);
634
    }
635

    
636
    /************************************************************************/
637
    /* FCF Dumper                                                           */
638
    /************************************************************************/
639
    void dump(FeatureControlFrame pFcf, int indent)
640
    {
641
      writeLine(indent++, pFcf.GetRXClass().Name, pFcf.Handle);
642
      writeLine(indent, "Location", pFcf.Location);
643
      writeLine(indent, "Text", pFcf.Text);
644
      writeLine(indent, "Dimension Style", pFcf.DimensionStyleName);
645
      writeLine(indent, "Dimension Gap", pFcf.Dimgap);
646
      writeLine(indent, "Dimension Scale", pFcf.Dimscale);
647
      writeLine(indent, "Text Height", pFcf.Dimtxt);
648
      writeLine(indent, "Frame Color", pFcf.Dimclrd);
649
      writeLine(indent, "Text Style", pFcf.TextStyleName);
650
      writeLine(indent, "Text Color", pFcf.Dimclrd);
651
      writeLine(indent, "X-Direction", pFcf.Direction);
652
      writeLine(indent, "Normal", pFcf.Normal);
653
      dumpEntityData(pFcf, indent);
654
    }
655

    
656
    /************************************************************************/
657
    /* Hatch Dumper                                                         */
658
    /************************************************************************/
659
    /***********************************************************************/
660
    /* Dump Polyline Loop                                                  */
661
    /***********************************************************************/
662
    static void dumpPolylineType(int loopIndex, Hatch pHatch, int indent)
663
    {
664
      HatchLoop hl = pHatch.GetLoopAt(loopIndex);
665
      for (int i = 0; i < hl.Polyline.Count; i++)
666
      {
667
        BulgeVertex bv = hl.Polyline[i];
668
        writeLine(indent, "Vertex " + i.ToString(), bv.Vertex.ToString());
669
        writeLine(indent + 1, "Bulge " + i.ToString(), bv.Bulge);
670
        writeLine(indent + 1, "Bulge angle " + i.ToString(), toDegreeString(4 * Math.Atan(bv.Bulge)));
671
      }
672
    }
673

    
674
    /**********************************************************************/
675
    /* Dump Circular Arc Edge                                             */
676
    /**********************************************************************/
677
    static void dumpCircularArcEdge(int indent, CircularArc2d pCircArc)
678
    {
679
      writeLine(indent, "Center", pCircArc.Center);
680
      writeLine(indent, "Radius", pCircArc.Radius);
681
      writeLine(indent, "Start Angle", toDegreeString(pCircArc.StartAngle));
682
      writeLine(indent, "End Angle", toDegreeString(pCircArc.EndAngle));
683
      writeLine(indent, "Clockwise", pCircArc.IsClockWise);
684
    }
685

    
686
    /**********************************************************************/
687
    /* Dump Elliptical Arc Edge                                           */
688
    /**********************************************************************/
689
    static void dumpEllipticalArcEdge(int indent, EllipticalArc2d pEllipArc)
690
    {
691
      writeLine(indent, "Center", pEllipArc.Center);
692
      writeLine(indent, "Major Radius", pEllipArc.MajorRadius);
693
      writeLine(indent, "Minor Radius", pEllipArc.MinorRadius);
694
      writeLine(indent, "Major Axis", pEllipArc.MajorAxis);
695
      writeLine(indent, "Minor Axis", pEllipArc.MinorAxis);
696
      writeLine(indent, "Start Angle", toDegreeString(pEllipArc.StartAngle));
697
      writeLine(indent, "End Angle", toDegreeString(pEllipArc.EndAngle));
698
      writeLine(indent, "Clockwise", pEllipArc.IsClockWise);
699
    }
700
    /**********************************************************************/
701
    /* Dump NurbCurve Edge                                           */
702
    /**********************************************************************/
703
    static void dumpNurbCurveEdge(int indent, NurbCurve2d pNurbCurve)
704
    {
705
      NurbCurve2dData d = pNurbCurve.DefinitionData;
706
      writeLine(indent, "Degree", d.Degree);
707
      writeLine(indent, "Rational", d.Rational);
708
      writeLine(indent, "Periodic", d.Periodic);
709

    
710
      writeLine(indent, "Number of Control Points", d.ControlPoints.Count);
711
      for (int i = 0; i < d.ControlPoints.Count; i++)
712
      {
713
        writeLine(indent, "Control Point " + i.ToString(), d.ControlPoints[i]);
714
      }
715
      writeLine(indent, "Number of Knots", d.Knots.Count);
716
      for (int i = 0; i < d.Knots.Count; i++)
717
      {
718
        writeLine(indent, "Knot " + i.ToString(), d.Knots[i]);
719
      }
720

    
721
      if (d.Rational)
722
      {
723
        writeLine(indent, "Number of Weights", d.Weights.Count);
724
        for (int i = 0; i < d.Weights.Count; i++)
725
        {
726
          writeLine(indent, "Weight " + i.ToString(), d.Weights[i]);
727
        }
728
      }
729
    }
730

    
731
    /***********************************************************************/
732
    /* Dump Edge Loop                                                      */
733
    /***********************************************************************/
734
    static void dumpEdgesType(int loopIndex, Hatch pHatch, int indent)
735
    {
736
      Curve2dCollection edges = pHatch.GetLoopAt(loopIndex).Curves;
737
      for (int i = 0; i < (int)edges.Count; i++)
738
      {
739
        using (Curve2d pEdge = edges[i])
740
        {
741
          writeLine(indent, string.Format("Edge {0}", i), pEdge.GetType().Name);
742
          switch (pEdge.GetType().Name)
743
          {
744
            case "LineSegment2d":
745
              break;
746
            case "CircularArc2d":
747
              dumpCircularArcEdge(indent + 1, (CircularArc2d)pEdge);
748
              break;
749
            case "EllipticalArc2d":
750
              dumpEllipticalArcEdge(indent + 1, (EllipticalArc2d)pEdge);
751
              break;
752
            case "NurbCurve2d":
753
              dumpNurbCurveEdge(indent + 1, (NurbCurve2d)pEdge);
754
              break;
755
          }
756

    
757
          /******************************************************************/
758
          /* Common Edge Properties                                         */
759
          /******************************************************************/
760
          Interval interval = pEdge.GetInterval();
761
          writeLine(indent + 1, "Start Point", pEdge.EvaluatePoint(interval.LowerBound));
762
          writeLine(indent + 1, "End Point", pEdge.EvaluatePoint(interval.UpperBound));
763
          writeLine(indent + 1, "Closed", pEdge.IsClosed());
764
        }
765
      }
766
    }
767
    /************************************************************************/
768
    /* Convert the specified value to a LoopType string                     */
769
    /************************************************************************/
770
    string toLooptypeString(HatchLoopTypes loopType)
771
    {
772
      string retVal = "";
773
      if ((loopType & HatchLoopTypes.External) != 0)
774
        retVal = retVal + " | kExternal";
775

    
776
      if ((loopType & HatchLoopTypes.Polyline) != 0)
777
        retVal = retVal + " | kPolyline";
778

    
779
      if ((loopType & HatchLoopTypes.Derived) != 0)
780
        retVal = retVal + " | kDerived";
781

    
782
      if ((loopType & HatchLoopTypes.Textbox) != 0)
783
        retVal = retVal + " | kTextbox";
784

    
785
      if ((loopType & HatchLoopTypes.Outermost) != 0)
786
        retVal = retVal + " | kOutermost";
787

    
788
      if ((loopType & HatchLoopTypes.NotClosed) != 0)
789
        retVal = retVal + " | kNotClosed";
790

    
791
      if ((loopType & HatchLoopTypes.SelfIntersecting) != 0)
792
        retVal = retVal + " | kSelfIntersecting";
793

    
794
      if ((loopType & HatchLoopTypes.TextIsland) != 0)
795
        retVal = retVal + " | kTextIsland";
796

    
797
      if ((loopType & HatchLoopTypes.Duplicate) != 0)
798
        retVal = retVal + " | kDuplicate";
799

    
800
      return retVal == "" ? "kDefault" : retVal.Substring(3);
801
    }
802
    void dump(Hatch pHatch, int indent)
803
    {
804
      writeLine(indent++, pHatch.GetRXClass().Name, pHatch.Handle);
805
      writeLine(indent, "Hatch Style", pHatch.HatchStyle);
806
      writeLine(indent, "Hatch Object Type", pHatch.HatchObjectType);
807
      writeLine(indent, "Is Hatch", pHatch.IsHatch);
808
      writeLine(indent, "Is Gradient", !pHatch.IsGradient);
809
      if (pHatch.IsHatch)
810
      {
811
        /******************************************************************/
812
        /* Dump Hatch Parameters                                          */
813
        /******************************************************************/
814
        writeLine(indent, "Pattern Type", pHatch.PatternType);
815
        switch (pHatch.PatternType)
816
        {
817
          case HatchPatternType.PreDefined:
818
          case HatchPatternType.CustomDefined:
819
            writeLine(indent, "Pattern Name", pHatch.PatternName);
820
            writeLine(indent, "Solid Fill", pHatch.IsSolidFill);
821
            if (!pHatch.IsSolidFill)
822
            {
823
              writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle));
824
              writeLine(indent, "Pattern Scale", pHatch.PatternScale);
825
            }
826
            break;
827
          case HatchPatternType.UserDefined:
828
            writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle));
829
            writeLine(indent, "Pattern Double", pHatch.PatternDouble);
830
            writeLine(indent, "Pattern Space", pHatch.PatternSpace);
831
            break;
832
        }
833
        DBObjectCollection entitySet = new DBObjectCollection();
834
        Handle hhh = pHatch.Handle;
835
        if (hhh.Value == 1692) //69C)
836
        {
837
          pHatch.Explode(entitySet);
838
          return;
839
        }
840
        if (hhh.Value == 1693) //69D)
841
        {
842
          try
843
          {
844
            pHatch.Explode(entitySet);
845
          }
846
          catch (System.Exception e)
847
          {
848
            if (e.Message == "eCannotExplodeEntity")
849
            {
850
              writeLine(indent, "Hatch " + e.Message + ": ", pHatch.Handle);
851
              return;
852
            }
853
          }
854
        }
855
      }
856
      if (pHatch.IsGradient)
857
      {
858
        /******************************************************************/
859
        /* Dump Gradient Parameters                                       */
860
        /******************************************************************/
861
        writeLine(indent, "Gradient Type", pHatch.GradientType);
862
        writeLine(indent, "Gradient Name", pHatch.GradientName);
863
        writeLine(indent, "Gradient Angle", toDegreeString(pHatch.GradientAngle));
864
        writeLine(indent, "Gradient Shift", pHatch.GradientShift);
865
        writeLine(indent, "Gradient One-Color Mode", pHatch.GradientOneColorMode);
866
        if (pHatch.GradientOneColorMode)
867
        {
868
          writeLine(indent, "ShadeTintValue", pHatch.ShadeTintValue);
869
        }
870
        GradientColor[] colors = pHatch.GetGradientColors();
871
        for (int i = 0; i < colors.Length; i++)
872
        {
873
          writeLine(indent, string.Format("Color         {0}", i), colors[i].get_Color());
874
          writeLine(indent, string.Format("Interpolation {0}", i), colors[i].get_Value());
875
        }
876
      }
877

    
878
      /********************************************************************/
879
      /* Dump Associated Objects                                          */
880
      /********************************************************************/
881
      writeLine(indent, "Associated objects", pHatch.Associative);
882
      foreach (ObjectId id in pHatch.GetAssociatedObjectIds())
883
      {
884
        writeLine(indent + 1, id.ObjectClass.Name, id.Handle);
885
      }
886

    
887
      /********************************************************************/
888
      /* Dump Loops                                                       */
889
      /********************************************************************/
890
      writeLine(indent, "Loops", pHatch.NumberOfLoops);
891
      for (int i = 0; i < pHatch.NumberOfLoops; i++)
892
      {
893
        writeLine(indent + 1, "Loop " + i.ToString(), toLooptypeString(pHatch.LoopTypeAt(i)));
894

    
895
        /******************************************************************/
896
        /* Dump Loop                                                      */
897
        /******************************************************************/
898
        if ((pHatch.LoopTypeAt(i) & HatchLoopTypes.Polyline) != 0)
899
        {
900
          dumpPolylineType(i, pHatch, indent + 2);
901
        }
902
        else
903
        {
904
          dumpEdgesType(i, pHatch, indent + 2);
905
        }
906
        /******************************************************************/
907
        /* Dump Associated Objects                                        */
908
        /******************************************************************/
909
        if (pHatch.Associative)
910
        {
911
          writeLine(indent + 2, "Associated objects");
912
          foreach (ObjectId id in pHatch.GetAssociatedObjectIdsAt(i))
913
          {
914
            writeLine(indent + 3, id.ObjectClass.Name, id.Handle);
915
          }
916
        }
917
      }
918

    
919
      writeLine(indent, "Elevation", pHatch.Elevation);
920
      writeLine(indent, "Normal", pHatch.Normal);
921
      dumpEntityData(pHatch, indent);
922
    }
923

    
924
    /************************************************************************/
925
    /* Leader Dumper                                                          */
926
    /************************************************************************/
927
    void dump(Leader pLeader, int indent)
928
    {
929
      writeLine(indent++, pLeader.GetRXClass().Name, pLeader.Handle);
930
      writeLine(indent, "Dimension Style", pLeader.DimensionStyleName);
931

    
932
      writeLine(indent, "Annotation");
933
      if (!pLeader.Annotation.IsNull)
934
      {
935
        writeLine(indent++, pLeader.Annotation.ObjectClass.Name, pLeader.Annotation.Handle);
936
      }
937
      writeLine(indent + 1, "Type", pLeader.AnnoType);
938
      writeLine(indent + 1, "Height", pLeader.AnnoHeight);
939
      writeLine(indent + 1, "Width", pLeader.AnnoWidth);
940
      writeLine(indent + 1, "Offset", pLeader.AnnotationOffset);
941
      writeLine(indent, "Has Arrowhead", pLeader.HasArrowHead);
942
      writeLine(indent, "Has Hook Line", pLeader.HasHookLine);
943
      writeLine(indent, "Splined", pLeader.IsSplined);
944

    
945
      for (int i = 0; i < pLeader.NumVertices; i++)
946
      {
947
        writeLine(indent, string.Format("Vertex {0}", i), pLeader.VertexAt(i));
948
      }
949
      writeLine(indent, "Normal", pLeader.Normal);
950
      dumpCurveData(pLeader, indent);
951
    }
952

    
953
    /************************************************************************/
954
    /* Line Dumper                                                          */
955
    /************************************************************************/
956
    void dump(Line pLine, int indent)
957
    {
958
      writeLine(indent++, pLine.GetRXClass().Name, pLine.Handle);
959
      writeLine(indent, "Normal", pLine.Normal);
960
      writeLine(indent, "Thickness", pLine.Thickness);
961
      dumpEntityData(pLine, indent);
962
    }
963
    /************************************************************************/
964
    /* MInsertBlock Dumper                                                  */
965
    /************************************************************************/
966
    void dump(MInsertBlock pMInsert, int indent)
967
    {
968
      writeLine(indent++, pMInsert.GetRXClass().Name, pMInsert.Handle);
969

    
970
      using (BlockTableRecord pRecord = (BlockTableRecord)pMInsert.BlockTableRecord.Open(OpenMode.ForRead))
971
      {
972
        writeLine(indent, "Name", pRecord.Name);
973
        writeLine(indent, "Rows", pMInsert.Rows);
974
        writeLine(indent, "Columns", pMInsert.Columns);
975
        writeLine(indent, "Row Spacing", pMInsert.RowSpacing);
976
        writeLine(indent, "Column Spacing", pMInsert.ColumnSpacing);
977
        dumpBlockRefData(pMInsert, indent);
978
      }
979
    }
980

    
981
    /************************************************************************/
982
    /* Mline Dumper                                                         */
983
    /************************************************************************/
984
    void dump(Mline pMline, int indent)
985
    {
986
      writeLine(indent++, pMline.GetRXClass().Name, pMline.Handle);
987
      writeLine(indent, "Style", pMline.Style);
988
      writeLine(indent, "Closed", pMline.IsClosed);
989
      writeLine(indent, "Scale", pMline.Scale);
990
      writeLine(indent, "Suppress Start Caps", pMline.SupressStartCaps);
991
      writeLine(indent, "Suppress End Caps", pMline.SupressEndCaps);
992
      writeLine(indent, "Normal", pMline.Normal);
993

    
994
      /********************************************************************/
995
      /* Dump the segment data                                            */
996
      /********************************************************************/
997
      for (int i = 0; i < pMline.NumberOfVertices; i++)
998
      {
999
        writeLine(indent, "Segment", i);
1000
        writeLine(indent + 1, "Vertex", pMline.VertexAt(i));
1001
      }
1002
      dumpEntityData(pMline, indent);
1003
    }
1004
    /************************************************************************/
1005
    /* MText Dumper                                                         */
1006
    /************************************************************************/
1007
    void dump(MText pMText, int indent)
1008
    {
1009
      writeLine(indent++, pMText.GetRXClass().Name, pMText.Handle);
1010
      writeLine(indent, "Contents", pMText.Contents);
1011
      writeLine(indent, "Location", pMText.Location);
1012
      writeLine(indent, "Height", pMText.TextHeight);
1013
      writeLine(indent, "Rotation", toDegreeString(pMText.Rotation));
1014
      writeLine(indent, "Text Style Id", pMText.TextStyleId);
1015
      writeLine(indent, "Attachment", pMText.Attachment);
1016
      writeLine(indent, "Background Fill On", pMText.BackgroundFill);
1017
      writeLine(indent, "Background Fill Color", pMText.BackgroundFillColor);
1018
      writeLine(indent, "Background Scale Factor", pMText.BackgroundScaleFactor);
1019
      writeLine(indent, "Background Transparency Method", pMText.BackgroundTransparency);
1020
      writeLine(indent, "X-Direction", pMText.Direction);
1021
      writeLine(indent, "Flow Direction", pMText.FlowDirection);
1022
      writeLine(indent, "Width", pMText.Width);
1023
      writeLine(indent, "Actual Height", pMText.ActualHeight);
1024
      writeLine(indent, "Actual Width", pMText.ActualWidth);
1025

    
1026
      Point3dCollection points = pMText.GetBoundingPoints();
1027
      writeLine(indent, "TL Bounding Point", points[0]);
1028
      writeLine(indent, "TR Bounding Point", points[1]);
1029
      writeLine(indent, "BL Bounding Point", points[2]);
1030
      writeLine(indent, "BR Bounding Point", points[3]);
1031
      writeLine(indent, "Normal", pMText.Normal);
1032

    
1033
      dumpEntityData(pMText, indent);
1034
    }
1035

    
1036
    /************************************************************************/
1037
    /* Ordinate Dimension Dumper                                            */
1038
    /************************************************************************/
1039
    void dump(OrdinateDimension pDim, int indent)
1040
    {
1041
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
1042
      writeLine(indent, "Defining Point", pDim.DefiningPoint);
1043
      writeLine(indent, "Using x-Axis", pDim.UsingXAxis);
1044
      writeLine(indent, "Using y-Axis", pDim.UsingYAxis);
1045
      writeLine(indent, "Leader End Point", pDim.LeaderEndPoint);
1046
      writeLine(indent, "Origin", pDim.Origin);
1047
      dumpDimData(pDim, indent);
1048
    }
1049
    /************************************************************************/
1050
    /* PolyFaceMesh Dumper                                                  */
1051
    /************************************************************************/
1052
    void dump(PolyFaceMesh pPoly, int indent)
1053
    {
1054
      writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1055
      writeLine(indent, "Number of Vertices", pPoly.NumVertices);
1056
      writeLine(indent, "Number of Faces", pPoly.NumFaces);
1057

    
1058
      /********************************************************************/
1059
      /* dump vertices and faces                                          */
1060
      /********************************************************************/
1061
      int vertexCount = 0;
1062
      int faceCount = 0;
1063
      foreach (ObjectId objId in pPoly)
1064
      {
1065
        using (Entity ent = (Entity)objId.GetObject(OpenMode.ForRead))
1066
        {
1067
          if (ent is PolyFaceMeshVertex)
1068
          {
1069
            PolyFaceMeshVertex pVertex = (PolyFaceMeshVertex)ent;
1070
            writeLine(indent, pVertex.GetRXClass().Name, ++vertexCount);
1071
            writeLine(indent + 1, "Handle", pVertex.Handle);
1072
            writeLine(indent + 1, "Position", pVertex.Position);
1073
            dumpEntityData(pVertex, indent + 1);
1074
          }
1075
          else if (ent is FaceRecord)
1076
          {
1077
            FaceRecord pFace = (FaceRecord)ent;
1078
            string face = "{";
1079
            for (short i = 0; i < 4; i++)
1080
            {
1081
              if (i > 0)
1082
              {
1083
                face = face + " ";
1084
              }
1085
              face = face + pFace.GetVertexAt(i).ToString();
1086
            }
1087
            face += "}";
1088
            writeLine(indent, pFace.GetRXClass().Name, ++faceCount);
1089
            writeLine(indent + 1, "Handle", pFace.Handle);
1090
            writeLine(indent + 1, "Vertices", face);
1091
            dumpEntityData(pFace, indent + 1);
1092
          }
1093
          else
1094
          { // Unknown entity type
1095
            writeLine(indent, "Unexpected Entity");
1096
          }
1097
        }
1098
      }
1099
      dumpEntityData(pPoly, indent);
1100
    }
1101

    
1102
    /************************************************************************/
1103
    /* Ole2Frame                                                            */
1104
    /************************************************************************/
1105
    void dump(Ole2Frame pOle, int indent)
1106
    {
1107
      writeLine(indent++, pOle.GetRXClass().Name, pOle.Handle);
1108

    
1109
      Rectangle3d pos = (Rectangle3d)pOle.Position3d;
1110
      writeLine(indent, "Lower Left", pos.LowerLeft);
1111
      writeLine(indent, "Lower Right", pos.LowerRight);
1112
      writeLine(indent, "Upper Left", pos.UpperLeft);
1113
      writeLine(indent, "Upper Right", pos.UpperRight);
1114
      writeLine(indent, "Type", pOle.Type);
1115
      writeLine(indent, "User Type", pOle.UserType);
1116
      if (pOle.Type == Ole2Frame.ItemType.Link)
1117
      {
1118
        writeLine(indent, "Link Name", pOle.LinkName);
1119
        writeLine(indent, "Link Path", pOle.LinkPath);
1120
      }
1121
      writeLine(indent, "Output Quality", pOle.OutputQuality);
1122
      dumpEntityData(pOle, indent);
1123
    }
1124

    
1125
    /************************************************************************/
1126
    /* Point Dumper                                                         */
1127
    /************************************************************************/
1128
    void dump(DBPoint pPoint, int indent)
1129
    {
1130
      writeLine(indent++, pPoint.GetRXClass().Name, pPoint.Handle);
1131
      writeLine(indent, "Position", pPoint.Position);
1132
      writeLine(indent, "ECS Rotation", toDegreeString(pPoint.EcsRotation));
1133
      writeLine(indent, "Normal", pPoint.Normal);
1134
      writeLine(indent, "Thickness", pPoint.Thickness);
1135
      dumpEntityData(pPoint, indent);
1136
    }
1137

    
1138
    /************************************************************************/
1139
    /* Polygon Mesh Dumper                                                  */
1140
    /************************************************************************/
1141
    void dump(PolygonMesh pPoly, int indent)
1142
    {
1143
      writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1144
      writeLine(indent, "m Size", pPoly.MSize);
1145
      writeLine(indent, "m-Closed", pPoly.IsMClosed);
1146
      writeLine(indent, "m Surface Density", pPoly.MSurfaceDensity);
1147
      writeLine(indent, "n Size", pPoly.NSize);
1148
      writeLine(indent, "n-Closed", pPoly.IsNClosed);
1149
      writeLine(indent, "n Surface Density", pPoly.NSurfaceDensity);
1150
      /********************************************************************/
1151
      /* dump vertices                                                    */
1152
      /********************************************************************/
1153
      int vertexCount = 0;
1154
      foreach (object o in pPoly)
1155
      {
1156
        PolygonMeshVertex pVertex = o as PolygonMeshVertex;
1157
        if (pVertex != null)
1158
        {
1159
          writeLine(indent, pVertex.GetRXClass().Name, vertexCount++);
1160
          writeLine(indent + 1, "Handle", pVertex.Handle);
1161
          writeLine(indent + 1, "Position", pVertex.Position);
1162
          writeLine(indent + 1, "Type", pVertex.VertexType);
1163
        }
1164
      }
1165
      dumpEntityData(pPoly, indent);
1166
    }
1167

    
1168
    /************************************************************************/
1169
    /* Polyline Dumper                                                      */
1170
    /************************************************************************/
1171
    void dump(Teigha.DatabaseServices.Polyline pPoly, int indent)
1172
    {
1173
      writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle);
1174
      writeLine(indent, "Has Width", pPoly.HasWidth);
1175
      if (!pPoly.HasWidth)
1176
      {
1177
        writeLine(indent, "Constant Width", pPoly.ConstantWidth);
1178
      }
1179
      writeLine(indent, "Has Bulges", pPoly.HasBulges);
1180
      writeLine(indent, "Elevation", pPoly.Elevation);
1181
      writeLine(indent, "Normal", pPoly.Normal);
1182
      writeLine(indent, "Thickness", pPoly.Thickness);
1183

    
1184
      /********************************************************************/
1185
      /* dump vertices                                                    */
1186
      /********************************************************************/
1187
      for (int i = 0; i < pPoly.NumberOfVertices; i++)
1188
      {
1189
        writeLine(indent, string.Format("Vertex {0}", i));
1190
        writeLine(indent + 1, "Segment Type", pPoly.GetSegmentType(i));
1191
        writeLine(indent + 1, "Point", pPoly.GetPoint3dAt(i));
1192
        if (pPoly.HasWidth)
1193
        {
1194
          writeLine(indent, "Start Width", pPoly.GetStartWidthAt(i));
1195
          writeLine(indent, "End Width", pPoly.GetEndWidthAt(i));
1196
        }
1197
        if (pPoly.HasBulges)
1198
        {
1199
          writeLine(indent, "Bulge", pPoly.GetBulgeAt(i));
1200
          if (pPoly.GetSegmentType(i) == SegmentType.Arc)
1201
          {
1202
            writeLine(indent, "Bulge Angle", toDegreeString(4 * Math.Atan(pPoly.GetBulgeAt(i))));
1203
          }
1204
        }
1205
      }
1206
      dumpEntityData(pPoly, indent);
1207
    }
1208
    class DrawContextDumper : Context
1209
    {
1210
      Database _db;
1211
      public DrawContextDumper(Database db)
1212
      {
1213
        _db = db;
1214
      }
1215
      public override Database Database
1216
      {
1217
        get { return _db; }
1218
      }
1219
      public override bool IsBoundaryClipping
1220
      {
1221
        get { return false; }
1222
      }
1223
      public override bool IsPlotGeneration
1224
      {
1225
        get { return false; }
1226
      }
1227
      public override bool IsPostScriptOut
1228
      {
1229
        get { return false; }
1230
      }
1231
    }
1232
    class SubEntityTraitsDumper : SubEntityTraits
1233
    {
1234
      short _color;
1235
      int _drawFlags;
1236
      FillType _ft;
1237
      ObjectId _layer;
1238
      ObjectId _linetype;
1239
      LineWeight _lineWeight;
1240
      Mapper _mapper;
1241
      double _lineTypeScale;
1242
      ObjectId _material;
1243
      PlotStyleDescriptor _plotStyleDescriptor;
1244
      bool _sectionable;
1245
      bool _selectionOnlyGeometry;
1246
      ShadowFlags _shadowFlags;
1247
      double _thickness;
1248
      EntityColor _trueColor;
1249
      Transparency _transparency;
1250
      ObjectId _visualStyle;
1251
      public SubEntityTraitsDumper(Database db)
1252
      {
1253
        _drawFlags = 0; // kNoDrawFlags 
1254
        _color = 0;
1255
        _ft = FillType.FillAlways;
1256
        _layer = db.Clayer;
1257
        _linetype = db.Celtype;
1258
        _lineWeight = db.Celweight;
1259
        _lineTypeScale = db.Celtscale;
1260
        _material = db.Cmaterial;
1261
        _shadowFlags = ShadowFlags.ShadowsIgnore;
1262
        _thickness = 0;
1263
        _trueColor = new EntityColor(ColorMethod.None);
1264
        _transparency = new Transparency();
1265
      }
1266

    
1267
      protected override void SetLayerFlags(LayerFlags flags)
1268
      {
1269
        writeLine(0, string.Format("SubEntityTraitsDumper.SetLayerFlags(flags = {0})", flags));
1270
      }
1271
      public override void AddLight(ObjectId lightId)
1272
      {
1273
        writeLine(0, string.Format("SubEntityTraitsDumper.AddLight(lightId = {0})", lightId.ToString()));
1274
      }
1275
      public override void SetupForEntity(Entity entity)
1276
      {
1277
        writeLine(0, string.Format("SubEntityTraitsDumper.SetupForEntity(entity = {0})", entity.ToString()));
1278
      }
1279

    
1280
      public override short Color
1281
      {
1282
        get { return _color; }
1283
        set { _color = value; }
1284
      }
1285
      public override int DrawFlags
1286
      {
1287
        get { return _drawFlags; }
1288
        set { _drawFlags = value; }
1289
      }
1290
      public override FillType FillType
1291
      {
1292
        get { return _ft; }
1293
        set { _ft = value; }
1294
      }
1295
      public override ObjectId Layer
1296
      {
1297
        get { return _layer; }
1298
        set { _layer = value; }
1299
      }
1300
      public override ObjectId LineType
1301
      {
1302
        get { return _linetype; }
1303
        set { _linetype = value; }
1304
      }
1305
      public override double LineTypeScale
1306
      {
1307
        get { return _lineTypeScale; }
1308
        set { _lineTypeScale = value; }
1309
      }
1310
      public override LineWeight LineWeight
1311
      {
1312
        get { return _lineWeight; }
1313
        set { _lineWeight = value; }
1314
      }
1315
      public override Mapper Mapper
1316
      {
1317
        get { return _mapper; }
1318
        set { _mapper = value; }
1319
      }
1320
      public override ObjectId Material
1321
      {
1322
        get { return _material; }
1323
        set { _material = value; }
1324
      }
1325
      public override PlotStyleDescriptor PlotStyleDescriptor
1326
      {
1327
        get { return _plotStyleDescriptor; }
1328
        set { _plotStyleDescriptor = value; }
1329
      }
1330
      public override bool Sectionable
1331
      {
1332
        get { return _sectionable; }
1333
        set { _sectionable = value; }
1334
      }
1335
      public override bool SelectionOnlyGeometry
1336
      {
1337
        get { return _selectionOnlyGeometry; }
1338
        set { _selectionOnlyGeometry = value; }
1339
      }
1340
      public override ShadowFlags ShadowFlags
1341
      {
1342
        get { return _shadowFlags; }
1343
        set { _shadowFlags = value; }
1344
      }
1345
      public override double Thickness
1346
      {
1347
        get { return _thickness; }
1348
        set { _thickness = value; }
1349
      }
1350
      public override EntityColor TrueColor
1351
      {
1352
        get { return _trueColor; }
1353
        set { _trueColor = value; }
1354
      }
1355
      public override Transparency Transparency
1356
      {
1357
        get { return _transparency; }
1358
        set { _transparency = value; }
1359
      }
1360
      public override ObjectId VisualStyle
1361
      {
1362
        get { return _visualStyle; }
1363
        set { _visualStyle = value; }
1364
      }
1365
      public override void SetSelectionMarker(IntPtr sm)
1366
      {
1367
      }
1368
    }
1369
    class WorldGeometryDumper : WorldGeometry
1370
    {
1371
      Stack<Matrix3d> modelMatrix;
1372
      Stack<ClipBoundary> clips;
1373
      int indent;
1374
      public WorldGeometryDumper(int indent)
1375
        : base()
1376
      {
1377
        this.indent = indent;
1378
        modelMatrix = new Stack<Matrix3d>();
1379
        clips = new Stack<ClipBoundary>();
1380
        modelMatrix.Push(Matrix3d.Identity);
1381
      }
1382
      public override Matrix3d ModelToWorldTransform
1383
      {
1384
        get { return modelMatrix.Peek(); }
1385
      }
1386
      public override Matrix3d WorldToModelTransform
1387
      {
1388
        get { return modelMatrix.Peek().Inverse(); }
1389
      }
1390

    
1391
      public override Matrix3d PushOrientationTransform(OrientationBehavior behavior)
1392
      {
1393
        writeLine(indent, string.Format("WorldGeometry.PushOrientationTransform(behavior = {0})", behavior));
1394
        return new Matrix3d();
1395
      }
1396
      public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point2d offset)
1397
      {
1398
        writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset));
1399
        return new Matrix3d();
1400
      }
1401
      public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point3d offset)
1402
      {
1403
        writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset));
1404
        return new Matrix3d();
1405
      }
1406
      public override bool OwnerDraw(GdiDrawObject gdiDrawObject, Point3d position, Vector3d u, Vector3d v)
1407
      {
1408
        writeLine(indent, string.Format("WorldGeometry.OwnerDraw(gdiDrawObject = {0}, position = {1}, u = {2}, v = {3})", gdiDrawObject, position, u, v));
1409
        return false;
1410
      }
1411
      public override bool Polyline(Teigha.GraphicsInterface.Polyline polylineObj)
1412
      {
1413
        writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}", polylineObj));
1414
        return false;
1415
      }
1416
      public override bool Polypoint(Point3dCollection points, Vector3dCollection normals, IntPtrCollection subentityMarkers)
1417
      {
1418
        writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, normals = {1}, subentityMarkers = {2}", points, normals, subentityMarkers));
1419
        return false;
1420
      }
1421
      public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, Vector3dCollection normals, IntPtrCollection subentityMarkers)
1422
      {
1423
        writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, normals = {2}, subentityMarkers = {3}", points, colors, normals, subentityMarkers));
1424
        return false;
1425
      }
1426
      public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, TransparencyCollection transparency, Vector3dCollection normals, IntPtrCollection subentityMarkers, int pointSize)
1427
      {
1428
        writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, transparency = {2}, normals = {3}, subentityMarkers = {4}, pointSize = {5}", points, colors, transparency, normals, subentityMarkers, pointSize));
1429
        return false;
1430
      }
1431
      public override bool PolyPolyline(Teigha.GraphicsInterface.PolylineCollection polylineCollection)
1432
      {
1433
        writeLine(indent, string.Format("WorldGeometry.PolyPolyline(polylineCollection = {0}", polylineCollection));
1434
        return false;
1435
      }
1436
      public override bool PolyPolygon(UInt32Collection numPolygonPositions, Point3dCollection polygonPositions, UInt32Collection numPolygonPoints, Point3dCollection polygonPoints, EntityColorCollection outlineColors, LinetypeCollection outlineTypes, EntityColorCollection fillColors, Teigha.Colors.TransparencyCollection fillOpacities)
1437
      {
1438
        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));
1439
        return false;
1440
      }
1441
      public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point2d extents)
1442
      {
1443
        writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents));
1444
        return new Matrix3d();
1445
      }
1446
      public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point3d extents)
1447
      {
1448
        writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents));
1449
        return new Matrix3d();
1450
      }
1451
      public override bool EllipticalArc(Point3d center, Vector3d normal, double majorAxisLength, double minorAxisLength, double startDegreeInRads, double endDegreeInRads, double tiltDegreeInRads, ArcType arType)
1452
      {
1453
        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));
1454
        return false;
1455
      }
1456
      public override bool Circle(Point3d center, double radius, Vector3d normal)
1457
      {
1458
        writeLine(indent, string.Format("WorldGeometry.Circle(center = {0}, radius = {1}, normal = {2})", center, radius, normal));
1459
        return false;
1460
      }
1461
      public override bool Circle(Point3d firstPoint, Point3d secondPoint, Point3d thirdPoint)
1462
      {
1463
        writeLine(indent, string.Format("WorldGeometry.Circle(firstPoint = {0}, secondPoint = {1}, thirdPoint = {2})", firstPoint, secondPoint, thirdPoint));
1464
        return false;
1465
      }
1466
      public override bool CircularArc(Point3d start, Point3d point, Point3d endingPoint, ArcType arcType)
1467
      {
1468
        writeLine(indent, string.Format("WorldGeometry.CircularArc(start = {0}, point = {1}, endingPoint = {2}, arcType = {3})", start, point, endingPoint, arcType));
1469
        return false;
1470
      }
1471
      public override bool CircularArc(Point3d center, double radius, Vector3d normal, Vector3d startVector, double sweepAngle, ArcType arcType)
1472
      {
1473
        writeLine(indent, string.Format("WorldGeometry.CircularArc(center = {0}, radius = {1}, normal = {2}, startVector = {3}, sweepAngle = {4}, arcType = {5}", center, radius, normal, startVector, sweepAngle, arcType));
1474
        return false;
1475
      }
1476
      public override bool Draw(Drawable value)
1477
      {
1478
        writeLine(indent, string.Format("WorldGeometry.Draw(value = {0}", value));
1479
        return false;
1480
      }
1481
      public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v)
1482
      {
1483
        writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}", position, u, v));
1484
        return false;
1485
      }
1486
      public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v, TransparencyMode transparencyMode)
1487
      {
1488
        writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}, transparencyMode = {4}", position, u, v, transparencyMode));
1489
        return false;
1490
      }
1491
      public override bool Mesh(int rows, int columns, Point3dCollection points, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals)
1492
      {
1493
        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));
1494
        return false;
1495
      }
1496
      public override bool Polygon(Point3dCollection points)
1497
      {
1498
        writeLine(indent, string.Format("WorldGeometry.Polygon(points = {0})", points));
1499
        return false;
1500
      }
1501
      public override bool Polyline(Teigha.DatabaseServices.Polyline value, int fromIndex, int segments)
1502
      {
1503
        writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}, fromIndex = {1}, segments = {2})", value, fromIndex, segments));
1504
        return false;
1505
      }
1506
      public override bool Polyline(Point3dCollection points, Vector3d normal, IntPtr subEntityMarker)
1507
      {
1508
        writeLine(indent, string.Format("WorldGeometry.Polyline(points = {0}, normal = {1}, subEntityMarker = {2})", points, normal, subEntityMarker));
1509
        return false;
1510
      }
1511
      public override void PopClipBoundary()
1512
      {
1513
        writeLine(indent, string.Format("WorldGeometry.PopClipBoundary"));
1514
        clips.Pop();
1515
      }
1516
      public override bool PopModelTransform()
1517
      {
1518
        return true;
1519
      }
1520
      public override bool PushClipBoundary(ClipBoundary boundary)
1521
      {
1522
        writeLine(indent, string.Format("WorldGeometry.PushClipBoundary"));
1523
        clips.Push(boundary);
1524
        return true;
1525
      }
1526
      public override bool PushModelTransform(Matrix3d matrix)
1527
      {
1528
        writeLine(indent, "WorldGeometry.PushModelTransform(Matrix3d)");
1529
        Matrix3d m = modelMatrix.Peek();
1530
        modelMatrix.Push(m * matrix);
1531
        return true;
1532
      }
1533
      public override bool PushModelTransform(Vector3d normal)
1534
      {
1535
        writeLine(indent, "WorldGeometry.PushModelTransform(Vector3d)");
1536
        PushModelTransform(Matrix3d.PlaneToWorld(normal));
1537
        return true;
1538
      }
1539
      public override bool RowOfDots(int count, Point3d start, Vector3d step)
1540
      {
1541
        writeLine(indent, string.Format("ViewportGeometry.RowOfDots(count = {0}, start = {1}, step = {1})", count, start, step));
1542
        return false;
1543
      }
1544
      public override bool Ray(Point3d point1, Point3d point2)
1545
      {
1546
        writeLine(indent, string.Format("WorldGeometry.Ray(point1 = {0}, point2 = {1})", point1, point2));
1547
        return false;
1548
      }
1549
      public override bool Shell(Point3dCollection points, IntegerCollection faces, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals)
1550
      {
1551
        writeLine(indent, string.Format("WorldGeometry.Shell(points = {0}, faces = {1}, edgeData = {2}, faceData = {3}, vertexData = {4}, bAutoGenerateNormals = {5})", points, faces, edgeData, faceData, vertexData, bAutoGenerateNormals));
1552
        return false;
1553
      }
1554
      public override bool Text(Point3d position, Vector3d normal, Vector3d direction, string message, bool raw, TextStyle textStyle)
1555
      {
1556
        writeLine(indent, string.Format("WorldGeometry.Text(position = {0}, normal = {1}, direction = {2}, message = {3}, raw = {4}, textStyle = {5})", position, normal, direction, message, raw, textStyle));
1557
        return false;
1558
      }
1559
      public override bool Text(Point3d position, Vector3d normal, Vector3d direction, double height, double width, double oblique, string message)
1560
      {
1561
        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));
1562
        return false;
1563
      }
1564
      public override bool WorldLine(Point3d startPoint, Point3d endPoint)
1565
      {
1566
        writeLine(indent, string.Format("WorldGeometry.WorldLine(startPoint = {0}, endPoint = {1})", startPoint, endPoint));
1567
        return false;
1568
      }
1569
      public override bool Xline(Point3d point1, Point3d point2)
1570
      {
1571
        writeLine(indent, string.Format("WorldGeometry.Xline(point1 = {0}, point2 = {1})", point1, point2));
1572
        return false;
1573
      }
1574

    
1575
      public override void SetExtents(Extents3d extents)
1576
      {
1577
        writeLine(indent, "WorldGeometry.SetExtents({0}) ", extents);
1578
      }
1579
      public override void StartAttributesSegment()
1580
      {
1581
        writeLine(indent, "WorldGeometry.StartAttributesSegment called");
1582
      }
1583
    }
1584

    
1585
    class WorldDrawDumper : WorldDraw
1586
    {
1587
      WorldGeometryDumper _geom;
1588
      DrawContextDumper _ctx;
1589
      SubEntityTraits _subents;
1590
      RegenType _regenType;
1591
      int indent;
1592
      public WorldDrawDumper(Database db, int indent)
1593
        : base()
1594
      {
1595
        _regenType = RegenType;
1596
        this.indent = indent;
1597
        _geom = new WorldGeometryDumper(indent);
1598
        _ctx = new DrawContextDumper(db);
1599
        _subents = new SubEntityTraitsDumper(db);
1600
      }
1601
      public override double Deviation(DeviationType deviationType, Point3d pointOnCurve)
1602
      {
1603
        return 1e-9;
1604
      }
1605
      public override WorldGeometry Geometry
1606
      {
1607
        get
1608
        {
1609
          return _geom;
1610
        }
1611
      }
1612
      public override bool IsDragging
1613
      {
1614
        get
1615
        {
1616
          return false;
1617
        }
1618
      }
1619
      public override Int32 NumberOfIsolines
1620
      {
1621
        get
1622
        {
1623
          return 10;
1624
        }
1625
      }
1626
      public override Geometry RawGeometry
1627
      {
1628
        get
1629
        {
1630
          return _geom;
1631
        }
1632
      }
1633
      public override bool RegenAbort
1634
      {
1635
        get
1636
        {
1637
          return false;
1638
        }
1639
      }
1640
      public override RegenType RegenType
1641
      {
1642
        get
1643
        {
1644
          writeLine(indent, "RegenType is asked");
1645
          return _regenType;
1646
        }
1647
      }
1648
      public override SubEntityTraits SubEntityTraits
1649
      {
1650
        get
1651
        {
1652
          return _subents;
1653
        }
1654
      }
1655
      public override Context Context
1656
      {
1657
        get
1658
        {
1659
          return _ctx;
1660
        }
1661
      }
1662
    }
1663

    
1664
    /************************************************************************/
1665
    /* Dump the common data and WorldDraw information for all               */
1666
    /* entities without explicit dumpers                                    */
1667
    /************************************************************************/
1668
    void dump(Entity pEnt, int indent)
1669
    {
1670
      writeLine(indent++, pEnt.GetRXClass().Name, pEnt.Handle);
1671
      dumpEntityData(pEnt, indent);
1672
      writeLine(indent, "WorldDraw()");
1673
      using (Database db = pEnt.Database)
1674
      {
1675
        /**********************************************************************/
1676
        /* Create an OdGiWorldDraw instance for the vectorization             */
1677
        /**********************************************************************/
1678
        WorldDrawDumper wd = new WorldDrawDumper(db, indent + 1);
1679
        /**********************************************************************/
1680
        /* Call worldDraw()                                                   */
1681
        /**********************************************************************/
1682
        pEnt.WorldDraw(wd);
1683
      }
1684
    }
1685

    
1686
    /************************************************************************/
1687
    /* Proxy Entity Dumper                                                  */
1688
    /************************************************************************/
1689
    void dump(ProxyEntity pProxy, int indent)
1690
    {
1691
      // this will dump proxy entity graphics
1692
      dump((Entity)pProxy, indent);
1693
      writeLine(indent, "Proxy OriginalClassName", pProxy.OriginalClassName);
1694

    
1695
      DBObjectCollection collection = new DBObjectCollection(); ;
1696
      try
1697
      {
1698
        pProxy.ExplodeGeometry(collection);
1699
      }
1700
      catch (System.Exception)
1701
      {
1702
        return;
1703
      }
1704
      foreach (Entity ent in collection)
1705
      {
1706
        if (ent is Polyline2d)
1707
        {
1708
          Polyline2d pline2d = (Polyline2d)ent;
1709
          int i = 0;
1710

    
1711
          try
1712
          {
1713
            foreach (Entity ent1 in pline2d)
1714
            {
1715
              if (ent1 is Vertex2d)
1716
              {
1717
                Vertex2d vtx2d = (Vertex2d)ent1;
1718
                dump2dVertex(indent, vtx2d, i++);
1719
              }
1720
            }
1721
          }
1722
          catch (System.Exception)
1723
          {
1724
            return;
1725
          }
1726
        }
1727
      }
1728
    }
1729

    
1730
    /************************************************************************/
1731
    /* Radial Dimension Dumper                                              */
1732
    /************************************************************************/
1733
    void dump(RadialDimension pDim, int indent)
1734
    {
1735
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
1736
      writeLine(indent, "Center", pDim.Center);
1737
      writeLine(indent, "Chord Point", pDim.ChordPoint);
1738
      writeLine(indent, "Leader Length", pDim.LeaderLength);
1739
      dumpDimData(pDim, indent);
1740
    }
1741
    /************************************************************************/
1742
    /* Dump Raster Image Def                                               */
1743
    /************************************************************************/
1744
    void dumpRasterImageDef(ObjectId id, int indent)
1745
    {
1746
      if (!id.IsValid)
1747
        return;
1748
      using (RasterImageDef pDef = (RasterImageDef)id.Open(OpenMode.ForRead))
1749
      {
1750
        writeLine(indent++, pDef.GetRXClass().Name, pDef.Handle);
1751
        writeLine(indent, "Source Filename", shortenPath(pDef.SourceFileName));
1752
        writeLine(indent, "Loaded", pDef.IsLoaded);
1753
        writeLine(indent, "mm per Pixel", pDef.ResolutionMMPerPixel);
1754
        writeLine(indent, "Loaded", pDef.IsLoaded);
1755
        writeLine(indent, "Resolution Units", pDef.ResolutionUnits);
1756
        writeLine(indent, "Size", pDef.Size);
1757
      }
1758
    }
1759
    /************************************************************************/
1760
    /* Dump Raster Image Data                                               */
1761
    /************************************************************************/
1762
    void dumpRasterImageData(RasterImage pImage, int indent)
1763
    {
1764
      writeLine(indent, "Brightness", pImage.Brightness);
1765
      writeLine(indent, "Clipped", pImage.IsClipped);
1766
      writeLine(indent, "Contrast", pImage.Contrast);
1767
      writeLine(indent, "Fade", pImage.Fade);
1768
      writeLine(indent, "kClip", pImage.DisplayOptions & ImageDisplayOptions.Clip);
1769
      writeLine(indent, "kShow", pImage.DisplayOptions & ImageDisplayOptions.Show);
1770
      writeLine(indent, "kShowUnAligned", pImage.DisplayOptions & ImageDisplayOptions.ShowUnaligned);
1771
      writeLine(indent, "kTransparent", pImage.DisplayOptions & ImageDisplayOptions.Transparent);
1772
      writeLine(indent, "Scale", pImage.Scale);
1773

    
1774
      /********************************************************************/
1775
      /* Dump clip boundary                                               */
1776
      /********************************************************************/
1777
      if (pImage.IsClipped)
1778
      {
1779
        writeLine(indent, "Clip Boundary Type", pImage.ClipBoundaryType);
1780
        if (pImage.ClipBoundaryType != ClipBoundaryType.Invalid)
1781
        {
1782
          Point2dCollection pt = pImage.GetClipBoundary();
1783
          for (int i = 0; i < pt.Count; i++)
1784
          {
1785
            writeLine(indent, string.Format("Clip Point {0}", i), pt[i]);
1786
          }
1787
        }
1788
      }
1789

    
1790
      /********************************************************************/
1791
      /* Dump frame                                                       */
1792
      /********************************************************************/
1793
      Point3dCollection vertices = pImage.GetVertices();
1794
      for (int i = 0; i < vertices.Count; i++)
1795
      {
1796
        writeLine(indent, "Frame Vertex " + i.ToString(), vertices[i]);
1797
      }
1798

    
1799
      /********************************************************************/
1800
      /* Dump orientation                                                 */
1801
      /********************************************************************/
1802
      writeLine(indent, "Orientation");
1803
      writeLine(indent + 1, "Origin", pImage.Orientation.Origin);
1804
      writeLine(indent + 1, "uVector", pImage.Orientation.Xaxis);
1805
      writeLine(indent + 1, "vVector", pImage.Orientation.Yaxis);
1806
      dumpRasterImageDef(pImage.ImageDefId, indent);
1807
      dumpEntityData(pImage, indent);
1808
    }
1809

    
1810
    /************************************************************************/
1811
    /* Raster Image Dumper                                                  */
1812
    /************************************************************************/
1813
    void dump(RasterImage pImage, int indent)
1814
    {
1815
      writeLine(indent++, pImage.GetRXClass().Name, pImage.Handle);
1816
      writeLine(indent, "Image size", pImage.ImageSize(true));
1817
      dumpRasterImageData(pImage, indent);
1818
    }
1819

    
1820
    /************************************************************************/
1821
    /* Ray Dumper                                                          */
1822
    /************************************************************************/
1823
    void dump(Ray pRay, int indent)
1824
    {
1825
      writeLine(indent++, pRay.GetRXClass().Name, pRay.Handle);
1826
      writeLine(indent, "Base Point", pRay.BasePoint);
1827
      writeLine(indent, "Unit Direction", pRay.UnitDir);
1828
      dumpCurveData(pRay, indent);
1829
    }
1830

    
1831
    /************************************************************************/
1832
    /* Region Dumper                                                        */
1833
    /************************************************************************/
1834
    void dump(Region pRegion, int indent)
1835
    {
1836
      writeLine(indent++, pRegion.GetRXClass().Name, pRegion.Handle);
1837
      dumpEntityData(pRegion, indent);
1838
    }
1839
    /************************************************************************/
1840
    /* Rotated Dimension Dumper                                             */
1841
    /************************************************************************/
1842
    void dump(RotatedDimension pDim, int indent)
1843
    {
1844
      writeLine(indent++, pDim.GetRXClass().Name, pDim.Handle);
1845
      writeLine(indent, "Dimension Line Point", pDim.DimLinePoint);
1846
      writeLine(indent, "Oblique", toDegreeString(pDim.Oblique));
1847
      writeLine(indent, "Rotation", toDegreeString(pDim.Rotation));
1848
      writeLine(indent, "Extension Line 1 Point", pDim.XLine1Point);
1849
      writeLine(indent, "Extension Line 2 Point", pDim.XLine2Point);
1850
      dumpDimData(pDim, indent);
1851
    }
1852
    /************************************************************************/
1853
    /* Shape Dumper                                                          */
1854
    /************************************************************************/
1855
    void dump(Shape pShape, int indent)
1856
    {
1857
      writeLine(indent++, pShape.GetRXClass().Name, pShape.Handle);
1858

    
1859
      if (!pShape.StyleId.IsNull)
1860
      {
1861
        using (TextStyleTableRecord pStyle = (TextStyleTableRecord)pShape.StyleId.Open(OpenMode.ForRead))
1862
          writeLine(indent, "Filename", shortenPath(pStyle.FileName));
1863
      }
1864

    
1865
      writeLine(indent, "Shape Number", pShape.ShapeNumber);
1866
      writeLine(indent, "Shape Name", pShape.Name);
1867
      writeLine(indent, "Position", pShape.Position);
1868
      writeLine(indent, "Size", pShape.Size);
1869
      writeLine(indent, "Rotation", toDegreeString(pShape.Rotation));
1870
      writeLine(indent, "Oblique", toDegreeString(pShape.Oblique));
1871
      writeLine(indent, "Normal", pShape.Normal);
1872
      writeLine(indent, "Thickness", pShape.Thickness);
1873
      dumpEntityData(pShape, indent);
1874
    }
1875

    
1876
    /************************************************************************/
1877
    /* Solid Dumper                                                         */
1878
    /************************************************************************/
1879
    // TODO:
1880
    /*  void dump(Solid pSolid, int indent)
1881
  {
1882
    writeLine(indent++, pSolid.GetRXClass().Name, pSolid.Handle);
1883

    
1884
    for (int i = 0; i < 4; i++)
1885
    {
1886
      writeLine(indent, "Point " + i.ToString(),  pSolid .GetPointAt(i));
1887
    }
1888
    dumpEntityData(pSolid, indent);
1889
  }
1890
*/
1891
    /************************************************************************/
1892
    /* Spline Dumper                                                        */
1893
    /************************************************************************/
1894
    void dump(Spline pSpline, int indent)
1895
    {
1896
      writeLine(indent++, pSpline.GetRXClass().Name, pSpline.Handle);
1897

    
1898
      NurbsData data = pSpline.NurbsData;
1899
      writeLine(indent, "Degree", data.Degree);
1900
      writeLine(indent, "Rational", data.Rational);
1901
      writeLine(indent, "Periodic", data.Periodic);
1902
      writeLine(indent, "Control Point Tolerance", data.ControlPointTolerance);
1903
      writeLine(indent, "Knot Tolerance", data.KnotTolerance);
1904

    
1905
      writeLine(indent, "Number of control points", data.GetControlPoints().Count);
1906
      for (int i = 0; i < data.GetControlPoints().Count; i++)
1907
      {
1908
        writeLine(indent, "Control Point " + i.ToString(), data.GetControlPoints()[i]);
1909
      }
1910

    
1911
      writeLine(indent, "Number of Knots", data.GetKnots().Count);
1912
      for (int i = 0; i < data.GetKnots().Count; i++)
1913
      {
1914
        writeLine(indent, "Knot " + i.ToString(), data.GetKnots()[i]);
1915
      }
1916

    
1917
      if (data.Rational)
1918
      {
1919
        writeLine(indent, "Number of Weights", data.GetWeights().Count);
1920
        for (int i = 0; i < data.GetWeights().Count; i++)
1921
        {
1922
          writeLine(indent, "Weight " + i.ToString(), data.GetWeights()[i]);
1923
        }
1924
      }
1925
      dumpCurveData(pSpline, indent);
1926
    }
1927
    /************************************************************************/
1928
    /* Table Dumper                                                         */
1929
    /************************************************************************/
1930
    void dump(Table pTable, int indent)
1931
    {
1932
      writeLine(indent++, pTable.GetRXClass().Name, pTable.Handle);
1933
      writeLine(indent, "Position", pTable.Position);
1934
      writeLine(indent, "X-Direction", pTable.Direction);
1935
      writeLine(indent, "Normal", pTable.Normal);
1936
      writeLine(indent, "Height", (int)pTable.Height);
1937
      writeLine(indent, "Width", (int)pTable.Width);
1938
      writeLine(indent, "Rows", (int)pTable.NumRows);
1939
      writeLine(indent, "Columns", (int)pTable.NumColumns);
1940

    
1941
      // TODO:
1942
      //TableStyle pStyle = (TableStyle)pTable.TableStyle.Open(OpenMode.ForRead);
1943
      //writeLine(indent, "Table Style",               pStyle.Name);
1944
      dumpEntityData(pTable, indent);
1945
    }
1946
    /************************************************************************/
1947
    /* Text Dumper                                                          */
1948
    /************************************************************************/
1949
    void dump(DBText pText, int indent)
1950
    {
1951
      writeLine();
1952
      writeLine(indent++, pText.GetRXClass().Name, pText.Handle);
1953
      dumpTextData(pText, indent);
1954
    }
1955
    /************************************************************************/
1956
    /* Trace Dumper                                                         */
1957
    /************************************************************************/
1958
    void dump(Trace pTrace, int indent)
1959
    {
1960
      writeLine(indent++, pTrace.GetRXClass().Name, pTrace.Handle);
1961

    
1962
      for (short i = 0; i < 4; i++)
1963
      {
1964
        writeLine(indent, "Point " + i.ToString(), pTrace.GetPointAt(i));
1965
      }
1966
      dumpEntityData(pTrace, indent);
1967
    }
1968

    
1969
    /************************************************************************/
1970
    /* Trace UnderlayReference                                                         */
1971
    /************************************************************************/
1972
    void dump(UnderlayReference pEnt, int indent)
1973
    {
1974
      writeLine(indent++, pEnt.GetRXClass().Name, pEnt.Handle);
1975
      writeLine(indent, "UnderlayReference Path ", pEnt.Path);
1976
      writeLine(indent, "UnderlayReference Position ", pEnt.Position);
1977
    }
1978

    
1979
    /************************************************************************/
1980
    /* Viewport Dumper                                                       */
1981
    /************************************************************************/
1982
    void dump(Teigha.DatabaseServices.Viewport pVport, int indent)
1983
    {
1984
      writeLine(indent++, pVport.GetRXClass().Name, pVport.Handle);
1985
      writeLine(indent, "Back Clip Distance", pVport.BackClipDistance);
1986
      writeLine(indent, "Back Clip On", pVport.BackClipOn);
1987
      writeLine(indent, "Center Point", pVport.CenterPoint);
1988
      writeLine(indent, "Circle sides", pVport.CircleSides);
1989
      writeLine(indent, "Custom Scale", pVport.CustomScale);
1990
      writeLine(indent, "Elevation", pVport.Elevation);
1991
      writeLine(indent, "Front Clip at Eye", pVport.FrontClipAtEyeOn);
1992
      writeLine(indent, "Front Clip Distance", pVport.FrontClipDistance);
1993
      writeLine(indent, "Front Clip On", pVport.FrontClipOn);
1994
      writeLine(indent, "Plot style sheet", pVport.EffectivePlotStyleSheet);
1995

    
1996
      ObjectIdCollection layerIds = pVport.GetFrozenLayers();
1997
      if (layerIds.Count > 0)
1998
      {
1999
        writeLine(indent, "Frozen Layers:");
2000
        for (int i = 0; i < layerIds.Count; i++)
2001
        {
2002
          writeLine(indent + 1, i, layerIds[i]);
2003
        }
2004
      }
2005
      else
2006
      {
2007
        writeLine(indent, "Frozen Layers", "None");
2008
      }
2009

    
2010
      Point3d origin = new Point3d();
2011
      Vector3d xAxis = new Vector3d();
2012
      Vector3d yAxis = new Vector3d();
2013
      pVport.GetUcs(ref origin, ref xAxis, ref yAxis);
2014
      writeLine(indent, "UCS origin", origin);
2015
      writeLine(indent, "UCS x-Axis", xAxis);
2016
      writeLine(indent, "UCS y-Axis", yAxis);
2017
      writeLine(indent, "Grid Increment", pVport.GridIncrement);
2018
      writeLine(indent, "Grid On", pVport.GridOn);
2019
      writeLine(indent, "Height", pVport.Height);
2020
      writeLine(indent, "Lens Length", pVport.LensLength);
2021
      writeLine(indent, "Locked", pVport.Locked);
2022
      writeLine(indent, "Non-Rectangular Clip", pVport.NonRectClipOn);
2023

    
2024
      if (!pVport.NonRectClipEntityId.IsNull)
2025
      {
2026
        writeLine(indent, "Non-rectangular Clipper", pVport.NonRectClipEntityId.Handle);
2027
      }
2028
      writeLine(indent, "Render Mode", pVport.RenderMode);
2029
      writeLine(indent, "Remove Hidden Lines", pVport.HiddenLinesRemoved);
2030
      writeLine(indent, "Shade Plot", pVport.ShadePlot);
2031
      writeLine(indent, "Snap Isometric", pVport.SnapIsometric);
2032
      writeLine(indent, "Snap On", pVport.SnapOn);
2033
      writeLine(indent, "Transparent", pVport.Transparent);
2034
      writeLine(indent, "UCS Follow", pVport.UcsFollowModeOn);
2035
      writeLine(indent, "UCS Icon at Origin", pVport.UcsIconAtOrigin);
2036

    
2037
      writeLine(indent, "UCS Orthographic", pVport.UcsOrthographic);
2038
      writeLine(indent, "UCS Saved with VP", pVport.UcsPerViewport);
2039

    
2040
      if (!pVport.UcsName.IsNull)
2041
      {
2042
        using (UcsTableRecord pUCS = (UcsTableRecord)pVport.UcsName.Open(OpenMode.ForRead))
2043
          writeLine(indent, "UCS Name", pUCS.Name);
2044
      }
2045
      else
2046
      {
2047
        writeLine(indent, "UCS Name", "Null");
2048
      }
2049

    
2050
      writeLine(indent, "View Center", pVport.ViewCenter);
2051
      writeLine(indent, "View Height", pVport.ViewHeight);
2052
      writeLine(indent, "View Target", pVport.ViewTarget);
2053
      writeLine(indent, "Width", pVport.Width);
2054
      dumpEntityData(pVport, indent);
2055

    
2056
      {
2057
        using (DBObjectCollection collection = new DBObjectCollection())
2058
        {
2059
          try
2060
          {
2061
            pVport.ExplodeGeometry(collection);
2062

    
2063
            foreach (Entity ent in collection)
2064
            {
2065
              if (ent is Polyline2d)
2066
              {
2067
                Polyline2d pline2d = (Polyline2d)ent;
2068
                int i = 0;
2069
                foreach (Entity ent1 in pline2d)
2070
                {
2071
                  if (ent1 is Vertex2d)
2072
                  {
2073
                    Vertex2d vtx2d = (Vertex2d)ent1;
2074
                    dump2dVertex(indent, vtx2d, i++);
2075
                  }
2076
                }
2077
              }
2078
            }
2079
          }
2080
          catch (System.Exception)
2081
          {
2082
          }
2083
        }
2084
      }
2085
    }
2086

    
2087
    /************************************************************************/
2088
    /* Wipeout Dumper                                                  */
2089
    /************************************************************************/
2090
    void dump(Wipeout pWipeout, int indent)
2091
    {
2092
      writeLine(indent++, pWipeout.GetRXClass().Name, pWipeout.Handle);
2093
      dumpRasterImageData(pWipeout, indent);
2094
    }
2095

    
2096
    /************************************************************************/
2097
    /* Xline Dumper                                                         */
2098
    /************************************************************************/
2099
    void dump(Xline pXline, int indent)
2100
    {
2101
      writeLine(indent++, pXline.GetRXClass().Name, pXline.Handle);
2102
      writeLine(indent, "Base Point", pXline.BasePoint);
2103
      writeLine(indent, "Unit Direction", pXline.UnitDir);
2104
      dumpCurveData(pXline, indent);
2105
    }
2106

    
2107
    public void dump(Database pDb, int indent)
2108
    {
2109
      using (BlockTableRecord btr = (BlockTableRecord)pDb.CurrentSpaceId.GetObject(OpenMode.ForRead))
2110
      {
2111
        using (Layout pLayout = (Layout)btr.LayoutId.GetObject(OpenMode.ForRead))
2112
        {
2113
          string layoutName = "";
2114
          layoutName = pLayout.LayoutName;
2115
          writeLine(indent, "Current Space: Layout Name ", layoutName);
2116
        }
2117
      }
2118

    
2119
      dumpHeader(pDb, indent);
2120
      dumpLayers(pDb, indent);
2121
      dumpLinetypes(pDb, indent);
2122
      dumpTextStyles(pDb, indent);
2123
      dumpDimStyles(pDb, indent);
2124
      dumpRegApps(pDb, indent);
2125
      dumpViewports(pDb, indent);
2126
      dumpViews(pDb, indent);
2127
      dumpMLineStyles(pDb, indent);
2128
      dumpUCSTable(pDb, indent);
2129
      dumpObject(pDb.NamedObjectsDictionaryId, "Named Objects Dictionary", indent);
2130
      dumpBlocks(pDb, indent);
2131
    }
2132
    /************************************************************************/
2133
    /* Dump the BlockTable                                                  */
2134
    /************************************************************************/
2135
    public void dumpBlocks(Database pDb, int indent)
2136
    {
2137
      /**********************************************************************/
2138
      /* Get a pointer to the BlockTable                               */
2139
      /**********************************************************************/
2140
      using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead))
2141
      {
2142
        /**********************************************************************/
2143
        /* Dump the Description                                               */
2144
        /**********************************************************************/
2145
        writeLine();
2146
        writeLine(indent++, pTable.GetRXClass().Name);
2147

    
2148
        /**********************************************************************/
2149
        /* Step through the BlockTable                                        */
2150
        /**********************************************************************/
2151
        foreach (ObjectId id in pTable)
2152
        {
2153
          /********************************************************************/
2154
          /* Open the BlockTableRecord for Reading                            */
2155
          /********************************************************************/
2156
          using (BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead))
2157
          {
2158
            /********************************************************************/
2159
            /* Dump the BlockTableRecord                                        */
2160
            /********************************************************************/
2161
            writeLine();
2162
            writeLine(indent, pBlock.GetRXClass().Name);
2163
            writeLine(indent + 1, "Name", pBlock.Name);
2164
            writeLine(indent + 1, "Anonymous", pBlock.IsAnonymous);
2165
            writeLine(indent + 1, "Comments", pBlock.Comments);
2166
            writeLine(indent + 1, "Origin", pBlock.Origin);
2167
            writeLine(indent + 1, "Block Insert Units", pBlock.Units);
2168
            writeLine(indent + 1, "Block Scaling", pBlock.BlockScaling);
2169
            writeLine(indent + 1, "Explodable", pBlock.Explodable);
2170
            writeLine(indent + 1, "IsDynamicBlock", pBlock.IsDynamicBlock);
2171

    
2172
            try
2173
            {
2174
              Extents3d extents = new Extents3d(new Point3d(1E+20, 1E+20, 1E+20), new Point3d(1E-20, 1E-20, 1E-20));
2175
              extents.AddBlockExtents(pBlock);
2176
              writeLine(indent + 1, "Min Extents", extents.MinPoint);
2177
              writeLine(indent + 1, "Max Extents", extents.MaxPoint);
2178
            }
2179
            catch (System.Exception)
2180
            {
2181
            }
2182
            writeLine(indent + 1, "Layout", pBlock.IsLayout);
2183
            writeLine(indent + 1, "Has Attribute Definitions", pBlock.HasAttributeDefinitions);
2184
            writeLine(indent + 1, "Xref Status", pBlock.XrefStatus);
2185
            if (pBlock.XrefStatus != XrefStatus.NotAnXref)
2186
            {
2187
              writeLine(indent + 1, "Xref Path", pBlock.PathName);
2188
              writeLine(indent + 1, "From Xref Attach", pBlock.IsFromExternalReference);
2189
              writeLine(indent + 1, "From Xref Overlay", pBlock.IsFromOverlayReference);
2190
              writeLine(indent + 1, "Xref Unloaded", pBlock.IsUnloaded);
2191
            }
2192

    
2193
            /********************************************************************/
2194
            /* Step through the BlockTableRecord                                */
2195
            /********************************************************************/
2196
            foreach (ObjectId entid in pBlock)
2197
            {
2198
              /********************************************************************/
2199
              /* Dump the Entity                                                  */
2200
              /********************************************************************/
2201
              dumpEntity(entid, indent + 1);
2202
            }
2203
          }
2204
        }
2205
      }
2206
    }
2207
    public void dumpDimStyles(Database pDb, int indent)
2208
    {
2209
      /**********************************************************************/
2210
      /* Get a SmartPointer to the DimStyleTable                            */
2211
      /**********************************************************************/
2212
      using (DimStyleTable pTable = (DimStyleTable)pDb.DimStyleTableId.Open(OpenMode.ForRead))
2213
      {
2214
        /**********************************************************************/
2215
        /* Dump the Description                                               */
2216
        /**********************************************************************/
2217
        writeLine();
2218
        writeLine(indent++, pTable.GetRXClass().Name);
2219

    
2220
        /**********************************************************************/
2221
        /* Step through the DimStyleTable                                    */
2222
        /**********************************************************************/
2223
        foreach (ObjectId id in pTable)
2224
        {
2225
          /*********************************************************************/
2226
          /* Open the DimStyleTableRecord for Reading                         */
2227
          /*********************************************************************/
2228
          using (DimStyleTableRecord pRecord = (DimStyleTableRecord)id.Open(OpenMode.ForRead))
2229
          {
2230
            /*********************************************************************/
2231
            /* Dump the DimStyleTableRecord                                      */
2232
            /*********************************************************************/
2233
            writeLine();
2234
            writeLine(indent, pRecord.GetRXClass().Name);
2235
            writeLine(indent, "Name", pRecord.Name);
2236
            writeLine(indent, "Arc Symbol", toArcSymbolTypeString(pRecord.Dimarcsym));
2237

    
2238
            writeLine(indent, "Background Text Color", pRecord.Dimtfillclr);
2239
            writeLine(indent, "BackgroundText Flags", pRecord.Dimtfill);
2240
            writeLine(indent, "Extension Line 1 Linetype", pRecord.Dimltex1);
2241
            writeLine(indent, "Extension Line 2 Linetype", pRecord.Dimltex2);
2242
            writeLine(indent, "Dimension Line Linetype", pRecord.Dimltype);
2243
            writeLine(indent, "Extension Line Fixed Len", pRecord.Dimfxlen);
2244
            writeLine(indent, "Extension Line Fixed Len Enable", pRecord.DimfxlenOn);
2245
            writeLine(indent, "Jog Angle", toDegreeString(pRecord.Dimjogang));
2246
            writeLine(indent, "Modified For Recompute", pRecord.IsModifiedForRecompute);
2247
            writeLine(indent, "DIMADEC", pRecord.Dimadec);
2248
            writeLine(indent, "DIMALT", pRecord.Dimalt);
2249
            writeLine(indent, "DIMALTD", pRecord.Dimaltd);
2250
            writeLine(indent, "DIMALTF", pRecord.Dimaltf);
2251
            writeLine(indent, "DIMALTRND", pRecord.Dimaltrnd);
2252
            writeLine(indent, "DIMALTTD", pRecord.Dimalttd);
2253
            writeLine(indent, "DIMALTTZ", pRecord.Dimalttz);
2254
            writeLine(indent, "DIMALTU", pRecord.Dimaltu);
2255
            writeLine(indent, "DIMALTZ", pRecord.Dimaltz);
2256
            writeLine(indent, "DIMAPOST", pRecord.Dimapost);
2257
            writeLine(indent, "DIMASZ", pRecord.Dimasz);
2258
            writeLine(indent, "DIMATFIT", pRecord.Dimatfit);
2259
            writeLine(indent, "DIMAUNIT", pRecord.Dimaunit);
2260
            writeLine(indent, "DIMAZIN", pRecord.Dimazin);
2261
            writeLine(indent, "DIMBLK", pRecord.Dimblk);
2262
            writeLine(indent, "DIMBLK1", pRecord.Dimblk1);
2263
            writeLine(indent, "DIMBLK2", pRecord.Dimblk2);
2264
            writeLine(indent, "DIMCEN", pRecord.Dimcen);
2265
            writeLine(indent, "DIMCLRD", pRecord.Dimclrd);
2266
            writeLine(indent, "DIMCLRE", pRecord.Dimclre);
2267
            writeLine(indent, "DIMCLRT", pRecord.Dimclrt);
2268
            writeLine(indent, "DIMDEC", pRecord.Dimdec);
2269
            writeLine(indent, "DIMDLE", pRecord.Dimdle);
2270
            writeLine(indent, "DIMDLI", pRecord.Dimdli);
2271
            writeLine(indent, "DIMDSEP", pRecord.Dimdsep);
2272
            writeLine(indent, "DIMEXE", pRecord.Dimexe);
2273
            writeLine(indent, "DIMEXO", pRecord.Dimexo);
2274
            writeLine(indent, "DIMFRAC", pRecord.Dimfrac);
2275
            writeLine(indent, "DIMGAP", pRecord.Dimgap);
2276
            writeLine(indent, "DIMJUST", pRecord.Dimjust);
2277
            writeLine(indent, "DIMLDRBLK", pRecord.Dimldrblk);
2278
            writeLine(indent, "DIMLFAC", pRecord.Dimlfac);
2279
            writeLine(indent, "DIMLIM", pRecord.Dimlim);
2280
            writeLine(indent, "DIMLUNIT", pRecord.Dimlunit);
2281
            writeLine(indent, "DIMLWD", pRecord.Dimlwd);
2282
            writeLine(indent, "DIMLWE", pRecord.Dimlwe);
2283
            writeLine(indent, "DIMPOST", pRecord.Dimpost);
2284
            writeLine(indent, "DIMRND", pRecord.Dimrnd);
2285
            writeLine(indent, "DIMSAH", pRecord.Dimsah);
2286
            writeLine(indent, "DIMSCALE", pRecord.Dimscale);
2287
            writeLine(indent, "DIMSD1", pRecord.Dimsd1);
2288
            writeLine(indent, "DIMSD2", pRecord.Dimsd2);
2289
            writeLine(indent, "DIMSE1", pRecord.Dimse1);
2290
            writeLine(indent, "DIMSE2", pRecord.Dimse2);
2291
            writeLine(indent, "DIMSOXD", pRecord.Dimsoxd);
2292
            writeLine(indent, "DIMTAD", pRecord.Dimtad);
2293
            writeLine(indent, "DIMTDEC", pRecord.Dimtdec);
2294
            writeLine(indent, "DIMTFAC", pRecord.Dimtfac);
2295
            writeLine(indent, "DIMTIH", pRecord.Dimtih);
2296
            writeLine(indent, "DIMTIX", pRecord.Dimtix);
2297
            writeLine(indent, "DIMTM", pRecord.Dimtm);
2298
            writeLine(indent, "DIMTOFL", pRecord.Dimtofl);
2299
            writeLine(indent, "DIMTOH", pRecord.Dimtoh);
2300
            writeLine(indent, "DIMTOL", pRecord.Dimtol);
2301
            writeLine(indent, "DIMTOLJ", pRecord.Dimtolj);
2302
            writeLine(indent, "DIMTP", pRecord.Dimtp);
2303
            writeLine(indent, "DIMTSZ", pRecord.Dimtsz);
2304
            writeLine(indent, "DIMTVP", pRecord.Dimtvp);
2305
            writeLine(indent, "DIMTXSTY", pRecord.Dimtxsty);
2306
            writeLine(indent, "DIMTXT", pRecord.Dimtxt);
2307
            writeLine(indent, "DIMTZIN", pRecord.Dimtzin);
2308
            writeLine(indent, "DIMUPT", pRecord.Dimupt);
2309
            writeLine(indent, "DIMZIN", pRecord.Dimzin);
2310

    
2311
            dumpSymbolTableRecord(pRecord, indent);
2312
          }
2313
        }
2314
      }
2315
    }
2316
    public void dumpEntity(ObjectId id, int indent)
2317
    {
2318
      /**********************************************************************/
2319
      /* Get a pointer to the Entity                                   */
2320
      /**********************************************************************/
2321
      using (Entity pEnt = (Entity)id.Open(OpenMode.ForRead, false, true))
2322
      {
2323
        /**********************************************************************/
2324
        /* Dump the entity                                                    */
2325
        /**********************************************************************/
2326
        writeLine();
2327
        // Protocol extensions are not supported in DD.NET (as well as in ARX.NET)
2328
        // so we just switch by entity type here
2329
        // (maybe it makes sense to make a map: type -> delegate)
2330
        switch (pEnt.GetRXClass().Name)
2331
        {
2332
          case "AcDbAlignedDimension":
2333
            dump((AlignedDimension)pEnt, indent);
2334
            break;
2335
          case "AcDbArc":
2336
            dump((Arc)pEnt, indent);
2337
            break;
2338
          case "AcDbArcDimension":
2339
            dump((ArcDimension)pEnt, indent);
2340
            break;
2341
          case "AcDbBlockReference":
2342
            dump((BlockReference)pEnt, indent);
2343
            break;
2344
          case "AcDbBody":
2345
            dump((Body)pEnt, indent);
2346
            break;
2347
          case "AcDbCircle":
2348
            dump((Circle)pEnt, indent);
2349
            break;
2350
          case "AcDbPoint":
2351
            dump((DBPoint)pEnt, indent);
2352
            break;
2353
          case "AcDbText":
2354
            dump((DBText)pEnt, indent);
2355
            break;
2356
          case "AcDbDiametricDimension":
2357
            dump((DiametricDimension)pEnt, indent);
2358
            break;
2359
          case "AcDbViewport":
2360
            dump((Teigha.DatabaseServices.Viewport)pEnt, indent);
2361
            break;
2362
          case "AcDbEllipse":
2363
            dump((Ellipse)pEnt, indent);
2364
            break;
2365
          case "AcDbFace":
2366
            dump((Face)pEnt, indent);
2367
            break;
2368
          case "AcDbFcf":
2369
            dump((FeatureControlFrame)pEnt, indent);
2370
            break;
2371
          case "AcDbHatch":
2372
            dump((Hatch)pEnt, indent);
2373
            break;
2374
          case "AcDbLeader":
2375
            dump((Leader)pEnt, indent);
2376
            break;
2377
          case "AcDbLine":
2378
            dump((Line)pEnt, indent);
2379
            break;
2380
          case "AcDb2LineAngularDimension":
2381
            dump((LineAngularDimension2)pEnt, indent);
2382
            break;
2383
          case "AcDbMInsertBlock":
2384
            dump((MInsertBlock)pEnt, indent);
2385
            break;
2386
          case "AcDbMline":
2387
            dump((Mline)pEnt, indent);
2388
            break;
2389
          case "AcDbMText":
2390
            dump((MText)pEnt, indent);
2391
            break;
2392
          case "AcDbOle2Frame":
2393
            dump((Ole2Frame)pEnt, indent);
2394
            break;
2395
          case "AcDbOrdinateDimension":
2396
            dump((OrdinateDimension)pEnt, indent);
2397
            break;
2398
          case "AcDb3PointAngularDimension":
2399
            dump((Point3AngularDimension)pEnt, indent);
2400
            break;
2401
          case "AcDbPolyFaceMesh":
2402
            dump((PolyFaceMesh)pEnt, indent);
2403
            break;
2404
          case "AcDbPolygonMesh":
2405
            dump((PolygonMesh)pEnt, indent);
2406
            break;
2407
          case "AcDbPolyline":
2408
            dump((Teigha.DatabaseServices.Polyline)pEnt, indent);
2409
            break;
2410
          case "AcDb2dPolyline":
2411
            dump((Polyline2d)pEnt, indent);
2412
            break;
2413
          case "AcDb3dPolyline":
2414
            dump((Polyline3d)pEnt, indent);
2415
            break;
2416
          case "AcDbProxyEntity":
2417
            dump((ProxyEntity)pEnt, indent);
2418
            break;
2419
          case "AcDbRadialDimension":
2420
            dump((RadialDimension)pEnt, indent);
2421
            break;
2422
          case "AcDbRasterImage":
2423
            dump((RasterImage)pEnt, indent);
2424
            break;
2425
          case "AcDbRay":
2426
            dump((Ray)pEnt, indent);
2427
            break;
2428
          case "AcDbRegion":
2429
            dump((Region)pEnt, indent);
2430
            break;
2431
          case "AcDbRotatedDimension":
2432
            dump((RotatedDimension)pEnt, indent);
2433
            break;
2434
          case "AcDbShape":
2435
            dump((Shape)pEnt, indent);
2436
            break;
2437
          case "AcDb3dSolid":
2438
            dump((Solid3d)pEnt, indent);
2439
            break;
2440
          case "AcDbSpline":
2441
            dump((Spline)pEnt, indent);
2442
            break;
2443
          case "AcDbTable":
2444
            dump((Table)pEnt, indent);
2445
            break;
2446
          case "AcDbTrace":
2447
            dump((Trace)pEnt, indent);
2448
            break;
2449
          case "AcDbWipeout":
2450
            dump((Wipeout)pEnt, indent);
2451
            break;
2452
          case "AcDbXline":
2453
            dump((Xline)pEnt, indent);
2454
            break;
2455
          case "AcDbPdfReference":
2456
          case "AcDbDwfReference":
2457
          case "AcDbDgnReference":
2458
            dump((UnderlayReference)pEnt, indent);
2459
            break;
2460
          default:
2461
            dump(pEnt, indent);
2462
            break;
2463
        }
2464
        /* Dump the Xdata                                                     */
2465
        /**********************************************************************/
2466
        dumpXdata(pEnt.XData, indent);
2467

    
2468
        /**********************************************************************/
2469
        /* Dump the Extension Dictionary                                      */
2470
        /**********************************************************************/
2471
        if (!pEnt.ExtensionDictionary.IsNull)
2472
        {
2473
          dumpObject(pEnt.ExtensionDictionary, "ACAD_XDICTIONARY", indent);
2474
        }
2475
      }
2476
    }
2477
    public void dumpHeader(Database pDb, int indent)
2478
    {
2479
      writeLine();
2480
      writeLine(indent, "Filename:", shortenPath(pDb.Filename));
2481
      writeLine(indent, ".dwg file version:", pDb.OriginalFileVersion);
2482

    
2483
      writeLine();
2484
      writeLine(indent++, "Header Variables:");
2485

    
2486
      //writeLine();
2487
      //writeLine(indent, "TDCREATE:", pDb.TDCREATE);
2488
      //writeLine(indent, "TDUPDATE:", pDb.TDUPDATE);
2489

    
2490
      writeLine();
2491
      writeLine(indent, "ANGBASE", pDb.Angbase);
2492
      writeLine(indent, "ANGDIR", pDb.Angdir);
2493
      writeLine(indent, "ATTMODE", pDb.Attmode);
2494
      writeLine(indent, "AUNITS", pDb.Aunits);
2495
      writeLine(indent, "AUPREC", pDb.Auprec);
2496
      writeLine(indent, "CECOLOR", pDb.Cecolor);
2497
      writeLine(indent, "CELTSCALE", pDb.Celtscale);
2498
      writeLine(indent, "CHAMFERA", pDb.Chamfera);
2499
      writeLine(indent, "CHAMFERB", pDb.Chamferb);
2500
      writeLine(indent, "CHAMFERC", pDb.Chamferc);
2501
      writeLine(indent, "CHAMFERD", pDb.Chamferd);
2502
      writeLine(indent, "CMLJUST", pDb.Cmljust);
2503
      writeLine(indent, "CMLSCALE", pDb.Cmljust);
2504
      writeLine(indent, "DIMADEC", pDb.Dimadec);
2505
      writeLine(indent, "DIMALT", pDb.Dimalt);
2506
      writeLine(indent, "DIMALTD", pDb.Dimaltd);
2507
      writeLine(indent, "DIMALTF", pDb.Dimaltf);
2508
      writeLine(indent, "DIMALTRND", pDb.Dimaltrnd);
2509
      writeLine(indent, "DIMALTTD", pDb.Dimalttd);
2510
      writeLine(indent, "DIMALTTZ", pDb.Dimalttz);
2511
      writeLine(indent, "DIMALTU", pDb.Dimaltu);
2512
      writeLine(indent, "DIMALTZ", pDb.Dimaltz);
2513
      writeLine(indent, "DIMAPOST", pDb.Dimapost);
2514
      writeLine(indent, "DIMASZ", pDb.Dimasz);
2515
      writeLine(indent, "DIMATFIT", pDb.Dimatfit);
2516
      writeLine(indent, "DIMAUNIT", pDb.Dimaunit);
2517
      writeLine(indent, "DIMAZIN", pDb.Dimazin);
2518
      writeLine(indent, "DIMBLK", pDb.Dimblk);
2519
      writeLine(indent, "DIMBLK1", pDb.Dimblk1);
2520
      writeLine(indent, "DIMBLK2", pDb.Dimblk2);
2521
      writeLine(indent, "DIMCEN", pDb.Dimcen);
2522
      writeLine(indent, "DIMCLRD", pDb.Dimclrd);
2523
      writeLine(indent, "DIMCLRE", pDb.Dimclre);
2524
      writeLine(indent, "DIMCLRT", pDb.Dimclrt);
2525
      writeLine(indent, "DIMDEC", pDb.Dimdec);
2526
      writeLine(indent, "DIMDLE", pDb.Dimdle);
2527
      writeLine(indent, "DIMDLI", pDb.Dimdli);
2528
      writeLine(indent, "DIMDSEP", pDb.Dimdsep);
2529
      writeLine(indent, "DIMEXE", pDb.Dimexe);
2530
      writeLine(indent, "DIMEXO", pDb.Dimexo);
2531
      writeLine(indent, "DIMFRAC", pDb.Dimfrac);
2532
      writeLine(indent, "DIMGAP", pDb.Dimgap);
2533
      writeLine(indent, "DIMJUST", pDb.Dimjust);
2534
      writeLine(indent, "DIMLDRBLK", pDb.Dimldrblk);
2535
      writeLine(indent, "DIMLFAC", pDb.Dimlfac);
2536
      writeLine(indent, "DIMLIM", pDb.Dimlim);
2537
      writeLine(indent, "DIMLUNIT", pDb.Dimlunit);
2538
      writeLine(indent, "DIMLWD", pDb.Dimlwd);
2539
      writeLine(indent, "DIMLWE", pDb.Dimlwe);
2540
      writeLine(indent, "DIMPOST", pDb.Dimpost);
2541
      writeLine(indent, "DIMRND", pDb.Dimrnd);
2542
      writeLine(indent, "DIMSAH", pDb.Dimsah);
2543
      writeLine(indent, "DIMSCALE", pDb.Dimscale);
2544
      writeLine(indent, "DIMSD1", pDb.Dimsd1);
2545
      writeLine(indent, "DIMSD2", pDb.Dimsd2);
2546
      writeLine(indent, "DIMSE1", pDb.Dimse1);
2547
      writeLine(indent, "DIMSE2", pDb.Dimse2);
2548
      writeLine(indent, "DIMSOXD", pDb.Dimsoxd);
2549
      writeLine(indent, "DIMTAD", pDb.Dimtad);
2550
      writeLine(indent, "DIMTDEC", pDb.Dimtdec);
2551
      writeLine(indent, "DIMTFAC", pDb.Dimtfac);
2552
      writeLine(indent, "DIMTIH", pDb.Dimtih);
2553
      writeLine(indent, "DIMTIX", pDb.Dimtix);
2554
      writeLine(indent, "DIMTM", pDb.Dimtm);
2555
      writeLine(indent, "DIMTOFL", pDb.Dimtofl);
2556
      writeLine(indent, "DIMTOH", pDb.Dimtoh);
2557
      writeLine(indent, "DIMTOL", pDb.Dimtol);
2558
      writeLine(indent, "DIMTOLJ", pDb.Dimtolj);
2559
      writeLine(indent, "DIMTP", pDb.Dimtp);
2560
      writeLine(indent, "DIMTSZ", pDb.Dimtsz);
2561
      writeLine(indent, "DIMTVP", pDb.Dimtvp);
2562
      writeLine(indent, "DIMTXSTY", pDb.Dimtxsty);
2563
      writeLine(indent, "DIMTXT", pDb.Dimtxt);
2564
      writeLine(indent, "DIMTZIN", pDb.Dimtzin);
2565
      writeLine(indent, "DIMUPT", pDb.Dimupt);
2566
      writeLine(indent, "DIMZIN", pDb.Dimzin);
2567
      writeLine(indent, "DISPSILH", pDb.DispSilh);
2568
      writeLine(indent, "DRAWORDERCTL", pDb.DrawOrderCtl);
2569
      writeLine(indent, "ELEVATION", pDb.Elevation);
2570
      writeLine(indent, "EXTMAX", pDb.Extmax);
2571
      writeLine(indent, "EXTMIN", pDb.Extmin);
2572
      writeLine(indent, "FACETRES", pDb.Facetres);
2573
      writeLine(indent, "FILLETRAD", pDb.Filletrad);
2574
      writeLine(indent, "FILLMODE", pDb.Fillmode);
2575
      writeLine(indent, "INSBASE", pDb.Insbase);
2576
      writeLine(indent, "ISOLINES", pDb.Isolines);
2577
      writeLine(indent, "LIMCHECK", pDb.Limcheck);
2578
      writeLine(indent, "LIMMAX", pDb.Limmax);
2579
      writeLine(indent, "LIMMIN", pDb.Limmin);
2580
      writeLine(indent, "LTSCALE", pDb.Ltscale);
2581
      writeLine(indent, "LUNITS", pDb.Lunits);
2582
      writeLine(indent, "LUPREC", pDb.Luprec);
2583
      writeLine(indent, "MAXACTVP", pDb.Maxactvp);
2584
      writeLine(indent, "MIRRTEXT", pDb.Mirrtext);
2585
      writeLine(indent, "ORTHOMODE", pDb.Orthomode);
2586
      writeLine(indent, "PDMODE", pDb.Pdmode);
2587
      writeLine(indent, "PDSIZE", pDb.Pdsize);
2588
      writeLine(indent, "PELEVATION", pDb.Pelevation);
2589
      writeLine(indent, "PELLIPSE", pDb.PlineEllipse);
2590
      writeLine(indent, "PEXTMAX", pDb.Pextmax);
2591
      writeLine(indent, "PEXTMIN", pDb.Pextmin);
2592
      writeLine(indent, "PINSBASE", pDb.Pinsbase);
2593
      writeLine(indent, "PLIMCHECK", pDb.Plimcheck);
2594
      writeLine(indent, "PLIMMAX", pDb.Plimmax);
2595
      writeLine(indent, "PLIMMIN", pDb.Plimmin);
2596
      writeLine(indent, "PLINEGEN", pDb.Plinegen);
2597
      writeLine(indent, "PLINEWID", pDb.Plinewid);
2598
      writeLine(indent, "PROXYGRAPHICS", pDb.Saveproxygraphics);
2599
      writeLine(indent, "PSLTSCALE", pDb.Psltscale);
2600
      writeLine(indent, "PUCSNAME", pDb.Pucsname);
2601
      writeLine(indent, "PUCSORG", pDb.Pucsorg);
2602
      writeLine(indent, "PUCSXDIR", pDb.Pucsxdir);
2603
      writeLine(indent, "PUCSYDIR", pDb.Pucsydir);
2604
      writeLine(indent, "QTEXTMODE", pDb.Qtextmode);
2605
      writeLine(indent, "REGENMODE", pDb.Regenmode);
2606
      writeLine(indent, "SHADEDGE", pDb.Shadedge);
2607
      writeLine(indent, "SHADEDIF", pDb.Shadedif);
2608
      writeLine(indent, "SKETCHINC", pDb.Sketchinc);
2609
      writeLine(indent, "SKPOLY", pDb.Skpoly);
2610
      writeLine(indent, "SPLFRAME", pDb.Splframe);
2611
      writeLine(indent, "SPLINESEGS", pDb.Splinesegs);
2612
      writeLine(indent, "SPLINETYPE", pDb.Splinetype);
2613
      writeLine(indent, "SURFTAB1", pDb.Surftab1);
2614
      writeLine(indent, "SURFTAB2", pDb.Surftab2);
2615
      writeLine(indent, "SURFTYPE", pDb.Surftype);
2616
      writeLine(indent, "SURFU", pDb.Surfu);
2617
      writeLine(indent, "SURFV", pDb.Surfv);
2618
      //writeLine(indent, "TEXTQLTY", pDb.TEXTQLTY);
2619
      writeLine(indent, "TEXTSIZE", pDb.Textsize);
2620
      writeLine(indent, "THICKNESS", pDb.Thickness);
2621
      writeLine(indent, "TILEMODE", pDb.TileMode);
2622
      writeLine(indent, "TRACEWID", pDb.Tracewid);
2623
      writeLine(indent, "TREEDEPTH", pDb.Treedepth);
2624
      writeLine(indent, "UCSNAME", pDb.Ucsname);
2625
      writeLine(indent, "UCSORG", pDb.Ucsorg);
2626
      writeLine(indent, "UCSXDIR", pDb.Ucsxdir);
2627
      writeLine(indent, "UCSYDIR", pDb.Ucsydir);
2628
      writeLine(indent, "UNITMODE", pDb.Unitmode);
2629
      writeLine(indent, "USERI1", pDb.Useri1);
2630
      writeLine(indent, "USERI2", pDb.Useri2);
2631
      writeLine(indent, "USERI3", pDb.Useri3);
2632
      writeLine(indent, "USERI4", pDb.Useri4);
2633
      writeLine(indent, "USERI5", pDb.Useri5);
2634
      writeLine(indent, "USERR1", pDb.Userr1);
2635
      writeLine(indent, "USERR2", pDb.Userr2);
2636
      writeLine(indent, "USERR3", pDb.Userr3);
2637
      writeLine(indent, "USERR4", pDb.Userr4);
2638
      writeLine(indent, "USERR5", pDb.Userr5);
2639
      writeLine(indent, "USRTIMER", pDb.Usrtimer);
2640
      writeLine(indent, "VISRETAIN", pDb.Visretain);
2641
      writeLine(indent, "WORLDVIEW", pDb.Worldview);
2642
    }
2643
    public void dumpLayers(Database pDb, int indent)
2644
    {
2645
      /**********************************************************************/
2646
      /* Get a SmartPointer to the LayerTable                               */
2647
      /**********************************************************************/
2648
      using (LayerTable pTable = (LayerTable)pDb.LayerTableId.Open(OpenMode.ForRead))
2649
      {
2650
        /**********************************************************************/
2651
        /* Dump the Description                                               */
2652
        /**********************************************************************/
2653
        writeLine();
2654
        writeLine(indent++, pTable.GetRXClass().Name);
2655

    
2656
        /**********************************************************************/
2657
        /* Get a SmartPointer to a new SymbolTableIterator                    */
2658
        /**********************************************************************/
2659

    
2660
        /**********************************************************************/
2661
        /* Step through the LayerTable                                        */
2662
        /**********************************************************************/
2663
        foreach (ObjectId id in pTable)
2664
        {
2665
          /********************************************************************/
2666
          /* Open the LayerTableRecord for Reading                            */
2667
          /********************************************************************/
2668
          using (LayerTableRecord pRecord = (LayerTableRecord)id.Open(OpenMode.ForRead))
2669
          {
2670
            /********************************************************************/
2671
            /* Dump the LayerTableRecord                                        */
2672
            /********************************************************************/
2673
            writeLine();
2674
            writeLine(indent, "<" + pRecord.GetRXClass().Name + ">");
2675
            writeLine(indent, "Name", pRecord.Name);
2676
            writeLine(indent, "In Use", pRecord.IsUsed);
2677
            writeLine(indent, "On", (!pRecord.IsOff));
2678
            writeLine(indent, "Frozen", pRecord.IsFrozen);
2679
            writeLine(indent, "Locked", pRecord.IsLocked);
2680
            writeLine(indent, "Color", pRecord.Color);
2681
            writeLine(indent, "Linetype", pRecord.LinetypeObjectId);
2682
            writeLine(indent, "Lineweight", pRecord.LineWeight);
2683
            writeLine(indent, "Plotstyle", pRecord.PlotStyleName);
2684
            writeLine(indent, "Plottable", pRecord.IsPlottable);
2685
            writeLine(indent, "New VP Freeze", pRecord.ViewportVisibilityDefault);
2686
            dumpSymbolTableRecord(pRecord, indent);
2687
          }
2688
        }
2689
      }
2690
    }
2691
    public void dumpLinetypes(Database pDb, int indent)
2692
    {
2693
      /**********************************************************************/
2694
      /* Get a pointer to the LinetypeTable                            */
2695
      /**********************************************************************/
2696
      using (LinetypeTable pTable = (LinetypeTable)pDb.LinetypeTableId.Open(OpenMode.ForRead))
2697
      {
2698
        /**********************************************************************/
2699
        /* Dump the Description                                               */
2700
        /**********************************************************************/
2701
        writeLine();
2702
        writeLine(indent++, "<" + pTable.GetRXClass().Name + ">");
2703

    
2704
        /**********************************************************************/
2705
        /* Step through the LinetypeTable                                     */
2706
        /**********************************************************************/
2707
        foreach (ObjectId id in pTable)
2708
        {
2709
          /*********************************************************************/
2710
          /* Open the LinetypeTableRecord for Reading                          */
2711
          /*********************************************************************/
2712
          using (LinetypeTableRecord pRecord = (LinetypeTableRecord)id.Open(OpenMode.ForRead))
2713
          {
2714
            /********************************************************************/
2715
            /* Dump the LinetypeTableRecord                                      */
2716
            /********************************************************************/
2717
            writeLine();
2718
            writeLine(indent, "<" + pRecord.GetRXClass().Name + ">");
2719
            /********************************************************************/
2720
            /* Dump the first line of record as in ACAD.LIN                     */
2721
            /********************************************************************/
2722
            string buffer = "*" + pRecord.Name;
2723
            if (pRecord.Comments != "")
2724
            {
2725
              buffer = buffer + "," + pRecord.Comments;
2726
            }
2727
            writeLine(indent, buffer);
2728

    
2729
            /********************************************************************/
2730
            /* Dump the second line of record as in ACAD.LIN                    */
2731
            /********************************************************************/
2732
            if (pRecord.NumDashes > 0)
2733
            {
2734
              buffer = pRecord.IsScaledToFit ? "S" : "A";
2735
              for (int i = 0; i < pRecord.NumDashes; i++)
2736
              {
2737
                buffer = buffer + "," + pRecord.DashLengthAt(i);
2738
                int shapeNumber = pRecord.ShapeNumberAt(i);
2739
                string text = pRecord.TextAt(i);
2740

    
2741
                /**************************************************************/
2742
                /* Dump the Complex Line                                      */
2743
                /**************************************************************/
2744
                if (shapeNumber != 0 || text != "")
2745
                {
2746
                  using (TextStyleTableRecord pTextStyle = (TextStyleTableRecord)(pRecord.ShapeStyleAt(i) == ObjectId.Null ? null : pRecord.ShapeStyleAt(i).Open(OpenMode.ForRead)))
2747
                  {
2748
                    if (shapeNumber != 0)
2749
                    {
2750
                      buffer = buffer + ",[" + shapeNumber + ",";
2751
                      if (pTextStyle != null)
2752
                        buffer = buffer + pTextStyle.FileName;
2753
                      else
2754
                        buffer = buffer + "NULL style";
2755
                    }
2756
                    else
2757
                    {
2758
                      buffer = buffer + ",[" + text + ",";
2759
                      if (pTextStyle != null)
2760
                        buffer = buffer + pTextStyle.Name;
2761
                      else
2762
                        buffer = buffer + "NULL style";
2763
                    }
2764
                  }
2765
                  if (pRecord.ShapeScaleAt(i) != 0.0)
2766
                  {
2767
                    buffer = buffer + ",S" + pRecord.ShapeScaleAt(i);
2768
                  }
2769
                  if (pRecord.ShapeRotationAt(i) != 0)
2770
                  {
2771
                    buffer = buffer + ",R" + toDegreeString(pRecord.ShapeRotationAt(i));
2772
                  }
2773
                  if (pRecord.ShapeOffsetAt(i).X != 0)
2774
                  {
2775
                    buffer = buffer + ",X" + pRecord.ShapeOffsetAt(i).X;
2776
                  }
2777
                  if (pRecord.ShapeOffsetAt(i).Y != 0)
2778
                  {
2779
                    buffer = buffer + ",Y" + pRecord.ShapeOffsetAt(i).Y;
2780
                  }
2781
                  buffer = buffer + "]";
2782
                }
2783
              }
2784
              writeLine(indent, buffer);
2785
            }
2786
            dumpSymbolTableRecord(pRecord, indent);
2787
          }
2788
        }
2789
      }
2790
    }
2791
    public void dumpRegApps(Database pDb, int indent)
2792
    {
2793
      /**********************************************************************/
2794
      /* Get a pointer to the RegAppTable                            */
2795
      /**********************************************************************/
2796
      using (RegAppTable pTable = (RegAppTable)pDb.RegAppTableId.Open(OpenMode.ForRead))
2797
      {
2798
        /**********************************************************************/
2799
        /* Dump the Description                                               */
2800
        /**********************************************************************/
2801
        writeLine();
2802
        writeLine(indent++, pTable.GetRXClass().Name);
2803

    
2804
        /**********************************************************************/
2805
        /* Step through the RegAppTable                                    */
2806
        /**********************************************************************/
2807
        foreach (ObjectId id in pTable)
2808
        {
2809
          /*********************************************************************/
2810
          /* Open the RegAppTableRecord for Reading                         */
2811
          /*********************************************************************/
2812
          using (RegAppTableRecord pRecord = (RegAppTableRecord)id.Open(OpenMode.ForRead))
2813
          {
2814
            /*********************************************************************/
2815
            /* Dump the RegAppTableRecord                                      */
2816
            /*********************************************************************/
2817
            writeLine();
2818
            writeLine(indent, pRecord.GetRXClass().Name);
2819
            writeLine(indent, "Name", pRecord.Name);
2820
          }
2821
        }
2822
      }
2823
    }
2824
    public void dumpSymbolTableRecord(SymbolTableRecord pRecord, int indent)
2825
    {
2826
      writeLine(indent, "Xref dependent", pRecord.IsDependent);
2827
      if (pRecord.IsDependent)
2828
      {
2829
        writeLine(indent, "Resolved", pRecord.IsResolved);
2830
      }
2831
    }
2832
    public void dumpTextStyles(Database pDb, int indent)
2833
    {
2834
      /**********************************************************************/
2835
      /* Get a SmartPointer to the TextStyleTable                            */
2836
      /**********************************************************************/
2837
      using (TextStyleTable pTable = (TextStyleTable)pDb.TextStyleTableId.Open(OpenMode.ForRead))
2838
      {
2839
        /**********************************************************************/
2840
        /* Dump the Description                                               */
2841
        /**********************************************************************/
2842
        writeLine();
2843
        writeLine(indent++, pTable.GetRXClass().Name);
2844

    
2845
        /**********************************************************************/
2846
        /* Step through the TextStyleTable                                    */
2847
        /**********************************************************************/
2848
        foreach (ObjectId id in pTable)
2849
        {
2850
          /*********************************************************************/
2851
          /* Open the TextStyleTableRecord for Reading                         */
2852
          /*********************************************************************/
2853
          using (TextStyleTableRecord pRecord = (TextStyleTableRecord)id.Open(OpenMode.ForRead))
2854
          {
2855
            /*********************************************************************/
2856
            /* Dump the TextStyleTableRecord                                      */
2857
            /*********************************************************************/
2858
            writeLine();
2859
            writeLine(indent, pRecord.GetRXClass().Name);
2860
            writeLine(indent, "Name", pRecord.Name);
2861
            writeLine(indent, "Shape File", pRecord.IsShapeFile);
2862
            writeLine(indent, "Text Height", pRecord.TextSize);
2863
            writeLine(indent, "Width Factor", pRecord.XScale);
2864
            writeLine(indent, "Obliquing Angle", toDegreeString(pRecord.ObliquingAngle));
2865
            writeLine(indent, "Backwards", (pRecord.FlagBits & 2));
2866
            writeLine(indent, "Vertical", pRecord.IsVertical);
2867
            writeLine(indent, "Upside Down", (pRecord.FlagBits & 4));
2868
            writeLine(indent, "Filename", shortenPath(pRecord.FileName));
2869
            writeLine(indent, "BigFont Filename", shortenPath(pRecord.BigFontFileName));
2870

    
2871
            FontDescriptor fd = pRecord.Font;
2872
            writeLine(indent, "Typeface", fd.TypeFace);
2873
            writeLine(indent, "Character Set", fd.CharacterSet);
2874
            writeLine(indent, "Bold", fd.Bold);
2875
            writeLine(indent, "Italic", fd.Italic);
2876
            writeLine(indent, "Font Pitch & Family", toHexString(fd.PitchAndFamily));
2877
            dumpSymbolTableRecord(pRecord, indent);
2878
          }
2879
        }
2880
      }
2881
    }
2882
    public void dumpAbstractViewTableRecord(AbstractViewTableRecord pView, int indent)
2883
    {
2884
      /*********************************************************************/
2885
      /* Dump the AbstractViewTableRecord                                  */
2886
      /*********************************************************************/
2887
      writeLine(indent, "Back Clip Dist", pView.BackClipDistance);
2888
      writeLine(indent, "Back Clip Enabled", pView.BackClipEnabled);
2889
      writeLine(indent, "Front Clip Dist", pView.FrontClipDistance);
2890
      writeLine(indent, "Front Clip Enabled", pView.FrontClipEnabled);
2891
      writeLine(indent, "Front Clip at Eye", pView.FrontClipAtEye);
2892
      writeLine(indent, "Elevation", pView.Elevation);
2893
      writeLine(indent, "Height", pView.Height);
2894
      writeLine(indent, "Width", pView.Width);
2895
      writeLine(indent, "Lens Length", pView.LensLength);
2896
      writeLine(indent, "Render Mode", pView.RenderMode);
2897
      writeLine(indent, "Perspective", pView.PerspectiveEnabled);
2898
      writeLine(indent, "UCS Name", pView.UcsName);
2899

    
2900
      //writeLine(indent, "UCS Orthographic", pView.IsUcsOrthographic(orthoUCS));
2901
      //writeLine(indent, "Orthographic UCS", orthoUCS);
2902

    
2903
      if (pView.UcsOrthographic != OrthographicView.NonOrthoView)
2904
      {
2905
        writeLine(indent, "UCS Origin", pView.Ucs.Origin);
2906
        writeLine(indent, "UCS x-Axis", pView.Ucs.Xaxis);
2907
        writeLine(indent, "UCS y-Axis", pView.Ucs.Yaxis);
2908
      }
2909

    
2910
      writeLine(indent, "Target", pView.Target);
2911
      writeLine(indent, "View Direction", pView.ViewDirection);
2912
      writeLine(indent, "Twist Angle", toDegreeString(pView.ViewTwist));
2913
      dumpSymbolTableRecord(pView, indent);
2914
    }
2915
    public void dumpDimAssoc(DBObject pObject, int indent)
2916
    {
2917

    
2918
    }
2919
    public void dumpMLineStyles(Database pDb, int indent)
2920
    {
2921
      using (DBDictionary pDictionary = (DBDictionary)pDb.MLStyleDictionaryId.Open(OpenMode.ForRead))
2922
      {
2923
        /**********************************************************************/
2924
        /* Dump the Description                                               */
2925
        /**********************************************************************/
2926
        writeLine();
2927
        writeLine(indent++, pDictionary.GetRXClass().Name);
2928

    
2929
        /**********************************************************************/
2930
        /* Step through the MlineStyle dictionary                             */
2931
        /**********************************************************************/
2932
        DbDictionaryEnumerator e = pDictionary.GetEnumerator();
2933
        while (e.MoveNext())
2934
        {
2935
          try
2936
          {
2937
            using (MlineStyle pEntry = (MlineStyle)e.Value.Open(OpenMode.ForRead))
2938
            {
2939
              /*********************************************************************/
2940
              /* Dump the MLineStyle dictionary entry                              */
2941
              /*********************************************************************/
2942
              writeLine();
2943
              writeLine(indent, pEntry.GetRXClass().Name);
2944
              writeLine(indent, "Name", pEntry.Name);
2945
              writeLine(indent, "Description", pEntry.Description);
2946
              writeLine(indent, "Start Angle", toDegreeString(pEntry.StartAngle));
2947
              writeLine(indent, "End Angle", toDegreeString(pEntry.EndAngle));
2948
              writeLine(indent, "Start Inner Arcs", pEntry.StartInnerArcs);
2949
              writeLine(indent, "End Inner Arcs", pEntry.EndInnerArcs);
2950
              writeLine(indent, "Start Round Cap", pEntry.StartRoundCap);
2951
              writeLine(indent, "End Round Cap", pEntry.EndRoundCap);
2952
              writeLine(indent, "Start Square Cap", pEntry.StartRoundCap);
2953
              writeLine(indent, "End Square Cap", pEntry.EndRoundCap);
2954
              writeLine(indent, "Show Miters", pEntry.ShowMiters);
2955
              /*********************************************************************/
2956
              /* Dump the elements                                                 */
2957
              /*********************************************************************/
2958
              if (pEntry.Elements.Count > 0)
2959
              {
2960
                writeLine(indent, "Elements:");
2961
              }
2962
              int i = 0;
2963
              foreach (MlineStyleElement el in pEntry.Elements)
2964
              {
2965
                writeLine(indent, "Index", (i++));
2966
                writeLine(indent + 1, "Offset", el.Offset);
2967
                writeLine(indent + 1, "Color", el.Color);
2968
                writeLine(indent + 1, "Linetype", el.LinetypeId);
2969
              }
2970
            }
2971
          }
2972
          catch (System.Exception)
2973
          {
2974
          }
2975
        }
2976
      }
2977
    }
2978
    public void dumpObject(ObjectId id, string itemName, int indent)
2979
    {
2980
      using (DBObject pObject = id.Open(OpenMode.ForRead))
2981
      {
2982
        /**********************************************************************/
2983
        /* Dump the item name and class name                                  */
2984
        /**********************************************************************/
2985
        if (pObject is DBDictionary)
2986
        {
2987
          writeLine();
2988
        }
2989
        writeLine(indent++, itemName, pObject.GetRXClass().Name);
2990

    
2991
        /**********************************************************************/
2992
        /* Dispatch                                                           */
2993
        /**********************************************************************/
2994
        if (pObject is DBDictionary)
2995
        {
2996
          /********************************************************************/
2997
          /* Dump the dictionary                                               */
2998
          /********************************************************************/
2999
          DBDictionary pDic = (DBDictionary)pObject;
3000

    
3001
          /********************************************************************/
3002
          /* Get a pointer to a new DictionaryIterator                   */
3003
          /********************************************************************/
3004
          DbDictionaryEnumerator pIter = pDic.GetEnumerator();
3005

    
3006
          /********************************************************************/
3007
          /* Step through the Dictionary                                      */
3008
          /********************************************************************/
3009
          while (pIter.MoveNext())
3010
          {
3011
            /******************************************************************/
3012
            /* Dump the Dictionary object                                     */
3013
            /******************************************************************/
3014
            dumpObject(pIter.Value, pIter.Key, indent);
3015
          }
3016
        }
3017
        else if (pObject is Xrecord)
3018
        {
3019
          /********************************************************************/
3020
          /* Dump an Xrecord                                                  */
3021
          /********************************************************************/
3022
          Xrecord pXRec = (Xrecord)pObject;
3023
          dumpXdata(pXRec.Data, indent);
3024
        }
3025
      }
3026
    }
3027

    
3028
    public void dumpUCSTable(Database pDb, int indent)
3029
    {
3030
      /**********************************************************************/
3031
      /* Get a pointer to the UCSTable                               */
3032
      /**********************************************************************/
3033
      using (UcsTable pTable = (UcsTable)pDb.UcsTableId.Open(OpenMode.ForRead))
3034
      {
3035
        /**********************************************************************/
3036
        /* Dump the Description                                               */
3037
        /**********************************************************************/
3038
        writeLine();
3039
        writeLine(indent++, pTable.GetRXClass().Name);
3040

    
3041
        /**********************************************************************/
3042
        /* Step through the UCSTable                                          */
3043
        /**********************************************************************/
3044
        foreach (ObjectId id in pTable)
3045
        {
3046
          /********************************************************************/
3047
          /* Open the UCSTableRecord for Reading                            */
3048
          /********************************************************************/
3049
          using (UcsTableRecord pRecord = (UcsTableRecord)id.Open(OpenMode.ForRead))
3050
          {
3051
            /********************************************************************/
3052
            /* Dump the UCSTableRecord                                        */
3053
            /********************************************************************/
3054
            writeLine();
3055
            writeLine(indent, pRecord.GetRXClass().Name);
3056
            writeLine(indent, "Name", pRecord.Name);
3057
            writeLine(indent, "UCS Origin", pRecord.Origin);
3058
            writeLine(indent, "UCS x-Axis", pRecord.XAxis);
3059
            writeLine(indent, "UCS y-Axis", pRecord.YAxis);
3060
            dumpSymbolTableRecord(pRecord, indent);
3061
          }
3062
        }
3063
      }
3064
    }
3065
    public void dumpViewports(Database pDb, int indent)
3066
    {
3067
      /**********************************************************************/
3068
      /* Get a pointer to the ViewportTable                            */
3069
      /**********************************************************************/
3070
      using (ViewportTable pTable = (ViewportTable)pDb.ViewportTableId.Open(OpenMode.ForRead))
3071
      {
3072
        /**********************************************************************/
3073
        /* Dump the Description                                               */
3074
        /**********************************************************************/
3075
        writeLine();
3076
        writeLine(indent++, pTable.GetRXClass().Name);
3077

    
3078
        /**********************************************************************/
3079
        /* Step through the ViewportTable                                    */
3080
        /**********************************************************************/
3081
        foreach (ObjectId id in pTable)
3082
        {
3083
          /*********************************************************************/
3084
          /* Open the ViewportTableRecord for Reading                          */
3085
          /*********************************************************************/
3086
          using (ViewportTableRecord pRecord = (ViewportTableRecord)id.Open(OpenMode.ForRead))
3087
          {
3088
            /*********************************************************************/
3089
            /* Dump the ViewportTableRecord                                      */
3090
            /*********************************************************************/
3091
            writeLine();
3092
            writeLine(indent, pRecord.GetRXClass().Name);
3093
            writeLine(indent, "Name", pRecord.Name);
3094
            writeLine(indent, "Circle Sides", pRecord.CircleSides);
3095
            writeLine(indent, "Fast Zooms Enabled", pRecord.FastZoomsEnabled);
3096
            writeLine(indent, "Grid Enabled", pRecord.GridEnabled);
3097
            writeLine(indent, "Grid Increments", pRecord.GridIncrements);
3098
            writeLine(indent, "Icon at Origin", pRecord.IconAtOrigin);
3099
            writeLine(indent, "Icon Enabled", pRecord.IconEnabled);
3100
            writeLine(indent, "Iso snap Enabled", pRecord.IsometricSnapEnabled);
3101
            writeLine(indent, "Iso Snap Pair", pRecord.SnapPair);
3102
            writeLine(indent, "UCS Saved w/Vport", pRecord.UcsSavedWithViewport);
3103
            writeLine(indent, "UCS follow", pRecord.UcsFollowMode);
3104
            writeLine(indent, "Lower-Left Corner", pRecord.LowerLeftCorner);
3105
            writeLine(indent, "Upper-Right Corner", pRecord.UpperRightCorner);
3106
            writeLine(indent, "Snap Angle", toDegreeString(pRecord.SnapAngle));
3107
            writeLine(indent, "Snap Base", pRecord.SnapBase);
3108
            writeLine(indent, "Snap Enabled", pRecord.SnapEnabled);
3109
            writeLine(indent, "Snap Increments", pRecord.SnapIncrements);
3110
            dumpAbstractViewTableRecord(pRecord, indent);
3111
          }
3112
        }
3113
      }
3114
    }
3115

    
3116
    /************************************************************************/
3117
    /* Dump the ViewTable                                                   */
3118
    /************************************************************************/
3119
    public void dumpViews(Database pDb, int indent)
3120
    {
3121
      /**********************************************************************/
3122
      /* Get a pointer to the ViewTable                                */
3123
      /**********************************************************************/
3124
      using (ViewTable pTable = (ViewTable)pDb.ViewTableId.Open(OpenMode.ForRead))
3125
      {
3126
        /**********************************************************************/
3127
        /* Dump the Description                                               */
3128
        /**********************************************************************/
3129
        writeLine();
3130
        writeLine(indent++, pTable.GetRXClass().Name);
3131

    
3132
        /**********************************************************************/
3133
        /* Step through the ViewTable                                         */
3134
        /**********************************************************************/
3135
        foreach (ObjectId id in pTable)
3136
        {
3137
          /*********************************************************************/
3138
          /* Open the ViewTableRecord for Reading                              */
3139
          /*********************************************************************/
3140
          using (ViewTableRecord pRecord = (ViewTableRecord)id.Open(OpenMode.ForRead))
3141
          {
3142
            /*********************************************************************/
3143
            /* Dump the ViewTableRecord                                          */
3144
            /*********************************************************************/
3145
            writeLine();
3146
            writeLine(indent, pRecord.GetRXClass().Name);
3147
            writeLine(indent, "Name", pRecord.Name);
3148
            writeLine(indent, "Category Name", pRecord.CategoryName);
3149
            writeLine(indent, "Layer State", pRecord.LayerState);
3150

    
3151
            string layoutName = "";
3152
            if (!pRecord.Layout.IsNull)
3153
            {
3154
              using (Layout pLayout = (Layout)pRecord.Layout.Open(OpenMode.ForRead))
3155
                layoutName = pLayout.LayoutName;
3156
            }
3157
            writeLine(indent, "Layout Name", layoutName);
3158
            writeLine(indent, "PaperSpace View", pRecord.IsPaperspaceView);
3159
            writeLine(indent, "Associated UCS", pRecord.IsUcsAssociatedToView);
3160
            writeLine(indent, "PaperSpace View", pRecord.ViewAssociatedToViewport);
3161
            dumpAbstractViewTableRecord(pRecord, indent);
3162
          }
3163
        }
3164
      }
3165
    }
3166
    /************************************************************************/
3167
    /* Dump Xdata                                                           */
3168
    /************************************************************************/
3169
    public void dumpXdata(ResultBuffer xIter, int indent)
3170
    {
3171
      if (xIter == null)
3172
        return;
3173
      writeLine(indent++, "Xdata:");
3174
      /**********************************************************************/
3175
      /* Step through the ResBuf chain                                      */
3176
      /**********************************************************************/
3177
      foreach (TypedValue resbuf in xIter)
3178
      {
3179
        writeLine(indent, resbuf);
3180
      }
3181
    }
3182
  }
3183
  class ExProtocolExtension
3184
  {
3185
  }
3186

    
3187
  class Program
3188
  {
3189
        public static XmlDocument xml = null;
3190
        public static double OffsetX = 0;
3191
        public static double OffsetY = 0;
3192
        public static double Scale = 0;
3193

    
3194
        static void Main(string[] args)
3195
    {
3196
      /********************************************************************/
3197
      /* Initialize Drawings.NET.                                         */
3198
      /********************************************************************/
3199
      bool bSuccess = true;
3200
      Teigha.Runtime.Services.odActivate(ActivationData.userInfo, ActivationData.userSignature);
3201
      using (Teigha.Runtime.Services srv = new Teigha.Runtime.Services())
3202
      {
3203
        try
3204
        {
3205
          HostApplicationServices.Current = new OdaMgdMViewApp.HostAppServ();
3206
          /**********************************************************************/
3207
          /* Display the Product and Version that created the executable        */
3208
          /**********************************************************************/
3209
          Console.WriteLine("\nReadExMgd developed using {0} ver {1}", HostApplicationServices.Current.Product, HostApplicationServices.Current.VersionString);
3210

    
3211
          if (args.Length != 4)//(false)
3212
                    {
3213
            Console.WriteLine("\n\n\tusage: OdReadExMgd <filename> <OffsetX> <OffsetY> <Scale>");
3214
            Console.WriteLine("\nPress ENTER to continue...\n");
3215
            Console.ReadLine();
3216
            bSuccess = false;
3217
          }
3218
          else
3219
          {
3220
            double.TryParse(args[1], out Program.OffsetX);
3221
            double.TryParse(args[2], out Program.OffsetY);
3222
            double.TryParse(args[3], out Program.Scale);
3223
            //double.TryParse("205", out Program.OffsetX);
3224
            //double.TryParse("131", out Program.OffsetY);
3225
            //double.TryParse("21.73944", out Program.Scale);
3226
            Program.xml = new XmlDocument();
3227
            {
3228
                XmlNode root = xml.CreateElement("ID2");
3229
                Program.xml.AppendChild(root);
3230

    
3231
                /******************************************************************/
3232
                /* Create a database and load the drawing into it.                
3233
                /* first parameter means - do not initialize database- it will be read from file
3234
                 * second parameter is not used by Teigha.NET Classic - it is left for ARX compatibility.
3235
                 * Note the 'using' clause - generally, wrappers should disposed after use, 
3236
                 * to close underlying database objects
3237
                /******************************************************************/
3238
                using (Database pDb = new Database(false, false))
3239
                {
3240
                    pDb.ReadDwgFile(args[0], FileShare.Read, true, "");
3241
                    //pDb.ReadDwgFile("Y:\\CPChem\\drawings\\Native\\20-PID-2011.dwg", FileShare.Read, true, "");
3242
                    HostApplicationServices.WorkingDatabase = pDb;
3243
                    /****************************************************************/
3244
                    /* Display the File Version                                     */
3245
                    /****************************************************************/
3246
                    Console.WriteLine("File Version: {0}", pDb.OriginalFileVersion);
3247
                    /****************************************************************/
3248
                    /* Dump the database                                            */
3249
                    /****************************************************************/
3250
                    DbDumper dumper = new DbDumper();
3251
                    dumper.dump(pDb, 0);
3252
                }
3253
                Program.xml.Save(Path.Combine(Path.GetDirectoryName(args[0]) , Path.GetFileNameWithoutExtension(args[0]) + ".xml"));
3254
                //Program.xml.Save(Path.Combine(Path.GetDirectoryName("Y:\\CPChem\\drawings\\Native\\20-PID-2011.dwg") , Path.GetFileNameWithoutExtension("Y:\\CPChem\\drawings\\Native\\20-PID-2011.dwg") + ".xml"));
3255
            }
3256
          }
3257
        }
3258
        /********************************************************************/
3259
        /* Display the error                                                */
3260
        /********************************************************************/
3261
        catch (System.Exception e)
3262
        {
3263
          bSuccess = false;
3264
          Console.WriteLine("Teigha?NET for .dwg files Error: " + e.Message);
3265
        }
3266

    
3267
        if (bSuccess)
3268
          Console.WriteLine("OdReadExMgd Finished Successfully");
3269
      }
3270
    }
3271
  }
3272
}
클립보드 이미지 추가 (최대 크기: 500 MB)