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