hytos / DTI_PID / OdReadExMgd / OdReadExMgd.cs @ 7e1124a2
이력 | 보기 | 이력해설 | 다운로드 (233 KB)
1 |
/////////////////////////////////////////////////////////////////////////////// |
---|---|
2 |
// Copyright (C) 2002-2019, Open Design Alliance (the "Alliance"). |
3 |
// All rights reserved. |
4 |
// |
5 |
// This software and its documentation and related materials are owned by |
6 |
// the Alliance. The software may only be incorporated into application |
7 |
// programs owned by members of the Alliance, subject to a signed |
8 |
// Membership Agreement and Supplemental Software License Agreement with the |
9 |
// Alliance. The structure and organization of this software are the valuable |
10 |
// trade secrets of the Alliance and its suppliers. The software is also |
11 |
// protected by copyright law and international treaty provisions. Application |
12 |
// programs incorporating this software must include the following statement |
13 |
// with their copyright notices: |
14 |
// |
15 |
// This application incorporates Open Design Alliance software pursuant to a license |
16 |
// agreement with Open Design Alliance. |
17 |
// Open Design Alliance Copyright (C) 2002-2019 by Open Design Alliance. |
18 |
// All rights reserved. |
19 |
// |
20 |
// By use of this software, its documentation or related materials, you |
21 |
// acknowledge and accept the above terms. |
22 |
/////////////////////////////////////////////////////////////////////////////// |
23 |
using System; |
24 |
using System.Collections.Generic; |
25 |
using System.Text; |
26 |
using System.IO; |
27 |
using System.Xml; |
28 |
using System.Linq; |
29 |
using Teigha.DatabaseServices; |
30 |
using Teigha.Geometry; |
31 |
using Teigha.GraphicsInterface; |
32 |
using Teigha.Colors; |
33 |
using Teigha; |
34 |
using Teigha.GraphicsSystem; |
35 |
using Teigha.Runtime; |
36 |
using Teigha.Export_Import; |
37 |
using System.Collections.Specialized; |
38 |
// note that GetObject doesn't work in Acad 2009, so we use "obsolete" Open instead |
39 |
#pragma warning disable 618 |
40 |
|
41 |
namespace OdReadExMgd |
42 |
{ |
43 |
class DbDumper |
44 |
{ |
45 |
public DbDumper() { } |
46 |
|
47 |
static string toDegreeString(double val) |
48 |
{ |
49 |
return (val * 180.0 / Math.PI) + "d"; |
50 |
} |
51 |
static string toHexString(int val) |
52 |
{ |
53 |
return string.Format("0{0:X}", val); |
54 |
} |
55 |
static string toArcSymbolTypeString(int val) |
56 |
{ |
57 |
switch (val) |
58 |
{ |
59 |
case 0: return "Precedes text"; |
60 |
case 1: return "Above text"; |
61 |
case 2: return "None"; |
62 |
} |
63 |
return "???"; |
64 |
} |
65 |
/************************************************************************/ |
66 |
/* Shorten a path with ellipses. */ |
67 |
/************************************************************************/ |
68 |
static string shortenPath(string Inpath, int maxPath) |
69 |
{ |
70 |
string path = Inpath; |
71 |
/**********************************************************************/ |
72 |
/* If the path fits, just return it */ |
73 |
/**********************************************************************/ |
74 |
if (path.Length <= maxPath) |
75 |
{ |
76 |
return path; |
77 |
} |
78 |
/**********************************************************************/ |
79 |
/* If there's no backslash, just truncate the path */ |
80 |
/**********************************************************************/ |
81 |
int lastBackslash = path.LastIndexOf('\\'); |
82 |
if (lastBackslash < 0) |
83 |
{ |
84 |
return path.Substring(0, maxPath - 3) + "..."; |
85 |
} |
86 |
|
87 |
/**********************************************************************/ |
88 |
/* Shorten the front of the path */ |
89 |
/**********************************************************************/ |
90 |
int fromLeft = (lastBackslash - 3) - (path.Length - maxPath); |
91 |
// (12 - 3) - (19 - 10) = 9 - 9 = 0 |
92 |
if ((lastBackslash <= 3) || (fromLeft < 1)) |
93 |
{ |
94 |
path = "..." + path.Substring(lastBackslash); |
95 |
} |
96 |
else |
97 |
{ |
98 |
path = path.Substring(0, fromLeft) + "..." + path.Substring(lastBackslash); |
99 |
} |
100 |
|
101 |
/**********************************************************************/ |
102 |
/* Truncate the path */ |
103 |
/**********************************************************************/ |
104 |
if (path.Length > maxPath) |
105 |
{ |
106 |
path = path.Substring(0, maxPath - 3) + "..."; |
107 |
} |
108 |
|
109 |
return path; |
110 |
} |
111 |
static string shortenPath(string Inpath) |
112 |
{ |
113 |
return shortenPath(Inpath, 40); |
114 |
} |
115 |
|
116 |
/************************************************************************/ |
117 |
/* Output a string in the form */ |
118 |
/* leftString:. . . . . . . . . . . .rightString */ |
119 |
/************************************************************************/ |
120 |
static void writeLine(int indent, object leftString, object rightString, int colWidth) |
121 |
{ |
122 |
string spaces = " "; |
123 |
string leader = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "; |
124 |
|
125 |
const int tabSize = 2; |
126 |
|
127 |
/**********************************************************************/ |
128 |
/* Indent leftString with spaces characters */ |
129 |
/**********************************************************************/ |
130 |
string newleftString = spaces.Substring(0, tabSize * indent) + leftString.ToString(); |
131 |
|
132 |
/**********************************************************************/ |
133 |
/* If rightString is not specified, just output the indented */ |
134 |
/* leftString. Otherwise, fill the space between leftString and */ |
135 |
/* rightString with leader characters. */ |
136 |
/**********************************************************************/ |
137 |
if (rightString == null || ((rightString is string) && ((string)rightString) == "")) |
138 |
{ |
139 |
Console.WriteLine(newleftString); |
140 |
} |
141 |
else |
142 |
{ |
143 |
int leaders = colWidth - newleftString.Length; |
144 |
if (leaders > 0) |
145 |
{ |
146 |
Console.WriteLine(newleftString + leader.Substring(newleftString.Length, leaders) + rightString.ToString()); |
147 |
} |
148 |
else |
149 |
{ |
150 |
Console.WriteLine(newleftString + ' ' + rightString.ToString()); |
151 |
} |
152 |
} |
153 |
} |
154 |
static void writeLine(int indent, object leftString, object rightString) |
155 |
{ |
156 |
writeLine(indent, leftString, rightString, 38); |
157 |
} |
158 |
static void writeLine(int indent, object leftString) |
159 |
{ |
160 |
writeLine(indent, leftString, null, 38); |
161 |
} |
162 |
static void writeLine() |
163 |
{ |
164 |
Console.WriteLine(); |
165 |
} |
166 |
|
167 |
static void dumpEntityData(Entity pEnt, int indent, XmlNode node) |
168 |
{ |
169 |
if (node != null) |
170 |
{ |
171 |
try |
172 |
{ |
173 |
Extents3d ext = pEnt.GeometricExtents; |
174 |
|
175 |
XmlAttribute MinExtentsAttr = Program.xml.CreateAttribute("MinExtents"); |
176 |
MinExtentsAttr.Value = ext.MinPoint.ToString(); |
177 |
node.Attributes.SetNamedItem(MinExtentsAttr); |
178 |
|
179 |
XmlAttribute MaxExtentsAttr = Program.xml.CreateAttribute("MaxExtents"); |
180 |
MaxExtentsAttr.Value = ext.MaxPoint.ToString(); |
181 |
node.Attributes.SetNamedItem(MaxExtentsAttr); |
182 |
} |
183 |
catch (System.Exception) |
184 |
{ |
185 |
} |
186 |
|
187 |
XmlAttribute LayerAttr = Program.xml.CreateAttribute("Layer"); |
188 |
LayerAttr.Value = pEnt.Layer; |
189 |
node.Attributes.SetNamedItem(LayerAttr); |
190 |
|
191 |
writeLine(indent, "Color Index", pEnt.ColorIndex); |
192 |
writeLine(indent, "Color", pEnt.Color); |
193 |
|
194 |
XmlAttribute LinetypeAttr = Program.xml.CreateAttribute("Linetype"); |
195 |
LinetypeAttr.Value = pEnt.Linetype; |
196 |
node.Attributes.SetNamedItem(LinetypeAttr); |
197 |
|
198 |
writeLine(indent, "LTscale", pEnt.LinetypeScale); |
199 |
writeLine(indent, "Lineweight", pEnt.LineWeight); |
200 |
writeLine(indent, "Plot Style", pEnt.PlotStyleName); |
201 |
writeLine(indent, "Transparency Method", pEnt.Transparency); |
202 |
writeLine(indent, "Visibility", pEnt.Visible); |
203 |
writeLine(indent, "Planar", pEnt.IsPlanar); |
204 |
|
205 |
if (pEnt.IsPlanar) |
206 |
{ |
207 |
try |
208 |
{ |
209 |
CoordinateSystem3d cs = (CoordinateSystem3d)pEnt.GetPlane().GetCoordinateSystem(); |
210 |
writeLine(indent + 1, "Origin", cs.Origin); |
211 |
writeLine(indent + 1, "u-Axis", cs.Xaxis); |
212 |
writeLine(indent + 1, "v-Axis", cs.Yaxis); |
213 |
} |
214 |
catch (System.Exception ex) |
215 |
{ |
216 |
writeLine(indent + 1, "pEnt.GetPlane().GetCoordinateSystem() failed", ex.Message); |
217 |
} |
218 |
} |
219 |
} |
220 |
} |
221 |
|
222 |
/************************************************************************/ |
223 |
/* Dump Text data */ |
224 |
/************************************************************************/ |
225 |
static XmlNode dumpTextData(DBText pText, int indent, XmlNode node) |
226 |
{ |
227 |
XmlNode TextNode = null; |
228 |
/// write text information to xml file |
229 |
if (node != null) |
230 |
{ |
231 |
TextNode = Program.xml.CreateElement(pText.GetRXClass().Name); |
232 |
|
233 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
234 |
XAttr.Value = pText.Position.X.ToString(); |
235 |
TextNode.Attributes.SetNamedItem(XAttr); |
236 |
|
237 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
238 |
YAttr.Value = pText.Position.Y.ToString(); |
239 |
TextNode.Attributes.SetNamedItem(YAttr); |
240 |
|
241 |
TextNode.InnerText = pText.TextString.Replace("%%U", ""); |
242 |
|
243 |
XmlAttribute AngleAttr = Program.xml.CreateAttribute("Angle"); |
244 |
AngleAttr.Value = pText.Rotation.ToString(); |
245 |
TextNode.Attributes.SetNamedItem(AngleAttr); |
246 |
|
247 |
XmlAttribute WidthAttr = Program.xml.CreateAttribute("Width"); |
248 |
WidthAttr.Value = String.Format("{0}", pText.WidthFactor * pText.Height * pText.TextString.Length); |
249 |
TextNode.Attributes.SetNamedItem(WidthAttr); |
250 |
|
251 |
XmlAttribute HeightAttr = Program.xml.CreateAttribute("Height"); |
252 |
HeightAttr.Value = pText.Height.ToString(); |
253 |
TextNode.Attributes.SetNamedItem(HeightAttr); |
254 |
|
255 |
XmlAttribute WidthFactorAttr = Program.xml.CreateAttribute("WidthFactor"); |
256 |
WidthFactorAttr.Value = pText.WidthFactor.ToString(); |
257 |
TextNode.Attributes.SetNamedItem(WidthFactorAttr); |
258 |
|
259 |
XmlAttribute IsDefaultAlignmentAttr = Program.xml.CreateAttribute("IsDefaultAlignment"); |
260 |
IsDefaultAlignmentAttr.Value = pText.IsDefaultAlignment.ToString(); |
261 |
TextNode.Attributes.SetNamedItem(IsDefaultAlignmentAttr); |
262 |
|
263 |
XmlAttribute AlignmentPointAttr = Program.xml.CreateAttribute("AlignmentPoint"); |
264 |
AlignmentPointAttr.Value = pText.AlignmentPoint.ToString(); |
265 |
TextNode.Attributes.SetNamedItem(AlignmentPointAttr); |
266 |
|
267 |
XmlAttribute HorizontalModeAttr = Program.xml.CreateAttribute("HorizontalMode"); |
268 |
HorizontalModeAttr.Value = pText.HorizontalMode.ToString(); |
269 |
TextNode.Attributes.SetNamedItem(HorizontalModeAttr); |
270 |
|
271 |
XmlAttribute VerticalModeAttr = Program.xml.CreateAttribute("VerticalMode"); |
272 |
VerticalModeAttr.Value = pText.VerticalMode.ToString(); |
273 |
TextNode.Attributes.SetNamedItem(VerticalModeAttr); |
274 |
|
275 |
XmlAttribute IsMirroredInXAttr = Program.xml.CreateAttribute("IsMirroredInX"); |
276 |
IsMirroredInXAttr.Value = pText.IsMirroredInX.ToString(); |
277 |
TextNode.Attributes.SetNamedItem(IsMirroredInXAttr); |
278 |
|
279 |
XmlAttribute IsMirroredInYAttr = Program.xml.CreateAttribute("IsMirroredInY"); |
280 |
IsMirroredInYAttr.Value = pText.IsMirroredInY.ToString(); |
281 |
TextNode.Attributes.SetNamedItem(IsMirroredInYAttr); |
282 |
|
283 |
XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique"); |
284 |
ObliqueAttr.Value = pText.Oblique.ToString(); |
285 |
TextNode.Attributes.SetNamedItem(ObliqueAttr); |
286 |
|
287 |
XmlAttribute TextStyleAttr = Program.xml.CreateAttribute("TextStyle"); |
288 |
TextStyleAttr.Value = pText.TextStyleName; |
289 |
TextNode.Attributes.SetNamedItem(TextStyleAttr); |
290 |
|
291 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
292 |
NormalAttr.Value = pText.Normal.ToString(); |
293 |
TextNode.Attributes.SetNamedItem(NormalAttr); |
294 |
|
295 |
XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness"); |
296 |
ThicknessAttr.Value = pText.Thickness.ToString(); |
297 |
TextNode.Attributes.SetNamedItem(ThicknessAttr); |
298 |
|
299 |
dumpEntityData(pText, indent, TextNode); |
300 |
|
301 |
node.AppendChild(TextNode); |
302 |
} |
303 |
|
304 |
return TextNode; |
305 |
} |
306 |
|
307 |
/************************************************************************/ |
308 |
/* Dump Attribute data */ |
309 |
/************************************************************************/ |
310 |
static void dumpAttributeData(int indent, AttributeReference pAttr, int i, XmlNode node) |
311 |
{ |
312 |
writeLine(indent, "Field Length", pAttr.FieldLength); |
313 |
writeLine(indent, "Invisible", pAttr.Invisible); |
314 |
writeLine(indent, "Preset", pAttr.IsPreset); |
315 |
writeLine(indent, "Verifiable", pAttr.IsVerifiable); |
316 |
writeLine(indent, "Locked in Position", pAttr.LockPositionInBlock); |
317 |
writeLine(indent, "Constant", pAttr.IsConstant); |
318 |
|
319 |
XmlNode TextNode = dumpTextData(pAttr, indent, node); |
320 |
if (TextNode != null) |
321 |
{ |
322 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
323 |
HandleAttr.Value = pAttr.Handle.ToString(); |
324 |
TextNode.Attributes.SetNamedItem(HandleAttr); |
325 |
|
326 |
XmlAttribute TagAttr = Program.xml.CreateAttribute("Tag"); |
327 |
TagAttr.Value = pAttr.Tag; |
328 |
TextNode.Attributes.SetNamedItem(TagAttr); |
329 |
} |
330 |
} |
331 |
|
332 |
/************************************************************************/ |
333 |
/* Dump Block Reference Data */ |
334 |
/************************************************************************/ |
335 |
static XmlNode dumpBlockRefData(BlockReference pBlkRef, int indent, XmlNode node) |
336 |
{ |
337 |
if (node != null) |
338 |
{ |
339 |
XmlNode BlockReferenceNode = Program.xml.CreateElement(pBlkRef.GetRXClass().Name); |
340 |
|
341 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
342 |
HandleAttr.Value = pBlkRef.Handle.ToString(); |
343 |
BlockReferenceNode.Attributes.SetNamedItem(HandleAttr); |
344 |
|
345 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
346 |
XAttr.Value = pBlkRef.Position.X.ToString(); |
347 |
BlockReferenceNode.Attributes.SetNamedItem(XAttr); |
348 |
|
349 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
350 |
YAttr.Value = pBlkRef.Position.Y.ToString(); |
351 |
BlockReferenceNode.Attributes.SetNamedItem(YAttr); |
352 |
|
353 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
354 |
ZAttr.Value = pBlkRef.Position.Z.ToString(); |
355 |
BlockReferenceNode.Attributes.SetNamedItem(ZAttr); |
356 |
|
357 |
XmlAttribute AngleAttr = Program.xml.CreateAttribute("Angle"); |
358 |
AngleAttr.Value = pBlkRef.Rotation.ToString(); |
359 |
BlockReferenceNode.Attributes.SetNamedItem(AngleAttr); |
360 |
|
361 |
XmlAttribute ScaleFactorsAttr = Program.xml.CreateAttribute("ScaleFactors"); |
362 |
ScaleFactorsAttr.Value = pBlkRef.ScaleFactors.ToString(); |
363 |
BlockReferenceNode.Attributes.SetNamedItem(ScaleFactorsAttr); |
364 |
|
365 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
366 |
NormalAttr.Value = pBlkRef.Normal.ToString(); |
367 |
BlockReferenceNode.Attributes.SetNamedItem(NormalAttr); |
368 |
|
369 |
XmlAttribute NameAttr = Program.xml.CreateAttribute("Name"); |
370 |
NameAttr.Value = pBlkRef.Name; |
371 |
BlockReferenceNode.Attributes.SetNamedItem(NameAttr); |
372 |
|
373 |
// BlockReference DBPoint |
374 |
string nodePointValue = string.Empty; |
375 |
Dictionary<long, Point3d> nodePointDic = new Dictionary<long, Point3d>(); |
376 |
using (BlockTableRecord pBtr = (BlockTableRecord)pBlkRef.BlockTableRecord.Open(OpenMode.ForRead, false, true)) |
377 |
{ |
378 |
foreach (ObjectId blkid in pBtr) |
379 |
{ |
380 |
using (Entity pBlkEnt = (Entity)blkid.Open(OpenMode.ForRead, false, true)) |
381 |
{ |
382 |
if (pBlkEnt.GetRXClass().Name == "AcDbPoint") |
383 |
{ |
384 |
DBPoint pt = (DBPoint)pBlkEnt; |
385 |
Point3d nodePt = pt.Position.TransformBy(pBlkRef.BlockTransform); |
386 |
nodePointDic.Add(Convert.ToInt64(pt.Handle.ToString(), 16), nodePt); |
387 |
} |
388 |
} |
389 |
} |
390 |
} |
391 |
if (nodePointDic.Count > 0) |
392 |
{ |
393 |
foreach (KeyValuePair<long, Point3d> item in nodePointDic.OrderBy(o => o.Key)) |
394 |
{ |
395 |
nodePointValue += item.Value.ToString() + "/"; |
396 |
} |
397 |
nodePointValue = nodePointValue.Substring(0, nodePointValue.Length - 1); |
398 |
} |
399 |
|
400 |
XmlAttribute NodePointAttr = Program.xml.CreateAttribute("Nodes"); |
401 |
NodePointAttr.Value = nodePointValue; |
402 |
BlockReferenceNode.Attributes.SetNamedItem(NodePointAttr); |
403 |
|
404 |
Matrix3d blockTransform = pBlkRef.BlockTransform; |
405 |
CoordinateSystem3d cs = blockTransform.CoordinateSystem3d; |
406 |
writeLine(indent + 1, "Origin", cs.Origin); |
407 |
writeLine(indent + 1, "u-Axis", cs.Xaxis); |
408 |
writeLine(indent + 1, "v-Axis", cs.Yaxis); |
409 |
writeLine(indent + 1, "z-Axis", cs.Zaxis); |
410 |
|
411 |
dumpEntityData(pBlkRef, indent, BlockReferenceNode); |
412 |
|
413 |
DBObjectCollection objColl = new DBObjectCollection(); |
414 |
|
415 |
pBlkRef.Explode(objColl); |
416 |
foreach (var obj in objColl) |
417 |
{ |
418 |
if (obj is DBText) |
419 |
{ |
420 |
dumpTextData(obj as DBText, indent, BlockReferenceNode); |
421 |
} |
422 |
} |
423 |
|
424 |
/**********************************************************************/ |
425 |
/* Dump the attributes */ |
426 |
/**********************************************************************/ |
427 |
int i = 0; |
428 |
AttributeCollection attCol = pBlkRef.AttributeCollection; |
429 |
foreach (ObjectId id in attCol) |
430 |
{ |
431 |
try |
432 |
{ |
433 |
using (AttributeReference pAttr = (AttributeReference)id.Open(OpenMode.ForRead)) |
434 |
dumpAttributeData(indent, pAttr, i++, BlockReferenceNode); |
435 |
} |
436 |
catch (System.Exception) |
437 |
{ |
438 |
|
439 |
} |
440 |
} |
441 |
|
442 |
node.AppendChild(BlockReferenceNode); |
443 |
|
444 |
return BlockReferenceNode; |
445 |
} |
446 |
|
447 |
return null; |
448 |
} |
449 |
/************************************************************************/ |
450 |
/* Dump data common to all OdDbCurves */ |
451 |
/************************************************************************/ |
452 |
static void dumpCurveData(Entity pEnt, int indent, XmlNode node) |
453 |
{ |
454 |
if (node != null) |
455 |
{ |
456 |
Curve pEntity = (Curve)pEnt; |
457 |
try |
458 |
{ |
459 |
writeLine(indent, "Start Point", pEntity.StartPoint); |
460 |
writeLine(indent, "End Point", pEntity.EndPoint); |
461 |
} |
462 |
catch (System.Exception) |
463 |
{ |
464 |
} |
465 |
writeLine(indent, "Closed", pEntity.Closed); |
466 |
writeLine(indent, "Periodic", pEntity.IsPeriodic); |
467 |
|
468 |
try |
469 |
{ |
470 |
writeLine(indent, "Area", pEntity.Area); |
471 |
} |
472 |
catch (System.Exception) |
473 |
{ |
474 |
} |
475 |
dumpEntityData(pEntity, indent, node); |
476 |
} |
477 |
} |
478 |
|
479 |
/************************************************************************/ |
480 |
/* Dump Dimension data */ |
481 |
/************************************************************************/ |
482 |
static XmlNode dumpDimData(Dimension pDim, int indent, XmlNode node) |
483 |
{ |
484 |
if (node != null) |
485 |
{ |
486 |
XmlElement DimDataNode = Program.xml.CreateElement("DimData"); |
487 |
|
488 |
XmlAttribute CurrentMeasurementAttr = Program.xml.CreateAttribute("CurrentMeasurement"); |
489 |
CurrentMeasurementAttr.Value = pDim.CurrentMeasurement.ToString(); |
490 |
DimDataNode.Attributes.SetNamedItem(CurrentMeasurementAttr); |
491 |
|
492 |
XmlAttribute DimensionTextAttr = Program.xml.CreateAttribute("DimensionText"); |
493 |
DimensionTextAttr.Value = pDim.DimensionText.ToString(); |
494 |
DimDataNode.Attributes.SetNamedItem(DimensionTextAttr); |
495 |
|
496 |
if (pDim.CurrentMeasurement >= 0.0) |
497 |
{ |
498 |
XmlAttribute FormattedMeasurementAttr = Program.xml.CreateAttribute("FormattedMeasurement"); |
499 |
FormattedMeasurementAttr.Value = pDim.FormatMeasurement(pDim.CurrentMeasurement, pDim.DimensionText); |
500 |
DimDataNode.Attributes.SetNamedItem(FormattedMeasurementAttr); |
501 |
} |
502 |
if (pDim.DimBlockId.IsNull) |
503 |
{ |
504 |
writeLine(indent, "Dimension Block NULL"); |
505 |
} |
506 |
else |
507 |
{ |
508 |
using (BlockTableRecord btr = (BlockTableRecord)pDim.DimBlockId.Open(OpenMode.ForRead)) |
509 |
{ |
510 |
XmlAttribute NameAttr = Program.xml.CreateAttribute("Name"); |
511 |
NameAttr.Value = btr.Name; |
512 |
DimDataNode.Attributes.SetNamedItem(NameAttr); |
513 |
} |
514 |
} |
515 |
|
516 |
XmlAttribute DimBlockPositionAttr = Program.xml.CreateAttribute("DimBlockPosition"); |
517 |
DimBlockPositionAttr.Value = pDim.DimBlockPosition.ToString(); |
518 |
DimDataNode.Attributes.SetNamedItem(DimBlockPositionAttr); |
519 |
|
520 |
XmlAttribute TextPositionAttr = Program.xml.CreateAttribute("TextPosition"); |
521 |
TextPositionAttr.Value = pDim.TextPosition.ToString(); |
522 |
DimDataNode.Attributes.SetNamedItem(TextPositionAttr); |
523 |
|
524 |
XmlAttribute TextRotationAttr = Program.xml.CreateAttribute("TextRotation"); |
525 |
TextRotationAttr.Value = pDim.TextRotation.ToString(); |
526 |
DimDataNode.Attributes.SetNamedItem(TextRotationAttr); |
527 |
|
528 |
XmlAttribute DimensionStyleNameAttr = Program.xml.CreateAttribute("DimensionStyleName"); |
529 |
DimensionStyleNameAttr.Value = pDim.DimensionStyleName.ToString(); |
530 |
DimDataNode.Attributes.SetNamedItem(DimensionStyleNameAttr); |
531 |
|
532 |
XmlAttribute DimtfillclrAttr = Program.xml.CreateAttribute("Dimtfillclr"); |
533 |
DimtfillclrAttr.Value = pDim.Dimtfillclr.ToString(); |
534 |
DimDataNode.Attributes.SetNamedItem(DimtfillclrAttr); |
535 |
|
536 |
XmlAttribute DimtfillAttr = Program.xml.CreateAttribute("Dimtfill"); |
537 |
DimtfillAttr.Value = pDim.Dimtfill.ToString(); |
538 |
DimDataNode.Attributes.SetNamedItem(DimtfillAttr); |
539 |
|
540 |
XmlAttribute Dimltex1Attr = Program.xml.CreateAttribute("Dimltex1"); |
541 |
Dimltex1Attr.Value = pDim.Dimltex1.ToString(); |
542 |
DimDataNode.Attributes.SetNamedItem(Dimltex1Attr); |
543 |
|
544 |
XmlAttribute Dimltex2Attr = Program.xml.CreateAttribute("Dimltex2"); |
545 |
Dimltex2Attr.Value = pDim.Dimltex2.ToString(); |
546 |
DimDataNode.Attributes.SetNamedItem(Dimltex2Attr); |
547 |
|
548 |
XmlAttribute DimltypeAttr = Program.xml.CreateAttribute("Dimltype"); |
549 |
DimltypeAttr.Value = pDim.Dimltype.ToString(); |
550 |
DimDataNode.Attributes.SetNamedItem(DimltypeAttr); |
551 |
|
552 |
XmlAttribute HorizontalRotationAttr = Program.xml.CreateAttribute("HorizontalRotation"); |
553 |
HorizontalRotationAttr.Value = pDim.HorizontalRotation.ToString(); |
554 |
DimDataNode.Attributes.SetNamedItem(HorizontalRotationAttr); |
555 |
|
556 |
XmlAttribute ElevationAttr = Program.xml.CreateAttribute("Elevation"); |
557 |
ElevationAttr.Value = pDim.Elevation.ToString(); |
558 |
DimDataNode.Attributes.SetNamedItem(ElevationAttr); |
559 |
|
560 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
561 |
NormalAttr.Value = pDim.Normal.ToString(); |
562 |
DimDataNode.Attributes.SetNamedItem(NormalAttr); |
563 |
|
564 |
dumpEntityData(pDim, indent, node); |
565 |
|
566 |
return DimDataNode; |
567 |
} |
568 |
|
569 |
return null; |
570 |
} |
571 |
|
572 |
/************************************************************************/ |
573 |
/* 2 Line Angular Dimension Dumper */ |
574 |
/************************************************************************/ |
575 |
static XmlNode dump(LineAngularDimension2 pDim, int indent, XmlNode node) |
576 |
{ |
577 |
if (node != null) |
578 |
{ |
579 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
580 |
|
581 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
582 |
HandleAttr.Value = pDim.Handle.ToString(); |
583 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
584 |
|
585 |
XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint"); |
586 |
ArcPointAttr.Value = pDim.ArcPoint.ToString(); |
587 |
DimNode.Attributes.SetNamedItem(ArcPointAttr); |
588 |
|
589 |
XmlAttribute XLine1StartAttr = Program.xml.CreateAttribute("XLine1Start"); |
590 |
XLine1StartAttr.Value = pDim.XLine1Start.ToString(); |
591 |
DimNode.Attributes.SetNamedItem(XLine1StartAttr); |
592 |
|
593 |
XmlAttribute XLine1EndAttr = Program.xml.CreateAttribute("XLine1End"); |
594 |
XLine1EndAttr.Value = pDim.XLine1End.ToString(); |
595 |
DimNode.Attributes.SetNamedItem(XLine1EndAttr); |
596 |
|
597 |
XmlAttribute XLine2StartAttr = Program.xml.CreateAttribute("XLine2Start"); |
598 |
XLine2StartAttr.Value = pDim.XLine2Start.ToString(); |
599 |
DimNode.Attributes.SetNamedItem(XLine2StartAttr); |
600 |
|
601 |
XmlAttribute XLine2EndAttr = Program.xml.CreateAttribute("XLine2End"); |
602 |
XLine2EndAttr.Value = pDim.XLine2End.ToString(); |
603 |
DimNode.Attributes.SetNamedItem(XLine2EndAttr); |
604 |
|
605 |
dumpDimData(pDim, indent, DimNode); |
606 |
|
607 |
return DimNode; |
608 |
} |
609 |
|
610 |
return null; |
611 |
} |
612 |
|
613 |
/************************************************************************/ |
614 |
/* Dump 2D Vertex data */ |
615 |
/************************************************************************/ |
616 |
static XmlNode dump2dVertex(int indent, Vertex2d pVertex, int i, XmlNode node) |
617 |
{ |
618 |
if (node != null) |
619 |
{ |
620 |
XmlElement VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name); |
621 |
|
622 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
623 |
HandleAttr.Value = pVertex.Handle.ToString(); |
624 |
VertexNode.Attributes.SetNamedItem(HandleAttr); |
625 |
|
626 |
XmlAttribute VertexTypeAttr = Program.xml.CreateAttribute("VertexType"); |
627 |
VertexTypeAttr.Value = pVertex.VertexType.ToString(); |
628 |
VertexNode.Attributes.SetNamedItem(VertexTypeAttr); |
629 |
|
630 |
XmlAttribute PositionAttr = Program.xml.CreateAttribute("Position"); |
631 |
PositionAttr.Value = pVertex.Position.ToString(); |
632 |
VertexNode.Attributes.SetNamedItem(PositionAttr); |
633 |
|
634 |
XmlAttribute StartWidthAttr = Program.xml.CreateAttribute("StartWidth"); |
635 |
StartWidthAttr.Value = pVertex.StartWidth.ToString(); |
636 |
VertexNode.Attributes.SetNamedItem(StartWidthAttr); |
637 |
|
638 |
XmlAttribute EndWidthAttr = Program.xml.CreateAttribute("EndWidth"); |
639 |
EndWidthAttr.Value = pVertex.EndWidth.ToString(); |
640 |
VertexNode.Attributes.SetNamedItem(EndWidthAttr); |
641 |
|
642 |
XmlAttribute BulgeAttr = Program.xml.CreateAttribute("Bulge"); |
643 |
BulgeAttr.Value = pVertex.Bulge.ToString(); |
644 |
VertexNode.Attributes.SetNamedItem(BulgeAttr); |
645 |
|
646 |
if (pVertex.Bulge != 0) |
647 |
{ |
648 |
XmlAttribute BulgeAngleAttr = Program.xml.CreateAttribute("BulgeAngle"); |
649 |
BulgeAngleAttr.Value = (4 * Math.Atan(pVertex.Bulge)).ToString(); |
650 |
VertexNode.Attributes.SetNamedItem(BulgeAngleAttr); |
651 |
} |
652 |
|
653 |
XmlAttribute TangentUsedAttr = Program.xml.CreateAttribute("TangentUsed"); |
654 |
TangentUsedAttr.Value = pVertex.TangentUsed.ToString(); |
655 |
VertexNode.Attributes.SetNamedItem(TangentUsedAttr); |
656 |
if (pVertex.TangentUsed) |
657 |
{ |
658 |
XmlAttribute TangentAttr = Program.xml.CreateAttribute("Tangent"); |
659 |
TangentAttr.Value = pVertex.Tangent.ToString(); |
660 |
VertexNode.Attributes.SetNamedItem(TangentAttr); |
661 |
} |
662 |
|
663 |
node.AppendChild(VertexNode); |
664 |
|
665 |
return VertexNode; |
666 |
} |
667 |
|
668 |
return null; |
669 |
} |
670 |
|
671 |
/************************************************************************/ |
672 |
/* 2D Polyline Dumper */ |
673 |
/************************************************************************/ |
674 |
static XmlNode dump(Polyline2d pPolyline, int indent, XmlNode node) |
675 |
{ |
676 |
/********************************************************************/ |
677 |
/* Dump the vertices */ |
678 |
/********************************************************************/ |
679 |
List<Vertex2d> Vertices = new List<Vertex2d>(); |
680 |
int i = 0; |
681 |
foreach (ObjectId obj in pPolyline) |
682 |
{ |
683 |
using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead)) |
684 |
{ |
685 |
if (dbObj is Vertex2d) |
686 |
{ |
687 |
Vertices.Add((Vertex2d)dbObj); |
688 |
/// dump2dVertex(indent, (Vertex2d)dbObj, i++); |
689 |
} |
690 |
} |
691 |
} |
692 |
|
693 |
if (node != null) |
694 |
{ |
695 |
XmlNode Polyline2dNode = Program.xml.CreateElement(pPolyline.GetRXClass().Name); |
696 |
|
697 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
698 |
HandleAttr.Value = pPolyline.Handle.ToString(); |
699 |
Polyline2dNode.Attributes.SetNamedItem(HandleAttr); |
700 |
|
701 |
XmlAttribute CountAttr = Program.xml.CreateAttribute("Count"); |
702 |
CountAttr.Value = Vertices.Count.ToString(); |
703 |
Polyline2dNode.Attributes.SetNamedItem(CountAttr); |
704 |
|
705 |
XmlAttribute ElevationAttr = Program.xml.CreateAttribute("Elevation"); |
706 |
ElevationAttr.Value = pPolyline.Elevation.ToString(); |
707 |
Polyline2dNode.Attributes.SetNamedItem(ElevationAttr); |
708 |
|
709 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
710 |
NormalAttr.Value = pPolyline.Normal.ToString(); |
711 |
Polyline2dNode.Attributes.SetNamedItem(NormalAttr); |
712 |
|
713 |
XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness"); |
714 |
ThicknessAttr.Value = pPolyline.Thickness.ToString(); |
715 |
Polyline2dNode.Attributes.SetNamedItem(ThicknessAttr); |
716 |
|
717 |
XmlAttribute ClosedAttr = Program.xml.CreateAttribute("Closed"); |
718 |
ClosedAttr.Value = pPolyline.Closed.ToString(); |
719 |
Polyline2dNode.Attributes.SetNamedItem(ClosedAttr); |
720 |
|
721 |
foreach (var vt in Vertices) |
722 |
{ |
723 |
XmlNode VertexNode = Program.xml.CreateElement("Vertex"); |
724 |
|
725 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
726 |
XAttr.Value = vt.Position.X.ToString(); |
727 |
VertexNode.Attributes.SetNamedItem(XAttr); |
728 |
|
729 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
730 |
YAttr.Value = vt.Position.Y.ToString(); |
731 |
VertexNode.Attributes.SetNamedItem(YAttr); |
732 |
|
733 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
734 |
ZAttr.Value = vt.Position.Z.ToString(); |
735 |
VertexNode.Attributes.SetNamedItem(ZAttr); |
736 |
|
737 |
Polyline2dNode.AppendChild(VertexNode); |
738 |
} |
739 |
|
740 |
dumpCurveData(pPolyline, indent, node); |
741 |
|
742 |
node.AppendChild(Polyline2dNode); |
743 |
|
744 |
return Polyline2dNode; |
745 |
} |
746 |
|
747 |
return null; |
748 |
} |
749 |
|
750 |
|
751 |
/************************************************************************/ |
752 |
/* Dump 3D Polyline Vertex data */ |
753 |
/************************************************************************/ |
754 |
XmlNode dump3dPolylineVertex(int indent, PolylineVertex3d pVertex, int i, XmlNode node) |
755 |
{ |
756 |
if (node != null) |
757 |
{ |
758 |
XmlNode VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name); |
759 |
|
760 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
761 |
HandleAttr.Value = pVertex.Handle.ToString(); |
762 |
VertexNode.Attributes.SetNamedItem(HandleAttr); |
763 |
|
764 |
XmlAttribute VertexxTypeAttr = Program.xml.CreateAttribute("VertexType"); |
765 |
VertexxTypeAttr.Value = pVertex.VertexType.ToString(); |
766 |
VertexNode.Attributes.SetNamedItem(VertexxTypeAttr); |
767 |
|
768 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
769 |
XAttr.Value = pVertex.Position.X.ToString(); |
770 |
VertexNode.Attributes.SetNamedItem(XAttr); |
771 |
|
772 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
773 |
YAttr.Value = pVertex.Position.Y.ToString(); |
774 |
VertexNode.Attributes.SetNamedItem(YAttr); |
775 |
|
776 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
777 |
ZAttr.Value = pVertex.Position.Z.ToString(); |
778 |
VertexNode.Attributes.SetNamedItem(ZAttr); |
779 |
|
780 |
node.AppendChild(VertexNode); |
781 |
|
782 |
return VertexNode; |
783 |
} |
784 |
|
785 |
return null; |
786 |
} |
787 |
|
788 |
/************************************************************************/ |
789 |
/* 3D Polyline Dumper */ |
790 |
/************************************************************************/ |
791 |
XmlNode dump(Polyline3d pPolyline, int indent, XmlNode node) |
792 |
{ |
793 |
if (node != null) |
794 |
{ |
795 |
XmlNode pPolylineNode = Program.xml.CreateElement(pPolyline.GetRXClass().Name); |
796 |
|
797 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
798 |
HandleAttr.Value = pPolyline.Handle.ToString(); |
799 |
pPolylineNode.Attributes.SetNamedItem(HandleAttr); |
800 |
|
801 |
/********************************************************************/ |
802 |
/* Dump the vertices */ |
803 |
/********************************************************************/ |
804 |
int i = 0; |
805 |
foreach (ObjectId obj in pPolyline) |
806 |
{ |
807 |
using (DBObject dbObj = (DBObject)obj.GetObject(OpenMode.ForRead)) |
808 |
{ |
809 |
if (dbObj is PolylineVertex3d) |
810 |
{ |
811 |
dump3dPolylineVertex(indent, (PolylineVertex3d)dbObj, i++, pPolylineNode); |
812 |
} |
813 |
} |
814 |
} |
815 |
dumpCurveData(pPolyline, indent, pPolylineNode); |
816 |
|
817 |
node.AppendChild(pPolylineNode); |
818 |
|
819 |
return pPolylineNode; |
820 |
} |
821 |
|
822 |
return null; |
823 |
} |
824 |
|
825 |
|
826 |
/************************************************************************/ |
827 |
/* 3DSolid Dumper */ |
828 |
/************************************************************************/ |
829 |
XmlNode dump(Solid3d pSolid, int indent, XmlNode node) |
830 |
{ |
831 |
if (node != null) |
832 |
{ |
833 |
XmlNode SolidNode = Program.xml.CreateElement(pSolid.GetRXClass().Name); |
834 |
|
835 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
836 |
HandleAttr.Value = pSolid.Handle.ToString(); |
837 |
SolidNode.Attributes.SetNamedItem(HandleAttr); |
838 |
|
839 |
dumpEntityData(pSolid, indent, node); |
840 |
|
841 |
node.AppendChild(SolidNode); |
842 |
|
843 |
return SolidNode; |
844 |
} |
845 |
|
846 |
return null; |
847 |
} |
848 |
|
849 |
|
850 |
/************************************************************************/ |
851 |
/* 3 Point Angular Dimension Dumper */ |
852 |
/************************************************************************/ |
853 |
XmlNode dump(Point3AngularDimension pDim, int indent, XmlNode node) |
854 |
{ |
855 |
if (node != null) |
856 |
{ |
857 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
858 |
|
859 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
860 |
HandleAttr.Value = pDim.Handle.ToString(); |
861 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
862 |
|
863 |
XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint"); |
864 |
ArcPointAttr.Value = pDim.ArcPoint.ToString(); |
865 |
DimNode.Attributes.SetNamedItem(ArcPointAttr); |
866 |
|
867 |
XmlAttribute CenterPointAttr = Program.xml.CreateAttribute("CenterPoint"); |
868 |
CenterPointAttr.Value = pDim.CenterPoint.ToString(); |
869 |
DimNode.Attributes.SetNamedItem(CenterPointAttr); |
870 |
|
871 |
XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point"); |
872 |
XLine1PointAttr.Value = pDim.XLine1Point.ToString(); |
873 |
DimNode.Attributes.SetNamedItem(XLine1PointAttr); |
874 |
|
875 |
XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point"); |
876 |
XLine2PointAttr.Value = pDim.XLine2Point.ToString(); |
877 |
DimNode.Attributes.SetNamedItem(XLine2PointAttr); |
878 |
|
879 |
dumpDimData(pDim, indent, DimNode); |
880 |
|
881 |
return DimNode; |
882 |
} |
883 |
|
884 |
return null; |
885 |
} |
886 |
|
887 |
/************************************************************************/ |
888 |
/* Aligned Dimension Dumper */ |
889 |
/************************************************************************/ |
890 |
XmlNode dump(AlignedDimension pDim, int indent, XmlNode node) |
891 |
{ |
892 |
if (node != null) |
893 |
{ |
894 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
895 |
|
896 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
897 |
HandleAttr.Value = pDim.Handle.ToString(); |
898 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
899 |
|
900 |
XmlAttribute DimLinePointAttr = Program.xml.CreateAttribute("DimLinePoint"); |
901 |
DimLinePointAttr.Value = pDim.DimLinePoint.ToString(); |
902 |
DimNode.Attributes.SetNamedItem(DimLinePointAttr); |
903 |
|
904 |
XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique"); |
905 |
ObliqueAttr.Value = pDim.Oblique.ToString(); |
906 |
DimNode.Attributes.SetNamedItem(ObliqueAttr); |
907 |
|
908 |
XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point"); |
909 |
XLine1PointAttr.Value = pDim.XLine1Point.ToString(); |
910 |
DimNode.Attributes.SetNamedItem(XLine1PointAttr); |
911 |
|
912 |
XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point"); |
913 |
XLine2PointAttr.Value = pDim.XLine2Point.ToString(); |
914 |
DimNode.Attributes.SetNamedItem(XLine2PointAttr); |
915 |
|
916 |
dumpDimData(pDim, indent, DimNode); |
917 |
|
918 |
return DimNode; |
919 |
} |
920 |
|
921 |
return null; |
922 |
} |
923 |
|
924 |
/************************************************************************/ |
925 |
/* Arc Dumper */ |
926 |
/************************************************************************/ |
927 |
XmlNode dump(Arc pArc, int indent, XmlNode node) |
928 |
{ |
929 |
if (node != null) |
930 |
{ |
931 |
XmlElement ArcNode = Program.xml.CreateElement(pArc.GetRXClass().Name); |
932 |
|
933 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
934 |
XAttr.Value = pArc.Center.X.ToString(); |
935 |
ArcNode.Attributes.SetNamedItem(XAttr); |
936 |
|
937 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
938 |
YAttr.Value = pArc.Center.Y.ToString(); |
939 |
ArcNode.Attributes.SetNamedItem(YAttr); |
940 |
|
941 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
942 |
ZAttr.Value = pArc.Center.Z.ToString(); |
943 |
ArcNode.Attributes.SetNamedItem(ZAttr); |
944 |
|
945 |
XmlAttribute RadiusAttr = Program.xml.CreateAttribute("Radius"); |
946 |
RadiusAttr.Value = pArc.Radius.ToString(); |
947 |
ArcNode.Attributes.SetNamedItem(RadiusAttr); |
948 |
|
949 |
XmlAttribute StartAngleAttr = Program.xml.CreateAttribute("StartAngle"); |
950 |
StartAngleAttr.Value = pArc.StartAngle.ToString(); |
951 |
ArcNode.Attributes.SetNamedItem(StartAngleAttr); |
952 |
|
953 |
XmlAttribute EndAngleAttr = Program.xml.CreateAttribute("EndAngle"); |
954 |
EndAngleAttr.Value = pArc.EndAngle.ToString(); |
955 |
ArcNode.Attributes.SetNamedItem(EndAngleAttr); |
956 |
|
957 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
958 |
NormalAttr.Value = pArc.Normal.ToString(); |
959 |
ArcNode.Attributes.SetNamedItem(NormalAttr); |
960 |
|
961 |
XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness"); |
962 |
ThicknessAttr.Value = pArc.Normal.ToString(); |
963 |
ArcNode.Attributes.SetNamedItem(ThicknessAttr); |
964 |
|
965 |
writeLine(indent++, pArc.GetRXClass().Name, pArc.Handle); |
966 |
dumpCurveData(pArc, indent, ArcNode); |
967 |
|
968 |
XmlNode StartPointNode = Program.xml.CreateElement("Vertex"); |
969 |
{ |
970 |
XAttr = Program.xml.CreateAttribute("X"); |
971 |
XAttr.Value = pArc.StartPoint.X.ToString(); |
972 |
StartPointNode.Attributes.SetNamedItem(XAttr); |
973 |
|
974 |
YAttr = Program.xml.CreateAttribute("Y"); |
975 |
YAttr.Value = pArc.StartPoint.Y.ToString(); |
976 |
StartPointNode.Attributes.SetNamedItem(YAttr); |
977 |
|
978 |
ZAttr = Program.xml.CreateAttribute("Z"); |
979 |
ZAttr.Value = pArc.StartPoint.Z.ToString(); |
980 |
StartPointNode.Attributes.SetNamedItem(ZAttr); |
981 |
} |
982 |
ArcNode.AppendChild(StartPointNode); |
983 |
|
984 |
XmlNode EndPointNode = Program.xml.CreateElement("Vertex"); |
985 |
{ |
986 |
XAttr = Program.xml.CreateAttribute("X"); |
987 |
XAttr.Value = pArc.EndPoint.X.ToString(); |
988 |
EndPointNode.Attributes.SetNamedItem(XAttr); |
989 |
|
990 |
YAttr = Program.xml.CreateAttribute("Y"); |
991 |
YAttr.Value = pArc.EndPoint.Y.ToString(); |
992 |
EndPointNode.Attributes.SetNamedItem(YAttr); |
993 |
|
994 |
ZAttr = Program.xml.CreateAttribute("Z"); |
995 |
ZAttr.Value = pArc.EndPoint.Z.ToString(); |
996 |
EndPointNode.Attributes.SetNamedItem(ZAttr); |
997 |
} |
998 |
ArcNode.AppendChild(EndPointNode); |
999 |
|
1000 |
node.AppendChild(ArcNode); |
1001 |
|
1002 |
return ArcNode; |
1003 |
} |
1004 |
|
1005 |
return null; |
1006 |
} |
1007 |
|
1008 |
/************************************************************************/ |
1009 |
/* Arc Dimension Dumper */ |
1010 |
/************************************************************************/ |
1011 |
XmlNode dump(ArcDimension pDim, int indent, XmlNode node) |
1012 |
{ |
1013 |
if (node != null) |
1014 |
{ |
1015 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
1016 |
|
1017 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1018 |
HandleAttr.Value = pDim.Handle.ToString(); |
1019 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
1020 |
|
1021 |
XmlAttribute ArcPointAttr = Program.xml.CreateAttribute("ArcPoint"); |
1022 |
ArcPointAttr.Value = pDim.ArcPoint.ToString(); |
1023 |
DimNode.Attributes.SetNamedItem(ArcPointAttr); |
1024 |
|
1025 |
XmlAttribute CenterPointAttr = Program.xml.CreateAttribute("CenterPoint"); |
1026 |
CenterPointAttr.Value = pDim.CenterPoint.ToString(); |
1027 |
DimNode.Attributes.SetNamedItem(CenterPointAttr); |
1028 |
|
1029 |
XmlAttribute ArcSymbolTypeAttr = Program.xml.CreateAttribute("ArcSymbolType"); |
1030 |
ArcSymbolTypeAttr.Value = pDim.ArcSymbolType.ToString(); |
1031 |
DimNode.Attributes.SetNamedItem(ArcSymbolTypeAttr); |
1032 |
|
1033 |
XmlAttribute IsPartialAttr = Program.xml.CreateAttribute("IsPartial"); |
1034 |
IsPartialAttr.Value = pDim.IsPartial.ToString(); |
1035 |
DimNode.Attributes.SetNamedItem(IsPartialAttr); |
1036 |
|
1037 |
XmlAttribute HasLeaderAttr = Program.xml.CreateAttribute("HasLeader"); |
1038 |
HasLeaderAttr.Value = pDim.HasLeader.ToString(); |
1039 |
DimNode.Attributes.SetNamedItem(HasLeaderAttr); |
1040 |
|
1041 |
if (pDim.HasLeader) |
1042 |
{ |
1043 |
XmlAttribute Leader1PointAttr = Program.xml.CreateAttribute("Leader1Point"); |
1044 |
Leader1PointAttr.Value = pDim.Leader1Point.ToString(); |
1045 |
DimNode.Attributes.SetNamedItem(Leader1PointAttr); |
1046 |
|
1047 |
XmlAttribute Leader2PointAttr = Program.xml.CreateAttribute("Leader2Point"); |
1048 |
Leader2PointAttr.Value = pDim.Leader2Point.ToString(); |
1049 |
DimNode.Attributes.SetNamedItem(Leader2PointAttr); |
1050 |
} |
1051 |
|
1052 |
XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point"); |
1053 |
XLine1PointAttr.Value = pDim.XLine1Point.ToString(); |
1054 |
DimNode.Attributes.SetNamedItem(XLine1PointAttr); |
1055 |
|
1056 |
XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point"); |
1057 |
XLine2PointAttr.Value = pDim.XLine2Point.ToString(); |
1058 |
DimNode.Attributes.SetNamedItem(XLine2PointAttr); |
1059 |
|
1060 |
dumpDimData(pDim, indent, DimNode); |
1061 |
|
1062 |
return DimNode; |
1063 |
} |
1064 |
|
1065 |
return null; |
1066 |
} |
1067 |
|
1068 |
|
1069 |
/************************************************************************/ |
1070 |
/* Block Reference Dumper */ |
1071 |
/************************************************************************/ |
1072 |
void dump(BlockReference pBlkRef, int indent, XmlNode node) |
1073 |
{ |
1074 |
using (BlockTableRecord pRecord = (BlockTableRecord)pBlkRef.BlockTableRecord.Open(OpenMode.ForRead)) |
1075 |
{ |
1076 |
XmlNode BlockRefNode = dumpBlockRefData(pBlkRef, indent, node); |
1077 |
if (BlockRefNode != null) |
1078 |
{ |
1079 |
XmlAttribute NameAttr = Program.xml.CreateAttribute("Name"); |
1080 |
NameAttr.Value = pRecord.Name; |
1081 |
BlockRefNode.Attributes.SetNamedItem(NameAttr); |
1082 |
} |
1083 |
} |
1084 |
} |
1085 |
|
1086 |
/************************************************************************/ |
1087 |
/* Body Dumper */ |
1088 |
/************************************************************************/ |
1089 |
XmlNode dump(Body pBody, int indent, XmlNode node) |
1090 |
{ |
1091 |
if (node != null) |
1092 |
{ |
1093 |
XmlNode BodyNode = Program.xml.CreateElement(pBody.GetRXClass().Name); |
1094 |
|
1095 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1096 |
HandleAttr.Value = pBody.Handle.ToString(); |
1097 |
BodyNode.Attributes.SetNamedItem(HandleAttr); |
1098 |
|
1099 |
dumpEntityData(pBody, indent, BodyNode); |
1100 |
|
1101 |
return BodyNode; |
1102 |
} |
1103 |
|
1104 |
return null; |
1105 |
} |
1106 |
|
1107 |
|
1108 |
/************************************************************************/ |
1109 |
/* Circle Dumper */ |
1110 |
/************************************************************************/ |
1111 |
XmlNode dump(Circle pCircle, int indent, XmlNode node) |
1112 |
{ |
1113 |
if (node != null) |
1114 |
{ |
1115 |
XmlElement CircleNode = Program.xml.CreateElement(pCircle.GetRXClass().Name); |
1116 |
|
1117 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
1118 |
XAttr.Value = pCircle.Center.X.ToString(); |
1119 |
CircleNode.Attributes.SetNamedItem(XAttr); |
1120 |
|
1121 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
1122 |
YAttr.Value = pCircle.Center.Y.ToString(); |
1123 |
CircleNode.Attributes.SetNamedItem(YAttr); |
1124 |
|
1125 |
XmlAttribute RadiusAttr = Program.xml.CreateAttribute("Radius"); |
1126 |
RadiusAttr.Value = pCircle.Radius.ToString(); |
1127 |
CircleNode.Attributes.SetNamedItem(RadiusAttr); |
1128 |
|
1129 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
1130 |
NormalAttr.Value = pCircle.Normal.ToString(); |
1131 |
CircleNode.Attributes.SetNamedItem(NormalAttr); |
1132 |
|
1133 |
XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness"); |
1134 |
ThicknessAttr.Value = pCircle.Thickness.ToString(); |
1135 |
CircleNode.Attributes.SetNamedItem(ThicknessAttr); |
1136 |
|
1137 |
dumpCurveData(pCircle, indent, CircleNode); |
1138 |
|
1139 |
node.AppendChild(CircleNode); |
1140 |
|
1141 |
return CircleNode; |
1142 |
} |
1143 |
|
1144 |
return null; |
1145 |
} |
1146 |
|
1147 |
/************************************************************************/ |
1148 |
/* Diametric Dimension Dumper */ |
1149 |
/************************************************************************/ |
1150 |
XmlNode dump(DiametricDimension pDim, int indent, XmlNode node) |
1151 |
{ |
1152 |
if (node != null) |
1153 |
{ |
1154 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
1155 |
|
1156 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1157 |
HandleAttr.Value = pDim.Handle.ToString(); |
1158 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
1159 |
|
1160 |
XmlAttribute ChordPointAttr = Program.xml.CreateAttribute("ChordPoint"); |
1161 |
ChordPointAttr.Value = pDim.ChordPoint.ToString(); |
1162 |
DimNode.Attributes.SetNamedItem(ChordPointAttr); |
1163 |
|
1164 |
XmlAttribute FarChordPointAttr = Program.xml.CreateAttribute("FarChordPoint"); |
1165 |
FarChordPointAttr.Value = pDim.FarChordPoint.ToString(); |
1166 |
DimNode.Attributes.SetNamedItem(FarChordPointAttr); |
1167 |
|
1168 |
XmlAttribute LeaderLengthAttr = Program.xml.CreateAttribute("LeaderLength"); |
1169 |
LeaderLengthAttr.Value = pDim.LeaderLength.ToString(); |
1170 |
DimNode.Attributes.SetNamedItem(LeaderLengthAttr); |
1171 |
|
1172 |
dumpDimData(pDim, indent, DimNode); |
1173 |
|
1174 |
return DimNode; |
1175 |
} |
1176 |
|
1177 |
return null; |
1178 |
} |
1179 |
|
1180 |
/************************************************************************/ |
1181 |
/* Ellipse Dumper */ |
1182 |
/************************************************************************/ |
1183 |
void dump(Ellipse pEllipse, int indent, XmlNode node) |
1184 |
{ |
1185 |
if (node != null) |
1186 |
{ |
1187 |
XmlElement EllipseNode = Program.xml.CreateElement(pEllipse.GetRXClass().Name); |
1188 |
|
1189 |
writeLine(indent++, pEllipse.GetRXClass().Name, pEllipse.Handle); |
1190 |
|
1191 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
1192 |
XAttr.Value = pEllipse.Center.X.ToString(); |
1193 |
EllipseNode.Attributes.SetNamedItem(XAttr); |
1194 |
|
1195 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
1196 |
YAttr.Value = pEllipse.Center.Y.ToString(); |
1197 |
EllipseNode.Attributes.SetNamedItem(YAttr); |
1198 |
|
1199 |
XmlAttribute MajorAxisAttr = Program.xml.CreateAttribute("MajorAxis"); |
1200 |
MajorAxisAttr.Value = pEllipse.MajorAxis.ToString(); |
1201 |
EllipseNode.Attributes.SetNamedItem(MajorAxisAttr); |
1202 |
|
1203 |
XmlAttribute MinorAxisAttr = Program.xml.CreateAttribute("MinorAxis"); |
1204 |
MinorAxisAttr.Value = pEllipse.MinorAxis.ToString(); |
1205 |
EllipseNode.Attributes.SetNamedItem(MinorAxisAttr); |
1206 |
|
1207 |
XmlAttribute MajorRadiusAttr = Program.xml.CreateAttribute("MajorRadius"); |
1208 |
MajorRadiusAttr.Value = pEllipse.MajorRadius.ToString(); |
1209 |
EllipseNode.Attributes.SetNamedItem(MajorRadiusAttr); |
1210 |
|
1211 |
XmlAttribute MinorRadiusAttr = Program.xml.CreateAttribute("MinorRadius"); |
1212 |
MinorRadiusAttr.Value = pEllipse.MinorRadius.ToString(); |
1213 |
EllipseNode.Attributes.SetNamedItem(MinorRadiusAttr); |
1214 |
|
1215 |
XmlAttribute RadiusRatioAttr = Program.xml.CreateAttribute("RadiusRatio"); |
1216 |
RadiusRatioAttr.Value = pEllipse.RadiusRatio.ToString(); |
1217 |
EllipseNode.Attributes.SetNamedItem(RadiusRatioAttr); |
1218 |
|
1219 |
XmlAttribute StartAngleAttr = Program.xml.CreateAttribute("StartAngle"); |
1220 |
StartAngleAttr.Value = pEllipse.StartAngle.ToString(); |
1221 |
EllipseNode.Attributes.SetNamedItem(StartAngleAttr); |
1222 |
|
1223 |
XmlAttribute EndAngleAttr = Program.xml.CreateAttribute("EndAngle"); |
1224 |
EndAngleAttr.Value = pEllipse.EndAngle.ToString(); |
1225 |
EllipseNode.Attributes.SetNamedItem(EndAngleAttr); |
1226 |
|
1227 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
1228 |
NormalAttr.Value = pEllipse.Normal.ToString(); |
1229 |
EllipseNode.Attributes.SetNamedItem(NormalAttr); |
1230 |
|
1231 |
dumpCurveData(pEllipse, indent, EllipseNode); |
1232 |
|
1233 |
node.AppendChild(EllipseNode); |
1234 |
} |
1235 |
} |
1236 |
|
1237 |
/************************************************************************/ |
1238 |
/* Face Dumper */ |
1239 |
/************************************************************************/ |
1240 |
XmlNode dump(Face pFace, int indent, XmlNode node) |
1241 |
{ |
1242 |
if (node != null) |
1243 |
{ |
1244 |
XmlElement FaceNode = Program.xml.CreateElement(pFace.GetRXClass().Name); |
1245 |
|
1246 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1247 |
HandleAttr.Value = pFace.Handle.ToString(); |
1248 |
FaceNode.Attributes.SetNamedItem(HandleAttr); |
1249 |
|
1250 |
for (short i = 0; i < 4; i++) |
1251 |
{ |
1252 |
XmlElement VertexNode = Program.xml.CreateElement("Vertex"); |
1253 |
|
1254 |
Point3d pt = pFace.GetVertexAt(i); |
1255 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
1256 |
XAttr.Value = pt.X.ToString(); |
1257 |
VertexNode.Attributes.SetNamedItem(XAttr); |
1258 |
|
1259 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
1260 |
YAttr.Value = pt.Y.ToString(); |
1261 |
VertexNode.Attributes.SetNamedItem(YAttr); |
1262 |
|
1263 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
1264 |
ZAttr.Value = pt.Z.ToString(); |
1265 |
VertexNode.Attributes.SetNamedItem(ZAttr); |
1266 |
|
1267 |
XmlAttribute VisibleAttr = Program.xml.CreateAttribute("Visible"); |
1268 |
VisibleAttr.Value = pFace.IsEdgeVisibleAt(i).ToString(); |
1269 |
VertexNode.Attributes.SetNamedItem(VisibleAttr); |
1270 |
|
1271 |
FaceNode.AppendChild(VertexNode); |
1272 |
} |
1273 |
dumpEntityData(pFace, indent, FaceNode); |
1274 |
|
1275 |
node.AppendChild(FaceNode); |
1276 |
|
1277 |
return FaceNode; |
1278 |
} |
1279 |
|
1280 |
return null; |
1281 |
} |
1282 |
|
1283 |
/************************************************************************/ |
1284 |
/* FCF Dumper */ |
1285 |
/************************************************************************/ |
1286 |
void dump(FeatureControlFrame pFcf, int indent) |
1287 |
{ |
1288 |
writeLine(indent++, pFcf.GetRXClass().Name, pFcf.Handle); |
1289 |
writeLine(indent, "Location", pFcf.Location); |
1290 |
writeLine(indent, "Text", pFcf.Text); |
1291 |
writeLine(indent, "Dimension Style", pFcf.DimensionStyleName); |
1292 |
writeLine(indent, "Dimension Gap", pFcf.Dimgap); |
1293 |
writeLine(indent, "Dimension Scale", pFcf.Dimscale); |
1294 |
writeLine(indent, "Text Height", pFcf.Dimtxt); |
1295 |
writeLine(indent, "Frame Color", pFcf.Dimclrd); |
1296 |
writeLine(indent, "Text Style", pFcf.TextStyleName); |
1297 |
writeLine(indent, "Text Color", pFcf.Dimclrd); |
1298 |
writeLine(indent, "X-Direction", pFcf.Direction); |
1299 |
writeLine(indent, "Normal", pFcf.Normal); |
1300 |
dumpEntityData(pFcf, indent, Program.xml.DocumentElement); |
1301 |
} |
1302 |
|
1303 |
/************************************************************************/ |
1304 |
/* Hatch Dumper */ |
1305 |
/************************************************************************/ |
1306 |
/***********************************************************************/ |
1307 |
/* Dump Polyline Loop */ |
1308 |
/***********************************************************************/ |
1309 |
static void dumpPolylineType(int loopIndex, Hatch pHatch, int indent) |
1310 |
{ |
1311 |
HatchLoop hl = pHatch.GetLoopAt(loopIndex); |
1312 |
for (int i = 0; i < hl.Polyline.Count; i++) |
1313 |
{ |
1314 |
BulgeVertex bv = hl.Polyline[i]; |
1315 |
writeLine(indent, "Vertex " + i.ToString(), bv.Vertex.ToString()); |
1316 |
writeLine(indent + 1, "Bulge " + i.ToString(), bv.Bulge); |
1317 |
writeLine(indent + 1, "Bulge angle " + i.ToString(), toDegreeString(4 * Math.Atan(bv.Bulge))); |
1318 |
} |
1319 |
} |
1320 |
|
1321 |
/**********************************************************************/ |
1322 |
/* Dump Circular Arc Edge */ |
1323 |
/**********************************************************************/ |
1324 |
static void dumpCircularArcEdge(int indent, CircularArc2d pCircArc) |
1325 |
{ |
1326 |
writeLine(indent, "Center", pCircArc.Center); |
1327 |
writeLine(indent, "Radius", pCircArc.Radius); |
1328 |
writeLine(indent, "Start Angle", toDegreeString(pCircArc.StartAngle)); |
1329 |
writeLine(indent, "End Angle", toDegreeString(pCircArc.EndAngle)); |
1330 |
writeLine(indent, "Clockwise", pCircArc.IsClockWise); |
1331 |
} |
1332 |
|
1333 |
/**********************************************************************/ |
1334 |
/* Dump Elliptical Arc Edge */ |
1335 |
/**********************************************************************/ |
1336 |
static void dumpEllipticalArcEdge(int indent, EllipticalArc2d pEllipArc) |
1337 |
{ |
1338 |
writeLine(indent, "Center", pEllipArc.Center); |
1339 |
writeLine(indent, "Major Radius", pEllipArc.MajorRadius); |
1340 |
writeLine(indent, "Minor Radius", pEllipArc.MinorRadius); |
1341 |
writeLine(indent, "Major Axis", pEllipArc.MajorAxis); |
1342 |
writeLine(indent, "Minor Axis", pEllipArc.MinorAxis); |
1343 |
writeLine(indent, "Start Angle", toDegreeString(pEllipArc.StartAngle)); |
1344 |
writeLine(indent, "End Angle", toDegreeString(pEllipArc.EndAngle)); |
1345 |
writeLine(indent, "Clockwise", pEllipArc.IsClockWise); |
1346 |
} |
1347 |
|
1348 |
/**********************************************************************/ |
1349 |
/* Dump NurbCurve Edge */ |
1350 |
/**********************************************************************/ |
1351 |
static void dumpNurbCurveEdge(int indent, NurbCurve2d pNurbCurve) |
1352 |
{ |
1353 |
NurbCurve2dData d = pNurbCurve.DefinitionData; |
1354 |
writeLine(indent, "Degree", d.Degree); |
1355 |
writeLine(indent, "Rational", d.Rational); |
1356 |
writeLine(indent, "Periodic", d.Periodic); |
1357 |
|
1358 |
writeLine(indent, "Number of Control Points", d.ControlPoints.Count); |
1359 |
for (int i = 0; i < d.ControlPoints.Count; i++) |
1360 |
{ |
1361 |
writeLine(indent, "Control Point " + i.ToString(), d.ControlPoints[i]); |
1362 |
} |
1363 |
writeLine(indent, "Number of Knots", d.Knots.Count); |
1364 |
for (int i = 0; i < d.Knots.Count; i++) |
1365 |
{ |
1366 |
writeLine(indent, "Knot " + i.ToString(), d.Knots[i]); |
1367 |
} |
1368 |
|
1369 |
if (d.Rational) |
1370 |
{ |
1371 |
writeLine(indent, "Number of Weights", d.Weights.Count); |
1372 |
for (int i = 0; i < d.Weights.Count; i++) |
1373 |
{ |
1374 |
writeLine(indent, "Weight " + i.ToString(), d.Weights[i]); |
1375 |
} |
1376 |
} |
1377 |
} |
1378 |
|
1379 |
/***********************************************************************/ |
1380 |
/* Dump Edge Loop */ |
1381 |
/***********************************************************************/ |
1382 |
static void dumpEdgesType(int loopIndex, Hatch pHatch, int indent) |
1383 |
{ |
1384 |
Curve2dCollection edges = pHatch.GetLoopAt(loopIndex).Curves; |
1385 |
for (int i = 0; i < (int)edges.Count; i++) |
1386 |
{ |
1387 |
using (Curve2d pEdge = edges[i]) |
1388 |
{ |
1389 |
writeLine(indent, string.Format("Edge {0}", i), pEdge.GetType().Name); |
1390 |
switch (pEdge.GetType().Name) |
1391 |
{ |
1392 |
case "LineSegment2d": |
1393 |
break; |
1394 |
case "CircularArc2d": |
1395 |
dumpCircularArcEdge(indent + 1, (CircularArc2d)pEdge); |
1396 |
break; |
1397 |
case "EllipticalArc2d": |
1398 |
dumpEllipticalArcEdge(indent + 1, (EllipticalArc2d)pEdge); |
1399 |
break; |
1400 |
case "NurbCurve2d": |
1401 |
dumpNurbCurveEdge(indent + 1, (NurbCurve2d)pEdge); |
1402 |
break; |
1403 |
} |
1404 |
|
1405 |
/******************************************************************/ |
1406 |
/* Common Edge Properties */ |
1407 |
/******************************************************************/ |
1408 |
Interval interval = pEdge.GetInterval(); |
1409 |
writeLine(indent + 1, "Start Point", pEdge.EvaluatePoint(interval.LowerBound)); |
1410 |
writeLine(indent + 1, "End Point", pEdge.EvaluatePoint(interval.UpperBound)); |
1411 |
writeLine(indent + 1, "Closed", pEdge.IsClosed()); |
1412 |
} |
1413 |
} |
1414 |
} |
1415 |
|
1416 |
/************************************************************************/ |
1417 |
/* Convert the specified value to a LoopType string */ |
1418 |
/************************************************************************/ |
1419 |
string toLooptypeString(HatchLoopTypes loopType) |
1420 |
{ |
1421 |
string retVal = ""; |
1422 |
if ((loopType & HatchLoopTypes.External) != 0) |
1423 |
retVal = retVal + " | kExternal"; |
1424 |
|
1425 |
if ((loopType & HatchLoopTypes.Polyline) != 0) |
1426 |
retVal = retVal + " | kPolyline"; |
1427 |
|
1428 |
if ((loopType & HatchLoopTypes.Derived) != 0) |
1429 |
retVal = retVal + " | kDerived"; |
1430 |
|
1431 |
if ((loopType & HatchLoopTypes.Textbox) != 0) |
1432 |
retVal = retVal + " | kTextbox"; |
1433 |
|
1434 |
if ((loopType & HatchLoopTypes.Outermost) != 0) |
1435 |
retVal = retVal + " | kOutermost"; |
1436 |
|
1437 |
if ((loopType & HatchLoopTypes.NotClosed) != 0) |
1438 |
retVal = retVal + " | kNotClosed"; |
1439 |
|
1440 |
if ((loopType & HatchLoopTypes.SelfIntersecting) != 0) |
1441 |
retVal = retVal + " | kSelfIntersecting"; |
1442 |
|
1443 |
if ((loopType & HatchLoopTypes.TextIsland) != 0) |
1444 |
retVal = retVal + " | kTextIsland"; |
1445 |
|
1446 |
if ((loopType & HatchLoopTypes.Duplicate) != 0) |
1447 |
retVal = retVal + " | kDuplicate"; |
1448 |
|
1449 |
return retVal == "" ? "kDefault" : retVal.Substring(3); |
1450 |
} |
1451 |
|
1452 |
void dump(Hatch pHatch, int indent) |
1453 |
{ |
1454 |
writeLine(indent++, pHatch.GetRXClass().Name, pHatch.Handle); |
1455 |
writeLine(indent, "Hatch Style", pHatch.HatchStyle); |
1456 |
writeLine(indent, "Hatch Object Type", pHatch.HatchObjectType); |
1457 |
writeLine(indent, "Is Hatch", pHatch.IsHatch); |
1458 |
writeLine(indent, "Is Gradient", !pHatch.IsGradient); |
1459 |
if (pHatch.IsHatch) |
1460 |
{ |
1461 |
/******************************************************************/ |
1462 |
/* Dump Hatch Parameters */ |
1463 |
/******************************************************************/ |
1464 |
writeLine(indent, "Pattern Type", pHatch.PatternType); |
1465 |
switch (pHatch.PatternType) |
1466 |
{ |
1467 |
case HatchPatternType.PreDefined: |
1468 |
case HatchPatternType.CustomDefined: |
1469 |
writeLine(indent, "Pattern Name", pHatch.PatternName); |
1470 |
writeLine(indent, "Solid Fill", pHatch.IsSolidFill); |
1471 |
if (!pHatch.IsSolidFill) |
1472 |
{ |
1473 |
writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle)); |
1474 |
writeLine(indent, "Pattern Scale", pHatch.PatternScale); |
1475 |
} |
1476 |
break; |
1477 |
case HatchPatternType.UserDefined: |
1478 |
writeLine(indent, "Pattern Angle", toDegreeString(pHatch.PatternAngle)); |
1479 |
writeLine(indent, "Pattern Double", pHatch.PatternDouble); |
1480 |
writeLine(indent, "Pattern Space", pHatch.PatternSpace); |
1481 |
break; |
1482 |
} |
1483 |
DBObjectCollection entitySet = new DBObjectCollection(); |
1484 |
Handle hhh = pHatch.Handle; |
1485 |
if (hhh.Value == 1692) //69C) |
1486 |
{ |
1487 |
pHatch.Explode(entitySet); |
1488 |
return; |
1489 |
} |
1490 |
if (hhh.Value == 1693) //69D) |
1491 |
{ |
1492 |
try |
1493 |
{ |
1494 |
pHatch.Explode(entitySet); |
1495 |
} |
1496 |
catch (System.Exception e) |
1497 |
{ |
1498 |
if (e.Message == "eCannotExplodeEntity") |
1499 |
{ |
1500 |
writeLine(indent, "Hatch " + e.Message + ": ", pHatch.Handle); |
1501 |
return; |
1502 |
} |
1503 |
} |
1504 |
} |
1505 |
} |
1506 |
if (pHatch.IsGradient) |
1507 |
{ |
1508 |
/******************************************************************/ |
1509 |
/* Dump Gradient Parameters */ |
1510 |
/******************************************************************/ |
1511 |
writeLine(indent, "Gradient Type", pHatch.GradientType); |
1512 |
writeLine(indent, "Gradient Name", pHatch.GradientName); |
1513 |
writeLine(indent, "Gradient Angle", toDegreeString(pHatch.GradientAngle)); |
1514 |
writeLine(indent, "Gradient Shift", pHatch.GradientShift); |
1515 |
writeLine(indent, "Gradient One-Color Mode", pHatch.GradientOneColorMode); |
1516 |
if (pHatch.GradientOneColorMode) |
1517 |
{ |
1518 |
writeLine(indent, "ShadeTintValue", pHatch.ShadeTintValue); |
1519 |
} |
1520 |
GradientColor[] colors = pHatch.GetGradientColors(); |
1521 |
for (int i = 0; i < colors.Length; i++) |
1522 |
{ |
1523 |
writeLine(indent, string.Format("Color {0}", i), colors[i].get_Color()); |
1524 |
writeLine(indent, string.Format("Interpolation {0}", i), colors[i].get_Value()); |
1525 |
} |
1526 |
} |
1527 |
|
1528 |
/********************************************************************/ |
1529 |
/* Dump Associated Objects */ |
1530 |
/********************************************************************/ |
1531 |
writeLine(indent, "Associated objects", pHatch.Associative); |
1532 |
foreach (ObjectId id in pHatch.GetAssociatedObjectIds()) |
1533 |
{ |
1534 |
writeLine(indent + 1, id.ObjectClass.Name, id.Handle); |
1535 |
} |
1536 |
|
1537 |
/********************************************************************/ |
1538 |
/* Dump Loops */ |
1539 |
/********************************************************************/ |
1540 |
writeLine(indent, "Loops", pHatch.NumberOfLoops); |
1541 |
for (int i = 0; i < pHatch.NumberOfLoops; i++) |
1542 |
{ |
1543 |
writeLine(indent + 1, "Loop " + i.ToString(), toLooptypeString(pHatch.LoopTypeAt(i))); |
1544 |
|
1545 |
/******************************************************************/ |
1546 |
/* Dump Loop */ |
1547 |
/******************************************************************/ |
1548 |
if ((pHatch.LoopTypeAt(i) & HatchLoopTypes.Polyline) != 0) |
1549 |
{ |
1550 |
dumpPolylineType(i, pHatch, indent + 2); |
1551 |
} |
1552 |
else |
1553 |
{ |
1554 |
dumpEdgesType(i, pHatch, indent + 2); |
1555 |
} |
1556 |
/******************************************************************/ |
1557 |
/* Dump Associated Objects */ |
1558 |
/******************************************************************/ |
1559 |
if (pHatch.Associative) |
1560 |
{ |
1561 |
writeLine(indent + 2, "Associated objects"); |
1562 |
foreach (ObjectId id in pHatch.GetAssociatedObjectIdsAt(i)) |
1563 |
{ |
1564 |
writeLine(indent + 3, id.ObjectClass.Name, id.Handle); |
1565 |
} |
1566 |
} |
1567 |
} |
1568 |
|
1569 |
writeLine(indent, "Elevation", pHatch.Elevation); |
1570 |
writeLine(indent, "Normal", pHatch.Normal); |
1571 |
dumpEntityData(pHatch, indent, Program.xml.DocumentElement); |
1572 |
} |
1573 |
|
1574 |
/************************************************************************/ |
1575 |
/* Leader Dumper */ |
1576 |
/************************************************************************/ |
1577 |
void dump(Leader pLeader, int indent) |
1578 |
{ |
1579 |
writeLine(indent++, pLeader.GetRXClass().Name, pLeader.Handle); |
1580 |
writeLine(indent, "Dimension Style", pLeader.DimensionStyleName); |
1581 |
|
1582 |
writeLine(indent, "Annotation"); |
1583 |
if (!pLeader.Annotation.IsNull) |
1584 |
{ |
1585 |
writeLine(indent++, pLeader.Annotation.ObjectClass.Name, pLeader.Annotation.Handle); |
1586 |
} |
1587 |
writeLine(indent + 1, "Type", pLeader.AnnoType); |
1588 |
writeLine(indent + 1, "Height", pLeader.AnnoHeight); |
1589 |
writeLine(indent + 1, "Width", pLeader.AnnoWidth); |
1590 |
writeLine(indent + 1, "Offset", pLeader.AnnotationOffset); |
1591 |
writeLine(indent, "Has Arrowhead", pLeader.HasArrowHead); |
1592 |
writeLine(indent, "Has Hook Line", pLeader.HasHookLine); |
1593 |
writeLine(indent, "Splined", pLeader.IsSplined); |
1594 |
|
1595 |
for (int i = 0; i < pLeader.NumVertices; i++) |
1596 |
{ |
1597 |
writeLine(indent, string.Format("Vertex {0}", i), pLeader.VertexAt(i)); |
1598 |
} |
1599 |
writeLine(indent, "Normal", pLeader.Normal); |
1600 |
dumpCurveData(pLeader, indent, Program.xml.DocumentElement); |
1601 |
} |
1602 |
|
1603 |
/************************************************************************/ |
1604 |
/* Line Dumper */ |
1605 |
/************************************************************************/ |
1606 |
void dump(Line pLine, int indent, XmlNode node) |
1607 |
{ |
1608 |
if (node != null && pLine != null && pLine.Length != 0) |
1609 |
{ |
1610 |
XmlNode LineNode = Program.xml.CreateElement(pLine.GetRXClass().Name); |
1611 |
XmlAttribute LengthAttr = Program.xml.CreateAttribute("Length"); |
1612 |
LengthAttr.Value = pLine.Length.ToString(); |
1613 |
LineNode.Attributes.SetNamedItem(LengthAttr); |
1614 |
|
1615 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1616 |
HandleAttr.Value = pLine.Handle.ToString(); |
1617 |
LineNode.Attributes.SetNamedItem(HandleAttr); |
1618 |
|
1619 |
XmlNode StartPointNode = Program.xml.CreateElement("Vertex"); |
1620 |
{ |
1621 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
1622 |
XAttr.Value = pLine.StartPoint.X.ToString(); |
1623 |
StartPointNode.Attributes.SetNamedItem(XAttr); |
1624 |
|
1625 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
1626 |
YAttr.Value = pLine.StartPoint.Y.ToString(); |
1627 |
StartPointNode.Attributes.SetNamedItem(YAttr); |
1628 |
|
1629 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
1630 |
ZAttr.Value = pLine.StartPoint.Z.ToString(); |
1631 |
StartPointNode.Attributes.SetNamedItem(ZAttr); |
1632 |
} |
1633 |
LineNode.AppendChild(StartPointNode); |
1634 |
|
1635 |
XmlNode EndPointNode = Program.xml.CreateElement("Vertex"); |
1636 |
{ |
1637 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
1638 |
XAttr.Value = pLine.EndPoint.X.ToString(); |
1639 |
EndPointNode.Attributes.SetNamedItem(XAttr); |
1640 |
|
1641 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
1642 |
YAttr.Value = pLine.EndPoint.Y.ToString(); |
1643 |
EndPointNode.Attributes.SetNamedItem(YAttr); |
1644 |
|
1645 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
1646 |
ZAttr.Value = pLine.EndPoint.Z.ToString(); |
1647 |
EndPointNode.Attributes.SetNamedItem(ZAttr); |
1648 |
} |
1649 |
LineNode.AppendChild(EndPointNode); |
1650 |
|
1651 |
XmlAttribute NormalAttr = Program.xml.CreateAttribute("Normal"); |
1652 |
NormalAttr.Value = pLine.Normal.ToString(); |
1653 |
LineNode.Attributes.SetNamedItem(NormalAttr); |
1654 |
|
1655 |
XmlAttribute ThicknessAttr = Program.xml.CreateAttribute("Thickness"); |
1656 |
ThicknessAttr.Value = pLine.Thickness.ToString(); |
1657 |
LineNode.Attributes.SetNamedItem(ThicknessAttr); |
1658 |
|
1659 |
dumpEntityData(pLine, indent, LineNode); |
1660 |
|
1661 |
node.AppendChild(LineNode); |
1662 |
} |
1663 |
else |
1664 |
{ |
1665 |
int d = 0; |
1666 |
} |
1667 |
} |
1668 |
|
1669 |
/************************************************************************/ |
1670 |
/* MInsertBlock Dumper */ |
1671 |
/************************************************************************/ |
1672 |
void dump(MInsertBlock pMInsert, int indent, XmlNode node) |
1673 |
{ |
1674 |
writeLine(indent++, pMInsert.GetRXClass().Name, pMInsert.Handle); |
1675 |
|
1676 |
using (BlockTableRecord pRecord = (BlockTableRecord)pMInsert.BlockTableRecord.Open(OpenMode.ForRead)) |
1677 |
{ |
1678 |
writeLine(indent, "Name", pRecord.Name); |
1679 |
writeLine(indent, "Rows", pMInsert.Rows); |
1680 |
writeLine(indent, "Columns", pMInsert.Columns); |
1681 |
writeLine(indent, "Row Spacing", pMInsert.RowSpacing); |
1682 |
writeLine(indent, "Column Spacing", pMInsert.ColumnSpacing); |
1683 |
dumpBlockRefData(pMInsert, indent, node); |
1684 |
} |
1685 |
} |
1686 |
|
1687 |
/************************************************************************/ |
1688 |
/* Mline Dumper */ |
1689 |
/************************************************************************/ |
1690 |
void dump(Mline pMline, int indent) |
1691 |
{ |
1692 |
writeLine(indent++, pMline.GetRXClass().Name, pMline.Handle); |
1693 |
writeLine(indent, "Style", pMline.Style); |
1694 |
writeLine(indent, "Closed", pMline.IsClosed); |
1695 |
writeLine(indent, "Scale", pMline.Scale); |
1696 |
writeLine(indent, "Suppress Start Caps", pMline.SupressStartCaps); |
1697 |
writeLine(indent, "Suppress End Caps", pMline.SupressEndCaps); |
1698 |
writeLine(indent, "Normal", pMline.Normal); |
1699 |
|
1700 |
/********************************************************************/ |
1701 |
/* Dump the segment data */ |
1702 |
/********************************************************************/ |
1703 |
for (int i = 0; i < pMline.NumberOfVertices; i++) |
1704 |
{ |
1705 |
writeLine(indent, "Segment", i); |
1706 |
writeLine(indent + 1, "Vertex", pMline.VertexAt(i)); |
1707 |
} |
1708 |
dumpEntityData(pMline, indent, Program.xml.DocumentElement); |
1709 |
} |
1710 |
|
1711 |
/************************************************************************/ |
1712 |
/* MText Dumper */ |
1713 |
/************************************************************************/ |
1714 |
/// <summary> |
1715 |
/// convert MText to normal Text |
1716 |
/// </summary> |
1717 |
/// <param name="pMText"></param> |
1718 |
/// <param name="indent"></param> |
1719 |
/// <param name="node"></param> |
1720 |
void dump(MText pMText, int indent, XmlNode node) |
1721 |
{ |
1722 |
DBObjectCollection objColl = new DBObjectCollection(); |
1723 |
pMText.Explode(objColl); |
1724 |
foreach (var obj in objColl) |
1725 |
{ |
1726 |
dumpTextData(obj as DBText, indent, node); |
1727 |
} |
1728 |
} |
1729 |
|
1730 |
/************************************************************************/ |
1731 |
/* Ordinate Dimension Dumper */ |
1732 |
/************************************************************************/ |
1733 |
XmlNode dump(OrdinateDimension pDim, int indent, XmlNode node) |
1734 |
{ |
1735 |
if (node != null) |
1736 |
{ |
1737 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
1738 |
|
1739 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1740 |
HandleAttr.Value = pDim.Handle.ToString(); |
1741 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
1742 |
|
1743 |
XmlAttribute DefiningPointAttr = Program.xml.CreateAttribute("DefiningPoint"); |
1744 |
DefiningPointAttr.Value = pDim.DefiningPoint.ToString(); |
1745 |
DimNode.Attributes.SetNamedItem(DefiningPointAttr); |
1746 |
|
1747 |
XmlAttribute UsingXAxisAttr = Program.xml.CreateAttribute("UsingXAxis"); |
1748 |
UsingXAxisAttr.Value = pDim.UsingXAxis.ToString(); |
1749 |
DimNode.Attributes.SetNamedItem(UsingXAxisAttr); |
1750 |
|
1751 |
XmlAttribute UsingYAxisAttr = Program.xml.CreateAttribute("UsingYAxis"); |
1752 |
UsingYAxisAttr.Value = pDim.UsingYAxis.ToString(); |
1753 |
DimNode.Attributes.SetNamedItem(UsingYAxisAttr); |
1754 |
|
1755 |
XmlAttribute LeaderEndPointAttr = Program.xml.CreateAttribute("LeaderEndPoint"); |
1756 |
LeaderEndPointAttr.Value = pDim.LeaderEndPoint.ToString(); |
1757 |
DimNode.Attributes.SetNamedItem(LeaderEndPointAttr); |
1758 |
|
1759 |
XmlAttribute OriginAttr = Program.xml.CreateAttribute("Origin"); |
1760 |
OriginAttr.Value = pDim.Origin.ToString(); |
1761 |
DimNode.Attributes.SetNamedItem(OriginAttr); |
1762 |
|
1763 |
dumpDimData(pDim, indent, DimNode); |
1764 |
|
1765 |
return DimNode; |
1766 |
} |
1767 |
|
1768 |
return null; |
1769 |
} |
1770 |
|
1771 |
/************************************************************************/ |
1772 |
/* PolyFaceMesh Dumper */ |
1773 |
/************************************************************************/ |
1774 |
XmlNode dump(PolyFaceMesh pPoly, int indent, XmlNode node) |
1775 |
{ |
1776 |
if (node != null) |
1777 |
{ |
1778 |
XmlElement PolyNode = Program.xml.CreateElement(pPoly.GetRXClass().Name); |
1779 |
|
1780 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1781 |
HandleAttr.Value = pPoly.Handle.ToString(); |
1782 |
PolyNode.Attributes.SetNamedItem(HandleAttr); |
1783 |
|
1784 |
XmlAttribute NumVerticesAttr = Program.xml.CreateAttribute("NumVertices"); |
1785 |
NumVerticesAttr.Value = pPoly.NumVertices.ToString(); |
1786 |
PolyNode.Attributes.SetNamedItem(NumVerticesAttr); |
1787 |
|
1788 |
XmlAttribute NumFacesAttr = Program.xml.CreateAttribute("NumFaces"); |
1789 |
NumFacesAttr.Value = pPoly.NumFaces.ToString(); |
1790 |
PolyNode.Attributes.SetNamedItem(NumFacesAttr); |
1791 |
|
1792 |
/********************************************************************/ |
1793 |
/* dump vertices and faces */ |
1794 |
/********************************************************************/ |
1795 |
int vertexCount = 0; |
1796 |
int faceCount = 0; |
1797 |
foreach (ObjectId objId in pPoly) |
1798 |
{ |
1799 |
using (Entity ent = (Entity)objId.GetObject(OpenMode.ForRead)) |
1800 |
{ |
1801 |
if (ent is PolyFaceMeshVertex) |
1802 |
{ |
1803 |
PolyFaceMeshVertex pVertex = (PolyFaceMeshVertex)ent; |
1804 |
|
1805 |
XmlElement VertexNode = Program.xml.CreateElement(pVertex.GetRXClass().Name); |
1806 |
|
1807 |
XmlAttribute _HandleAttr = Program.xml.CreateAttribute("Handle"); |
1808 |
_HandleAttr.Value = pVertex.Handle.ToString(); |
1809 |
VertexNode.Attributes.SetNamedItem(_HandleAttr); |
1810 |
|
1811 |
XmlAttribute PositionAttr = Program.xml.CreateAttribute("Position"); |
1812 |
PositionAttr.Value = pVertex.Position.ToString(); |
1813 |
VertexNode.Attributes.SetNamedItem(PositionAttr); |
1814 |
|
1815 |
dumpEntityData(pVertex, indent + 1, VertexNode); |
1816 |
|
1817 |
PolyNode.AppendChild(VertexNode); |
1818 |
} |
1819 |
else if (ent is FaceRecord) |
1820 |
{ |
1821 |
FaceRecord pFace = (FaceRecord)ent; |
1822 |
string face = "{"; |
1823 |
for (short i = 0; i < 4; i++) |
1824 |
{ |
1825 |
if (i > 0) |
1826 |
{ |
1827 |
face = face + " "; |
1828 |
} |
1829 |
face = face + pFace.GetVertexAt(i).ToString(); |
1830 |
} |
1831 |
|
1832 |
face += "}"; |
1833 |
|
1834 |
XmlElement FaceNode = Program.xml.CreateElement(pFace.GetRXClass().Name); |
1835 |
|
1836 |
XmlAttribute _HandleAttr = Program.xml.CreateAttribute("Handle"); |
1837 |
_HandleAttr.Value = pFace.Handle.ToString(); |
1838 |
FaceNode.Attributes.SetNamedItem(_HandleAttr); |
1839 |
FaceNode.InnerText = face; |
1840 |
|
1841 |
dumpEntityData(pFace, indent + 1, FaceNode); |
1842 |
|
1843 |
PolyNode.AppendChild(FaceNode); |
1844 |
} |
1845 |
else |
1846 |
{ // Unknown entity type |
1847 |
writeLine(indent, "Unexpected Entity"); |
1848 |
} |
1849 |
} |
1850 |
} |
1851 |
dumpEntityData(pPoly, indent, PolyNode); |
1852 |
|
1853 |
return PolyNode; |
1854 |
} |
1855 |
|
1856 |
return null; |
1857 |
} |
1858 |
|
1859 |
/************************************************************************/ |
1860 |
/* Ole2Frame */ |
1861 |
/************************************************************************/ |
1862 |
void dump(Ole2Frame pOle, int indent) |
1863 |
{ |
1864 |
writeLine(indent++, pOle.GetRXClass().Name, pOle.Handle); |
1865 |
|
1866 |
Rectangle3d pos = (Rectangle3d)pOle.Position3d; |
1867 |
writeLine(indent, "Lower Left", pos.LowerLeft); |
1868 |
writeLine(indent, "Lower Right", pos.LowerRight); |
1869 |
writeLine(indent, "Upper Left", pos.UpperLeft); |
1870 |
writeLine(indent, "Upper Right", pos.UpperRight); |
1871 |
writeLine(indent, "Type", pOle.Type); |
1872 |
writeLine(indent, "User Type", pOle.UserType); |
1873 |
if (pOle.Type == Ole2Frame.ItemType.Link) |
1874 |
{ |
1875 |
writeLine(indent, "Link Name", pOle.LinkName); |
1876 |
writeLine(indent, "Link Path", pOle.LinkPath); |
1877 |
} |
1878 |
writeLine(indent, "Output Quality", pOle.OutputQuality); |
1879 |
dumpEntityData(pOle, indent, Program.xml.DocumentElement); |
1880 |
} |
1881 |
|
1882 |
/************************************************************************/ |
1883 |
/* Point Dumper */ |
1884 |
/************************************************************************/ |
1885 |
void dump(DBPoint pPoint, int indent) |
1886 |
{ |
1887 |
writeLine(indent++, pPoint.GetRXClass().Name, pPoint.Handle); |
1888 |
writeLine(indent, "Position", pPoint.Position); |
1889 |
writeLine(indent, "ECS Rotation", toDegreeString(pPoint.EcsRotation)); |
1890 |
writeLine(indent, "Normal", pPoint.Normal); |
1891 |
writeLine(indent, "Thickness", pPoint.Thickness); |
1892 |
dumpEntityData(pPoint, indent, Program.xml.DocumentElement); |
1893 |
} |
1894 |
|
1895 |
/************************************************************************/ |
1896 |
/* Polygon Mesh Dumper */ |
1897 |
/************************************************************************/ |
1898 |
void dump(PolygonMesh pPoly, int indent) |
1899 |
{ |
1900 |
writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle); |
1901 |
writeLine(indent, "m Size", pPoly.MSize); |
1902 |
writeLine(indent, "m-Closed", pPoly.IsMClosed); |
1903 |
writeLine(indent, "m Surface Density", pPoly.MSurfaceDensity); |
1904 |
writeLine(indent, "n Size", pPoly.NSize); |
1905 |
writeLine(indent, "n-Closed", pPoly.IsNClosed); |
1906 |
writeLine(indent, "n Surface Density", pPoly.NSurfaceDensity); |
1907 |
/********************************************************************/ |
1908 |
/* dump vertices */ |
1909 |
/********************************************************************/ |
1910 |
int vertexCount = 0; |
1911 |
foreach (object o in pPoly) |
1912 |
{ |
1913 |
PolygonMeshVertex pVertex = o as PolygonMeshVertex; |
1914 |
if (pVertex != null) |
1915 |
{ |
1916 |
writeLine(indent, pVertex.GetRXClass().Name, vertexCount++); |
1917 |
writeLine(indent + 1, "Handle", pVertex.Handle); |
1918 |
writeLine(indent + 1, "Position", pVertex.Position); |
1919 |
writeLine(indent + 1, "Type", pVertex.VertexType); |
1920 |
} |
1921 |
} |
1922 |
dumpEntityData(pPoly, indent, Program.xml.DocumentElement); |
1923 |
} |
1924 |
|
1925 |
/************************************************************************/ |
1926 |
/* Polyline Dumper */ |
1927 |
/************************************************************************/ |
1928 |
void dump(Teigha.DatabaseServices.Polyline pPoly, int indent, XmlNode node) |
1929 |
{ |
1930 |
if (pPoly != null && pPoly.Length != 0) |
1931 |
{ |
1932 |
writeLine(indent++, pPoly.GetRXClass().Name, pPoly.Handle); |
1933 |
writeLine(indent, "Has Width", pPoly.HasWidth); |
1934 |
if (!pPoly.HasWidth) |
1935 |
{ |
1936 |
writeLine(indent, "Constant Width", pPoly.ConstantWidth); |
1937 |
} |
1938 |
|
1939 |
/********************************************************************/ |
1940 |
/* dump vertices */ |
1941 |
/********************************************************************/ |
1942 |
if (node != null) |
1943 |
{ |
1944 |
XmlNode PolylineNode = Program.xml.CreateElement(pPoly.GetRXClass().Name); |
1945 |
XmlAttribute LengthAttr = Program.xml.CreateAttribute("Length"); |
1946 |
LengthAttr.Value = pPoly.Length.ToString(); |
1947 |
PolylineNode.Attributes.SetNamedItem(LengthAttr); |
1948 |
|
1949 |
XmlAttribute CountAttr = Program.xml.CreateAttribute("Count"); |
1950 |
CountAttr.Value = pPoly.NumberOfVertices.ToString(); |
1951 |
PolylineNode.Attributes.SetNamedItem(CountAttr); |
1952 |
|
1953 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
1954 |
HandleAttr.Value = pPoly.Handle.ToString(); |
1955 |
PolylineNode.Attributes.SetNamedItem(HandleAttr); |
1956 |
|
1957 |
XmlAttribute ClosedAttr = Program.xml.CreateAttribute("Closed"); |
1958 |
ClosedAttr.Value = pPoly.Closed.ToString(); |
1959 |
PolylineNode.Attributes.SetNamedItem(ClosedAttr); |
1960 |
|
1961 |
for (int i = 0; i < pPoly.NumberOfVertices; i++) |
1962 |
{ |
1963 |
XmlNode VertexNode = Program.xml.CreateElement("Vertex"); |
1964 |
|
1965 |
XmlAttribute SegmentTypeAttr = Program.xml.CreateAttribute("SegmentType"); |
1966 |
SegmentTypeAttr.Value = pPoly.GetSegmentType(i).ToString(); |
1967 |
|
1968 |
Point3d pt = pPoly.GetPoint3dAt(i); |
1969 |
XmlAttribute XAttr = Program.xml.CreateAttribute("X"); |
1970 |
XAttr.Value = pt.X.ToString(); |
1971 |
VertexNode.Attributes.SetNamedItem(XAttr); |
1972 |
|
1973 |
XmlAttribute YAttr = Program.xml.CreateAttribute("Y"); |
1974 |
YAttr.Value = pt.Y.ToString(); |
1975 |
VertexNode.Attributes.SetNamedItem(YAttr); |
1976 |
|
1977 |
XmlAttribute ZAttr = Program.xml.CreateAttribute("Z"); |
1978 |
ZAttr.Value = pt.Z.ToString(); |
1979 |
VertexNode.Attributes.SetNamedItem(ZAttr); |
1980 |
|
1981 |
if (pPoly.HasWidth) |
1982 |
{ |
1983 |
XmlAttribute StartWidthAttr = Program.xml.CreateAttribute("StartWidth"); |
1984 |
StartWidthAttr.Value = pPoly.GetStartWidthAt(i).ToString(); |
1985 |
VertexNode.Attributes.SetNamedItem(StartWidthAttr); |
1986 |
|
1987 |
XmlAttribute EndWidthAttr = Program.xml.CreateAttribute("EndWidth"); |
1988 |
EndWidthAttr.Value = pPoly.GetEndWidthAt(i).ToString(); |
1989 |
VertexNode.Attributes.SetNamedItem(EndWidthAttr); |
1990 |
} |
1991 |
if (pPoly.HasBulges) |
1992 |
{ |
1993 |
XmlAttribute BulgeAttr = Program.xml.CreateAttribute("Bulge"); |
1994 |
BulgeAttr.Value = pPoly.GetBulgeAt(i).ToString(); |
1995 |
VertexNode.Attributes.SetNamedItem(BulgeAttr); |
1996 |
|
1997 |
if (pPoly.GetSegmentType(i) == SegmentType.Arc) |
1998 |
{ |
1999 |
XmlAttribute BulgeAngleAttr = Program.xml.CreateAttribute("BulgeAngle"); |
2000 |
BulgeAngleAttr.Value = pPoly.GetBulgeAt(i).ToString(); |
2001 |
VertexNode.Attributes.SetNamedItem(BulgeAngleAttr); |
2002 |
} |
2003 |
} |
2004 |
|
2005 |
PolylineNode.AppendChild(VertexNode); |
2006 |
} |
2007 |
|
2008 |
dumpEntityData(pPoly, indent, PolylineNode); |
2009 |
node.AppendChild(PolylineNode); |
2010 |
} |
2011 |
} |
2012 |
else |
2013 |
{ |
2014 |
int d = 0; |
2015 |
} |
2016 |
} |
2017 |
|
2018 |
class DrawContextDumper : Context |
2019 |
{ |
2020 |
Database _db; |
2021 |
public DrawContextDumper(Database db) |
2022 |
{ |
2023 |
_db = db; |
2024 |
} |
2025 |
public override Database Database |
2026 |
{ |
2027 |
get { return _db; } |
2028 |
} |
2029 |
public override bool IsBoundaryClipping |
2030 |
{ |
2031 |
get { return false; } |
2032 |
} |
2033 |
public override bool IsPlotGeneration |
2034 |
{ |
2035 |
get { return false; } |
2036 |
} |
2037 |
public override bool IsPostScriptOut |
2038 |
{ |
2039 |
get { return false; } |
2040 |
} |
2041 |
} |
2042 |
class SubEntityTraitsDumper : SubEntityTraits |
2043 |
{ |
2044 |
short _color; |
2045 |
int _drawFlags; |
2046 |
FillType _ft; |
2047 |
ObjectId _layer; |
2048 |
ObjectId _linetype; |
2049 |
LineWeight _lineWeight; |
2050 |
Mapper _mapper; |
2051 |
double _lineTypeScale; |
2052 |
ObjectId _material; |
2053 |
PlotStyleDescriptor _plotStyleDescriptor; |
2054 |
bool _sectionable; |
2055 |
bool _selectionOnlyGeometry; |
2056 |
ShadowFlags _shadowFlags; |
2057 |
double _thickness; |
2058 |
EntityColor _trueColor; |
2059 |
Transparency _transparency; |
2060 |
ObjectId _visualStyle; |
2061 |
public SubEntityTraitsDumper(Database db) |
2062 |
{ |
2063 |
_drawFlags = 0; // kNoDrawFlags |
2064 |
_color = 0; |
2065 |
_ft = FillType.FillAlways; |
2066 |
_layer = db.Clayer; |
2067 |
_linetype = db.Celtype; |
2068 |
_lineWeight = db.Celweight; |
2069 |
_lineTypeScale = db.Celtscale; |
2070 |
_material = db.Cmaterial; |
2071 |
_shadowFlags = ShadowFlags.ShadowsIgnore; |
2072 |
_thickness = 0; |
2073 |
_trueColor = new EntityColor(ColorMethod.None); |
2074 |
_transparency = new Transparency(); |
2075 |
} |
2076 |
|
2077 |
protected override void SetLayerFlags(LayerFlags flags) |
2078 |
{ |
2079 |
writeLine(0, string.Format("SubEntityTraitsDumper.SetLayerFlags(flags = {0})", flags)); |
2080 |
} |
2081 |
public override void AddLight(ObjectId lightId) |
2082 |
{ |
2083 |
writeLine(0, string.Format("SubEntityTraitsDumper.AddLight(lightId = {0})", lightId.ToString())); |
2084 |
} |
2085 |
public override void SetupForEntity(Entity entity) |
2086 |
{ |
2087 |
writeLine(0, string.Format("SubEntityTraitsDumper.SetupForEntity(entity = {0})", entity.ToString())); |
2088 |
} |
2089 |
|
2090 |
public override short Color |
2091 |
{ |
2092 |
get { return _color; } |
2093 |
set { _color = value; } |
2094 |
} |
2095 |
public override int DrawFlags |
2096 |
{ |
2097 |
get { return _drawFlags; } |
2098 |
set { _drawFlags = value; } |
2099 |
} |
2100 |
public override FillType FillType |
2101 |
{ |
2102 |
get { return _ft; } |
2103 |
set { _ft = value; } |
2104 |
} |
2105 |
public override ObjectId Layer |
2106 |
{ |
2107 |
get { return _layer; } |
2108 |
set { _layer = value; } |
2109 |
} |
2110 |
public override ObjectId LineType |
2111 |
{ |
2112 |
get { return _linetype; } |
2113 |
set { _linetype = value; } |
2114 |
} |
2115 |
public override double LineTypeScale |
2116 |
{ |
2117 |
get { return _lineTypeScale; } |
2118 |
set { _lineTypeScale = value; } |
2119 |
} |
2120 |
public override LineWeight LineWeight |
2121 |
{ |
2122 |
get { return _lineWeight; } |
2123 |
set { _lineWeight = value; } |
2124 |
} |
2125 |
public override Mapper Mapper |
2126 |
{ |
2127 |
get { return _mapper; } |
2128 |
set { _mapper = value; } |
2129 |
} |
2130 |
public override ObjectId Material |
2131 |
{ |
2132 |
get { return _material; } |
2133 |
set { _material = value; } |
2134 |
} |
2135 |
public override PlotStyleDescriptor PlotStyleDescriptor |
2136 |
{ |
2137 |
get { return _plotStyleDescriptor; } |
2138 |
set { _plotStyleDescriptor = value; } |
2139 |
} |
2140 |
public override bool Sectionable |
2141 |
{ |
2142 |
get { return _sectionable; } |
2143 |
set { _sectionable = value; } |
2144 |
} |
2145 |
public override bool SelectionOnlyGeometry |
2146 |
{ |
2147 |
get { return _selectionOnlyGeometry; } |
2148 |
set { _selectionOnlyGeometry = value; } |
2149 |
} |
2150 |
public override ShadowFlags ShadowFlags |
2151 |
{ |
2152 |
get { return _shadowFlags; } |
2153 |
set { _shadowFlags = value; } |
2154 |
} |
2155 |
public override double Thickness |
2156 |
{ |
2157 |
get { return _thickness; } |
2158 |
set { _thickness = value; } |
2159 |
} |
2160 |
public override EntityColor TrueColor |
2161 |
{ |
2162 |
get { return _trueColor; } |
2163 |
set { _trueColor = value; } |
2164 |
} |
2165 |
public override Transparency Transparency |
2166 |
{ |
2167 |
get { return _transparency; } |
2168 |
set { _transparency = value; } |
2169 |
} |
2170 |
public override ObjectId VisualStyle |
2171 |
{ |
2172 |
get { return _visualStyle; } |
2173 |
set { _visualStyle = value; } |
2174 |
} |
2175 |
public override void SetSelectionMarker(IntPtr sm) |
2176 |
{ |
2177 |
} |
2178 |
} |
2179 |
class WorldGeometryDumper : WorldGeometry |
2180 |
{ |
2181 |
Stack<Matrix3d> modelMatrix; |
2182 |
Stack<ClipBoundary> clips; |
2183 |
int indent; |
2184 |
public WorldGeometryDumper(int indent) |
2185 |
: base() |
2186 |
{ |
2187 |
this.indent = indent; |
2188 |
modelMatrix = new Stack<Matrix3d>(); |
2189 |
clips = new Stack<ClipBoundary>(); |
2190 |
modelMatrix.Push(Matrix3d.Identity); |
2191 |
} |
2192 |
public override Matrix3d ModelToWorldTransform |
2193 |
{ |
2194 |
get { return modelMatrix.Peek(); } |
2195 |
} |
2196 |
public override Matrix3d WorldToModelTransform |
2197 |
{ |
2198 |
get { return modelMatrix.Peek().Inverse(); } |
2199 |
} |
2200 |
|
2201 |
public override Matrix3d PushOrientationTransform(OrientationBehavior behavior) |
2202 |
{ |
2203 |
writeLine(indent, string.Format("WorldGeometry.PushOrientationTransform(behavior = {0})", behavior)); |
2204 |
return new Matrix3d(); |
2205 |
} |
2206 |
public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point2d offset) |
2207 |
{ |
2208 |
writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset)); |
2209 |
return new Matrix3d(); |
2210 |
} |
2211 |
public override Matrix3d PushPositionTransform(PositionBehavior behavior, Point3d offset) |
2212 |
{ |
2213 |
writeLine(indent, string.Format("WorldGeometry.PushPositionTransform(behavior = {0}, offset = {1})", behavior, offset)); |
2214 |
return new Matrix3d(); |
2215 |
} |
2216 |
public override bool OwnerDraw(GdiDrawObject gdiDrawObject, Point3d position, Vector3d u, Vector3d v) |
2217 |
{ |
2218 |
writeLine(indent, string.Format("WorldGeometry.OwnerDraw(gdiDrawObject = {0}, position = {1}, u = {2}, v = {3})", gdiDrawObject, position, u, v)); |
2219 |
return false; |
2220 |
} |
2221 |
public override bool Polyline(Teigha.GraphicsInterface.Polyline polylineObj) |
2222 |
{ |
2223 |
writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}", polylineObj)); |
2224 |
return false; |
2225 |
} |
2226 |
public override bool Polypoint(Point3dCollection points, Vector3dCollection normals, IntPtrCollection subentityMarkers) |
2227 |
{ |
2228 |
writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, normals = {1}, subentityMarkers = {2}", points, normals, subentityMarkers)); |
2229 |
return false; |
2230 |
} |
2231 |
public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, Vector3dCollection normals, IntPtrCollection subentityMarkers) |
2232 |
{ |
2233 |
writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, normals = {2}, subentityMarkers = {3}", points, colors, normals, subentityMarkers)); |
2234 |
return false; |
2235 |
} |
2236 |
public override bool Polypoint(Point3dCollection points, EntityColorCollection colors, TransparencyCollection transparency, Vector3dCollection normals, IntPtrCollection subentityMarkers, int pointSize) |
2237 |
{ |
2238 |
writeLine(indent, string.Format("WorldGeometry.Polypoint(points = {0}, colors = {1}, transparency = {2}, normals = {3}, subentityMarkers = {4}, pointSize = {5}", points, colors, transparency, normals, subentityMarkers, pointSize)); |
2239 |
return false; |
2240 |
} |
2241 |
public override bool PolyPolyline(Teigha.GraphicsInterface.PolylineCollection polylineCollection) |
2242 |
{ |
2243 |
writeLine(indent, string.Format("WorldGeometry.PolyPolyline(polylineCollection = {0}", polylineCollection)); |
2244 |
return false; |
2245 |
} |
2246 |
public override bool PolyPolygon(UInt32Collection numPolygonPositions, Point3dCollection polygonPositions, UInt32Collection numPolygonPoints, Point3dCollection polygonPoints, EntityColorCollection outlineColors, LinetypeCollection outlineTypes, EntityColorCollection fillColors, Teigha.Colors.TransparencyCollection fillOpacities) |
2247 |
{ |
2248 |
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)); |
2249 |
return false; |
2250 |
} |
2251 |
public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point2d extents) |
2252 |
{ |
2253 |
writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents)); |
2254 |
return new Matrix3d(); |
2255 |
} |
2256 |
public override Matrix3d PushScaleTransform(ScaleBehavior behavior, Point3d extents) |
2257 |
{ |
2258 |
writeLine(indent, string.Format("WorldGeometry.PushScaleTransform(behavior = {0}, extents = {1})", behavior, extents)); |
2259 |
return new Matrix3d(); |
2260 |
} |
2261 |
public override bool EllipticalArc(Point3d center, Vector3d normal, double majorAxisLength, double minorAxisLength, double startDegreeInRads, double endDegreeInRads, double tiltDegreeInRads, ArcType arType) |
2262 |
{ |
2263 |
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)); |
2264 |
return false; |
2265 |
} |
2266 |
public override bool Circle(Point3d center, double radius, Vector3d normal) |
2267 |
{ |
2268 |
writeLine(indent, string.Format("WorldGeometry.Circle(center = {0}, radius = {1}, normal = {2})", center, radius, normal)); |
2269 |
return false; |
2270 |
} |
2271 |
public override bool Circle(Point3d firstPoint, Point3d secondPoint, Point3d thirdPoint) |
2272 |
{ |
2273 |
writeLine(indent, string.Format("WorldGeometry.Circle(firstPoint = {0}, secondPoint = {1}, thirdPoint = {2})", firstPoint, secondPoint, thirdPoint)); |
2274 |
return false; |
2275 |
} |
2276 |
public override bool CircularArc(Point3d start, Point3d point, Point3d endingPoint, ArcType arcType) |
2277 |
{ |
2278 |
writeLine(indent, string.Format("WorldGeometry.CircularArc(start = {0}, point = {1}, endingPoint = {2}, arcType = {3})", start, point, endingPoint, arcType)); |
2279 |
return false; |
2280 |
} |
2281 |
public override bool CircularArc(Point3d center, double radius, Vector3d normal, Vector3d startVector, double sweepAngle, ArcType arcType) |
2282 |
{ |
2283 |
writeLine(indent, string.Format("WorldGeometry.CircularArc(center = {0}, radius = {1}, normal = {2}, startVector = {3}, sweepAngle = {4}, arcType = {5}", center, radius, normal, startVector, sweepAngle, arcType)); |
2284 |
return false; |
2285 |
} |
2286 |
public override bool Draw(Drawable value) |
2287 |
{ |
2288 |
writeLine(indent, string.Format("WorldGeometry.Draw(value = {0}", value)); |
2289 |
return false; |
2290 |
} |
2291 |
public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v) |
2292 |
{ |
2293 |
writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}", position, u, v)); |
2294 |
return false; |
2295 |
} |
2296 |
public override bool Image(ImageBGRA32 imageSource, Point3d position, Vector3d u, Vector3d v, TransparencyMode transparencyMode) |
2297 |
{ |
2298 |
writeLine(indent, string.Format("WorldGeometry.Image(imageSource = , position = {1}, Vector3d = {2}, Vector3d = {3}, transparencyMode = {4}", position, u, v, transparencyMode)); |
2299 |
return false; |
2300 |
} |
2301 |
public override bool Mesh(int rows, int columns, Point3dCollection points, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals) |
2302 |
{ |
2303 |
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)); |
2304 |
return false; |
2305 |
} |
2306 |
public override bool Polygon(Point3dCollection points) |
2307 |
{ |
2308 |
writeLine(indent, string.Format("WorldGeometry.Polygon(points = {0})", points)); |
2309 |
return false; |
2310 |
} |
2311 |
public override bool Polyline(Teigha.DatabaseServices.Polyline value, int fromIndex, int segments) |
2312 |
{ |
2313 |
writeLine(indent, string.Format("WorldGeometry.Polyline(value = {0}, fromIndex = {1}, segments = {2})", value, fromIndex, segments)); |
2314 |
return false; |
2315 |
} |
2316 |
public override bool Polyline(Point3dCollection points, Vector3d normal, IntPtr subEntityMarker) |
2317 |
{ |
2318 |
writeLine(indent, string.Format("WorldGeometry.Polyline(points = {0}, normal = {1}, subEntityMarker = {2})", points, normal, subEntityMarker)); |
2319 |
return false; |
2320 |
} |
2321 |
public override void PopClipBoundary() |
2322 |
{ |
2323 |
writeLine(indent, string.Format("WorldGeometry.PopClipBoundary")); |
2324 |
clips.Pop(); |
2325 |
} |
2326 |
public override bool PopModelTransform() |
2327 |
{ |
2328 |
return true; |
2329 |
} |
2330 |
public override bool PushClipBoundary(ClipBoundary boundary) |
2331 |
{ |
2332 |
writeLine(indent, string.Format("WorldGeometry.PushClipBoundary")); |
2333 |
clips.Push(boundary); |
2334 |
return true; |
2335 |
} |
2336 |
public override bool PushModelTransform(Matrix3d matrix) |
2337 |
{ |
2338 |
writeLine(indent, "WorldGeometry.PushModelTransform(Matrix3d)"); |
2339 |
Matrix3d m = modelMatrix.Peek(); |
2340 |
modelMatrix.Push(m * matrix); |
2341 |
return true; |
2342 |
} |
2343 |
public override bool PushModelTransform(Vector3d normal) |
2344 |
{ |
2345 |
writeLine(indent, "WorldGeometry.PushModelTransform(Vector3d)"); |
2346 |
PushModelTransform(Matrix3d.PlaneToWorld(normal)); |
2347 |
return true; |
2348 |
} |
2349 |
public override bool RowOfDots(int count, Point3d start, Vector3d step) |
2350 |
{ |
2351 |
writeLine(indent, string.Format("ViewportGeometry.RowOfDots(count = {0}, start = {1}, step = {1})", count, start, step)); |
2352 |
return false; |
2353 |
} |
2354 |
public override bool Ray(Point3d point1, Point3d point2) |
2355 |
{ |
2356 |
writeLine(indent, string.Format("WorldGeometry.Ray(point1 = {0}, point2 = {1})", point1, point2)); |
2357 |
return false; |
2358 |
} |
2359 |
public override bool Shell(Point3dCollection points, IntegerCollection faces, EdgeData edgeData, FaceData faceData, VertexData vertexData, bool bAutoGenerateNormals) |
2360 |
{ |
2361 |
writeLine(indent, string.Format("WorldGeometry.Shell(points = {0}, faces = {1}, edgeData = {2}, faceData = {3}, vertexData = {4}, bAutoGenerateNormals = {5})", points, faces, edgeData, faceData, vertexData, bAutoGenerateNormals)); |
2362 |
return false; |
2363 |
} |
2364 |
public override bool Text(Point3d position, Vector3d normal, Vector3d direction, string message, bool raw, TextStyle textStyle) |
2365 |
{ |
2366 |
writeLine(indent, string.Format("WorldGeometry.Text(position = {0}, normal = {1}, direction = {2}, message = {3}, raw = {4}, textStyle = {5})", position, normal, direction, message, raw, textStyle)); |
2367 |
return false; |
2368 |
} |
2369 |
public override bool Text(Point3d position, Vector3d normal, Vector3d direction, double height, double width, double oblique, string message) |
2370 |
{ |
2371 |
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)); |
2372 |
return false; |
2373 |
} |
2374 |
public override bool WorldLine(Point3d startPoint, Point3d endPoint) |
2375 |
{ |
2376 |
writeLine(indent, string.Format("WorldGeometry.WorldLine(startPoint = {0}, endPoint = {1})", startPoint, endPoint)); |
2377 |
return false; |
2378 |
} |
2379 |
public override bool Xline(Point3d point1, Point3d point2) |
2380 |
{ |
2381 |
writeLine(indent, string.Format("WorldGeometry.Xline(point1 = {0}, point2 = {1})", point1, point2)); |
2382 |
return false; |
2383 |
} |
2384 |
|
2385 |
public override void SetExtents(Extents3d extents) |
2386 |
{ |
2387 |
writeLine(indent, "WorldGeometry.SetExtents({0}) ", extents); |
2388 |
} |
2389 |
public override void StartAttributesSegment() |
2390 |
{ |
2391 |
writeLine(indent, "WorldGeometry.StartAttributesSegment called"); |
2392 |
} |
2393 |
} |
2394 |
|
2395 |
class WorldDrawDumper : WorldDraw |
2396 |
{ |
2397 |
WorldGeometryDumper _geom; |
2398 |
DrawContextDumper _ctx; |
2399 |
SubEntityTraits _subents; |
2400 |
RegenType _regenType; |
2401 |
int indent; |
2402 |
public WorldDrawDumper(Database db, int indent) |
2403 |
: base() |
2404 |
{ |
2405 |
_regenType = RegenType; |
2406 |
this.indent = indent; |
2407 |
_geom = new WorldGeometryDumper(indent); |
2408 |
_ctx = new DrawContextDumper(db); |
2409 |
_subents = new SubEntityTraitsDumper(db); |
2410 |
} |
2411 |
public override double Deviation(DeviationType deviationType, Point3d pointOnCurve) |
2412 |
{ |
2413 |
return 1e-9; |
2414 |
} |
2415 |
public override WorldGeometry Geometry |
2416 |
{ |
2417 |
get |
2418 |
{ |
2419 |
return _geom; |
2420 |
} |
2421 |
} |
2422 |
public override bool IsDragging |
2423 |
{ |
2424 |
get |
2425 |
{ |
2426 |
return false; |
2427 |
} |
2428 |
} |
2429 |
public override Int32 NumberOfIsolines |
2430 |
{ |
2431 |
get |
2432 |
{ |
2433 |
return 10; |
2434 |
} |
2435 |
} |
2436 |
public override Geometry RawGeometry |
2437 |
{ |
2438 |
get |
2439 |
{ |
2440 |
return _geom; |
2441 |
} |
2442 |
} |
2443 |
public override bool RegenAbort |
2444 |
{ |
2445 |
get |
2446 |
{ |
2447 |
return false; |
2448 |
} |
2449 |
} |
2450 |
public override RegenType RegenType |
2451 |
{ |
2452 |
get |
2453 |
{ |
2454 |
writeLine(indent, "RegenType is asked"); |
2455 |
return _regenType; |
2456 |
} |
2457 |
} |
2458 |
public override SubEntityTraits SubEntityTraits |
2459 |
{ |
2460 |
get |
2461 |
{ |
2462 |
return _subents; |
2463 |
} |
2464 |
} |
2465 |
public override Context Context |
2466 |
{ |
2467 |
get |
2468 |
{ |
2469 |
return _ctx; |
2470 |
} |
2471 |
} |
2472 |
} |
2473 |
|
2474 |
/************************************************************************/ |
2475 |
/* Dump the common data and WorldDraw information for all */ |
2476 |
/* entities without explicit dumpers */ |
2477 |
/************************************************************************/ |
2478 |
XmlNode dump(Entity pEnt, int indent, XmlNode node) |
2479 |
{ |
2480 |
if (node != null) |
2481 |
{ |
2482 |
XmlElement EntNode = Program.xml.CreateElement(pEnt.GetRXClass().Name); |
2483 |
|
2484 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
2485 |
HandleAttr.Value = pEnt.Handle.ToString(); |
2486 |
EntNode.Attributes.SetNamedItem(HandleAttr); |
2487 |
|
2488 |
dumpEntityData(pEnt, indent, EntNode); |
2489 |
using (Database db = pEnt.Database) |
2490 |
{ |
2491 |
/**********************************************************************/ |
2492 |
/* Create an OdGiWorldDraw instance for the vectorization */ |
2493 |
/**********************************************************************/ |
2494 |
WorldDrawDumper wd = new WorldDrawDumper(db, indent + 1); |
2495 |
/**********************************************************************/ |
2496 |
/* Call worldDraw() */ |
2497 |
/**********************************************************************/ |
2498 |
pEnt.WorldDraw(wd); |
2499 |
} |
2500 |
|
2501 |
node.AppendChild(EntNode); |
2502 |
|
2503 |
return EntNode; |
2504 |
} |
2505 |
|
2506 |
return null; |
2507 |
} |
2508 |
|
2509 |
/************************************************************************/ |
2510 |
/* Proxy Entity Dumper */ |
2511 |
/************************************************************************/ |
2512 |
XmlNode dump(ProxyEntity pProxy, int indent, XmlNode node) |
2513 |
{ |
2514 |
if (node != null) |
2515 |
{ |
2516 |
XmlElement ProxyNode = Program.xml.CreateElement(pProxy.GetRXClass().Name); |
2517 |
|
2518 |
XmlAttribute OriginalClassNameAttr = Program.xml.CreateAttribute("OriginalClassName"); |
2519 |
OriginalClassNameAttr.Value = pProxy.OriginalClassName.ToString(); |
2520 |
ProxyNode.Attributes.SetNamedItem(OriginalClassNameAttr); |
2521 |
|
2522 |
// this will dump proxy entity graphics |
2523 |
dump((Entity)pProxy, indent, node); |
2524 |
|
2525 |
DBObjectCollection collection = new DBObjectCollection(); ; |
2526 |
try |
2527 |
{ |
2528 |
pProxy.ExplodeGeometry(collection); |
2529 |
} |
2530 |
catch (System.Exception) |
2531 |
{ |
2532 |
return null; |
2533 |
} |
2534 |
|
2535 |
foreach (Entity ent in collection) |
2536 |
{ |
2537 |
if (ent is Polyline2d) |
2538 |
{ |
2539 |
Polyline2d pline2d = (Polyline2d)ent; |
2540 |
int i = 0; |
2541 |
|
2542 |
try |
2543 |
{ |
2544 |
foreach (Entity ent1 in pline2d) |
2545 |
{ |
2546 |
if (ent1 is Vertex2d) |
2547 |
{ |
2548 |
Vertex2d vtx2d = (Vertex2d)ent1; |
2549 |
dump2dVertex(indent, vtx2d, i++, ProxyNode); |
2550 |
} |
2551 |
} |
2552 |
} |
2553 |
catch (System.Exception) |
2554 |
{ |
2555 |
return null; |
2556 |
} |
2557 |
} |
2558 |
} |
2559 |
|
2560 |
node.AppendChild(ProxyNode); |
2561 |
return ProxyNode; |
2562 |
} |
2563 |
|
2564 |
return null; |
2565 |
} |
2566 |
|
2567 |
/************************************************************************/ |
2568 |
/* Radial Dimension Dumper */ |
2569 |
/************************************************************************/ |
2570 |
XmlNode dump(RadialDimension pDim, int indent, XmlNode node) |
2571 |
{ |
2572 |
if (node != null) |
2573 |
{ |
2574 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
2575 |
|
2576 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
2577 |
HandleAttr.Value = pDim.Handle.ToString(); |
2578 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
2579 |
|
2580 |
XmlAttribute CenterAttr = Program.xml.CreateAttribute("Center"); |
2581 |
CenterAttr.Value = pDim.Center.ToString(); |
2582 |
DimNode.Attributes.SetNamedItem(CenterAttr); |
2583 |
|
2584 |
XmlAttribute ChordPointAttr = Program.xml.CreateAttribute("ChordPoint"); |
2585 |
ChordPointAttr.Value = pDim.ChordPoint.ToString(); |
2586 |
DimNode.Attributes.SetNamedItem(ChordPointAttr); |
2587 |
|
2588 |
XmlAttribute LeaderLengthAttr = Program.xml.CreateAttribute("LeaderLength"); |
2589 |
LeaderLengthAttr.Value = pDim.LeaderLength.ToString(); |
2590 |
DimNode.Attributes.SetNamedItem(LeaderLengthAttr); |
2591 |
|
2592 |
dumpDimData(pDim, indent, DimNode); |
2593 |
|
2594 |
node.AppendChild(DimNode); |
2595 |
|
2596 |
return DimNode; |
2597 |
} |
2598 |
|
2599 |
return null; |
2600 |
} |
2601 |
|
2602 |
/************************************************************************/ |
2603 |
/* Dump Raster Image Def */ |
2604 |
/************************************************************************/ |
2605 |
void dumpRasterImageDef(ObjectId id, int indent) |
2606 |
{ |
2607 |
if (!id.IsValid) |
2608 |
return; |
2609 |
using (RasterImageDef pDef = (RasterImageDef)id.Open(OpenMode.ForRead)) |
2610 |
{ |
2611 |
writeLine(indent++, pDef.GetRXClass().Name, pDef.Handle); |
2612 |
writeLine(indent, "Source Filename", shortenPath(pDef.SourceFileName)); |
2613 |
writeLine(indent, "Loaded", pDef.IsLoaded); |
2614 |
writeLine(indent, "mm per Pixel", pDef.ResolutionMMPerPixel); |
2615 |
writeLine(indent, "Loaded", pDef.IsLoaded); |
2616 |
writeLine(indent, "Resolution Units", pDef.ResolutionUnits); |
2617 |
writeLine(indent, "Size", pDef.Size); |
2618 |
} |
2619 |
} |
2620 |
/************************************************************************/ |
2621 |
/* Dump Raster Image Data */ |
2622 |
/************************************************************************/ |
2623 |
void dumpRasterImageData(RasterImage pImage, int indent) |
2624 |
{ |
2625 |
writeLine(indent, "Brightness", pImage.Brightness); |
2626 |
writeLine(indent, "Clipped", pImage.IsClipped); |
2627 |
writeLine(indent, "Contrast", pImage.Contrast); |
2628 |
writeLine(indent, "Fade", pImage.Fade); |
2629 |
writeLine(indent, "kClip", pImage.DisplayOptions & ImageDisplayOptions.Clip); |
2630 |
writeLine(indent, "kShow", pImage.DisplayOptions & ImageDisplayOptions.Show); |
2631 |
writeLine(indent, "kShowUnAligned", pImage.DisplayOptions & ImageDisplayOptions.ShowUnaligned); |
2632 |
writeLine(indent, "kTransparent", pImage.DisplayOptions & ImageDisplayOptions.Transparent); |
2633 |
writeLine(indent, "Scale", pImage.Scale); |
2634 |
|
2635 |
/********************************************************************/ |
2636 |
/* Dump clip boundary */ |
2637 |
/********************************************************************/ |
2638 |
if (pImage.IsClipped) |
2639 |
{ |
2640 |
writeLine(indent, "Clip Boundary Type", pImage.ClipBoundaryType); |
2641 |
if (pImage.ClipBoundaryType != ClipBoundaryType.Invalid) |
2642 |
{ |
2643 |
Point2dCollection pt = pImage.GetClipBoundary(); |
2644 |
for (int i = 0; i < pt.Count; i++) |
2645 |
{ |
2646 |
writeLine(indent, string.Format("Clip Point {0}", i), pt[i]); |
2647 |
} |
2648 |
} |
2649 |
} |
2650 |
|
2651 |
/********************************************************************/ |
2652 |
/* Dump frame */ |
2653 |
/********************************************************************/ |
2654 |
Point3dCollection vertices = pImage.GetVertices(); |
2655 |
for (int i = 0; i < vertices.Count; i++) |
2656 |
{ |
2657 |
writeLine(indent, "Frame Vertex " + i.ToString(), vertices[i]); |
2658 |
} |
2659 |
|
2660 |
/********************************************************************/ |
2661 |
/* Dump orientation */ |
2662 |
/********************************************************************/ |
2663 |
writeLine(indent, "Orientation"); |
2664 |
writeLine(indent + 1, "Origin", pImage.Orientation.Origin); |
2665 |
writeLine(indent + 1, "uVector", pImage.Orientation.Xaxis); |
2666 |
writeLine(indent + 1, "vVector", pImage.Orientation.Yaxis); |
2667 |
dumpRasterImageDef(pImage.ImageDefId, indent); |
2668 |
dumpEntityData(pImage, indent, Program.xml.DocumentElement); |
2669 |
} |
2670 |
|
2671 |
/************************************************************************/ |
2672 |
/* Raster Image Dumper */ |
2673 |
/************************************************************************/ |
2674 |
void dump(RasterImage pImage, int indent) |
2675 |
{ |
2676 |
writeLine(indent++, pImage.GetRXClass().Name, pImage.Handle); |
2677 |
writeLine(indent, "Image size", pImage.ImageSize(true)); |
2678 |
dumpRasterImageData(pImage, indent); |
2679 |
} |
2680 |
|
2681 |
/************************************************************************/ |
2682 |
/* Ray Dumper */ |
2683 |
/************************************************************************/ |
2684 |
void dump(Ray pRay, int indent) |
2685 |
{ |
2686 |
writeLine(indent++, pRay.GetRXClass().Name, pRay.Handle); |
2687 |
writeLine(indent, "Base Point", pRay.BasePoint); |
2688 |
writeLine(indent, "Unit Direction", pRay.UnitDir); |
2689 |
dumpCurveData(pRay, indent, Program.xml.DocumentElement); |
2690 |
} |
2691 |
|
2692 |
/************************************************************************/ |
2693 |
/* Region Dumper */ |
2694 |
/************************************************************************/ |
2695 |
void dump(Region pRegion, int indent) |
2696 |
{ |
2697 |
writeLine(indent++, pRegion.GetRXClass().Name, pRegion.Handle); |
2698 |
dumpEntityData(pRegion, indent, Program.xml.DocumentElement); |
2699 |
} |
2700 |
|
2701 |
/************************************************************************/ |
2702 |
/* Rotated Dimension Dumper */ |
2703 |
/************************************************************************/ |
2704 |
XmlNode dump(RotatedDimension pDim, int indent, XmlNode node) |
2705 |
{ |
2706 |
if (node != null) |
2707 |
{ |
2708 |
XmlElement DimNode = Program.xml.CreateElement(pDim.GetRXClass().Name); |
2709 |
|
2710 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
2711 |
HandleAttr.Value = pDim.Handle.ToString(); |
2712 |
DimNode.Attributes.SetNamedItem(HandleAttr); |
2713 |
|
2714 |
XmlAttribute DimLinePointAttr = Program.xml.CreateAttribute("DimLinePoint"); |
2715 |
DimLinePointAttr.Value = pDim.DimLinePoint.ToString(); |
2716 |
DimNode.Attributes.SetNamedItem(DimLinePointAttr); |
2717 |
|
2718 |
XmlAttribute ObliqueAttr = Program.xml.CreateAttribute("Oblique"); |
2719 |
ObliqueAttr.Value = pDim.Oblique.ToString(); |
2720 |
DimNode.Attributes.SetNamedItem(ObliqueAttr); |
2721 |
|
2722 |
XmlAttribute RotationAttr = Program.xml.CreateAttribute("Rotation"); |
2723 |
RotationAttr.Value = pDim.Rotation.ToString(); |
2724 |
DimNode.Attributes.SetNamedItem(RotationAttr); |
2725 |
|
2726 |
XmlAttribute XLine1PointAttr = Program.xml.CreateAttribute("XLine1Point"); |
2727 |
XLine1PointAttr.Value = pDim.XLine1Point.ToString(); |
2728 |
DimNode.Attributes.SetNamedItem(XLine1PointAttr); |
2729 |
|
2730 |
XmlAttribute XLine2PointAttr = Program.xml.CreateAttribute("XLine2Point"); |
2731 |
XLine2PointAttr.Value = pDim.XLine2Point.ToString(); |
2732 |
DimNode.Attributes.SetNamedItem(XLine2PointAttr); |
2733 |
|
2734 |
dumpDimData(pDim, indent, DimNode); |
2735 |
node.AppendChild(DimNode); |
2736 |
|
2737 |
return DimNode; |
2738 |
} |
2739 |
|
2740 |
return null; |
2741 |
} |
2742 |
|
2743 |
/************************************************************************/ |
2744 |
/* Shape Dumper */ |
2745 |
/************************************************************************/ |
2746 |
void dump(Shape pShape, int indent) |
2747 |
{ |
2748 |
writeLine(indent++, pShape.GetRXClass().Name, pShape.Handle); |
2749 |
|
2750 |
if (!pShape.StyleId.IsNull) |
2751 |
{ |
2752 |
using (TextStyleTableRecord pStyle = (TextStyleTableRecord)pShape.StyleId.Open(OpenMode.ForRead)) |
2753 |
writeLine(indent, "Filename", shortenPath(pStyle.FileName)); |
2754 |
} |
2755 |
|
2756 |
writeLine(indent, "Shape Number", pShape.ShapeNumber); |
2757 |
writeLine(indent, "Shape Name", pShape.Name); |
2758 |
writeLine(indent, "Position", pShape.Position); |
2759 |
writeLine(indent, "Size", pShape.Size); |
2760 |
writeLine(indent, "Rotation", toDegreeString(pShape.Rotation)); |
2761 |
writeLine(indent, "Oblique", toDegreeString(pShape.Oblique)); |
2762 |
writeLine(indent, "Normal", pShape.Normal); |
2763 |
writeLine(indent, "Thickness", pShape.Thickness); |
2764 |
dumpEntityData(pShape, indent, Program.xml.DocumentElement); |
2765 |
} |
2766 |
|
2767 |
/************************************************************************/ |
2768 |
/* Solid Dumper */ |
2769 |
/************************************************************************/ |
2770 |
// TODO: |
2771 |
/* void dump(Solid pSolid, int indent) |
2772 |
{ |
2773 |
writeLine(indent++, pSolid.GetRXClass().Name, pSolid.Handle); |
2774 |
|
2775 |
for (int i = 0; i < 4; i++) |
2776 |
{ |
2777 |
writeLine(indent, "Point " + i.ToString(), pSolid .GetPointAt(i)); |
2778 |
} |
2779 |
dumpEntityData(pSolid, indent); |
2780 |
} |
2781 |
*/ |
2782 |
/************************************************************************/ |
2783 |
/* Spline Dumper */ |
2784 |
/************************************************************************/ |
2785 |
void dump(Spline pSpline, int indent) |
2786 |
{ |
2787 |
writeLine(indent++, pSpline.GetRXClass().Name, pSpline.Handle); |
2788 |
|
2789 |
NurbsData data = pSpline.NurbsData; |
2790 |
writeLine(indent, "Degree", data.Degree); |
2791 |
writeLine(indent, "Rational", data.Rational); |
2792 |
writeLine(indent, "Periodic", data.Periodic); |
2793 |
writeLine(indent, "Control Point Tolerance", data.ControlPointTolerance); |
2794 |
writeLine(indent, "Knot Tolerance", data.KnotTolerance); |
2795 |
|
2796 |
writeLine(indent, "Number of control points", data.GetControlPoints().Count); |
2797 |
for (int i = 0; i < data.GetControlPoints().Count; i++) |
2798 |
{ |
2799 |
writeLine(indent, "Control Point " + i.ToString(), data.GetControlPoints()[i]); |
2800 |
} |
2801 |
|
2802 |
writeLine(indent, "Number of Knots", data.GetKnots().Count); |
2803 |
for (int i = 0; i < data.GetKnots().Count; i++) |
2804 |
{ |
2805 |
writeLine(indent, "Knot " + i.ToString(), data.GetKnots()[i]); |
2806 |
} |
2807 |
|
2808 |
if (data.Rational) |
2809 |
{ |
2810 |
writeLine(indent, "Number of Weights", data.GetWeights().Count); |
2811 |
for (int i = 0; i < data.GetWeights().Count; i++) |
2812 |
{ |
2813 |
writeLine(indent, "Weight " + i.ToString(), data.GetWeights()[i]); |
2814 |
} |
2815 |
} |
2816 |
dumpCurveData(pSpline, indent, Program.xml.DocumentElement); |
2817 |
} |
2818 |
/************************************************************************/ |
2819 |
/* Table Dumper */ |
2820 |
/************************************************************************/ |
2821 |
void dump(Table pTable, int indent) |
2822 |
{ |
2823 |
writeLine(indent++, pTable.GetRXClass().Name, pTable.Handle); |
2824 |
writeLine(indent, "Position", pTable.Position); |
2825 |
writeLine(indent, "X-Direction", pTable.Direction); |
2826 |
writeLine(indent, "Normal", pTable.Normal); |
2827 |
writeLine(indent, "Height", (int)pTable.Height); |
2828 |
writeLine(indent, "Width", (int)pTable.Width); |
2829 |
writeLine(indent, "Rows", (int)pTable.NumRows); |
2830 |
writeLine(indent, "Columns", (int)pTable.NumColumns); |
2831 |
|
2832 |
// TODO: |
2833 |
//TableStyle pStyle = (TableStyle)pTable.TableStyle.Open(OpenMode.ForRead); |
2834 |
//writeLine(indent, "Table Style", pStyle.Name); |
2835 |
dumpEntityData(pTable, indent, Program.xml.DocumentElement); |
2836 |
} |
2837 |
|
2838 |
/************************************************************************/ |
2839 |
/* Text Dumper */ |
2840 |
/************************************************************************/ |
2841 |
static void dump(DBText pText, int indent, XmlNode node) |
2842 |
{ |
2843 |
if (node != null) |
2844 |
{ |
2845 |
dumpTextData(pText, indent, node); |
2846 |
} |
2847 |
} |
2848 |
/************************************************************************/ |
2849 |
/* Trace Dumper */ |
2850 |
/************************************************************************/ |
2851 |
void dump(Trace pTrace, int indent) |
2852 |
{ |
2853 |
writeLine(indent++, pTrace.GetRXClass().Name, pTrace.Handle); |
2854 |
|
2855 |
for (short i = 0; i < 4; i++) |
2856 |
{ |
2857 |
writeLine(indent, "Point " + i.ToString(), pTrace.GetPointAt(i)); |
2858 |
} |
2859 |
dumpEntityData(pTrace, indent, Program.xml.DocumentElement); |
2860 |
} |
2861 |
|
2862 |
/************************************************************************/ |
2863 |
/* Trace UnderlayReference */ |
2864 |
/************************************************************************/ |
2865 |
void dump(UnderlayReference pEnt, int indent) |
2866 |
{ |
2867 |
writeLine(indent++, pEnt.GetRXClass().Name, pEnt.Handle); |
2868 |
writeLine(indent, "UnderlayReference Path ", pEnt.Path); |
2869 |
writeLine(indent, "UnderlayReference Position ", pEnt.Position); |
2870 |
} |
2871 |
|
2872 |
/************************************************************************/ |
2873 |
/* Viewport Dumper */ |
2874 |
/************************************************************************/ |
2875 |
XmlNode dump(Teigha.DatabaseServices.Viewport pVport, int indent, XmlNode node) |
2876 |
{ |
2877 |
if (node != null) |
2878 |
{ |
2879 |
XmlElement VportNode = Program.xml.CreateElement(pVport.GetRXClass().Name); |
2880 |
|
2881 |
XmlAttribute HandleAttr = Program.xml.CreateAttribute("Handle"); |
2882 |
HandleAttr.Value = pVport.Handle.ToString(); |
2883 |
VportNode.Attributes.SetNamedItem(HandleAttr); |
2884 |
|
2885 |
writeLine(indent, "Back Clip Distance", pVport.BackClipDistance); |
2886 |
writeLine(indent, "Back Clip On", pVport.BackClipOn); |
2887 |
writeLine(indent, "Center Point", pVport.CenterPoint); |
2888 |
writeLine(indent, "Circle sides", pVport.CircleSides); |
2889 |
writeLine(indent, "Custom Scale", pVport.CustomScale); |
2890 |
writeLine(indent, "Elevation", pVport.Elevation); |
2891 |
writeLine(indent, "Front Clip at Eye", pVport.FrontClipAtEyeOn); |
2892 |
writeLine(indent, "Front Clip Distance", pVport.FrontClipDistance); |
2893 |
writeLine(indent, "Front Clip On", pVport.FrontClipOn); |
2894 |
writeLine(indent, "Plot style sheet", pVport.EffectivePlotStyleSheet); |
2895 |
|
2896 |
ObjectIdCollection layerIds = pVport.GetFrozenLayers(); |
2897 |
if (layerIds.Count > 0) |
2898 |
{ |
2899 |
writeLine(indent, "Frozen Layers:"); |
2900 |
for (int i = 0; i < layerIds.Count; i++) |
2901 |
{ |
2902 |
writeLine(indent + 1, i, layerIds[i]); |
2903 |
} |
2904 |
} |
2905 |
else |
2906 |
{ |
2907 |
writeLine(indent, "Frozen Layers", "None"); |
2908 |
} |
2909 |
|
2910 |
Point3d origin = new Point3d(); |
2911 |
Vector3d xAxis = new Vector3d(); |
2912 |
Vector3d yAxis = new Vector3d(); |
2913 |
pVport.GetUcs(ref origin, ref xAxis, ref yAxis); |
2914 |
writeLine(indent, "UCS origin", origin); |
2915 |
writeLine(indent, "UCS x-Axis", xAxis); |
2916 |
writeLine(indent, "UCS y-Axis", yAxis); |
2917 |
writeLine(indent, "Grid Increment", pVport.GridIncrement); |
2918 |
writeLine(indent, "Grid On", pVport.GridOn); |
2919 |
writeLine(indent, "Height", pVport.Height); |
2920 |
writeLine(indent, "Lens Length", pVport.LensLength); |
2921 |
writeLine(indent, "Locked", pVport.Locked); |
2922 |
writeLine(indent, "Non-Rectangular Clip", pVport.NonRectClipOn); |
2923 |
|
2924 |
if (!pVport.NonRectClipEntityId.IsNull) |
2925 |
{ |
2926 |
writeLine(indent, "Non-rectangular Clipper", pVport.NonRectClipEntityId.Handle); |
2927 |
} |
2928 |
writeLine(indent, "Render Mode", pVport.RenderMode); |
2929 |
writeLine(indent, "Remove Hidden Lines", pVport.HiddenLinesRemoved); |
2930 |
writeLine(indent, "Shade Plot", pVport.ShadePlot); |
2931 |
writeLine(indent, "Snap Isometric", pVport.SnapIsometric); |
2932 |
writeLine(indent, "Snap On", pVport.SnapOn); |
2933 |
writeLine(indent, "Transparent", pVport.Transparent); |
2934 |
writeLine(indent, "UCS Follow", pVport.UcsFollowModeOn); |
2935 |
writeLine(indent, "UCS Icon at Origin", pVport.UcsIconAtOrigin); |
2936 |
|
2937 |
writeLine(indent, "UCS Orthographic", pVport.UcsOrthographic); |
2938 |
writeLine(indent, "UCS Saved with VP", pVport.UcsPerViewport); |
2939 |
|
2940 |
if (!pVport.UcsName.IsNull) |
2941 |
{ |
2942 |
using (UcsTableRecord pUCS = (UcsTableRecord)pVport.UcsName.Open(OpenMode.ForRead)) |
2943 |
writeLine(indent, "UCS Name", pUCS.Name); |
2944 |
} |
2945 |
else |
2946 |
{ |
2947 |
writeLine(indent, "UCS Name", "Null"); |
2948 |
} |
2949 |
|
2950 |
writeLine(indent, "View Center", pVport.ViewCenter); |
2951 |
writeLine(indent, "View Height", pVport.ViewHeight); |
2952 |
writeLine(indent, "View Target", pVport.ViewTarget); |
2953 |
writeLine(indent, "Width", pVport.Width); |
2954 |
dumpEntityData(pVport, indent, Program.xml.DocumentElement); |
2955 |
|
2956 |
{ |
2957 |
using (DBObjectCollection collection = new DBObjectCollection()) |
2958 |
{ |
2959 |
try |
2960 |
{ |
2961 |
pVport.ExplodeGeometry(collection); |
2962 |
|
2963 |
foreach (Entity ent in collection) |
2964 |
{ |
2965 |
if (ent is Polyline2d) |
2966 |
{ |
2967 |
Polyline2d pline2d = (Polyline2d)ent; |
2968 |
int i = 0; |
2969 |
foreach (Entity ent1 in pline2d) |
2970 |
{ |
2971 |
if (ent1 is Vertex2d) |
2972 |
{ |
2973 |
Vertex2d vtx2d = (Vertex2d)ent1; |
2974 |
dump2dVertex(indent, vtx2d, i++, VportNode); |
2975 |
} |
2976 |
} |
2977 |
} |
2978 |
} |
2979 |
} |
2980 |
catch (System.Exception) |
2981 |
{ |
2982 |
} |
2983 |
} |
2984 |
} |
2985 |
|
2986 |
node.AppendChild(VportNode); |
2987 |
return VportNode; |
2988 |
} |
2989 |
|
2990 |
return null; |
2991 |
} |
2992 |
|
2993 |
/************************************************************************/ |
2994 |
/* Wipeout Dumper */ |
2995 |
/************************************************************************/ |
2996 |
void dump(Wipeout pWipeout, int indent) |
2997 |
{ |
2998 |
writeLine(indent++, pWipeout.GetRXClass().Name, pWipeout.Handle); |
2999 |
dumpRasterImageData(pWipeout, indent); |
3000 |
} |
3001 |
|
3002 |
/************************************************************************/ |
3003 |
/* Xline Dumper */ |
3004 |
/************************************************************************/ |
3005 |
void dump(Xline pXline, int indent) |
3006 |
{ |
3007 |
writeLine(indent++, pXline.GetRXClass().Name, pXline.Handle); |
3008 |
writeLine(indent, "Base Point", pXline.BasePoint); |
3009 |
writeLine(indent, "Unit Direction", pXline.UnitDir); |
3010 |
dumpCurveData(pXline, indent, Program.xml.DocumentElement); |
3011 |
} |
3012 |
|
3013 |
public void dump(Database pDb, int indent, XmlNode node) |
3014 |
{ |
3015 |
using (BlockTableRecord btr = (BlockTableRecord)pDb.CurrentSpaceId.GetObject(OpenMode.ForRead)) |
3016 |
{ |
3017 |
using (Layout pLayout = (Layout)btr.LayoutId.GetObject(OpenMode.ForRead)) |
3018 |
{ |
3019 |
string layoutName = ""; |
3020 |
layoutName = pLayout.LayoutName; |
3021 |
|
3022 |
XmlAttribute LayoutNameAttr = Program.xml.CreateAttribute("LayoutName"); |
3023 |
LayoutNameAttr.Value = layoutName; |
3024 |
node.Attributes.SetNamedItem(LayoutNameAttr); |
3025 |
} |
3026 |
} |
3027 |
|
3028 |
dumpHeader(pDb, indent, node); |
3029 |
dumpLayers(pDb, indent, node); |
3030 |
dumpLinetypes(pDb, indent, node); |
3031 |
dumpTextStyles(pDb, indent, node); |
3032 |
dumpDimStyles(pDb, indent, node); |
3033 |
dumpRegApps(pDb, indent); |
3034 |
dumpViewports(pDb, indent, node); |
3035 |
dumpViews(pDb, indent, node); |
3036 |
dumpMLineStyles(pDb, indent); |
3037 |
dumpUCSTable(pDb, indent, node); |
3038 |
dumpObject(pDb.NamedObjectsDictionaryId, "Named Objects Dictionary", indent); |
3039 |
|
3040 |
dumpBlocks(pDb, indent, node); |
3041 |
} |
3042 |
|
3043 |
/************************************************************************/ |
3044 |
/* Export DWG to PDF */ |
3045 |
/************************************************************************/ |
3046 |
public void ExportPDF(Database pDb, string filePath) |
3047 |
{ |
3048 |
DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(filePath)); |
3049 |
string dirPath = di.Parent != null ? di.Parent.FullName : di.FullName; |
3050 |
string pdfPath = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(filePath) + ".pdf"); |
3051 |
|
3052 |
using (mPDFExportParams param = new mPDFExportParams()) |
3053 |
{ |
3054 |
param.Database = pDb; |
3055 |
|
3056 |
TransactionManager tm = pDb.TransactionManager; |
3057 |
using (Transaction ta = tm.StartTransaction()) |
3058 |
{ |
3059 |
using (FileStreamBuf fileStrem = new FileStreamBuf(pdfPath, false, FileShareMode.DenyNo, FileCreationDisposition.CreateAlways)) |
3060 |
{ |
3061 |
param.OutputStream = fileStrem; |
3062 |
|
3063 |
bool embededTTF = false; |
3064 |
bool shxTextAsGeometry = true; |
3065 |
bool ttfGeometry = true; |
3066 |
bool simpleGeomOptimization = false; |
3067 |
bool zoomToExtentsMode = true; |
3068 |
bool enableLayers = false; |
3069 |
bool includeOffLayers = false; |
3070 |
bool enablePrcMode = true; |
3071 |
bool monochrome = true; |
3072 |
bool allLayout = false; |
3073 |
double paperWidth = 841; |
3074 |
double paperHeight = 594; |
3075 |
|
3076 |
param.Flags = (embededTTF ? PDFExportFlags.EmbededTTF : 0) | |
3077 |
(shxTextAsGeometry ? PDFExportFlags.SHXTextAsGeometry : 0) | |
3078 |
(ttfGeometry ? PDFExportFlags.TTFTextAsGeometry : 0) | |
3079 |
(simpleGeomOptimization ? PDFExportFlags.SimpleGeomOptimization : 0) | |
3080 |
(zoomToExtentsMode ? PDFExportFlags.ZoomToExtentsMode : 0) | |
3081 |
(enableLayers ? PDFExportFlags.EnableLayers : 0) | |
3082 |
(includeOffLayers ? PDFExportFlags.IncludeOffLayers : 0); |
3083 |
|
3084 |
param.Title = ""; |
3085 |
param.Author = ""; |
3086 |
param.Subject = ""; |
3087 |
param.Keywords = ""; |
3088 |
param.Creator = ""; |
3089 |
param.Producer = ""; |
3090 |
param.UseHLR = !enablePrcMode; |
3091 |
param.FlateCompression = true; |
3092 |
param.ASCIIHEXEncodeStream = true; |
3093 |
param.hatchDPI = 720; |
3094 |
|
3095 |
bool bV15 = enableLayers || includeOffLayers; |
3096 |
param.Versions = bV15 ? PDFExportVersions.PDFv1_5 : PDFExportVersions.PDFv1_4; |
3097 |
|
3098 |
if (enablePrcMode) |
3099 |
{ |
3100 |
Module pModule = SystemObjects.DynamicLinker.LoadApp("OdPrcModule", false, false); |
3101 |
if (pModule != null) |
3102 |
{ |
3103 |
pModule = SystemObjects.DynamicLinker.LoadApp("OdPrcExport", false, false); |
3104 |
} |
3105 |
if (pModule != null) |
3106 |
{ |
3107 |
RXObject pObj = null; |
3108 |
bool bUsePRCSingleViewMode = true; // provide a corresponding checkbox in Export to PDF dialog similar to one in OdaMfcApp |
3109 |
if (bUsePRCSingleViewMode) |
3110 |
{ |
3111 |
pObj = SystemObjects.ClassDictionary.At("OdPrcContextForPdfExport_AllInSingleView"); |
3112 |
} |
3113 |
else |
3114 |
{ |
3115 |
pObj = SystemObjects.ClassDictionary.At("OdPrcContextForPdfExport_Default"); |
3116 |
} |
3117 |
if (pObj != null) |
3118 |
{ |
3119 |
RXClass pCls = (RXClass)pObj; |
3120 |
if (pCls != null) |
3121 |
{ |
3122 |
param.PRCContext = pCls.Create(); |
3123 |
param.PRCMode = PRCSupport.AsBrep; //(bUsePRCAsBRep == TRUE ? PRCSupport.AsBrep : PRCSupport.AsMesh); |
3124 |
} |
3125 |
else |
3126 |
{ |
3127 |
Console.WriteLine("PDF Export, PRC support - RXClass failed"); |
3128 |
} |
3129 |
} |
3130 |
else |
3131 |
{ |
3132 |
Console.WriteLine("PDF Export, PRC support - context failed"); |
3133 |
} |
3134 |
} |
3135 |
else |
3136 |
{ |
3137 |
Console.WriteLine("PRC module was not loaded", "Error"); |
3138 |
} |
3139 |
} |
3140 |
|
3141 |
PlotSettingsValidator plotSettingVal = PlotSettingsValidator.Current; |
3142 |
|
3143 |
StringCollection styleCol = plotSettingVal.GetPlotStyleSheetList(); |
3144 |
int iIndexStyle = monochrome ? styleCol.IndexOf(String.Format("monochrome.ctb")) : -1; |
3145 |
|
3146 |
StringCollection strColl = new StringCollection(); |
3147 |
if (allLayout) |
3148 |
{ |
3149 |
using (DBDictionary layouts = (DBDictionary)pDb.LayoutDictionaryId.GetObject(OpenMode.ForRead)) |
3150 |
{ |
3151 |
foreach (DBDictionaryEntry entry in layouts) |
3152 |
{ |
3153 |
if ("Model" == entry.Key) |
3154 |
strColl.Insert(0, entry.Key); |
3155 |
else |
3156 |
strColl.Add(entry.Key); |
3157 |
if (-1 != iIndexStyle) |
3158 |
{ |
3159 |
PlotSettings ps = (PlotSettings)ta.GetObject(entry.Value, OpenMode.ForWrite); |
3160 |
plotSettingVal.SetCurrentStyleSheet(ps, styleCol[iIndexStyle]); |
3161 |
} |
3162 |
} |
3163 |
} |
3164 |
} |
3165 |
else if (-1 != iIndexStyle) |
3166 |
{ |
3167 |
using (BlockTableRecord paperBTR = (BlockTableRecord)pDb.CurrentSpaceId.GetObject(OpenMode.ForRead)) |
3168 |
{ |
3169 |
using (PlotSettings pLayout = (PlotSettings)paperBTR.LayoutId.GetObject(OpenMode.ForWrite)) |
3170 |
{ |
3171 |
plotSettingVal.SetCurrentStyleSheet(pLayout, styleCol[iIndexStyle]); |
3172 |
} |
3173 |
} |
3174 |
} |
3175 |
param.Layouts = strColl; |
3176 |
|
3177 |
int nPages = Math.Max(1, strColl.Count); |
3178 |
PageParamsCollection pParCol = new PageParamsCollection(); |
3179 |
for (int i = 0; i < nPages; ++i) |
3180 |
{ |
3181 |
PageParams pp = new PageParams(); |
3182 |
pp.setParams(paperWidth, paperHeight); |
3183 |
pParCol.Add(pp); |
3184 |
} |
3185 |
param.PageParams = pParCol; |
3186 |
Export_Import.ExportPDF(param); |
3187 |
} |
3188 |
ta.Abort(); |
3189 |
} |
3190 |
} |
3191 |
} |
3192 |
|
3193 |
/************************************************************************/ |
3194 |
/* Export DWG to PNG */ |
3195 |
/************************************************************************/ |
3196 |
public void ExportPNG(Database pDb, string filePath) |
3197 |
{ |
3198 |
chageColorAllObjects(pDb); |
3199 |
|
3200 |
string gdPath = "WinOpenGL_20.5_15.txv"; |
3201 |
|
3202 |
DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(filePath)); |
3203 |
string dirPath = di.Parent != null ? di.Parent.FullName : di.FullName; |
3204 |
string bmpPath = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(filePath) + ".bmp"); |
3205 |
string pngPath = Path.Combine(dirPath, Path.GetFileNameWithoutExtension(filePath) + ".png"); |
3206 |
|
3207 |
using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule(gdPath, false, true)) |
3208 |
{ |
3209 |
if (gsModule == null) |
3210 |
{ |
3211 |
Console.WriteLine("\nCould not load graphics module {0} \nExport cancelled.", gdPath); |
3212 |
return; |
3213 |
} |
3214 |
|
3215 |
// create graphics device |
3216 |
using (Teigha.GraphicsSystem.Device dev = gsModule.CreateBitmapDevice()) |
3217 |
{ |
3218 |
// setup device properties |
3219 |
using (Dictionary props = dev.Properties) |
3220 |
{ |
3221 |
props.AtPut("BitPerPixel", new RxVariant(32)); |
3222 |
} |
3223 |
using (ContextForDbDatabase ctx = new ContextForDbDatabase(pDb)) |
3224 |
{ |
3225 |
ctx.PaletteBackground = System.Drawing.Color.White; |
3226 |
ctx.SetPlotGeneration(true); |
3227 |
|
3228 |
using (LayoutHelperDevice helperDevice = LayoutHelperDevice.SetupActiveLayoutViews(dev, ctx)) |
3229 |
{ |
3230 |
helperDevice.SetLogicalPalette(Device.LightPalette); // Drark palette |
3231 |
int width = 9600; |
3232 |
int height = 6787; |
3233 |
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height); |
3234 |
helperDevice.OnSize(rect); |
3235 |
|
3236 |
if (ctx.IsPlotGeneration) |
3237 |
helperDevice.BackgroundColor = System.Drawing.Color.White; |
3238 |
else |
3239 |
helperDevice.BackgroundColor = System.Drawing.Color.FromArgb(0, 173, 174, 173); |
3240 |
|
3241 |
helperDevice.ActiveView.ZoomExtents(pDb.Extmin, pDb.Extmax); |
3242 |
helperDevice.ActiveView.Zoom(0.99); |
3243 |
helperDevice.Update(); |
3244 |
|
3245 |
Export_Import.ExportBitmap(helperDevice, bmpPath); |
3246 |
} |
3247 |
} |
3248 |
} |
3249 |
} |
3250 |
|
3251 |
if (File.Exists(bmpPath)) |
3252 |
{ |
3253 |
if (File.Exists(pngPath)) |
3254 |
{ |
3255 |
File.Delete(pngPath); |
3256 |
} |
3257 |
|
3258 |
////bmp => grayscale bmp => png |
3259 |
//using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bmpPath)) |
3260 |
//{ |
3261 |
// System.Drawing.Bitmap newBmp = new System.Drawing.Bitmap(bmp.Width, bmp.Height); |
3262 |
// //get a graphics object from the new image |
3263 |
// using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newBmp)) |
3264 |
// { |
3265 |
// //create the grayscale ColorMatrix |
3266 |
// System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(new float[][] |
3267 |
// { |
3268 |
// new float[] { 0.299f, 0.299f, 0.299f, 0, 0 }, |
3269 |
// new float[] { 0.587f, 0.587f, 0.587f, 0, 0 }, |
3270 |
// new float[] { 0.114f, 0.114f, 0.114f, 0, 0 }, |
3271 |
// new float[] { 0, 0, 0, 1, 0 }, |
3272 |
// new float[] { 0, 0, 0, 0, 1 } |
3273 |
// }); |
3274 |
|
3275 |
// //create some image attributes |
3276 |
// using (System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes()) |
3277 |
// { |
3278 |
// //set the color matrix attribute |
3279 |
// attributes.SetColorMatrix(colorMatrix); |
3280 |
// //attributes.SetThreshold(0.8F); |
3281 |
|
3282 |
// //draw the original image on the new image |
3283 |
// //using the grayscale color matrix |
3284 |
// g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), |
3285 |
// 0, 0, bmp.Width, bmp.Height, System.Drawing.GraphicsUnit.Pixel, attributes); |
3286 |
// } |
3287 |
|
3288 |
// } |
3289 |
// newBmp.Save(pngPath, System.Drawing.Imaging.ImageFormat.Png); |
3290 |
//} |
3291 |
|
3292 |
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bmpPath)) |
3293 |
{ |
3294 |
bmp.Save(pngPath, System.Drawing.Imaging.ImageFormat.Png); |
3295 |
} |
3296 |
if (File.Exists(bmpPath)) |
3297 |
{ |
3298 |
File.Delete(bmpPath); |
3299 |
} |
3300 |
} |
3301 |
} |
3302 |
|
3303 |
/************************************************************************/ |
3304 |
/* Change the color of all objects */ |
3305 |
/************************************************************************/ |
3306 |
private void chageColorAllObjects(Database pDb) |
3307 |
{ |
3308 |
using (Transaction tr = pDb.TransactionManager.StartTransaction()) |
3309 |
{ |
3310 |
BlockTable bt = (BlockTable)tr.GetObject(pDb.BlockTableId, OpenMode.ForRead); |
3311 |
BlockTableRecord btrModelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead); |
3312 |
|
3313 |
foreach (ObjectId id in btrModelSpace) |
3314 |
{ |
3315 |
Entity ent = tr.GetObject(id, OpenMode.ForWrite, false, true) as Entity; |
3316 |
if (ent == null) continue; |
3317 |
|
3318 |
ent.ColorIndex = 7; |
3319 |
|
3320 |
if (ent is BlockReference) |
3321 |
{ |
3322 |
changeColorBlocks(tr, (BlockReference)ent); |
3323 |
} |
3324 |
} |
3325 |
|
3326 |
DBDictionary dbdic = (DBDictionary)tr.GetObject(pDb.GroupDictionaryId, OpenMode.ForRead); |
3327 |
foreach (DBDictionaryEntry entry in dbdic) |
3328 |
{ |
3329 |
Group group = tr.GetObject(entry.Value, OpenMode.ForRead) as Group; |
3330 |
if (group == null) continue; |
3331 |
|
3332 |
ObjectId[] idarrTags = group.GetAllEntityIds(); |
3333 |
if (idarrTags == null) continue; |
3334 |
|
3335 |
foreach (ObjectId id in idarrTags) |
3336 |
{ |
3337 |
Entity ent = tr.GetObject(id, OpenMode.ForWrite, false, true) as Entity; |
3338 |
if (ent == null) continue; |
3339 |
|
3340 |
ent.ColorIndex = 7; |
3341 |
} |
3342 |
} |
3343 |
|
3344 |
foreach (ObjectId btrId in bt) |
3345 |
{ |
3346 |
BlockTableRecord btr = tr.GetObject(btrId, OpenMode.ForRead) as BlockTableRecord; |
3347 |
if (btr == null) continue; |
3348 |
if (btr.Name.StartsWith("*")) continue; |
3349 |
|
3350 |
foreach (ObjectId entId in btr) |
3351 |
{ |
3352 |
Entity ent = tr.GetObject(entId, OpenMode.ForWrite, false, true) as Entity; |
3353 |
if (ent == null) continue; |
3354 |
ent.ColorIndex = 0;//ByBlock |
3355 |
} |
3356 |
} |
3357 |
|
3358 |
tr.Commit(); |
3359 |
} |
3360 |
} |
3361 |
|
3362 |
/************************************************************************/ |
3363 |
/* Change the color of blocks */ |
3364 |
/************************************************************************/ |
3365 |
private void changeColorBlocks(Transaction tr, BlockReference blkRef) |
3366 |
{ |
3367 |
if (blkRef == null) return; |
3368 |
|
3369 |
if (blkRef.AttributeCollection != null && blkRef.AttributeCollection.Count > 0) |
3370 |
{ |
3371 |
foreach (ObjectId objectId in blkRef.AttributeCollection) |
3372 |
{ |
3373 |
AttributeReference attRef = tr.GetObject(objectId, OpenMode.ForWrite, false, true) as AttributeReference; |
3374 |
attRef.ColorIndex = 7; |
3375 |
} |
3376 |
} |
3377 |
|
3378 |
BlockTableRecord btrBlock = tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord; |
3379 |
if (btrBlock == null) return; |
3380 |
|
3381 |
foreach (ObjectId oid in btrBlock) |
3382 |
{ |
3383 |
Entity ent = tr.GetObject(oid, OpenMode.ForWrite, false, true) as Entity; |
3384 |
if (ent == null) continue; |
3385 |
|
3386 |
ent.ColorIndex = 7; |
3387 |
|
3388 |
if (ent is BlockReference) |
3389 |
{ |
3390 |
changeColorBlocks(tr, (BlockReference)ent); |
3391 |
} |
3392 |
} |
3393 |
} |
3394 |
|
3395 |
/************************************************************************/ |
3396 |
/* Nested block Explode & Purge */ |
3397 |
/************************************************************************/ |
3398 |
public void ExplodeAndPurgeNestedBlocks(Database pDb) |
3399 |
{ |
3400 |
HashSet<string> blockNameList = new HashSet<string>(); |
3401 |
// Explode ModelSpace Nested Block |
3402 |
blockNameList = explodeNestedBlocks(pDb); |
3403 |
|
3404 |
// Prepare Block Purge |
3405 |
preparePurgeBlocks(pDb, blockNameList); |
3406 |
|
3407 |
// Block Purge |
3408 |
ObjectIdCollection oids = new ObjectIdCollection(); |
3409 |
using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead)) |
3410 |
{ |
3411 |
foreach (ObjectId id in pTable) |
3412 |
{ |
3413 |
BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead, false, true); |
3414 |
oids.Add(id); |
3415 |
} |
3416 |
} |
3417 |
pDb.Purge(oids); |
3418 |
|
3419 |
foreach (ObjectId oid in oids) |
3420 |
{ |
3421 |
using (BlockTableRecord btr = (BlockTableRecord)oid.Open(OpenMode.ForWrite, false, true)) |
3422 |
{ |
3423 |
btr.Erase(true); |
3424 |
} |
3425 |
} |
3426 |
} |
3427 |
|
3428 |
private HashSet<string> explodeNestedBlocks(Database pDb) |
3429 |
{ |
3430 |
HashSet<string> blockNameList = new HashSet<string>(); |
3431 |
HashSet<ObjectId> oidSet = new HashSet<ObjectId>(); |
3432 |
|
3433 |
using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead)) |
3434 |
{ |
3435 |
using (BlockTableRecord pBlock = (BlockTableRecord)pTable[BlockTableRecord.ModelSpace].Open(OpenMode.ForRead, false, true)) |
3436 |
{ |
3437 |
foreach (ObjectId entid in pBlock) |
3438 |
{ |
3439 |
using (Entity pEnt = (Entity)entid.Open(OpenMode.ForRead, false, true)) |
3440 |
{ |
3441 |
if (pEnt.GetRXClass().Name != "AcDbBlockReference") continue; |
3442 |
BlockReference blockRef = (BlockReference)pEnt; |
3443 |
|
3444 |
using (BlockTableRecord pBtr = (BlockTableRecord)blockRef.BlockTableRecord.Open(OpenMode.ForRead, false, true)) |
3445 |
{ |
3446 |
bool isNestedBlock = false; |
3447 |
foreach (ObjectId blkid in pBtr) |
3448 |
{ |
3449 |
using (Entity pBlkEnt = (Entity)blkid.Open(OpenMode.ForRead, false, true)) |
3450 |
{ |
3451 |
if (pBlkEnt.GetRXClass().Name == "AcDbBlockReference") |
3452 |
{ |
3453 |
oidSet.Add(entid); |
3454 |
isNestedBlock = true; |
3455 |
} |
3456 |
} |
3457 |
} |
3458 |
if (!isNestedBlock) |
3459 |
{ |
3460 |
blockNameList.Add(blockRef.Name); |
3461 |
} |
3462 |
} |
3463 |
} |
3464 |
} |
3465 |
} |
3466 |
} |
3467 |
|
3468 |
if (oidSet.Count > 0) |
3469 |
{ |
3470 |
explodeBlocks(oidSet); |
3471 |
blockNameList = explodeNestedBlocks(pDb); |
3472 |
} |
3473 |
|
3474 |
return blockNameList; |
3475 |
} |
3476 |
|
3477 |
private void preparePurgeBlocks(Database pDb, HashSet<string> blockNameList) |
3478 |
{ |
3479 |
HashSet<ObjectId> oidSet = new HashSet<ObjectId>(); |
3480 |
|
3481 |
using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead)) |
3482 |
{ |
3483 |
foreach (ObjectId id in pTable) |
3484 |
{ |
3485 |
using (BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForWrite, false, true)) |
3486 |
{ |
3487 |
if (pBlock.IsLayout) continue; |
3488 |
pBlock.Explodable = true; |
3489 |
if (blockNameList.Contains(pBlock.Name)) continue; |
3490 |
|
3491 |
foreach (ObjectId entid in pBlock) |
3492 |
{ |
3493 |
using (Entity pEnt = (Entity)entid.Open(OpenMode.ForRead, false, true)) |
3494 |
{ |
3495 |
if (pEnt.GetRXClass().Name != "AcDbBlockReference") continue; |
3496 |
|
3497 |
oidSet.Add(entid); |
3498 |
} |
3499 |
} |
3500 |
} |
3501 |
} |
3502 |
} |
3503 |
|
3504 |
if (oidSet.Count > 0) |
3505 |
{ |
3506 |
explodeBlocks(oidSet); |
3507 |
preparePurgeBlocks(pDb, blockNameList); |
3508 |
} |
3509 |
|
3510 |
return; |
3511 |
} |
3512 |
private void explodeBlocks(HashSet<ObjectId> oidSet) |
3513 |
{ |
3514 |
foreach (ObjectId blkId in oidSet) |
3515 |
{ |
3516 |
BlockReference blkRef = (BlockReference)blkId.Open(OpenMode.ForWrite, false, true); |
3517 |
blkRef.ExplodeGeometryToOwnerSpace(); |
3518 |
blkRef.Erase(); |
3519 |
} |
3520 |
} |
3521 |
|
3522 |
/************************************************************************/ |
3523 |
/* Dump the BlockTable */ |
3524 |
/************************************************************************/ |
3525 |
public void dumpBlocks(Database pDb, int indent, XmlNode node) |
3526 |
{ |
3527 |
/**********************************************************************/ |
3528 |
/* Get a pointer to the BlockTable */ |
3529 |
/**********************************************************************/ |
3530 |
using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead)) |
3531 |
{ |
3532 |
/**********************************************************************/ |
3533 |
/* Dump the Description */ |
3534 |
/**********************************************************************/ |
3535 |
XmlElement BlocksNode = Program.xml.CreateElement(pTable.GetRXClass().Name); |
3536 |
|
3537 |
/**********************************************************************/ |
3538 |
/* Step through the BlockTable */ |
3539 |
/**********************************************************************/ |
3540 |
foreach (ObjectId id in pTable) |
3541 |
{ |
3542 |
/********************************************************************/ |
3543 |
/* Open the BlockTableRecord for Reading */ |
3544 |
/********************************************************************/ |
3545 |
using (BlockTableRecord pBlock = (BlockTableRecord)id.Open(OpenMode.ForRead)) |
3546 |
{ |
3547 |
/********************************************************************/ |
3548 |
/* Dump the BlockTableRecord */ |
3549 |
/********************************************************************/ |
3550 |
XmlElement BlockNode = Program.xml.CreateElement(pBlock.GetRXClass().Name); |
3551 |
|
3552 |
XmlAttribute NameAttr = Program.xml.CreateAttribute("Name"); |
3553 |
NameAttr.Value = pBlock.Name; |
3554 |
BlockNode.Attributes.SetNamedItem(NameAttr); |
3555 |
|
3556 |
XmlAttribute CommentsAttr = Program.xml.CreateAttribute("Comments"); |
3557 |
CommentsAttr.Value = pBlock.Comments; |
3558 |
BlockNode.Attributes.SetNamedItem(CommentsAttr); |
3559 |
|
3560 |
XmlAttribute OriginAttr = Program.xml.CreateAttribute("Origin"); |
3561 |
OriginAttr.Value = pBlock.Origin.ToString(); |
3562 |
BlockNode.Attributes.SetNamedItem(OriginAttr); |
3563 |
|
3564 |
writeLine(indent, pBlock.GetRXClass().Name); |
3565 |
writeLine(indent + 1, "Anonymous", pBlock.IsAnonymous); |
3566 |
writeLine(indent + 1, "Block Insert Units", pBlock.Units); |
3567 |
writeLine(indent + 1, "Block Scaling", pBlock.BlockScaling); |
3568 |
writeLine(indent + 1, "Explodable", pBlock.Explodable); |
3569 |
writeLine(indent + 1, "IsDynamicBlock", pBlock.IsDynamicBlock); |
3570 |
|
3571 |
try |
3572 |
{ |
3573 |
Extents3d extents = new Extents3d(new Point3d(1E+20, 1E+20, 1E+20), new Point3d(1E-20, 1E-20, 1E-20)); |
3574 |
extents.AddBlockExtents(pBlock); |
3575 |
|
3576 |
XmlAttribute MinExtentsAttr = Program.xml.CreateAttribute("MinExtents"); |
3577 |
MinExtentsAttr.Value = extents.MinPoint.ToString(); |
3578 |
BlockNode.Attributes.SetNamedItem(MinExtentsAttr); |
3579 |
|
3580 |
XmlAttribute MaxExtentsAttr = Program.xml.CreateAttribute("MaxExtents"); |
3581 |
MaxExtentsAttr.Value = extents.MaxPoint.ToString(); |
3582 |
BlockNode.Attributes.SetNamedItem(MaxExtentsAttr); |
3583 |
} |
3584 |
catch (System.Exception) |
3585 |
{ |
3586 |
} |
3587 |
|
3588 |
writeLine(indent + 1, "Layout", pBlock.IsLayout); |
3589 |
writeLine(indent + 1, "Has Attribute Definitions", pBlock.HasAttributeDefinitions); |
3590 |
writeLine(indent + 1, "Xref Status", pBlock.XrefStatus); |
3591 |
if (pBlock.XrefStatus != XrefStatus.NotAnXref) |
3592 |
{ |
3593 |
writeLine(indent + 1, "Xref Path", pBlock.PathName); |
3594 |
writeLine(indent + 1, "From Xref Attach", pBlock.IsFromExternalReference); |
3595 |
writeLine(indent + 1, "From Xref Overlay", pBlock.IsFromOverlayReference); |
3596 |
writeLine(indent + 1, "Xref Unloaded", pBlock.IsUnloaded); |
3597 |
} |
3598 |
|
3599 |
/********************************************************************/ |
3600 |
/* Step through the BlockTableRecord */ |
3601 |
/********************************************************************/ |
3602 |
foreach (ObjectId entid in pBlock) |
3603 |
{ |
3604 |
/********************************************************************/ |
3605 |
/* Dump the Entity */ |
3606 |
/********************************************************************/ |
3607 |
dumpEntity(entid, indent + 1, BlockNode); |
3608 |
} |
3609 |
|
3610 |
BlocksNode.AppendChild(BlockNode); |
3611 |
} |
3612 |
} |
3613 |
|
3614 |
node.AppendChild(BlocksNode); |
3615 |
} |
3616 |
} |
3617 |
|
3618 |
public void dumpDimStyles(Database pDb, int indent, XmlNode node) |
3619 |
{ |
3620 |
/**********************************************************************/ |
3621 |
/* Get a SmartPointer to the DimStyleTable */ |
3622 |
/**********************************************************************/ |
3623 |
using (DimStyleTable pTable = (DimStyleTable)pDb.DimStyleTableId.Open(OpenMode.ForRead)) |
3624 |
{ |
3625 |
/**********************************************************************/ |
3626 |
/* Dump the Description */ |
3627 |
/**********************************************************************/ |
3628 |
writeLine(); |
3629 |
writeLine(indent++, pTable.GetRXClass().Name); |
3630 |
|
3631 |
/**********************************************************************/ |
3632 |
/* Step through the DimStyleTable */ |
3633 |
/**********************************************************************/ |
3634 |
foreach (ObjectId id in pTable) |
3635 |
{ |
3636 |
/*********************************************************************/ |
3637 |
/* Open the DimStyleTableRecord for Reading */ |
3638 |
/*********************************************************************/ |
3639 |
using (DimStyleTableRecord pRecord = (DimStyleTableRecord)id.Open(OpenMode.ForRead)) |
3640 |
{ |
3641 |
/*********************************************************************/ |
3642 |
/* Dump the DimStyleTableRecord */ |
3643 |
/*********************************************************************/ |
3644 |
writeLine(); |
3645 |
writeLine(indent, pRecord.GetRXClass().Name); |
3646 |
writeLine(indent, "Name", pRecord.Name); |
3647 |
writeLine(indent, "Arc Symbol", toArcSymbolTypeString(pRecord.Dimarcsym)); |
3648 |
|
3649 |
writeLine(indent, "Background Text Color", pRecord.Dimtfillclr); |
3650 |
writeLine(indent, "BackgroundText Flags", pRecord.Dimtfill); |
3651 |
writeLine(indent, "Extension Line 1 Linetype", pRecord.Dimltex1); |
3652 |
writeLine(indent, "Extension Line 2 Linetype", pRecord.Dimltex2); |
3653 |
writeLine(indent, "Dimension Line Linetype", pRecord.Dimltype); |
3654 |
writeLine(indent, "Extension Line Fixed Len", pRecord.Dimfxlen); |
3655 |
writeLine(indent, "Extension Line Fixed Len Enable", pRecord.DimfxlenOn); |
3656 |
writeLine(indent, "Jog Angle", toDegreeString(pRecord.Dimjogang)); |
3657 |
writeLine(indent, "Modified For Recompute", pRecord.IsModifiedForRecompute); |
3658 |
writeLine(indent, "DIMADEC", pRecord.Dimadec); |
3659 |
writeLine(indent, "DIMALT", pRecord.Dimalt); |
3660 |
writeLine(indent, "DIMALTD", pRecord.Dimaltd); |
3661 |
writeLine(indent, "DIMALTF", pRecord.Dimaltf); |
3662 |
writeLine(indent, "DIMALTRND", pRecord.Dimaltrnd); |
3663 |
writeLine(indent, "DIMALTTD", pRecord.Dimalttd); |
3664 |
writeLine(indent, "DIMALTTZ", pRecord.Dimalttz); |
3665 |
writeLine(indent, "DIMALTU", pRecord.Dimaltu); |
3666 |
writeLine(indent, "DIMALTZ", pRecord.Dimaltz); |
3667 |
writeLine(indent, "DIMAPOST", pRecord.Dimapost); |
3668 |
writeLine(indent, "DIMASZ", pRecord.Dimasz); |
3669 |
writeLine(indent, "DIMATFIT", pRecord.Dimatfit); |
3670 |
writeLine(indent, "DIMAUNIT", pRecord.Dimaunit); |
3671 |
writeLine(indent, "DIMAZIN", pRecord.Dimazin); |
3672 |
writeLine(indent, "DIMBLK", pRecord.Dimblk); |
3673 |
writeLine(indent, "DIMBLK1", pRecord.Dimblk1); |
3674 |
writeLine(indent, "DIMBLK2", pRecord.Dimblk2); |
3675 |
writeLine(indent, "DIMCEN", pRecord.Dimcen); |
3676 |
writeLine(indent, "DIMCLRD", pRecord.Dimclrd); |
3677 |
writeLine(indent, "DIMCLRE", pRecord.Dimclre); |
3678 |
writeLine(indent, "DIMCLRT", pRecord.Dimclrt); |
3679 |
writeLine(indent, "DIMDEC", pRecord.Dimdec); |
3680 |
writeLine(indent, "DIMDLE", pRecord.Dimdle); |
3681 |
writeLine(indent, "DIMDLI", pRecord.Dimdli); |
3682 |
writeLine(indent, "DIMDSEP", pRecord.Dimdsep); |
3683 |
writeLine(indent, "DIMEXE", pRecord.Dimexe); |
3684 |
writeLine(indent, "DIMEXO", pRecord.Dimexo); |
3685 |
writeLine(indent, "DIMFRAC", pRecord.Dimfrac); |
3686 |
writeLine(indent, "DIMGAP", pRecord.Dimgap); |
3687 |
writeLine(indent, "DIMJUST", pRecord.Dimjust); |
3688 |
writeLine(indent, "DIMLDRBLK", pRecord.Dimldrblk); |
3689 |
writeLine(indent, "DIMLFAC", pRecord.Dimlfac); |
3690 |
writeLine(indent, "DIMLIM", pRecord.Dimlim); |
3691 |
writeLine(indent, "DIMLUNIT", pRecord.Dimlunit); |
3692 |
writeLine(indent, "DIMLWD", pRecord.Dimlwd); |
3693 |
writeLine(indent, "DIMLWE", pRecord.Dimlwe); |
3694 |
writeLine(indent, "DIMPOST", pRecord.Dimpost); |
3695 |
writeLine(indent, "DIMRND", pRecord.Dimrnd); |
3696 |
writeLine(indent, "DIMSAH", pRecord.Dimsah); |
3697 |
writeLine(indent, "DIMSCALE", pRecord.Dimscale); |
3698 |
writeLine(indent, "DIMSD1", pRecord.Dimsd1); |
3699 |
writeLine(indent, "DIMSD2", pRecord.Dimsd2); |
3700 |
writeLine(indent, "DIMSE1", pRecord.Dimse1); |
3701 |
writeLine(indent, "DIMSE2", pRecord.Dimse2); |
3702 |
writeLine(indent, "DIMSOXD", pRecord.Dimsoxd); |
3703 |
writeLine(indent, "DIMTAD", pRecord.Dimtad); |
3704 |
writeLine(indent, "DIMTDEC", pRecord.Dimtdec); |
3705 |
writeLine(indent, "DIMTFAC", pRecord.Dimtfac); |
3706 |
writeLine(indent, "DIMTIH", pRecord.Dimtih); |
3707 |
writeLine(indent, "DIMTIX", pRecord.Dimtix); |
3708 |
writeLine(indent, "DIMTM", pRecord.Dimtm); |
3709 |
writeLine(indent, "DIMTOFL", pRecord.Dimtofl); |
3710 |
writeLine(indent, "DIMTOH", pRecord.Dimtoh); |
3711 |
writeLine(indent, "DIMTOL", pRecord.Dimtol); |
3712 |
writeLine(indent, "DIMTOLJ", pRecord.Dimtolj); |
3713 |
writeLine(indent, "DIMTP", pRecord.Dimtp); |
3714 |
writeLine(indent, "DIMTSZ", pRecord.Dimtsz); |
3715 |
writeLine(indent, "DIMTVP", pRecord.Dimtvp); |
3716 |
writeLine(indent, "DIMTXSTY", pRecord.Dimtxsty); |
3717 |
writeLine(indent, "DIMTXT", pRecord.Dimtxt); |
3718 |
writeLine(indent, "DIMTZIN", pRecord.Dimtzin); |
3719 |
writeLine(indent, "DIMUPT", pRecord.Dimupt); |
3720 |
writeLine(indent, "DIMZIN", pRecord.Dimzin); |
3721 |
|
3722 |
dumpSymbolTableRecord(pRecord, indent, node); |
3723 |
} |
3724 |
} |
3725 |
} |
3726 |
} |
3727 |
|
3728 |
/// <summary> |
3729 |
/// extract information from entity has given id |
3730 |
/// </summary> |
3731 |
/// <param name="id"></param> |
3732 |
/// <param name="indent"></param> |
3733 |
/// <param name="node">XmlNode</param> |
3734 |
public void dumpEntity(ObjectId id, int indent, XmlNode node) |
3735 |
{ |
3736 |
/**********************************************************************/ |
3737 |
/* Get a pointer to the Entity */ |
3738 |
/**********************************************************************/ |
3739 |
try |
3740 |
{ |
3741 |
using (Entity pEnt = (Entity)id.Open(OpenMode.ForRead, false, true)) |
3742 |
{ |
3743 |
/**********************************************************************/ |
3744 |
/* Dump the entity */ |
3745 |
/**********************************************************************/ |
3746 |
writeLine(); |
3747 |
// Protocol extensions are not supported in DD.NET (as well as in ARX.NET) |
3748 |
// so we just switch by entity type here |
3749 |
// (maybe it makes sense to make a map: type -> delegate) |
3750 |
switch (pEnt.GetRXClass().Name) |
3751 |
{ |
3752 |
case "AcDbAlignedDimension": |
3753 |
dump((AlignedDimension)pEnt, indent, node); |
3754 |
break; |
3755 |
case "AcDbArc": |
3756 |
dump((Arc)pEnt, indent, node); |
3757 |
break; |
3758 |
case "AcDbArcDimension": |
3759 |
dump((ArcDimension)pEnt, indent, node); |
3760 |
break; |
3761 |
case "AcDbBlockReference": |
3762 |
dump((BlockReference)pEnt, indent, node); |
3763 |
break; |
3764 |
case "AcDbBody": |
3765 |
dump((Body)pEnt, indent, node); |
3766 |
break; |
3767 |
case "AcDbCircle": |
3768 |
dump((Circle)pEnt, indent, node); |
3769 |
break; |
3770 |
case "AcDbPoint": |
3771 |
dump((DBPoint)pEnt, indent); |
3772 |
break; |
3773 |
case "AcDbText": |
3774 |
dump((DBText)pEnt, indent, node); |
3775 |
break; |
3776 |
case "AcDbDiametricDimension": |
3777 |
dump((DiametricDimension)pEnt, indent, node); |
3778 |
break; |
3779 |
case "AcDbViewport": |
3780 |
dump((Teigha.DatabaseServices.Viewport)pEnt, indent, node); |
3781 |
break; |
3782 |
case "AcDbEllipse": |
3783 |
dump((Ellipse)pEnt, indent, node); |
3784 |
break; |
3785 |
case "AcDbFace": |
3786 |
dump((Face)pEnt, indent, node); |
3787 |
break; |
3788 |
case "AcDbFcf": |
3789 |
dump((FeatureControlFrame)pEnt, indent); |
3790 |
break; |
3791 |
case "AcDbHatch": |
3792 |
dump((Hatch)pEnt, indent); |
3793 |
break; |
3794 |
case "AcDbLeader": |
3795 |
dump((Leader)pEnt, indent); |
3796 |
break; |
3797 |
case "AcDbLine": |
3798 |
dump((Line)pEnt, indent, node); |
3799 |
break; |
3800 |
case "AcDb2LineAngularDimension": |
3801 |
dump((LineAngularDimension2)pEnt, indent, node); |
3802 |
break; |
3803 |
case "AcDbMInsertBlock": |
3804 |
dump((MInsertBlock)pEnt, indent, node); |
3805 |
break; |
3806 |
case "AcDbMline": |
3807 |
dump((Mline)pEnt, indent); |
3808 |
break; |
3809 |
case "AcDbMText": |
3810 |
dump((MText)pEnt, indent, node); |
3811 |
break; |
3812 |
case "AcDbOle2Frame": |
3813 |
dump((Ole2Frame)pEnt, indent); |
3814 |
break; |
3815 |
case "AcDbOrdinateDimension": |
3816 |
dump((OrdinateDimension)pEnt, indent, node); |
3817 |
break; |
3818 |
case "AcDb3PointAngularDimension": |
3819 |
dump((Point3AngularDimension)pEnt, indent, node); |
3820 |
break; |
3821 |
case "AcDbPolyFaceMesh": |
3822 |
dump((PolyFaceMesh)pEnt, indent, node); |
3823 |
break; |
3824 |
case "AcDbPolygonMesh": |
3825 |
dump((PolygonMesh)pEnt, indent); |
3826 |
break; |
3827 |
case "AcDbPolyline": |
3828 |
dump((Teigha.DatabaseServices.Polyline)pEnt, indent, node); |
3829 |
break; |
3830 |
case "AcDb2dPolyline": |
3831 |
dump((Polyline2d)pEnt, indent, node); |
3832 |
break; |
3833 |
case "AcDb3dPolyline": |
3834 |
dump((Polyline3d)pEnt, indent, node); |
3835 |
break; |
3836 |
case "AcDbProxyEntity": |
3837 |
dump((ProxyEntity)pEnt, indent, node); |
3838 |
break; |
3839 |
case "AcDbRadialDimension": |
3840 |
dump((RadialDimension)pEnt, indent, node); |
3841 |
break; |
3842 |
case "AcDbRasterImage": |
3843 |
dump((RasterImage)pEnt, indent); |
3844 |
break; |
3845 |
case "AcDbRay": |
3846 |
dump((Ray)pEnt, indent); |
3847 |
break; |
3848 |
case "AcDbRegion": |
3849 |
dump((Region)pEnt, indent); |
3850 |
break; |
3851 |
case "AcDbRotatedDimension": |
3852 |
dump((RotatedDimension)pEnt, indent, node); |
3853 |
break; |
3854 |
case "AcDbShape": |
3855 |
dump((Shape)pEnt, indent); |
3856 |
break; |
3857 |
case "AcDb3dSolid": |
3858 |
dump((Solid3d)pEnt, indent, node); |
3859 |
break; |
3860 |
case "AcDbSpline": |
3861 |
dump((Spline)pEnt, indent); |
3862 |
break; |
3863 |
case "AcDbTable": |
3864 |
dump((Table)pEnt, indent); |
3865 |
break; |
3866 |
case "AcDbTrace": |
3867 |
dump((Trace)pEnt, indent); |
3868 |
break; |
3869 |
case "AcDbWipeout": |
3870 |
dump((Wipeout)pEnt, indent); |
3871 |
break; |
3872 |
case "AcDbXline": |
3873 |
dump((Xline)pEnt, indent); |
3874 |
break; |
3875 |
case "AcDbPdfReference": |
3876 |
case "AcDbDwfReference": |
3877 |
case "AcDbDgnReference": |
3878 |
dump((UnderlayReference)pEnt, indent); |
3879 |
break; |
3880 |
default: |
3881 |
dump(pEnt, indent, node); |
3882 |
break; |
3883 |
} |
3884 |
/* Dump the Xdata */ |
3885 |
/**********************************************************************/ |
3886 |
dumpXdata(pEnt.XData, indent); |
3887 |
|
3888 |
/**********************************************************************/ |
3889 |
/* Dump the Extension Dictionary */ |
3890 |
/**********************************************************************/ |
3891 |
if (!pEnt.ExtensionDictionary.IsNull) |
3892 |
{ |
3893 |
dumpObject(pEnt.ExtensionDictionary, "ACAD_XDICTIONARY", indent); |
3894 |
} |
3895 |
} |
3896 |
} |
3897 |
catch (System.Exception ex) |
3898 |
{ |
3899 |
writeLine(indent, $"OID = {id.ToString()}, Error = {ex.Message}"); |
3900 |
} |
3901 |
} |
3902 |
public void dumpHeader(Database pDb, int indent, XmlNode node) |
3903 |
{ |
3904 |
if (node != null) |
3905 |
{ |
3906 |
XmlAttribute FileNameAttr = Program.xml.CreateAttribute("FileName"); |
3907 |
FileNameAttr.Value = shortenPath(pDb.Filename); |
3908 |
node.Attributes.SetNamedItem(FileNameAttr); |
3909 |
|
3910 |
XmlAttribute OriginalFileVersionAttr = Program.xml.CreateAttribute("OriginalFileVersion"); |
3911 |
OriginalFileVersionAttr.Value = pDb.OriginalFileVersion.ToString(); |
3912 |
node.Attributes.SetNamedItem(OriginalFileVersionAttr); |
3913 |
|
3914 |
writeLine(); |
3915 |
writeLine(indent++, "Header Variables:"); |
3916 |
|
3917 |
//writeLine(); |
3918 |
//writeLine(indent, "TDCREATE:", pDb.TDCREATE); |
3919 |
//writeLine(indent, "TDUPDATE:", pDb.TDUPDATE); |
3920 |
|
3921 |
writeLine(); |
3922 |
writeLine(indent, "ANGBASE", pDb.Angbase); |
3923 |
writeLine(indent, "ANGDIR", pDb.Angdir); |
3924 |
writeLine(indent, "ATTMODE", pDb.Attmode); |
3925 |
writeLine(indent, "AUNITS", pDb.Aunits); |
3926 |
writeLine(indent, "AUPREC", pDb.Auprec); |
3927 |
writeLine(indent, "CECOLOR", pDb.Cecolor); |
3928 |
writeLine(indent, "CELTSCALE", pDb.Celtscale); |
3929 |
writeLine(indent, "CHAMFERA", pDb.Chamfera); |
3930 |
writeLine(indent, "CHAMFERB", pDb.Chamferb); |
3931 |
writeLine(indent, "CHAMFERC", pDb.Chamferc); |
3932 |
writeLine(indent, "CHAMFERD", pDb.Chamferd); |
3933 |
writeLine(indent, "CMLJUST", pDb.Cmljust); |
3934 |
writeLine(indent, "CMLSCALE", pDb.Cmljust); |
3935 |
writeLine(indent, "DIMADEC", pDb.Dimadec); |
3936 |
writeLine(indent, "DIMALT", pDb.Dimalt); |
3937 |
writeLine(indent, "DIMALTD", pDb.Dimaltd); |
3938 |
writeLine(indent, "DIMALTF", pDb.Dimaltf); |
3939 |
writeLine(indent, "DIMALTRND", pDb.Dimaltrnd); |
3940 |
writeLine(indent, "DIMALTTD", pDb.Dimalttd); |
3941 |
writeLine(indent, "DIMALTTZ", pDb.Dimalttz); |
3942 |
writeLine(indent, "DIMALTU", pDb.Dimaltu); |
3943 |
writeLine(indent, "DIMALTZ", pDb.Dimaltz); |
3944 |
writeLine(indent, "DIMAPOST", pDb.Dimapost); |
3945 |
writeLine(indent, "DIMASZ", pDb.Dimasz); |
3946 |
writeLine(indent, "DIMATFIT", pDb.Dimatfit); |
3947 |
writeLine(indent, "DIMAUNIT", pDb.Dimaunit); |
3948 |
writeLine(indent, "DIMAZIN", pDb.Dimazin); |
3949 |
writeLine(indent, "DIMBLK", pDb.Dimblk); |
3950 |
writeLine(indent, "DIMBLK1", pDb.Dimblk1); |
3951 |
writeLine(indent, "DIMBLK2", pDb.Dimblk2); |
3952 |
writeLine(indent, "DIMCEN", pDb.Dimcen); |
3953 |
writeLine(indent, "DIMCLRD", pDb.Dimclrd); |
3954 |
writeLine(indent, "DIMCLRE", pDb.Dimclre); |
3955 |
writeLine(indent, "DIMCLRT", pDb.Dimclrt); |
3956 |
writeLine(indent, "DIMDEC", pDb.Dimdec); |
3957 |
writeLine(indent, "DIMDLE", pDb.Dimdle); |
3958 |
writeLine(indent, "DIMDLI", pDb.Dimdli); |
3959 |
writeLine(indent, "DIMDSEP", pDb.Dimdsep); |
3960 |
writeLine(indent, "DIMEXE", pDb.Dimexe); |
3961 |
writeLine(indent, "DIMEXO", pDb.Dimexo); |
3962 |
writeLine(indent, "DIMFRAC", pDb.Dimfrac); |
3963 |
writeLine(indent, "DIMGAP", pDb.Dimgap); |
3964 |
writeLine(indent, "DIMJUST", pDb.Dimjust); |
3965 |
writeLine(indent, "DIMLDRBLK", pDb.Dimldrblk); |
3966 |
writeLine(indent, "DIMLFAC", pDb.Dimlfac); |
3967 |
writeLine(indent, "DIMLIM", pDb.Dimlim); |
3968 |
writeLine(indent, "DIMLUNIT", pDb.Dimlunit); |
3969 |
writeLine(indent, "DIMLWD", pDb.Dimlwd); |
3970 |
writeLine(indent, "DIMLWE", pDb.Dimlwe); |
3971 |
writeLine(indent, "DIMPOST", pDb.Dimpost); |
3972 |
writeLine(indent, "DIMRND", pDb.Dimrnd); |
3973 |
writeLine(indent, "DIMSAH", pDb.Dimsah); |
3974 |
writeLine(indent, "DIMSCALE", pDb.Dimscale); |
3975 |
writeLine(indent, "DIMSD1", pDb.Dimsd1); |
3976 |
writeLine(indent, "DIMSD2", pDb.Dimsd2); |
3977 |
writeLine(indent, "DIMSE1", pDb.Dimse1); |
3978 |
writeLine(indent, "DIMSE2", pDb.Dimse2); |
3979 |
writeLine(indent, "DIMSOXD", pDb.Dimsoxd); |
3980 |
writeLine(indent, "DIMTAD", pDb.Dimtad); |
3981 |
writeLine(indent, "DIMTDEC", pDb.Dimtdec); |
3982 |
writeLine(indent, "DIMTFAC", pDb.Dimtfac); |
3983 |
writeLine(indent, "DIMTIH", pDb.Dimtih); |
3984 |
writeLine(indent, "DIMTIX", pDb.Dimtix); |
3985 |
writeLine(indent, "DIMTM", pDb.Dimtm); |
3986 |
writeLine(indent, "DIMTOFL", pDb.Dimtofl); |
3987 |
writeLine(indent, "DIMTOH", pDb.Dimtoh); |
3988 |
writeLine(indent, "DIMTOL", pDb.Dimtol); |
3989 |
writeLine(indent, "DIMTOLJ", pDb.Dimtolj); |
3990 |
writeLine(indent, "DIMTP", pDb.Dimtp); |
3991 |
writeLine(indent, "DIMTSZ", pDb.Dimtsz); |
3992 |
writeLine(indent, "DIMTVP", pDb.Dimtvp); |
3993 |
writeLine(indent, "DIMTXSTY", pDb.Dimtxsty); |
3994 |
writeLine(indent, "DIMTXT", pDb.Dimtxt); |
3995 |
writeLine(indent, "DIMTZIN", pDb.Dimtzin); |
3996 |
writeLine(indent, "DIMUPT", pDb.Dimupt); |
3997 |
writeLine(indent, "DIMZIN", pDb.Dimzin); |
3998 |
writeLine(indent, "DISPSILH", pDb.DispSilh); |
3999 |
writeLine(indent, "DRAWORDERCTL", pDb.DrawOrderCtl); |
4000 |
writeLine(indent, "ELEVATION", pDb.Elevation); |
4001 |
writeLine(indent, "EXTMAX", pDb.Extmax); |
4002 |
writeLine(indent, "EXTMIN", pDb.Extmin); |
4003 |
writeLine(indent, "FACETRES", pDb.Facetres); |
4004 |
writeLine(indent, "FILLETRAD", pDb.Filletrad); |
4005 |
writeLine(indent, "FILLMODE", pDb.Fillmode); |
4006 |
writeLine(indent, "INSBASE", pDb.Insbase); |
4007 |
writeLine(indent, "ISOLINES", pDb.Isolines); |
4008 |
writeLine(indent, "LIMCHECK", pDb.Limcheck); |
4009 |
writeLine(indent, "LIMMAX", pDb.Limmax); |
4010 |
writeLine(indent, "LIMMIN", pDb.Limmin); |
4011 |
writeLine(indent, "LTSCALE", pDb.Ltscale); |
4012 |
writeLine(indent, "LUNITS", pDb.Lunits); |
4013 |
writeLine(indent, "LUPREC", pDb.Luprec); |
4014 |
writeLine(indent, "MAXACTVP", pDb.Maxactvp); |
4015 |
writeLine(indent, "MIRRTEXT", pDb.Mirrtext); |
4016 |
writeLine(indent, "ORTHOMODE", pDb.Orthomode); |
4017 |
writeLine(indent, "PDMODE", pDb.Pdmode); |
4018 |
writeLine(indent, "PDSIZE", pDb.Pdsize); |
4019 |
writeLine(indent, "PELEVATION", pDb.Pelevation); |
4020 |
writeLine(indent, "PELLIPSE", pDb.PlineEllipse); |
4021 |
writeLine(indent, "PEXTMAX", pDb.Pextmax); |
4022 |
writeLine(indent, "PEXTMIN", pDb.Pextmin); |
4023 |
writeLine(indent, "PINSBASE", pDb.Pinsbase); |
4024 |
writeLine(indent, "PLIMCHECK", pDb.Plimcheck); |
4025 |
writeLine(indent, "PLIMMAX", pDb.Plimmax); |
4026 |
writeLine(indent, "PLIMMIN", pDb.Plimmin); |
4027 |
writeLine(indent, "PLINEGEN", pDb.Plinegen); |
4028 |
writeLine(indent, "PLINEWID", pDb.Plinewid); |
4029 |
writeLine(indent, "PROXYGRAPHICS", pDb.Saveproxygraphics); |
4030 |
writeLine(indent, "PSLTSCALE", pDb.Psltscale); |
4031 |
writeLine(indent, "PUCSNAME", pDb.Pucsname); |
4032 |
writeLine(indent, "PUCSORG", pDb.Pucsorg); |
4033 |
writeLine(indent, "PUCSXDIR", pDb.Pucsxdir); |
4034 |
writeLine(indent, "PUCSYDIR", pDb.Pucsydir); |
4035 |
writeLine(indent, "QTEXTMODE", pDb.Qtextmode); |
4036 |
writeLine(indent, "REGENMODE", pDb.Regenmode); |
4037 |
writeLine(indent, "SHADEDGE", pDb.Shadedge); |
4038 |
writeLine(indent, "SHADEDIF", pDb.Shadedif); |
4039 |
writeLine(indent, "SKETCHINC", pDb.Sketchinc); |
4040 |
writeLine(indent, "SKPOLY", pDb.Skpoly); |
4041 |
writeLine(indent, "SPLFRAME", pDb.Splframe); |
4042 |
writeLine(indent, "SPLINESEGS", pDb.Splinesegs); |
4043 |
writeLine(indent, "SPLINETYPE", pDb.Splinetype); |
4044 |
writeLine(indent, "SURFTAB1", pDb.Surftab1); |
4045 |
writeLine(indent, "SURFTAB2", pDb.Surftab2); |
4046 |
writeLine(indent, "SURFTYPE", pDb.Surftype); |
4047 |
writeLine(indent, "SURFU", pDb.Surfu); |
4048 |
writeLine(indent, "SURFV", pDb.Surfv); |
4049 |
//writeLine(indent, "TEXTQLTY", pDb.TEXTQLTY); |
4050 |
writeLine(indent, "TEXTSIZE", pDb.Textsize); |
4051 |
writeLine(indent, "THICKNESS", pDb.Thickness); |
4052 |
writeLine(indent, "TILEMODE", pDb.TileMode); |
4053 |
writeLine(indent, "TRACEWID", pDb.Tracewid); |
4054 |
writeLine(indent, "TREEDEPTH", pDb.Treedepth); |
4055 |
writeLine(indent, "UCSNAME", pDb.Ucsname); |
4056 |
writeLine(indent, "UCSORG", pDb.Ucsorg); |
4057 |
writeLine(indent, "UCSXDIR", pDb.Ucsxdir); |
4058 |
writeLine(indent, "UCSYDIR", pDb.Ucsydir); |
4059 |
writeLine(indent, "UNITMODE", pDb.Unitmode); |
4060 |
writeLine(indent, "USERI1", pDb.Useri1); |
4061 |
writeLine(indent, "USERI2", pDb.Useri2); |
4062 |
writeLine(indent, "USERI3", pDb.Useri3); |
4063 |
writeLine(indent, "USERI4", pDb.Useri4); |
4064 |
writeLine(indent, "USERI5", pDb.Useri5); |
4065 |
writeLine(indent, "USERR1", pDb.Userr1); |
4066 |
writeLine(indent, "USERR2", pDb.Userr2); |
4067 |
writeLine(indent, "USERR3", pDb.Userr3); |
4068 |
writeLine(indent, "USERR4", pDb.Userr4); |
4069 |
writeLine(indent, "USERR5", pDb.Userr5); |
4070 |
writeLine(indent, "USRTIMER", pDb.Usrtimer); |
4071 |
writeLine(indent, "VISRETAIN", pDb.Visretain); |
4072 |
writeLine(indent, "WORLDVIEW", pDb.Worldview); |
4073 |
} |
4074 |
} |
4075 |
|
4076 |
public void dumpLayers(Database pDb, int indent, XmlNode node) |
4077 |
{ |
4078 |
if (node != null) |
4079 |
{ |
4080 |
/**********************************************************************/ |
4081 |
/* Get a SmartPointer to the LayerTable */ |
4082 |
/**********************************************************************/ |
4083 |
using (LayerTable pTable = (LayerTable)pDb.LayerTableId.Open(OpenMode.ForRead)) |
4084 |
{ |
4085 |
/**********************************************************************/ |
4086 |
/* Dump the Description */ |
4087 |
/**********************************************************************/ |
4088 |
XmlElement LayerNode = Program.xml.CreateElement(pTable.GetRXClass().Name); |
4089 |
|
4090 |
/**********************************************************************/ |
4091 |
/* Get a SmartPointer to a new SymbolTableIterator */ |
4092 |
/**********************************************************************/ |
4093 |
|
4094 |
/**********************************************************************/ |
4095 |
/* Step through the LayerTable */ |
4096 |
/**********************************************************************/ |
4097 |
foreach (ObjectId id in pTable) |
4098 |
{ |
4099 |
/********************************************************************/ |
4100 |
/* Open the LayerTableRecord for Reading */ |
4101 |
/********************************************************************/ |
4102 |
using (LayerTableRecord pRecord = (LayerTableRecord)id.Open(OpenMode.ForRead)) |
4103 |
{ |
4104 |
/********************************************************************/ |
4105 |
/* Dump the LayerTableRecord */ |
4106 |
/********************************************************************/ |
4107 |
XmlElement RecordNode = Program.xml.CreateElement(pRecord.GetRXClass().Name); |
4108 |
|
4109 |
XmlAttribute NameAttr = Program.xml.CreateAttribute("Name"); |
4110 |
NameAttr.Value = pRecord.Name.ToString(); |
4111 |
RecordNode.Attributes.SetNamedItem(NameAttr); |
4112 |
|
4113 |
XmlAttribute IsUsedAttr = Program.xml.CreateAttribute("IsUsed"); |
4114 |
IsUsedAttr.Value = pRecord.IsUsed.ToString(); |
4115 |
RecordNode.Attributes.SetNamedItem(IsUsedAttr); |
4116 |
|
4117 |
XmlAttribute IsOffAttr = Program.xml.CreateAttribute("IsOff"); |
4118 |
IsOffAttr.Value = pRecord.IsOff.ToString(); |
4119 |
RecordNode.Attributes.SetNamedItem(IsOffAttr); |
4120 |
|
4121 |
XmlAttribute IsFrozenAttr = Program.xml.CreateAttribute("IsFrozen"); |
4122 |
IsFrozenAttr.Value = pRecord.IsFrozen.ToString(); |
4123 |
RecordNode.Attributes.SetNamedItem(IsFrozenAttr); |
4124 |
|
4125 |
XmlAttribute IsLockedAttr = Program.xml.CreateAttribute("IsLocked"); |
4126 |
IsLockedAttr.Value = pRecord.IsLocked.ToString(); |
4127 |
RecordNode.Attributes.SetNamedItem(IsLockedAttr); |
4128 |
|
4129 |
XmlAttribute ColorAttr = Program.xml.CreateAttribute("Color"); |
4130 |
ColorAttr.Value = pRecord.Color.ToString(); |
4131 |
RecordNode.Attributes.SetNamedItem(ColorAttr); |
4132 |
|
4133 |
XmlAttribute LinetypeObjectIdAttr = Program.xml.CreateAttribute("LinetypeObjectId"); |
4134 |
LinetypeObjectIdAttr.Value = pRecord.LinetypeObjectId.ToString(); |
4135 |
RecordNode.Attributes.SetNamedItem(LinetypeObjectIdAttr); |
4136 |
|
4137 |
XmlAttribute LineWeightAttr = Program.xml.CreateAttribute("LineWeight"); |
4138 |
LineWeightAttr.Value = pRecord.LineWeight.ToString(); |
4139 |
RecordNode.Attributes.SetNamedItem(LineWeightAttr); |
4140 |
|
4141 |
XmlAttribute PlotStyleNameAttr = Program.xml.CreateAttribute("PlotStyleName"); |
4142 |
PlotStyleNameAttr.Value = pRecord.PlotStyleName.ToString(); |
4143 |
RecordNode.Attributes.SetNamedItem(PlotStyleNameAttr); |
4144 |
|
4145 |
XmlAttribute IsPlottableAttr = Program.xml.CreateAttribute("IsPlottable"); |
4146 |
IsPlottableAttr.Value = pRecord.IsPlottable.ToString(); |
4147 |
RecordNode.Attributes.SetNamedItem(IsPlottableAttr); |
4148 |
|
4149 |
XmlAttribute ViewportVisibilityDefaultAttr = Program.xml.CreateAttribute("ViewportVisibilityDefault"); |
4150 |
ViewportVisibilityDefaultAttr.Value = pRecord.ViewportVisibilityDefault.ToString(); |
4151 |
RecordNode.Attributes.SetNamedItem(ViewportVisibilityDefaultAttr); |
4152 |
|
4153 |
dumpSymbolTableRecord(pRecord, indent, RecordNode); |
4154 |
LayerNode.AppendChild(RecordNode); |
4155 |
} |
4156 |
} |
4157 |
|
4158 |
node.AppendChild(LayerNode); |
4159 |
} |
4160 |
} |
4161 |
} |
4162 |
|
4163 |
public void dumpLinetypes(Database pDb, int indent, XmlNode node) |
4164 |
{ |
4165 |
if (node != null) |
4166 |
{ |
4167 |
/**********************************************************************/ |
4168 |
/* Get a pointer to the LinetypeTable */ |
4169 |
/**********************************************************************/ |
4170 |
using (LinetypeTable pTable = (LinetypeTable)pDb.LinetypeTableId.Open(OpenMode.ForRead)) |
4171 |
{ |
4172 |
XmlElement LinetypeNode = Program.xml.CreateElement(pTable.GetRXClass().Name); |
4173 |
|
4174 |
/**********************************************************************/ |
4175 |
/* Step through the LinetypeTable */ |
4176 |
/**********************************************************************/ |
4177 |
foreach (ObjectId id in pTable) |
4178 |
{ |
4179 |
/*********************************************************************/ |
4180 |
/* Open the LinetypeTableRecord for Reading */ |
4181 |
/*********************************************************************/ |
4182 |
using (LinetypeTableRecord pRecord = (LinetypeTableRecord)id.Open(OpenMode.ForRead)) |
4183 |
{ |
4184 |
XmlElement RecordNode = Program.xml.CreateElement(pRecord.GetRXClass().Name); |
4185 |
|
4186 |
XmlAttribute ObjectIdAttr = Program.xml.CreateAttribute("ObjectId"); |
4187 |
ObjectIdAttr.Value = pRecord.ObjectId.ToString(); |
4188 |
RecordNode.Attributes.SetNamedItem(ObjectIdAttr); |
4189 |
|
4190 |
XmlAttribute NameAttr = Program.xml.CreateAttribute("Name"); |
4191 |
NameAttr.Value = pRecord.Name; |
4192 |
RecordNode.Attributes.SetNamedItem(NameAttr); |
4193 |
|
4194 |
XmlAttribute CommentsAttr = Program.xml.CreateAttribute("Comments"); |
4195 |
CommentsAttr.Value = pRecord.Comments; |
4196 |
RecordNode.Attributes.SetNamedItem(CommentsAttr); |
4197 |
|
4198 |
/********************************************************************/ |
4199 |
/* Dump the first line of record as in ACAD.LIN */ |
4200 |
/********************************************************************/ |
4201 |
string buffer = "*" + pRecord.Name; |
4202 |
if (pRecord.Comments != "") |
4203 |
{ |
4204 |
buffer = buffer + "," + pRecord.Comments; |
4205 |
} |
4206 |
writeLine(indent, buffer); |
4207 |
|
4208 |
/********************************************************************/ |
4209 |
/* Dump the second line of record as in ACAD.LIN */ |
4210 |
/********************************************************************/ |
4211 |
if (pRecord.NumDashes > 0) |
4212 |
{ |
4213 |
buffer = pRecord.IsScaledToFit ? "S" : "A"; |
4214 |
for (int i = 0; i < pRecord.NumDashes; i++) |
4215 |
{ |
4216 |
buffer = buffer + "," + pRecord.DashLengthAt(i); |
4217 |
int shapeNumber = pRecord.ShapeNumberAt(i); |
4218 |
string text = pRecord.TextAt(i); |
4219 |
|
4220 |
/**************************************************************/ |
4221 |
/* Dump the Complex Line */ |
4222 |
/**************************************************************/ |
4223 |
if (shapeNumber != 0 || text != "") |
4224 |
{ |
4225 |
using (TextStyleTableRecord pTextStyle = (TextStyleTableRecord)(pRecord.ShapeStyleAt(i) == ObjectId.Null ? null : pRecord.ShapeStyleAt(i).Open(OpenMode.ForRead))) |
4226 |
{ |
4227 |
if (shapeNumber != 0) |
4228 |
{ |
4229 |
buffer = buffer + ",[" + shapeNumber + ","; |
4230 |
if (pTextStyle != null) |
4231 |
buffer = buffer + pTextStyle.FileName; |
4232 |
else |
4233 |
buffer = buffer + "NULL style"; |
4234 |
} |
4235 |
else |
4236 |
{ |
4237 |
buffer = buffer + ",[" + text + ","; |
4238 |
if (pTextStyle != null) |
4239 |
buffer = buffer + pTextStyle.Name; |
4240 |
else |
4241 |
buffer = buffer + "NULL style"; |
4242 |
} |
4243 |
} |
4244 |
|
4245 |
if (pRecord.ShapeScaleAt(i) != 0.0) |
4246 |
{ |
4247 |
buffer = buffer + ",S" + pRecord.ShapeScaleAt(i); |
4248 |
} |
4249 |
if (pRecord.ShapeRotationAt(i) != 0) |
4250 |
{ |
4251 |
buffer = buffer + ",R" + toDegreeString(pRecord.ShapeRotationAt(i)); |
4252 |
} |
4253 |
if (pRecord.ShapeOffsetAt(i).X != 0) |
4254 |
{ |
4255 |
buffer = buffer + ",X" + pRecord.ShapeOffsetAt(i).X; |
4256 |
} |
4257 |
if (pRecord.ShapeOffsetAt(i).Y != 0) |
4258 |
{ |
4259 |
buffer = buffer + ",Y" + pRecord.ShapeOffsetAt(i).Y; |
4260 |
} |
4261 |
buffer = buffer + "]"; |
4262 |
} |
4263 |
} |
4264 |
writeLine(indent, buffer); |
4265 |
} |
4266 |
dumpSymbolTableRecord(pRecord, indent, node); |
4267 |
LinetypeNode.AppendChild(RecordNode); |
4268 |
} |
4269 |
} |
4270 |
|
4271 |
node.AppendChild(LinetypeNode); |
4272 |
} |
4273 |
} |
4274 |
} |
4275 |
|
4276 |
public void dumpRegApps(Database pDb, int indent) |
4277 |
{ |
4278 |
/**********************************************************************/ |
4279 |
/* Get a pointer to the RegAppTable */ |
4280 |
/**********************************************************************/ |
4281 |
using (RegAppTable pTable = (RegAppTable)pDb.RegAppTableId.Open(OpenMode.ForRead)) |
4282 |
{ |
4283 |
/**********************************************************************/ |
4284 |
/* Dump the Description */ |
4285 |
/**********************************************************************/ |
4286 |
writeLine(); |
4287 |
writeLine(indent++, pTable.GetRXClass().Name); |
4288 |
|
4289 |
/**********************************************************************/ |
4290 |
/* Step through the RegAppTable */ |
4291 |
/**********************************************************************/ |
4292 |
foreach (ObjectId id in pTable) |
4293 |
{ |
4294 |
/*********************************************************************/ |
4295 |
/* Open the RegAppTableRecord for Reading */ |
4296 |
/*********************************************************************/ |
4297 |
using (RegAppTableRecord pRecord = (RegAppTableRecord)id.Open(OpenMode.ForRead)) |
4298 |
{ |
4299 |
/*********************************************************************/ |
4300 |
/* Dump the RegAppTableRecord */ |
4301 |
/*********************************************************************/ |
4302 |
writeLine(); |
4303 |
writeLine(indent, pRecord.GetRXClass().Name); |
4304 |
writeLine(indent, "Name", pRecord.Name); |
4305 |
} |
4306 |
} |
4307 |
} |
4308 |
} |
4309 |
|
4310 |
public void dumpSymbolTableRecord(SymbolTableRecord pRecord, int indent, XmlNode node) |
4311 |
{ |
4312 |
writeLine(indent, "Xref dependent", pRecord.IsDependent); |
4313 |
if (pRecord.IsDependent) |
4314 |
{ |
4315 |
writeLine(indent, "Resolved", pRecord.IsResolved); |
4316 |
} |
4317 |
} |
4318 |
|
4319 |
public void dumpTextStyles(Database pDb, int indent, XmlNode node) |
4320 |
{ |
4321 |
/**********************************************************************/ |
4322 |
/* Get a SmartPointer to the TextStyleTable */ |
4323 |
/**********************************************************************/ |
4324 |
using (TextStyleTable pTable = (TextStyleTable)pDb.TextStyleTableId.Open(OpenMode.ForRead)) |
4325 |
{ |
4326 |
/**********************************************************************/ |
4327 |
/* Dump the Description */ |
4328 |
/**********************************************************************/ |
4329 |
writeLine(); |
4330 |
writeLine(indent++, pTable.GetRXClass().Name); |
4331 |
|
4332 |
/**********************************************************************/ |
4333 |
/* Step through the TextStyleTable */ |
4334 |
/**********************************************************************/ |
4335 |
foreach (ObjectId id in pTable) |
4336 |
{ |
4337 |
/*********************************************************************/ |
4338 |
/* Open the TextStyleTableRecord for Reading */ |
4339 |
/*********************************************************************/ |
4340 |
using (TextStyleTableRecord pRecord = (TextStyleTableRecord)id.Open(OpenMode.ForRead)) |
4341 |
{ |
4342 |
/*********************************************************************/ |
4343 |
/* Dump the TextStyleTableRecord */ |
4344 |
/*********************************************************************/ |
4345 |
writeLine(); |
4346 |
writeLine(indent, pRecord.GetRXClass().Name); |
4347 |
writeLine(indent, "Name", pRecord.Name); |
4348 |
writeLine(indent, "Shape File", pRecord.IsShapeFile); |
4349 |
writeLine(indent, "Text Height", pRecord.TextSize); |
4350 |
writeLine(indent, "Width Factor", pRecord.XScale); |
4351 |
writeLine(indent, "Obliquing Angle", toDegreeString(pRecord.ObliquingAngle)); |
4352 |
writeLine(indent, "Backwards", (pRecord.FlagBits & 2)); |
4353 |
writeLine(indent, "Vertical", pRecord.IsVertical); |
4354 |
writeLine(indent, "Upside Down", (pRecord.FlagBits & 4)); |
4355 |
writeLine(indent, "Filename", shortenPath(pRecord.FileName)); |
4356 |
writeLine(indent, "BigFont Filename", shortenPath(pRecord.BigFontFileName)); |
4357 |
|
4358 |
FontDescriptor fd = pRecord.Font; |
4359 |
writeLine(indent, "Typeface", fd.TypeFace); |
4360 |
writeLine(indent, "Character Set", fd.CharacterSet); |
4361 |
writeLine(indent, "Bold", fd.Bold); |
4362 |
writeLine(indent, "Italic", fd.Italic); |
4363 |
writeLine(indent, "Font Pitch & Family", toHexString(fd.PitchAndFamily)); |
4364 |
dumpSymbolTableRecord(pRecord, indent, node); |
4365 |
} |
4366 |
} |
4367 |
} |
4368 |
} |
4369 |
public void dumpAbstractViewTableRecord(AbstractViewTableRecord pView, int indent, XmlNode node) |
4370 |
{ |
4371 |
/*********************************************************************/ |
4372 |
/* Dump the AbstractViewTableRecord */ |
4373 |
/*********************************************************************/ |
4374 |
writeLine(indent, "Back Clip Dist", pView.BackClipDistance); |
4375 |
writeLine(indent, "Back Clip Enabled", pView.BackClipEnabled); |
4376 |
writeLine(indent, "Front Clip Dist", pView.FrontClipDistance); |
4377 |
writeLine(indent, "Front Clip Enabled", pView.FrontClipEnabled); |
4378 |
writeLine(indent, "Front Clip at Eye", pView.FrontClipAtEye); |
4379 |
writeLine(indent, "Elevation", pView.Elevation); |
4380 |
writeLine(indent, "Height", pView.Height); |
4381 |
writeLine(indent, "Width", pView.Width); |
4382 |
writeLine(indent, "Lens Length", pView.LensLength); |
4383 |
writeLine(indent, "Render Mode", pView.RenderMode); |
4384 |
writeLine(indent, "Perspective", pView.PerspectiveEnabled); |
4385 |
writeLine(indent, "UCS Name", pView.UcsName); |
4386 |
|
4387 |
//writeLine(indent, "UCS Orthographic", pView.IsUcsOrthographic(orthoUCS)); |
4388 |
//writeLine(indent, "Orthographic UCS", orthoUCS); |
4389 |
|
4390 |
if (pView.UcsOrthographic != OrthographicView.NonOrthoView) |
4391 |
{ |
4392 |
writeLine(indent, "UCS Origin", pView.Ucs.Origin); |
4393 |
writeLine(indent, "UCS x-Axis", pView.Ucs.Xaxis); |
4394 |
writeLine(indent, "UCS y-Axis", pView.Ucs.Yaxis); |
4395 |
} |
4396 |
|
4397 |
writeLine(indent, "Target", pView.Target); |
4398 |
writeLine(indent, "View Direction", pView.ViewDirection); |
4399 |
writeLine(indent, "Twist Angle", toDegreeString(pView.ViewTwist)); |
4400 |
dumpSymbolTableRecord(pView, indent, node); |
4401 |
} |
4402 |
public void dumpDimAssoc(DBObject pObject, int indent) |
4403 |
{ |
4404 |
|
4405 |
} |
4406 |
public void dumpMLineStyles(Database pDb, int indent) |
4407 |
{ |
4408 |
using (DBDictionary pDictionary = (DBDictionary)pDb.MLStyleDictionaryId.Open(OpenMode.ForRead)) |
4409 |
{ |
4410 |
/**********************************************************************/ |
4411 |
/* Dump the Description */ |
4412 |
/**********************************************************************/ |
4413 |
writeLine(); |
4414 |
writeLine(indent++, pDictionary.GetRXClass().Name); |
4415 |
|
4416 |
/**********************************************************************/ |
4417 |
/* Step through the MlineStyle dictionary */ |
4418 |
/**********************************************************************/ |
4419 |
DbDictionaryEnumerator e = pDictionary.GetEnumerator(); |
4420 |
while (e.MoveNext()) |
4421 |
{ |
4422 |
try |
4423 |
{ |
4424 |
using (MlineStyle pEntry = (MlineStyle)e.Value.Open(OpenMode.ForRead)) |
4425 |
{ |
4426 |
/*********************************************************************/ |
4427 |
/* Dump the MLineStyle dictionary entry */ |
4428 |
/*********************************************************************/ |
4429 |
writeLine(); |
4430 |
writeLine(indent, pEntry.GetRXClass().Name); |
4431 |
writeLine(indent, "Name", pEntry.Name); |
4432 |
writeLine(indent, "Description", pEntry.Description); |
4433 |
writeLine(indent, "Start Angle", toDegreeString(pEntry.StartAngle)); |
4434 |
writeLine(indent, "End Angle", toDegreeString(pEntry.EndAngle)); |
4435 |
writeLine(indent, "Start Inner Arcs", pEntry.StartInnerArcs); |
4436 |
writeLine(indent, "End Inner Arcs", pEntry.EndInnerArcs); |
4437 |
writeLine(indent, "Start Round Cap", pEntry.StartRoundCap); |
4438 |
writeLine(indent, "End Round Cap", pEntry.EndRoundCap); |
4439 |
writeLine(indent, "Start Square Cap", pEntry.StartRoundCap); |
4440 |
writeLine(indent, "End Square Cap", pEntry.EndRoundCap); |
4441 |
writeLine(indent, "Show Miters", pEntry.ShowMiters); |
4442 |
/*********************************************************************/ |
4443 |
/* Dump the elements */ |
4444 |
/*********************************************************************/ |
4445 |
if (pEntry.Elements.Count > 0) |
4446 |
{ |
4447 |
writeLine(indent, "Elements:"); |
4448 |
} |
4449 |
int i = 0; |
4450 |
foreach (MlineStyleElement el in pEntry.Elements) |
4451 |
{ |
4452 |
writeLine(indent, "Index", (i++)); |
4453 |
writeLine(indent + 1, "Offset", el.Offset); |
4454 |
writeLine(indent + 1, "Color", el.Color); |
4455 |
writeLine(indent + 1, "Linetype", el.LinetypeId); |
4456 |
} |
4457 |
} |
4458 |
} |
4459 |
catch (System.Exception) |
4460 |
{ |
4461 |
} |
4462 |
} |
4463 |
} |
4464 |
} |
4465 |
public void dumpObject(ObjectId id, string itemName, int indent) |
4466 |
{ |
4467 |
using (DBObject pObject = id.Open(OpenMode.ForRead)) |
4468 |
{ |
4469 |
/**********************************************************************/ |
4470 |
/* Dump the item name and class name */ |
4471 |
/**********************************************************************/ |
4472 |
if (pObject is DBDictionary) |
4473 |
{ |
4474 |
writeLine(); |
4475 |
} |
4476 |
writeLine(indent++, itemName, pObject.GetRXClass().Name); |
4477 |
|
4478 |
/**********************************************************************/ |
4479 |
/* Dispatch */ |
4480 |
/**********************************************************************/ |
4481 |
if (pObject is DBDictionary) |
4482 |
{ |
4483 |
/********************************************************************/ |
4484 |
/* Dump the dictionary */ |
4485 |
/********************************************************************/ |
4486 |
DBDictionary pDic = (DBDictionary)pObject; |
4487 |
|
4488 |
/********************************************************************/ |
4489 |
/* Get a pointer to a new DictionaryIterator */ |
4490 |
/********************************************************************/ |
4491 |
DbDictionaryEnumerator pIter = pDic.GetEnumerator(); |
4492 |
|
4493 |
/********************************************************************/ |
4494 |
/* Step through the Dictionary */ |
4495 |
/********************************************************************/ |
4496 |
while (pIter.MoveNext()) |
4497 |
{ |
4498 |
/******************************************************************/ |
4499 |
/* Dump the Dictionary object */ |
4500 |
/******************************************************************/ |
4501 |
dumpObject(pIter.Value, pIter.Key, indent); |
4502 |
} |
4503 |
} |
4504 |
else if (pObject is Xrecord) |
4505 |
{ |
4506 |
/********************************************************************/ |
4507 |
/* Dump an Xrecord */ |
4508 |
/********************************************************************/ |
4509 |
Xrecord pXRec = (Xrecord)pObject; |
4510 |
dumpXdata(pXRec.Data, indent); |
4511 |
} |
4512 |
} |
4513 |
} |
4514 |
|
4515 |
public void dumpUCSTable(Database pDb, int indent, XmlNode node) |
4516 |
{ |
4517 |
/**********************************************************************/ |
4518 |
/* Get a pointer to the UCSTable */ |
4519 |
/**********************************************************************/ |
4520 |
using (UcsTable pTable = (UcsTable)pDb.UcsTableId.Open(OpenMode.ForRead)) |
4521 |
{ |
4522 |
/**********************************************************************/ |
4523 |
/* Dump the Description */ |
4524 |
/**********************************************************************/ |
4525 |
writeLine(); |
4526 |
writeLine(indent++, pTable.GetRXClass().Name); |
4527 |
|
4528 |
/**********************************************************************/ |
4529 |
/* Step through the UCSTable */ |
4530 |
/**********************************************************************/ |
4531 |
foreach (ObjectId id in pTable) |
4532 |
{ |
4533 |
/********************************************************************/ |
4534 |
/* Open the UCSTableRecord for Reading */ |
4535 |
/********************************************************************/ |
4536 |
using (UcsTableRecord pRecord = (UcsTableRecord)id.Open(OpenMode.ForRead)) |
4537 |
{ |
4538 |
/********************************************************************/ |
4539 |
/* Dump the UCSTableRecord */ |
4540 |
/********************************************************************/ |
4541 |
writeLine(); |
4542 |
writeLine(indent, pRecord.GetRXClass().Name); |
4543 |
writeLine(indent, "Name", pRecord.Name); |
4544 |
writeLine(indent, "UCS Origin", pRecord.Origin); |
4545 |
writeLine(indent, "UCS x-Axis", pRecord.XAxis); |
4546 |
writeLine(indent, "UCS y-Axis", pRecord.YAxis); |
4547 |
dumpSymbolTableRecord(pRecord, indent, node); |
4548 |
} |
4549 |
} |
4550 |
} |
4551 |
} |
4552 |
public void dumpViewports(Database pDb, int indent, XmlNode node) |
4553 |
{ |
4554 |
/**********************************************************************/ |
4555 |
/* Get a pointer to the ViewportTable */ |
4556 |
/**********************************************************************/ |
4557 |
using (ViewportTable pTable = (ViewportTable)pDb.ViewportTableId.Open(OpenMode.ForRead)) |
4558 |
{ |
4559 |
/**********************************************************************/ |
4560 |
/* Dump the Description */ |
4561 |
/**********************************************************************/ |
4562 |
writeLine(); |
4563 |
writeLine(indent++, pTable.GetRXClass().Name); |
4564 |
|
4565 |
/**********************************************************************/ |
4566 |
/* Step through the ViewportTable */ |
4567 |
/**********************************************************************/ |
4568 |
foreach (ObjectId id in pTable) |
4569 |
{ |
4570 |
/*********************************************************************/ |
4571 |
/* Open the ViewportTableRecord for Reading */ |
4572 |
/*********************************************************************/ |
4573 |
using (ViewportTableRecord pRecord = (ViewportTableRecord)id.Open(OpenMode.ForRead)) |
4574 |
{ |
4575 |
/*********************************************************************/ |
4576 |
/* Dump the ViewportTableRecord */ |
4577 |
/*********************************************************************/ |
4578 |
writeLine(); |
4579 |
writeLine(indent, pRecord.GetRXClass().Name); |
4580 |
writeLine(indent, "Name", pRecord.Name); |
4581 |
writeLine(indent, "Circle Sides", pRecord.CircleSides); |
4582 |
writeLine(indent, "Fast Zooms Enabled", pRecord.FastZoomsEnabled); |
4583 |
writeLine(indent, "Grid Enabled", pRecord.GridEnabled); |
4584 |
writeLine(indent, "Grid Increments", pRecord.GridIncrements); |
4585 |
writeLine(indent, "Icon at Origin", pRecord.IconAtOrigin); |
4586 |
writeLine(indent, "Icon Enabled", pRecord.IconEnabled); |
4587 |
writeLine(indent, "Iso snap Enabled", pRecord.IsometricSnapEnabled); |
4588 |
writeLine(indent, "Iso Snap Pair", pRecord.SnapPair); |
4589 |
writeLine(indent, "UCS Saved w/Vport", pRecord.UcsSavedWithViewport); |
4590 |
writeLine(indent, "UCS follow", pRecord.UcsFollowMode); |
4591 |
writeLine(indent, "Lower-Left Corner", pRecord.LowerLeftCorner); |
4592 |
writeLine(indent, "Upper-Right Corner", pRecord.UpperRightCorner); |
4593 |
writeLine(indent, "Snap Angle", toDegreeString(pRecord.SnapAngle)); |
4594 |
writeLine(indent, "Snap Base", pRecord.SnapBase); |
4595 |
writeLine(indent, "Snap Enabled", pRecord.SnapEnabled); |
4596 |
writeLine(indent, "Snap Increments", pRecord.SnapIncrements); |
4597 |
dumpAbstractViewTableRecord(pRecord, indent, node); |
4598 |
} |
4599 |
} |
4600 |
} |
4601 |
} |
4602 |
|
4603 |
/************************************************************************/ |
4604 |
/* Dump the ViewTable */ |
4605 |
/************************************************************************/ |
4606 |
public void dumpViews(Database pDb, int indent, XmlNode node) |
4607 |
{ |
4608 |
/**********************************************************************/ |
4609 |
/* Get a pointer to the ViewTable */ |
4610 |
/**********************************************************************/ |
4611 |
using (ViewTable pTable = (ViewTable)pDb.ViewTableId.Open(OpenMode.ForRead)) |
4612 |
{ |
4613 |
/**********************************************************************/ |
4614 |
/* Dump the Description */ |
4615 |
/**********************************************************************/ |
4616 |
writeLine(); |
4617 |
writeLine(indent++, pTable.GetRXClass().Name); |
4618 |
|
4619 |
/**********************************************************************/ |
4620 |
/* Step through the ViewTable */ |
4621 |
/**********************************************************************/ |
4622 |
foreach (ObjectId id in pTable) |
4623 |
{ |
4624 |
/*********************************************************************/ |
4625 |
/* Open the ViewTableRecord for Reading */ |
4626 |
/*********************************************************************/ |
4627 |
using (ViewTableRecord pRecord = (ViewTableRecord)id.Open(OpenMode.ForRead)) |
4628 |
{ |
4629 |
/*********************************************************************/ |
4630 |
/* Dump the ViewTableRecord */ |
4631 |
/*********************************************************************/ |
4632 |
writeLine(); |
4633 |
writeLine(indent, pRecord.GetRXClass().Name); |
4634 |
writeLine(indent, "Name", pRecord.Name); |
4635 |
writeLine(indent, "Category Name", pRecord.CategoryName); |
4636 |
writeLine(indent, "Layer State", pRecord.LayerState); |
4637 |
|
4638 |
string layoutName = ""; |
4639 |
if (!pRecord.Layout.IsNull) |
4640 |
{ |
4641 |
using (Layout pLayout = (Layout)pRecord.Layout.Open(OpenMode.ForRead)) |
4642 |
layoutName = pLayout.LayoutName; |
4643 |
} |
4644 |
writeLine(indent, "Layout Name", layoutName); |
4645 |
writeLine(indent, "PaperSpace View", pRecord.IsPaperspaceView); |
4646 |
writeLine(indent, "Associated UCS", pRecord.IsUcsAssociatedToView); |
4647 |
writeLine(indent, "PaperSpace View", pRecord.ViewAssociatedToViewport); |
4648 |
dumpAbstractViewTableRecord(pRecord, indent, node); |
4649 |
} |
4650 |
} |
4651 |
} |
4652 |
} |
4653 |
/************************************************************************/ |
4654 |
/* Dump Xdata */ |
4655 |
/************************************************************************/ |
4656 |
public void dumpXdata(ResultBuffer xIter, int indent) |
4657 |
{ |
4658 |
if (xIter == null) |
4659 |
return; |
4660 |
writeLine(indent++, "Xdata:"); |
4661 |
/**********************************************************************/ |
4662 |
/* Step through the ResBuf chain */ |
4663 |
/**********************************************************************/ |
4664 |
foreach (TypedValue resbuf in xIter) |
4665 |
{ |
4666 |
writeLine(indent, resbuf); |
4667 |
} |
4668 |
} |
4669 |
} |
4670 |
class ExProtocolExtension |
4671 |
{ |
4672 |
} |
4673 |
|
4674 |
class Program |
4675 |
{ |
4676 |
public static XmlDocument xml = null; |
4677 |
public static double OffsetX = 0; |
4678 |
public static double OffsetY = 0; |
4679 |
public static double Scale = 0; |
4680 |
public static double getDrawing = 0; |
4681 |
public static List<string> Layers = new List<string>() { "MINOR", "INSTR", "ELECT", "INSTRUMENT", "LINES" }; |
4682 |
|
4683 |
static void Main(string[] args) |
4684 |
{ |
4685 |
/********************************************************************/ |
4686 |
/* Initialize Drawings.NET. */ |
4687 |
/********************************************************************/ |
4688 |
bool bSuccess = true; |
4689 |
Teigha.Runtime.Services.odActivate(ActivationData.userInfo, ActivationData.userSignature); |
4690 |
using (Teigha.Runtime.Services srv = new Teigha.Runtime.Services()) |
4691 |
{ |
4692 |
try |
4693 |
{ |
4694 |
HostApplicationServices.Current = new OdaMgdMViewApp.HostAppServ(); |
4695 |
/**********************************************************************/ |
4696 |
/* Display the Product and Version that created the executable */ |
4697 |
/**********************************************************************/ |
4698 |
Console.WriteLine("\nReadExMgd developed using {0} ver {1}", HostApplicationServices.Current.Product, HostApplicationServices.Current.VersionString); |
4699 |
|
4700 |
if (args.Length != 5) |
4701 |
{ |
4702 |
Console.WriteLine("\n\n\tusage: OdReadExMgd <filename> <OffsetX> <OffsetY> <Scale> <GenDrawing>"); |
4703 |
Console.WriteLine("\nPress ENTER to continue...\n"); |
4704 |
Console.ReadLine(); |
4705 |
bSuccess = false; |
4706 |
} |
4707 |
else |
4708 |
{ |
4709 |
Console.WriteLine("\n File Name = " + args[0]); |
4710 |
|
4711 |
double.TryParse(args[1], out Program.OffsetX); |
4712 |
double.TryParse(args[2], out Program.OffsetY); |
4713 |
double.TryParse(args[3], out Program.Scale); |
4714 |
double.TryParse(args[4], out Program.getDrawing); |
4715 |
Program.xml = new XmlDocument(); |
4716 |
{ |
4717 |
XmlNode root = xml.CreateElement("ID2"); |
4718 |
Program.xml.AppendChild(root); |
4719 |
|
4720 |
/******************************************************************/ |
4721 |
/* Create a database and load the drawing into it. |
4722 |
/* first parameter means - do not initialize database- it will be read from file |
4723 |
* second parameter is not used by Teigha.NET Classic - it is left for ARX compatibility. |
4724 |
* Note the 'using' clause - generally, wrappers should disposed after use, |
4725 |
* to close underlying database objects |
4726 |
/******************************************************************/ |
4727 |
using (Database pDb = new Database(false, false)) |
4728 |
{ |
4729 |
pDb.ReadDwgFile(args[0], FileShare.Read, true, ""); |
4730 |
HostApplicationServices.WorkingDatabase = pDb; |
4731 |
/****************************************************************/ |
4732 |
/* Display the File Version */ |
4733 |
/****************************************************************/ |
4734 |
Console.WriteLine("File Version: {0}", pDb.OriginalFileVersion); |
4735 |
/****************************************************************/ |
4736 |
/* Dump the database */ |
4737 |
/****************************************************************/ |
4738 |
DbDumper dumper = new DbDumper(); |
4739 |
dumper.ExplodeAndPurgeNestedBlocks(pDb); |
4740 |
if (Program.getDrawing == 1) |
4741 |
{ |
4742 |
dumper.ExportPNG(pDb, args[0]); |
4743 |
dumper.ExportPDF(pDb, args[0]); |
4744 |
} |
4745 |
|
4746 |
dumper.dump(pDb, 0, Program.xml.DocumentElement); |
4747 |
} |
4748 |
Program.xml.Save(Path.Combine(Path.GetDirectoryName(args[0]), Path.GetFileNameWithoutExtension(args[0]) + ".xml")); |
4749 |
} |
4750 |
} |
4751 |
} |
4752 |
/********************************************************************/ |
4753 |
/* Display the error */ |
4754 |
/********************************************************************/ |
4755 |
catch (System.Exception e) |
4756 |
{ |
4757 |
bSuccess = false; |
4758 |
Console.WriteLine("Teigha?NET for .dwg files Error: " + e.Message); |
4759 |
} |
4760 |
|
4761 |
if (bSuccess) |
4762 |
Console.WriteLine("OdReadExMgd Finished Successfully"); |
4763 |
} |
4764 |
} |
4765 |
} |
4766 |
} |