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