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