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