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