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