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