├── AutocadDwgReaderTest
├── AccoreconsoleLauncher
│ ├── AccoreconsoleLauncher.csproj
│ ├── App.config
│ ├── DebenuPDFLibraryDLL1113.cs
│ ├── LayoutScriptContent.cs
│ ├── LayoutScriptOptions.cs
│ ├── ModelScriptContent.cs
│ ├── ModelScriptOptions.cs
│ ├── PWPPDFMgr.cs
│ ├── PdfDocument.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ScriptContent.cs
│ ├── ScriptOptions.cs
│ └── TrueViewConsole.cs
├── AutocadConnector
│ ├── AutoCADDocument.cs
│ ├── AutocadConnector.csproj
│ ├── Connect.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── AutocadDwgReaderTest.sln
├── AutocadDwgReaderTest
│ ├── App.config
│ ├── AutocadDwgReaderTest.csproj
│ ├── EntryPoint.cs
│ ├── Enum.cs
│ ├── MainForm.Designer.cs
│ ├── MainForm.cs
│ ├── MainForm.resx
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ └── bin
│ │ └── Debug
│ │ ├── DebenuPDFLibrary64DLL1113.dll
│ │ ├── DebenuPDFLibraryDLL1113.dll
│ │ ├── MuPDF_Basic_Operation_Dll_1.dll
│ │ └── MuPDF_Basic_Operation_Dll_1.pdb
├── DwgTextExtracter
│ ├── DwgTextExtracter.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── TextExtracter.cs
├── DwgToPdfConverter
│ ├── DWGtoPDF.cs
│ ├── DwgToPdfConverter.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
├── JsonExporter
│ ├── AdnMeshData.cs
│ ├── AutoCADCustomJsonExporter.csproj
│ ├── CentroidVolume.cs
│ ├── Command.cs
│ ├── Converter.cs
│ ├── ExportContextAdnMesh.cs
│ ├── NormalLookupXyz.cs
│ ├── PointInt.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Util.cs
│ ├── VertexLookupInt.cs
│ ├── utils.cs
│ └── x.cs
└── Types
│ ├── IScriptOptions.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── Types.csproj
└── README.md
/AutocadDwgReaderTest/AccoreconsoleLauncher/AccoreconsoleLauncher.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}
8 | Library
9 | Properties
10 | AccoreconsoleLauncher
11 | AccoreconsoleLauncher
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | true
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 | true
24 | AnyCPU
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | False
37 | E:\Image Tile Service TFS\DLL\MuPDF_Dll_v1.6\x64\Debug\MuPDF_Basic_Operation_Dll_1.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ..\Types\bin\Debug\Types.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | Designer
66 |
67 |
68 |
69 |
76 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | c:\Temp
29 |
30 |
31 | 30000
32 |
33 |
34 |
35 |
36 |
37 | True
38 |
39 |
40 | c:\Temp\IN
41 |
42 |
43 | c:\Temp\OUT
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/DebenuPDFLibraryDLL1113.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amit-k-pathak/3D-Model-to-Pdf-Conversion-and-Text-Extraction/b2b55d093f86e116936c4d9e8a5ad4440a8593d0/AutocadDwgReaderTest/AccoreconsoleLauncher/DebenuPDFLibraryDLL1113.cs
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/LayoutScriptContent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AccoreconsoleLauncher
8 | {
9 | internal class LayoutScriptContent : ScriptContent
10 | {
11 | public LayoutScriptContent()
12 | {
13 |
14 | }
15 |
16 | public virtual string PrepareScript(LayoutScriptOptions opts)
17 | {
18 | string content = "";
19 |
20 | //Command:
21 | content += GetCommand();
22 |
23 | //Detailed plot configuration? [Yes/No] :
24 | content += opts.detailedPlotConfig;
25 |
26 | //Enter a layout name or [?] :
27 | content += "\"" + opts.modelOrLayoutName + "\"";
28 |
29 | //Enter an output device name or [?] :
30 | content += opts.outputDevice;
31 |
32 | //Enter paper size or [?] :
33 | content += opts.paperSize;
34 |
35 | //Enter paper units [Inches/Millimeters] :
36 | content += opts.paperUnits;
37 |
38 | //Enter drawing orientation [Portrait/Landscape] :
39 | content += opts.drawingOrientation;
40 |
41 | //Plot upside down? [Yes/No] :
42 | content += opts.plotUpsideDown;
43 |
44 | //Enter plot area [Display/Extents/Limits/View/Window/layout] :
45 | content += opts.plotArea;
46 |
47 | //Enter plot scale (Plotted Inches=Drawing Units) or [Fit] :
48 | content += opts.plotScale;
49 |
50 | //Enter plot offset (x,y)<0.00,0.00>:
51 | content += opts.plotOffset;
52 |
53 | //Plot with plot styles? [Yes/No] :
54 | content += opts.plotWithStyles;
55 |
56 | //Enter plot style table name or [?] (enter . for none) <>:
57 | content += opts.plotStyleTable;
58 |
59 | //Plot with lineweights? [Yes/No] :
60 | content += opts.plotWithLinewieghts;
61 |
62 | //Plot paper space first?[Yes/No] :
63 | content += opts._plotPaperSpaceFirst;
64 |
65 | //Hide paper space objects[Yes/No] :
66 | content += opts._plotPaperSpaceFirst;
67 |
68 | //Enter file name :
69 | content += opts.enterFileName;
70 |
71 | //Save changes to page setup? Or set shade plot quality? [Yes/No/Quality] :
72 | content += opts.saveChanges;
73 |
74 | //Proceed with plot [Yes/No] :
75 | content += opts.proceedWithplot;
76 |
77 | return content;
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/LayoutScriptOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Types;
7 |
8 | namespace AccoreconsoleLauncher
9 | {
10 | public class LayoutScriptOptions : ScriptOptions
11 | {
12 | public string _plotPaperSpaceFirst;
13 | public string _hidePaperSpaceObjects;
14 |
15 | public LayoutScriptOptions()
16 | {
17 |
18 | }
19 |
20 | public void SetOptions(string layoutName)
21 | {
22 | base.modelOrLayoutName = layoutName;
23 | base.detailedPlotConfig = "Yes";
24 | base.plotUpsideDown = "No";
25 | base.plotWithStyles = "Yes";
26 | base.plotStyleTable = ".";
27 | base.plotWithLinewieghts = "Yes";
28 | base.outputDevice = "DWG To PDF.pc3";
29 | base.paperSize = "ANSI expand A (8.50 x 11.00 Inches)";
30 | base.paperUnits = "Inches";
31 | base.drawingOrientation = "Landscape";
32 | base.plotArea = "Layout";
33 | base.plotScale = "Fit";
34 | base.plotOffset = "";
35 | base.enterFileName = "";
36 | base.saveChanges = "N";
37 | base.proceedWithplot = "Y";
38 | this._plotPaperSpaceFirst = "No";
39 | this._hidePaperSpaceObjects = "No";
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/ModelScriptContent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Types;
7 |
8 | namespace AccoreconsoleLauncher
9 | {
10 | internal class ModelScriptContent : ScriptContent
11 | {
12 | public ModelScriptContent()
13 | {
14 |
15 | }
16 |
17 | public virtual string PrepareScript(ModelScriptOptions opts)
18 | {
19 | string content = "";
20 |
21 | //Command:
22 | content += GetCommand();
23 |
24 | //Detailed plot configuration? [Yes/No] :
25 | content += opts.detailedPlotConfig;
26 |
27 | //Enter a layout name or [?] :
28 | content += "\"" + opts.modelOrLayoutName + "\"";
29 |
30 | //Enter an output device name or [?] :
31 | content += opts.outputDevice;
32 | //Enter paper size or [?] :
33 | content += opts.paperSize;
34 |
35 | //Enter paper units [Inches/Millimeters] :
36 | content += opts.paperUnits;
37 |
38 | //Enter drawing orientation [Portrait/Landscape] :
39 | content += opts.drawingOrientation;
40 |
41 | //Plot upside down? [Yes/No] :
42 | content += opts.plotUpsideDown;
43 |
44 | //Enter plot area [Display/Extents/Limits/View/Window] :
45 | content += opts.plotArea;
46 |
47 | //Enter plot scale (Plotted Inches=Drawing Units) or [Fit] :
48 | content += opts.plotScale;
49 |
50 | //Enter plot offset (x,y) or [Center] <0.00,0.00>:
51 | content += opts.plotOffset;
52 |
53 | //Plot with plot styles? [Yes/No] :
54 | content += opts.plotWithStyles;
55 |
56 | //Enter plot style table name or [?] (enter . for none) <>:
57 | content += opts.plotStyleTable;
58 |
59 | //Plot with lineweights? [Yes/No] :
60 | content += opts.plotWithLinewieghts;
61 |
62 | //Enter shade plot settings [As displayed/legacy Wireframe/legacy Hidden] :
63 | content += opts._shadePlotSettings;
64 |
65 | //Enter file name :
66 | content += opts.enterFileName;
67 |
68 | //Save changes to page setup? Or set shade plot quality? [Yes/No/Quality] :
69 | content += opts.saveChanges;
70 |
71 | //Proceed with plot [Yes/No] :
72 | content += opts.proceedWithplot;
73 |
74 | return content;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/ModelScriptOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Types;
7 |
8 | namespace AccoreconsoleLauncher
9 | {
10 | internal class ModelScriptOptions : ScriptOptions
11 | {
12 | public string _shadePlotSettings;
13 |
14 | public ModelScriptOptions()
15 | {
16 |
17 | }
18 |
19 | public void SetOptions(string modelName)
20 | {
21 | base.modelOrLayoutName = modelName;
22 | base.detailedPlotConfig = "Yes";
23 | base.plotUpsideDown = "No";
24 | base.plotWithStyles = "Yes";
25 | base.plotStyleTable = ".";
26 | base.plotWithLinewieghts = "Yes";
27 | base.outputDevice = "DWG To PDF.pc3";
28 | base.paperSize = "ANSI expand A (8.50 x 11.00 Inches)";
29 | base.paperUnits = "Inches";
30 | base.drawingOrientation = "Landscape";
31 | base.plotArea = "Extents";
32 | base.plotScale = "Fit";
33 | base.plotOffset = "Center";
34 | base.enterFileName = "";
35 | base.saveChanges = "N";
36 | base.proceedWithplot = "Y";
37 | this._shadePlotSettings = "As displayed";
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/PWPPDFMgr.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.Collections.Specialized;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Runtime.InteropServices;
10 | using System.Configuration;
11 |
12 |
13 | namespace PWPFileProcessingLib
14 | {
15 | public class PWPPDFMgr
16 | {
17 | private PDFLibrary pdfLib = new PDFLibrary(@"DebenuPDFLibrary64DLL1113.dll");
18 | private bool isLibraryLoaded = false;
19 | public PWPPDFMgr()
20 | {
21 |
22 | }
23 | ~PWPPDFMgr()
24 | {
25 | if(isLibraryLoaded == true)
26 | {
27 | pdfLib.ReleaseLibrary();
28 | isLibraryLoaded = false;
29 | }
30 | }
31 |
32 | private bool LoadPDFLib()
33 | {
34 | bool result = true;
35 | try
36 | {
37 | if (isLibraryLoaded == false)
38 | {
39 | if (pdfLib.LibraryLoaded())
40 | {
41 | // Create an instance of the class and give it the path to the DLL
42 | string LicKey = (!string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["DebenuLicenceKey"]) ? System.Configuration.ConfigurationSettings.AppSettings["DebenuLicenceKey"].ToString() : "jc8am89q6n57ue8q87xd7nt4y");
43 | pdfLib.UnlockKey(LicKey);
44 |
45 | if (pdfLib.Unlocked() == 0)
46 | {
47 | //LogManager.Trace("PWPPDFMgr::LoadPDFLib", TraceCategoryType.Error, "License unlock failed. Please update your key in the form1.cs source code", "");
48 | result = false;
49 | }
50 | else
51 | {
52 | isLibraryLoaded = true;
53 | }
54 | }
55 | else
56 | {
57 | //LogManager.Trace("PWPPDFMgr::LoadPDFLib", TraceCategoryType.Error, "Could not locate the Debenu PDF Library DLL, please check the path");
58 | result = false;
59 | }
60 | }
61 | }
62 | catch(Exception Ex)
63 | {
64 | //LogManager.Trace("PWPPDFMgr::LoadPDFLib", Ex1, "Could not locate the Debenu PDF Library DLL, please check the path");
65 | result = false;
66 | }
67 | return result;
68 | }
69 |
70 | public bool ExtractPDFPages(string srcpath, string destpath, int PagesCnt, out string err)//, int primaryid, int secondaryid, float ordinalNum)
71 | {
72 | bool result = false;
73 | int opsResult = -1;
74 | int FileHandle = -1;
75 | int count = PagesCnt;
76 | int errorcode = 0;
77 | err = "";
78 | try
79 | {
80 | if (isLibraryLoaded == false)
81 | {
82 | result = LoadPDFLib();
83 | if (result == false)
84 | {
85 | return result;
86 | }
87 | }
88 |
89 | //Page count is 0 - findout at runtime page count
90 | if (PagesCnt == -1)
91 | {
92 | FileHandle = pdfLib.DAOpenFileReadOnly(srcpath, "");
93 | if (FileHandle == 0)
94 | {
95 | errorcode = pdfLib.LastErrorCode();
96 | err += "Debenu Error Code " + errorcode;
97 | //LogManager.Trace("PWPPDFMgr::ExtractPDFPages", TraceCategoryType.Error, "DAOpenFileReadOnly failed - Unable to open file-srcpath", srcpath, "errorcode", errorcode.ToString());
98 | return result;
99 | }
100 | count = pdfLib.DAGetPageCount(FileHandle);
101 |
102 | if (FileHandle != -1)
103 | {
104 | pdfLib.DACloseFile(FileHandle);
105 | }
106 | }
107 |
108 |
109 | string pagefilename = string.Empty;
110 | string pagewisepath = string.Empty;
111 | string pagesRange = string.Empty;
112 | //PWPDocumentInfo docpageInfo = null;
113 |
114 | if(!Directory.Exists(Path.Combine(destpath, Path.GetFileName(srcpath))))
115 | {
116 | Directory.CreateDirectory(Path.Combine(destpath, Path.GetFileNameWithoutExtension(srcpath) ));
117 | pagefilename = Path.Combine(destpath, Path.GetFileNameWithoutExtension(srcpath));
118 | }
119 |
120 | for (int idx = 1; idx <= count; idx++)
121 | {
122 | pagewisepath = string.Empty;
123 | pagesRange = string.Empty;
124 |
125 | pagewisepath = Path.Combine(pagefilename, "Page_" + idx + ".pdf");
126 | pagesRange = idx.ToString() + "-" + idx.ToString();
127 | opsResult = pdfLib.ExtractFilePages(srcpath, "", pagewisepath, pagesRange);
128 | if (opsResult == 0)
129 | {
130 | errorcode = pdfLib.LastErrorCode();
131 | err += "Debenu Error Code " + errorcode;
132 | break;
133 | }
134 | }
135 | }
136 | catch(Exception ex)
137 | {
138 | result = false;
139 | err += ex.Message;
140 | }
141 | return result;
142 | }
143 |
144 | public bool MergePDFFiles(List pdfFiles, string outPdfFileName, out string err)
145 | {
146 | bool result = false;
147 | int count = 0;
148 | err = "";
149 |
150 | try
151 | {
152 | if (isLibraryLoaded == false)
153 | {
154 | result = LoadPDFLib();
155 | if (result == false)
156 | {
157 | return result;
158 | }
159 | }
160 |
161 | if (pdfFiles != null)
162 | {
163 | foreach (string fileName in pdfFiles)
164 | pdfLib.AddToFileList("PDFList", fileName);
165 |
166 | if (string.IsNullOrWhiteSpace(outPdfFileName))
167 | outPdfFileName = "MergedPdf.pdf";
168 |
169 | count = pdfLib.MergeFileList("PDFList", Path.Combine(Path.GetDirectoryName(pdfFiles[0]), outPdfFileName));
170 |
171 |
172 | //int FileHandle = pdfLib.DAOpenFileReadOnly(Path.Combine(Path.GetDirectoryName(pdfFiles[0]), outPdfFileName), "");
173 | //if (FileHandle == 0)
174 | //{
175 | // err += "Debenu Error Code " + pdfLib.LastErrorCode().ToString();
176 | // //LogManager.Trace("PWPPDFMgr::ExtractPDFPages", TraceCategoryType.Error, "DAOpenFileReadOnly failed - Unable to open file-srcpath", srcpath, "errorcode", errorcode.ToString());
177 | // return result;
178 | //}
179 |
180 | //pdfLib.ClearPageLabels();
181 | //pdfLib.AddPageLabels(0, 2, 1, "Page ");
182 |
183 | //if (FileHandle != -1)
184 | //{
185 | // pdfLib.DACloseFile(FileHandle);
186 | //}
187 |
188 | result = (count == pdfFiles.Count);
189 | }
190 | }
191 | catch (Exception ex)
192 | {
193 | err += ex.Message + "\n";
194 | err += pdfLib.LastErrorCode();
195 | }
196 | return result;
197 | }
198 |
199 | public bool ExtractAllTextFromDwg(string inPdfFileName, string outTxtFileName, out string err)
200 | {
201 | bool result = false;
202 | string annotType = "";
203 | string contents = "";
204 | err = "";
205 |
206 | try
207 | {
208 | if (isLibraryLoaded == false)
209 | {
210 | result = LoadPDFLib();
211 | if (result == false)
212 | {
213 | return result;
214 | }
215 | }
216 |
217 | int docId = pdfLib.LoadFromFile(inPdfFileName, "");
218 |
219 | if (docId == 0) //failed
220 | {
221 | err += pdfLib.LastErrorCode();
222 | return false;
223 | }
224 |
225 | pdfLib.SelectDocument(docId);
226 |
227 | for (int pageNo = 1; pageNo <= pdfLib.PageCount(); ++pageNo) //Model contains no text
228 | {
229 | pdfLib.SelectPage(pageNo);
230 |
231 | for (int i = 1; i < pdfLib.AnnotationCount(); ++i)
232 | {
233 | annotType = pdfLib.GetAnnotStrProperty(i, 101);
234 |
235 | if (annotType.Equals("Square"))
236 | {
237 | contents += pdfLib.GetAnnotStrProperty(i, 102) + "\n"; //102 = contents
238 | }
239 | }
240 | }
241 |
242 | if (!string.IsNullOrWhiteSpace(contents))
243 | {
244 | File.WriteAllText(outTxtFileName, contents);
245 | }
246 | }
247 | catch (Exception ex)
248 | {
249 | err += ex.Message + "\n";
250 | err += pdfLib.LastErrorCode();
251 | }
252 | return result;
253 | }
254 | }
255 |
256 | }
257 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/PdfDocument.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace AccoreconsoleLauncher
10 | {
11 | public class PdfDocument
12 | {
13 | protected int fileIndex;
14 |
15 | #region Structs and Enums
16 |
17 | protected unsafe struct DllPageOutput
18 | {
19 | public byte* img_data;
20 | public int img_width;
21 | public int img_height;
22 | public int img_n;
23 | public int totalNumberofPages;
24 | public int numberAnnotations;
25 | public float resolution;
26 | public int rectangleX0;
27 | public int rectangleY0;
28 | public int rectangleX1;
29 | public int rectangleY1;
30 | public int flag;
31 | }
32 |
33 | protected struct UIRenderParameters
34 | {
35 | public float resolution;
36 | public int rectangleX0;
37 | public int rectangleY0;
38 | public int rectangleX1;
39 | public int rectangleY1;
40 | }
41 |
42 | protected enum TileDimension : int
43 | {
44 | TILE512 = 512,
45 | TILE1024 = 1024,
46 | TILE2048 = 2048,
47 | TILE4096 = 4096,
48 | TILE8192 = 8192
49 | };
50 |
51 | public struct fz_rect
52 | {
53 | public float x0, y0;
54 | public float x1, y1;
55 | }
56 |
57 | protected unsafe struct copyInformation
58 | {
59 | public char *copyStr;
60 | public int length;
61 | };
62 |
63 | private enum ERROR : int
64 | {
65 | MUPDF_SUCCESS = 0,
66 |
67 | MUPDF_ABNORMAL_TERMINATION = -1,
68 |
69 | MUPDF_ERROR_DLL_INITIALIZATION_FAILED = -2,
70 |
71 | MUPDF_ERROR_FILE_NOT_FOUND = -3,
72 |
73 | MUPDF_ERROR_FILE_OPENING_FAILED = -4,
74 |
75 | MUPDF_ERROR_FILE_FORMAT_UNKNOWN = -5,
76 |
77 | MUPDF_ERROR_FILE_IS_CORRUPT = -6,
78 |
79 | MUPDF_ERROR_FILE_PASSWORD_PROTECTED = -7,
80 |
81 | MUPDF_ERROR_PAGE_NOT_FOUND = -8,
82 |
83 | MUPDF_ERROR_FILE_SAVING_FAILED = -9
84 | }
85 |
86 | //protected enum DocumentType : int
87 | //{
88 | // NONE = 0,
89 | // DRAWING = 1,
90 | // SPECS = 2
91 | //}
92 |
93 | //protected enum Rotation : int
94 | //{
95 | // None = 0,
96 | // Rotate90ClockWise = 90,
97 | // Rotate90AntiClockWise = -90
98 | //}
99 |
100 | #endregion
101 |
102 | #region DLL entry point functions
103 |
104 | private const string DLL = "MuPDF_Basic_Operation_Dll_1.dll";
105 |
106 | [DllImport(DLL, EntryPoint = "initializeDll")]
107 | private static extern ERROR initializeDll();
108 |
109 | [DllImport(DLL, EntryPoint = "createPdfReference")]
110 | private static extern ERROR createPdfReference(int pdfFileIndex, char[] fileName);
111 |
112 | [DllImport(DLL, EntryPoint = "loadPdfPage")]
113 | private static extern ERROR loadPdfPage(int pdfFileIndex, int pageNumber);
114 |
115 | [DllImport(DLL, EntryPoint = "countPage")]
116 | private unsafe static extern int countPage(int pdfFileIndex);
117 |
118 | [DllImport(DLL, EntryPoint = "closeDocument")]
119 | private static extern void closeDocument(int pdfFileIndex);
120 |
121 | [DllImport(DLL, EntryPoint = "extractAndSaveText")]
122 | private static extern ERROR extractAndSaveText(char[] fileName, int pdfFileNumber, fz_rect rect);
123 |
124 | [DllImport(DLL, EntryPoint = "getDefaultPdfPageDimension")]
125 | protected static extern fz_rect getDefaultPdfPageDimension(int pdfFileIndex, int pageNumber);
126 |
127 | [DllImport(DLL, EntryPoint = "loadPdfPageForTiles")]
128 | protected static extern int loadPdfPageForTiles(int pdfFileIndex, int pageNumber);
129 |
130 | [DllImport(DLL, EntryPoint = "renderPdfPage")]
131 | protected unsafe static extern DllPageOutput renderPdfPage(int pdfFileIndex, int pageNumber, UIRenderParameters* input);
132 |
133 | [DllImport(DLL, EntryPoint = "mergePdfFiles")]
134 | private static extern ERROR mergePdfFiles(char[] fileName, int numDocs);
135 |
136 | #endregion
137 |
138 | #region Public Methods
139 |
140 | public PdfDocument()
141 | {
142 | this.fileIndex = 0;
143 | }
144 |
145 | private int getDllPdfIndex()
146 | {
147 | return fileIndex; //increment not required as it's not multithreaded
148 | }
149 |
150 | public void InitDll()
151 | {
152 | ERROR err;
153 | err = (ERROR)initializeDll();
154 |
155 | if (err == ERROR.MUPDF_ERROR_DLL_INITIALIZATION_FAILED)
156 | {
157 | Console.Error.WriteLine("MUPDF ERROR : Failed to initialise Dll...");
158 | throw new Exception("Failed to initialise Dll...\n");
159 | }
160 | }
161 |
162 | public int LoadPdfDocument(string pdfFileName)
163 | {
164 | ERROR err;
165 | int dllPdfIndex = getDllPdfIndex();
166 |
167 | err = (ERROR)createPdfReference(dllPdfIndex, (pdfFileName + "\0").ToCharArray());
168 |
169 |
170 | switch (err)
171 | {
172 | case ERROR.MUPDF_ERROR_FILE_NOT_FOUND:
173 | Console.Error.WriteLine("MUPDF ERROR : PDF File not found..." + pdfFileName);
174 | throw new Exception("PDF File not found..." + pdfFileName);
175 |
176 | case ERROR.MUPDF_ERROR_FILE_FORMAT_UNKNOWN:
177 | Console.Error.WriteLine("MUPDF ERROR : PDF Loading failed : Unrecognized format or File formatting Error in file..." + pdfFileName);
178 | throw new Exception("Unrecognized format or File formatting Error..." + pdfFileName);
179 |
180 | case ERROR.MUPDF_ERROR_FILE_OPENING_FAILED:
181 | case ERROR.MUPDF_ERROR_FILE_IS_CORRUPT:
182 | Console.Error.WriteLine("MUPDF ERROR : PDF Loading failed : File is corrupt..." + pdfFileName);
183 | throw new Exception("Can not open pdf document..." + pdfFileName);
184 |
185 | case ERROR.MUPDF_ERROR_FILE_PASSWORD_PROTECTED:
186 | Console.Error.WriteLine("MUPDF ERROR : PDF Loading failed : PDF File is password protected : " + pdfFileName);
187 | throw new Exception("Can not open pdf document..." + pdfFileName);
188 |
189 | }
190 |
191 | return dllPdfIndex;
192 | }
193 |
194 | public void LoadPdfPage(int dllPdfIndex, string pdfFileName, int pageNumber)
195 | {
196 | ERROR err;
197 |
198 | err = (ERROR)loadPdfPage(dllPdfIndex, pageNumber);
199 |
200 | if (err == ERROR.MUPDF_ERROR_PAGE_NOT_FOUND)
201 | {
202 | Console.Error.WriteLine("MUPDF ERROR : PDF Page Load failed : Specified Pagenumber: " + pageNumber + " not found in file " + pdfFileName);
203 | throw new Exception("Specified Pagenumber: " + pageNumber + " not found in file :" + pdfFileName + "\n");
204 | }
205 | }
206 |
207 | public fz_rect GetPageDimension(int dllPdfIndex, int pageNumber)
208 | {
209 | fz_rect pageRect;
210 | pageRect = getDefaultPdfPageDimension(dllPdfIndex, pageNumber);
211 | return pageRect;
212 | }
213 |
214 | public int GetTotalPageCount(int dllPdfIndex)
215 | {
216 | return countPage(dllPdfIndex);
217 | }
218 |
219 | public void GetAllText(int dllPdfIndex, string savePath, fz_rect pageRect)
220 | {
221 | ERROR err;
222 | err = extractAndSaveText((savePath + "\0").ToCharArray(), dllPdfIndex, pageRect);
223 |
224 | if (err == ERROR.MUPDF_ABNORMAL_TERMINATION)
225 | {
226 | //throw new Exception("Failed to extract text from pdf file...");
227 | }
228 | }
229 |
230 | public void MergePdfFiles(List pdfFilesToMerge, string outPdfFileName)
231 | {
232 | ERROR err;
233 |
234 | err = mergePdfFiles((pdfFilesToMerge[0] + "\0").ToCharArray(), 1);
235 |
236 | if (err == ERROR.MUPDF_ABNORMAL_TERMINATION)
237 | {
238 | throw new Exception("Merging Failed...");
239 | }
240 | }
241 |
242 | public void SplitPdf(string pdfFileName, int fromPage, int toPage)
243 | {
244 | //To-Do
245 | }
246 |
247 | public void ClosePdfDocument(int dllPdfIndex)
248 | {
249 | closeDocument(dllPdfIndex);
250 | }
251 |
252 | #endregion
253 | }
254 | }
255 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AccoreconsoleLauncher")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("SELF")]
12 | [assembly: AssemblyProduct("AccoreconsoleLauncher")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8c23f56f-e5a1-4f5f-8f89-05fbd44550d4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/ScriptContent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Types;
7 |
8 | namespace AccoreconsoleLauncher
9 | {
10 | internal class ScriptContent
11 | {
12 | private string _command;
13 | private ApplicationType _appType;
14 | private DWGPageType _pageType;
15 |
16 | public ScriptContent()
17 | {
18 |
19 | }
20 |
21 | public ScriptContent(ApplicationType type)
22 | {
23 | this._appType = type;
24 | }
25 |
26 | public void SetCommand(string cmd)
27 | {
28 | if (!string.IsNullOrWhiteSpace(cmd))
29 | this._command = cmd;
30 | else
31 | {
32 | this._command = (this._appType == ApplicationType.DWGTrueView) ? "_PLOT" : "-PLOT"; //default is plot command
33 | }
34 | }
35 |
36 | public string GetCommand()
37 | {
38 | return this._command;
39 | }
40 |
41 | public virtual string PrepareScript(ScriptOptions opts)
42 | {
43 | return "";
44 | }
45 | }
46 |
47 | public enum ApplicationType
48 | {
49 | DWGTrueView,
50 | AutoCAD2016
51 | }
52 |
53 | public enum DWGPageType
54 | {
55 | Model,
56 | Layout
57 | }
58 |
59 | public enum OperationType
60 | {
61 | PlotPdf,
62 | ExtratAllText
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AccoreconsoleLauncher/ScriptOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Types;
7 |
8 | namespace AccoreconsoleLauncher
9 | {
10 | public class ScriptOptions : IScriptOptions
11 | {
12 | public string drawingOrientation
13 | {
14 | get
15 | {
16 | return drawingOrientation;
17 | }
18 | set
19 | {
20 | this.drawingOrientation = value;
21 | }
22 | }
23 |
24 | public string outputDevice
25 | {
26 | get
27 | {
28 | return outputDevice;
29 | }
30 | set
31 | {
32 | this.outputDevice = value;
33 | }
34 | }
35 |
36 | public string paperSize
37 | {
38 | get
39 | {
40 | return paperSize;
41 | }
42 | set
43 | {
44 | this.paperSize = value;
45 | }
46 | }
47 |
48 | public string paperUnits
49 | {
50 | get
51 | {
52 | return paperUnits;
53 | }
54 | set
55 | {
56 | this.paperUnits = value;
57 | }
58 | }
59 |
60 | public string plotArea
61 | {
62 | get
63 | {
64 | return plotArea;
65 | }
66 | set
67 | {
68 | this.plotArea = value;
69 | }
70 | }
71 |
72 | public string plotOffset
73 | {
74 | get
75 | {
76 | return plotOffset;
77 | }
78 | set
79 | {
80 | this.plotOffset = value;
81 | }
82 | }
83 |
84 | public string plotScale
85 | {
86 | get
87 | {
88 | return plotScale;
89 | }
90 | set
91 | {
92 | this.plotScale = value;
93 | }
94 | }
95 |
96 | public string detailedPlotConfig
97 | {
98 | get
99 | {
100 | return detailedPlotConfig;
101 | }
102 | set
103 | {
104 | this.detailedPlotConfig = value;
105 | }
106 | }
107 |
108 | public string enterFileName
109 | {
110 | get
111 | {
112 | return enterFileName;
113 | }
114 | set
115 | {
116 | this.enterFileName = value;
117 | }
118 | }
119 |
120 | public string plotStyleTable
121 | {
122 | get
123 | {
124 | return plotStyleTable;
125 | }
126 | set
127 | {
128 | this.plotStyleTable = value;
129 | }
130 | }
131 |
132 | public string plotUpsideDown
133 | {
134 | get
135 | {
136 | return plotUpsideDown;
137 | }
138 | set
139 | {
140 | this.plotUpsideDown = value;
141 | }
142 | }
143 |
144 | public string plotWithLinewieghts
145 | {
146 | get
147 | {
148 | return plotWithLinewieghts;
149 | }
150 | set
151 | {
152 | this.plotWithLinewieghts = value;
153 | }
154 | }
155 |
156 | public string plotWithStyles
157 | {
158 | get
159 | {
160 | return plotWithStyles;
161 | }
162 | set
163 | {
164 | this.plotWithStyles = value;
165 | }
166 | }
167 |
168 | public string proceedWithplot
169 | {
170 | get
171 | {
172 | return proceedWithplot;
173 | }
174 | set
175 | {
176 | this.proceedWithplot = value;
177 | }
178 | }
179 |
180 | public string saveChanges
181 | {
182 | get
183 | {
184 | return saveChanges;
185 | }
186 | set
187 | {
188 | this.saveChanges = value;
189 | }
190 | }
191 |
192 |
193 | public string modelOrLayoutName
194 | {
195 | get
196 | {
197 | return modelOrLayoutName;
198 | }
199 | set
200 | {
201 | this.modelOrLayoutName = value;
202 | }
203 | }
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadConnector/AutoCADDocument.cs:
--------------------------------------------------------------------------------
1 | using Autodesk.AutoCAD.Interop;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AutocadConnector
9 | {
10 | public class AutoCADDocument
11 | {
12 | private Connector _connector;
13 | private AcadDocument _doc;
14 |
15 | public AutoCADDocument()
16 | {
17 | this._connector = null;
18 | this._doc = null;
19 | }
20 |
21 | public void OpenDocument(string fileName)
22 | {
23 | AcadApplication app = null;
24 |
25 | try
26 | {
27 | this._connector = new Connector();
28 | app = _connector.GetAcadApplication();
29 | this._doc = app.Documents.Open(fileName, Type.Missing, Type.Missing);
30 | }
31 | catch (Exception ex)
32 | {
33 | throw ex;
34 | }
35 | finally
36 | {
37 | app = null;
38 | this._connector = null;
39 | }
40 | }
41 |
42 | public void CloseDocument()
43 | {
44 | try
45 | {
46 | if (!(_doc == null))
47 | {
48 | _doc.Close(Type.Missing, Type.Missing);
49 | }
50 | }
51 | catch (Exception ex)
52 | {
53 | throw ex;
54 | }
55 | finally
56 | {
57 | this._connector = null;
58 | this._doc = null;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadConnector/AutocadConnector.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}
8 | Library
9 | Properties
10 | AutocadConnector
11 | AutocadConnector
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcCoreMgd.dll
35 | False
36 |
37 |
38 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc-x64\Autodesk.AutoCAD.Interop.dll
39 | True
40 |
41 |
42 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc-x64\Autodesk.AutoCAD.Interop.Common.dll
43 | True
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadConnector/Connect.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Configuration;
3 | using System.Runtime.InteropServices;
4 | using Autodesk.AutoCAD.Runtime;
5 | using Autodesk.AutoCAD.ApplicationServices;
6 | using Autodesk.AutoCAD.Interop;
7 | using System.Reflection;
8 | using Autodesk.AutoCAD.ApplicationServices.Core;
9 | using System.Collections.Generic;
10 |
11 | namespace AutocadConnector
12 | {
13 | public class Connector
14 | {
15 | AcadApplication _acAppComObj;
16 | string _strProgId;
17 | string _customDllPath;
18 | bool _isAssemblyLoaded;
19 |
20 | public Connector()
21 | {
22 | this._acAppComObj = null;
23 | this._strProgId = "";
24 | this._customDllPath = "";
25 | this._isAssemblyLoaded = false;
26 | }
27 |
28 | // Read configs
29 | private void ReadConfig()
30 | {
31 | try
32 | {
33 | this._strProgId = (ConfigurationSettings.AppSettings["ProgramId"] == null) ? "AutoCAD.Application" : ConfigurationSettings.AppSettings["ProgramId"]; // autocad application
34 | this._customDllPath = (ConfigurationSettings.AppSettings["CustomDllPath"] == null) ? "" : ConfigurationSettings.AppSettings["CustomDllPath"]; // add your dll path here
35 | }
36 | catch (Exception ex)
37 | {
38 | throw ex;
39 | }
40 | }
41 |
42 | public void SetCustomDllPath(string path)
43 | {
44 | this._customDllPath = path;
45 | }
46 |
47 | private void GetRunningAutoCADInstance()
48 | {
49 | _acAppComObj = (AcadApplication)Marshal.GetActiveObject(_strProgId);
50 | }
51 |
52 | private void StartNewAutoCADInstance()
53 | {
54 | _acAppComObj = (AcadApplication)Activator.CreateInstance(Type.GetTypeFromProgID(_strProgId), true);
55 | }
56 |
57 | public AcadDocument GetActiveDocument()
58 | {
59 | return !(_acAppComObj == null) ? _acAppComObj.ActiveDocument : null;
60 | }
61 |
62 | public void LoadCustomAssemblyIntoAutoCAD(AcadDocument doc)
63 | {
64 | try
65 | {
66 | if (!this._isAssemblyLoaded)
67 | {
68 | doc.SendCommand("(command " + (char)34 + "NETLOAD" + (char)34 + " " + (char)34 + _customDllPath + (char)34 + ") ");
69 | this._isAssemblyLoaded = true;
70 | }
71 | }
72 | catch (Exception ex)
73 | {
74 | this._isAssemblyLoaded = false;
75 | throw ex;
76 | }
77 | }
78 |
79 | public void SendCommand(AcadDocument doc, string command)
80 | {
81 | try
82 | {
83 | doc.SendCommand(command);
84 | }
85 | catch (Exception ex)
86 | {
87 | throw ex;
88 | }
89 | }
90 |
91 | public bool ConnectToAutoCAD(out string info)
92 | {
93 | bool isStarted = false;
94 | info = "";
95 |
96 | try
97 | {
98 | ReadConfig();
99 |
100 | // Get a running instance of AutoCAD
101 | GetRunningAutoCADInstance();
102 | isStarted = true;
103 | }
104 | catch // An error occurs if no instance is running
105 | {
106 | try
107 | {
108 | // Create a new instance of AutoCAD
109 | StartNewAutoCADInstance();
110 | isStarted = true;
111 | }
112 | catch (Exception exc)
113 | {
114 | // If an instance of AutoCAD is not created then message and return
115 | info = "Instance of 'AutoCAD.Application'" + " could not be created." + "\n" + exc.Message;
116 | isStarted = false;
117 | throw exc;
118 | }
119 | }
120 |
121 | if (isStarted == true)
122 | {
123 | // Display the application and return the name and version
124 | _acAppComObj.Visible = true;
125 | info = "Now running " + _acAppComObj.Name + " version " + _acAppComObj.Version;
126 | }
127 | return isStarted;
128 |
129 | // Get the active document
130 | //GetActiveDocument();
131 |
132 | // Optionally, load your assembly and start your command or if your assembly
133 | // is demandloaded, simply start the command of your in-process assembly.
134 | }
135 |
136 | public AcadApplication GetAcadApplication()
137 | {
138 | return _acAppComObj;
139 | }
140 |
141 | public void CloseApplication()
142 | {
143 | try
144 | {
145 | foreach (AcadDocument doc in _acAppComObj.Documents)
146 | {
147 | doc.Close();
148 | }
149 | _acAppComObj = null;
150 | }
151 | catch (Exception ex)
152 | {
153 | throw ex;
154 | }
155 | finally
156 | {
157 | _acAppComObj = null;
158 | }
159 | }
160 |
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadConnector/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AutocadConnector")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AutocadConnector")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8b43b419-f13d-4683-9e01-038623dabf06")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutocadDwgReaderTest", "AutocadDwgReaderTest\AutocadDwgReaderTest.csproj", "{BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {97B91107-C4DC-435A-858A-F5DF8A31D312} = {97B91107-C4DC-435A-858A-F5DF8A31D312}
7 | {3A5D6519-A518-492C-BEB8-2F15001D4451} = {3A5D6519-A518-492C-BEB8-2F15001D4451}
8 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E} = {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}
9 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C} = {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}
10 | {F3977977-DDC8-4869-A8EA-66BF8386FF06} = {F3977977-DDC8-4869-A8EA-66BF8386FF06}
11 | EndProjectSection
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DwgFileReader", "DwgFileReader\DwgFileReader.csproj", "{97B91107-C4DC-435A-858A-F5DF8A31D312}"
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DwgTextExtracter", "DwgTextExtracter\DwgTextExtracter.csproj", "{F3977977-DDC8-4869-A8EA-66BF8386FF06}"
16 | EndProject
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutocadConnector", "AutocadConnector\AutocadConnector.csproj", "{C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccoreconsoleLauncher", "AccoreconsoleLauncher\AccoreconsoleLauncher.csproj", "{FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}"
20 | ProjectSection(ProjectDependencies) = postProject
21 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD} = {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}
22 | EndProjectSection
23 | EndProject
24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoCADCustomJsonExporter", "JsonExporter\AutoCADCustomJsonExporter.csproj", "{4EFE4654-706B-42E1-A88C-D71E2B34F66F}"
25 | EndProject
26 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DwgToPdfConverter", "DwgToPdfConverter\DwgToPdfConverter.csproj", "{3A5D6519-A518-492C-BEB8-2F15001D4451}"
27 | EndProject
28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Types", "Types\Types.csproj", "{E7957AFD-CD65-4229-842B-2E73F9DEF7AD}"
29 | EndProject
30 | Global
31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
32 | Debug|Any CPU = Debug|Any CPU
33 | Debug|x64 = Debug|x64
34 | Release|Any CPU = Release|Any CPU
35 | Release|x64 = Release|x64
36 | EndGlobalSection
37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
38 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Debug|x64.ActiveCfg = Debug|x64
41 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Debug|x64.Build.0 = Debug|x64
42 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Release|x64.ActiveCfg = Release|x64
45 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}.Release|x64.Build.0 = Release|x64
46 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Debug|x64.ActiveCfg = Debug|x64
49 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Debug|x64.Build.0 = Debug|x64
50 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Release|x64.ActiveCfg = Release|x64
53 | {97B91107-C4DC-435A-858A-F5DF8A31D312}.Release|x64.Build.0 = Release|x64
54 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}.Debug|x64.ActiveCfg = Debug|Any CPU
57 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}.Release|Any CPU.Build.0 = Release|Any CPU
59 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}.Release|x64.ActiveCfg = Release|Any CPU
60 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}.Debug|x64.ActiveCfg = Debug|Any CPU
63 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
64 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}.Release|Any CPU.Build.0 = Release|Any CPU
65 | {C244C01E-A5B6-4BE3-A779-D9F1B6F67A0E}.Release|x64.ActiveCfg = Release|Any CPU
66 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}.Debug|Any CPU.Build.0 = Debug|Any CPU
68 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}.Debug|x64.ActiveCfg = Debug|Any CPU
69 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}.Release|Any CPU.ActiveCfg = Release|Any CPU
70 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}.Release|Any CPU.Build.0 = Release|Any CPU
71 | {FBFB1E2A-10D6-44D2-B1FF-1B3D025A576C}.Release|x64.ActiveCfg = Release|Any CPU
72 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}.Debug|Any CPU.Build.0 = Debug|Any CPU
74 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}.Debug|x64.ActiveCfg = Debug|Any CPU
75 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}.Release|Any CPU.ActiveCfg = Release|Any CPU
76 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}.Release|Any CPU.Build.0 = Release|Any CPU
77 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}.Release|x64.ActiveCfg = Release|Any CPU
78 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Debug|Any CPU.Build.0 = Debug|Any CPU
80 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Debug|x64.ActiveCfg = Debug|x64
81 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Debug|x64.Build.0 = Debug|x64
82 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Release|Any CPU.ActiveCfg = Release|Any CPU
83 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Release|Any CPU.Build.0 = Release|Any CPU
84 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Release|x64.ActiveCfg = Release|x64
85 | {3A5D6519-A518-492C-BEB8-2F15001D4451}.Release|x64.Build.0 = Release|x64
86 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
88 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}.Debug|x64.ActiveCfg = Debug|Any CPU
89 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
90 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}.Release|Any CPU.Build.0 = Release|Any CPU
91 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}.Release|x64.ActiveCfg = Release|Any CPU
92 | EndGlobalSection
93 | GlobalSection(SolutionProperties) = preSolution
94 | HideSolutionNode = FALSE
95 | EndGlobalSection
96 | EndGlobal
97 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/AutocadDwgReaderTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BDC9A824-C84F-4D7C-B642-7ACC0FD8EBF3}
8 | WinExe
9 | Properties
10 | AutocadDwgReaderTest
11 | AutocadDwgReaderTest
12 | v4.5
13 | 512
14 |
15 |
16 | x64
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 | true
36 | bin\x64\Debug\
37 | DEBUG;TRACE
38 | full
39 | x64
40 | prompt
41 | MinimumRecommendedRules.ruleset
42 | true
43 |
44 |
45 | bin\x64\Release\
46 | TRACE
47 | true
48 | pdbonly
49 | x64
50 | prompt
51 | MinimumRecommendedRules.ruleset
52 | true
53 |
54 |
55 |
56 | ..\AccoreconsoleLauncher\bin\Debug\AccoreconsoleLauncher.dll
57 |
58 |
59 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcCoreMgd.dll
60 | False
61 |
62 |
63 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcDbMgd.dll
64 | False
65 |
66 |
67 | ..\AutocadConnector\bin\Debug\AutocadConnector.dll
68 | False
69 |
70 |
71 | ..\DwgFileReader\bin\Debug\DwgFileReader.dll
72 | False
73 |
74 |
75 | ..\DwgToPdfConverter\bin\Debug\DwgToPdfConverter.dll
76 | False
77 |
78 |
79 | E:\Image Tile Service TFS\DLL\MuPDF_Dll_v1.6\x64\Debug\MuPDF_Basic_Operation_Dll_1.dll
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | Form
96 |
97 |
98 | MainForm.cs
99 |
100 |
101 |
102 |
103 | MainForm.cs
104 |
105 |
106 | ResXFileCodeGenerator
107 | Resources.Designer.cs
108 | Designer
109 |
110 |
111 | True
112 | Resources.resx
113 |
114 |
115 | SettingsSingleFileGenerator
116 | Settings.Designer.cs
117 |
118 |
119 | True
120 | Settings.settings
121 | True
122 |
123 |
124 |
125 |
126 |
127 |
128 |
135 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/EntryPoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace AutocadDwgReaderTest
8 | {
9 | static class EntryPoint
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new MainForm());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/Enum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AutocadDwgReaderTest
8 | {
9 | public enum LogMessageType
10 | {
11 | Error,
12 | Information
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace AutocadDwgReaderTest
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.menuStrip = new System.Windows.Forms.MenuStrip();
32 | this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
33 | this.openDwgFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
34 | this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
35 | this.convertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
36 | this.convertToPDFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
37 | this.convertToMultisheetPDFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
38 | this.mergePDFsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
39 | this.connectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
40 | this.connectToAutoCADToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
41 | this.launchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
42 | this.accToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
43 | this.exitToolStripMainMenu = new System.Windows.Forms.ToolStripMenuItem();
44 | this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
45 | this.listBoxFileContents = new System.Windows.Forms.ListBox();
46 | this.buttonSaveLog = new System.Windows.Forms.Button();
47 | this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
48 | this.extractAllVectorContentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
49 | this.menuStrip.SuspendLayout();
50 | this.SuspendLayout();
51 | //
52 | // menuStrip
53 | //
54 | this.menuStrip.BackColor = System.Drawing.SystemColors.ActiveCaption;
55 | this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
56 | this.fileToolStripMenuItem,
57 | this.convertToolStripMenuItem,
58 | this.connectToolStripMenuItem,
59 | this.launchToolStripMenuItem,
60 | this.exitToolStripMainMenu});
61 | this.menuStrip.Location = new System.Drawing.Point(0, 0);
62 | this.menuStrip.Name = "menuStrip";
63 | this.menuStrip.Size = new System.Drawing.Size(742, 24);
64 | this.menuStrip.TabIndex = 0;
65 | this.menuStrip.Text = "menuStrip";
66 | //
67 | // fileToolStripMenuItem
68 | //
69 | this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
70 | this.openDwgFileToolStripMenuItem,
71 | this.exitToolStripMenuItem});
72 | this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
73 | this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
74 | this.fileToolStripMenuItem.Text = "File";
75 | //
76 | // openDwgFileToolStripMenuItem
77 | //
78 | this.openDwgFileToolStripMenuItem.Name = "openDwgFileToolStripMenuItem";
79 | this.openDwgFileToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
80 | this.openDwgFileToolStripMenuItem.Text = "Open Dwg/Dxf File";
81 | this.openDwgFileToolStripMenuItem.Click += new System.EventHandler(this.openDwgFileToolStripMenuItem_Click);
82 | //
83 | // exitToolStripMenuItem
84 | //
85 | this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
86 | this.exitToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
87 | this.exitToolStripMenuItem.Text = "Exit";
88 | this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
89 | //
90 | // convertToolStripMenuItem
91 | //
92 | this.convertToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
93 | this.convertToPDFToolStripMenuItem,
94 | this.convertToMultisheetPDFToolStripMenuItem,
95 | this.mergePDFsToolStripMenuItem,
96 | this.extractAllVectorContentsToolStripMenuItem});
97 | this.convertToolStripMenuItem.Name = "convertToolStripMenuItem";
98 | this.convertToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
99 | this.convertToolStripMenuItem.Text = "Convert";
100 | //
101 | // convertToPDFToolStripMenuItem
102 | //
103 | this.convertToPDFToolStripMenuItem.Name = "convertToPDFToolStripMenuItem";
104 | this.convertToPDFToolStripMenuItem.Size = new System.Drawing.Size(213, 22);
105 | this.convertToPDFToolStripMenuItem.Text = "Convert to PDF";
106 | this.convertToPDFToolStripMenuItem.Click += new System.EventHandler(this.convertToPDFToolStripMenuItem_Click);
107 | //
108 | // convertToMultisheetPDFToolStripMenuItem
109 | //
110 | this.convertToMultisheetPDFToolStripMenuItem.Name = "convertToMultisheetPDFToolStripMenuItem";
111 | this.convertToMultisheetPDFToolStripMenuItem.Size = new System.Drawing.Size(213, 22);
112 | this.convertToMultisheetPDFToolStripMenuItem.Text = "Convert to Multisheet PDF";
113 | this.convertToMultisheetPDFToolStripMenuItem.Click += new System.EventHandler(this.convertToMultisheetPDFToolStripMenuItem_Click);
114 | //
115 | // mergePDFsToolStripMenuItem
116 | //
117 | this.mergePDFsToolStripMenuItem.Name = "mergePDFsToolStripMenuItem";
118 | this.mergePDFsToolStripMenuItem.Size = new System.Drawing.Size(213, 22);
119 | this.mergePDFsToolStripMenuItem.Text = "Merge PDFs";
120 | this.mergePDFsToolStripMenuItem.Click += new System.EventHandler(this.mergePDFsToolStripMenuItem_Click);
121 | //
122 | // connectToolStripMenuItem
123 | //
124 | this.connectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
125 | this.connectToAutoCADToolStripMenuItem});
126 | this.connectToolStripMenuItem.Name = "connectToolStripMenuItem";
127 | this.connectToolStripMenuItem.Size = new System.Drawing.Size(64, 20);
128 | this.connectToolStripMenuItem.Text = "Connect";
129 | //
130 | // connectToAutoCADToolStripMenuItem
131 | //
132 | this.connectToAutoCADToolStripMenuItem.Name = "connectToAutoCADToolStripMenuItem";
133 | this.connectToAutoCADToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
134 | this.connectToAutoCADToolStripMenuItem.Text = "Connect to AutoCAD";
135 | this.connectToAutoCADToolStripMenuItem.Click += new System.EventHandler(this.connectToAutoCADToolStripMenuItem_Click);
136 | //
137 | // launchToolStripMenuItem
138 | //
139 | this.launchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
140 | this.accToolStripMenuItem});
141 | this.launchToolStripMenuItem.Name = "launchToolStripMenuItem";
142 | this.launchToolStripMenuItem.Size = new System.Drawing.Size(58, 20);
143 | this.launchToolStripMenuItem.Text = "Launch";
144 | //
145 | // accToolStripMenuItem
146 | //
147 | this.accToolStripMenuItem.Name = "accToolStripMenuItem";
148 | this.accToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
149 | this.accToolStripMenuItem.Text = "Accore DWG True View";
150 | this.accToolStripMenuItem.Click += new System.EventHandler(this.accToolStripMenuItem_Click);
151 | //
152 | // exitToolStripMainMenu
153 | //
154 | this.exitToolStripMainMenu.Name = "exitToolStripMainMenu";
155 | this.exitToolStripMainMenu.Size = new System.Drawing.Size(37, 20);
156 | this.exitToolStripMainMenu.Text = "Exit";
157 | this.exitToolStripMainMenu.Click += new System.EventHandler(this.exitToolStripMainMenu_Click);
158 | //
159 | // openFileDialog
160 | //
161 | this.openFileDialog.FileName = "openFileDialog";
162 | this.openFileDialog.Filter = "DWG Files|*.dwg|DXF Files|*.dxf";
163 | //
164 | // listBoxFileContents
165 | //
166 | this.listBoxFileContents.FormattingEnabled = true;
167 | this.listBoxFileContents.Location = new System.Drawing.Point(21, 49);
168 | this.listBoxFileContents.Name = "listBoxFileContents";
169 | this.listBoxFileContents.Size = new System.Drawing.Size(698, 550);
170 | this.listBoxFileContents.TabIndex = 1;
171 | //
172 | // buttonSaveLog
173 | //
174 | this.buttonSaveLog.Location = new System.Drawing.Point(315, 609);
175 | this.buttonSaveLog.Name = "buttonSaveLog";
176 | this.buttonSaveLog.Size = new System.Drawing.Size(115, 23);
177 | this.buttonSaveLog.TabIndex = 2;
178 | this.buttonSaveLog.Text = "Save Log";
179 | this.buttonSaveLog.UseVisualStyleBackColor = true;
180 | this.buttonSaveLog.Click += new System.EventHandler(this.buttonSaveLog_Click);
181 | //
182 | // saveFileDialog
183 | //
184 | this.saveFileDialog.Filter = "Text Files|*.txt";
185 | //
186 | // extractAllVectorContentsToolStripMenuItem
187 | //
188 | this.extractAllVectorContentsToolStripMenuItem.Name = "extractAllVectorContentsToolStripMenuItem";
189 | this.extractAllVectorContentsToolStripMenuItem.Size = new System.Drawing.Size(213, 22);
190 | this.extractAllVectorContentsToolStripMenuItem.Text = "Extract All vector contents";
191 | this.extractAllVectorContentsToolStripMenuItem.Click += new System.EventHandler(this.extractAllVectorContentsToolStripMenuItem_Click);
192 | //
193 | // MainForm
194 | //
195 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
196 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
197 | this.BackColor = System.Drawing.SystemColors.ButtonFace;
198 | this.ClientSize = new System.Drawing.Size(742, 644);
199 | this.Controls.Add(this.buttonSaveLog);
200 | this.Controls.Add(this.listBoxFileContents);
201 | this.Controls.Add(this.menuStrip);
202 | this.MainMenuStrip = this.menuStrip;
203 | this.Name = "MainForm";
204 | this.Text = "Main Form";
205 | this.menuStrip.ResumeLayout(false);
206 | this.menuStrip.PerformLayout();
207 | this.ResumeLayout(false);
208 | this.PerformLayout();
209 |
210 | }
211 |
212 | #endregion
213 |
214 | private System.Windows.Forms.MenuStrip menuStrip;
215 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
216 | private System.Windows.Forms.ToolStripMenuItem openDwgFileToolStripMenuItem;
217 | private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
218 | private System.Windows.Forms.ToolStripMenuItem exitToolStripMainMenu;
219 | private System.Windows.Forms.OpenFileDialog openFileDialog;
220 | private System.Windows.Forms.ListBox listBoxFileContents;
221 | private System.Windows.Forms.ToolStripMenuItem convertToolStripMenuItem;
222 | private System.Windows.Forms.ToolStripMenuItem convertToPDFToolStripMenuItem;
223 | private System.Windows.Forms.ToolStripMenuItem convertToMultisheetPDFToolStripMenuItem;
224 | private System.Windows.Forms.ToolStripMenuItem connectToolStripMenuItem;
225 | private System.Windows.Forms.ToolStripMenuItem connectToAutoCADToolStripMenuItem;
226 | private System.Windows.Forms.ToolStripMenuItem launchToolStripMenuItem;
227 | private System.Windows.Forms.ToolStripMenuItem accToolStripMenuItem;
228 | private System.Windows.Forms.ToolStripMenuItem mergePDFsToolStripMenuItem;
229 | private System.Windows.Forms.Button buttonSaveLog;
230 | private System.Windows.Forms.SaveFileDialog saveFileDialog;
231 | private System.Windows.Forms.ToolStripMenuItem extractAllVectorContentsToolStripMenuItem;
232 | }
233 | }
234 |
235 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using DwgFileReader;
11 | using DwgToPdfConverter;
12 | using AutocadConnector;
13 | using AccoreconsoleLauncher;
14 | using System.Threading;
15 | using System.IO;
16 | using System.Diagnostics;
17 |
18 | namespace AutocadDwgReaderTest
19 | {
20 | public partial class MainForm : Form
21 | {
22 | #region Private Variables
23 |
24 | private enum Filter : int
25 | {
26 | DwgDxfFile,
27 | PdfFile,
28 | DwfFile
29 | }
30 |
31 | private bool _proceed;
32 |
33 | private string _fileName;
34 |
35 | private BackgroundWorker _worker;
36 |
37 | private bool _flag;
38 |
39 | Stopwatch watch ;
40 |
41 | #endregion
42 |
43 | #region Constructors
44 |
45 | public MainForm()
46 | {
47 | InitializeComponent();
48 | this.MaximizeBox = false;
49 | this._proceed = false;
50 | this._worker = null;
51 | this._fileName = "";
52 | this._flag = false;
53 | }
54 |
55 | #endregion
56 |
57 | #region Private Methods
58 |
59 | #region worker
60 |
61 | private void Init()
62 | {
63 | if (this._worker == null)
64 | {
65 | this._worker = new BackgroundWorker();
66 | this._worker.WorkerReportsProgress = true;
67 | this._worker.WorkerSupportsCancellation = false;
68 | this._worker.DoWork += new DoWorkEventHandler(HandleDoWork);
69 | this._worker.ProgressChanged += new ProgressChangedEventHandler(HandleProgressChanged);
70 | this._worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(HandleWorkerCompleted);
71 | this.watch = new Stopwatch();
72 | }
73 | }
74 |
75 | private void StartWorker(Accoreconsole console)
76 | {
77 | Init();
78 |
79 | if (!_worker.IsBusy)
80 | {
81 | watch.Start();
82 | this._worker.RunWorkerAsync(console);
83 | }
84 | }
85 |
86 | private void HandleDoWork(object sender, DoWorkEventArgs e)
87 | {
88 | BackgroundWorker worker = sender as BackgroundWorker;
89 | Accoreconsole console = e.Argument as Accoreconsole;
90 |
91 | int i = 0;
92 | string msg = "";
93 |
94 | if (!(worker == null))
95 | {
96 | if (!(console == null))
97 | {
98 | console.Process(_fileName);
99 | msg = console.GetLog();
100 | worker.ReportProgress(++i, msg);
101 | }
102 | }
103 | }
104 |
105 | private void HandleWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
106 | {
107 | BackgroundWorker worker = sender as BackgroundWorker;
108 |
109 | if (!(worker == null))
110 | {
111 | if (e.Error == null)
112 | {
113 | this._flag = true;
114 | WriteLog("Seems like, all done !!", LogMessageType.Information);
115 | watch.Stop();
116 | WriteLog("Total Time : " + watch.ElapsedMilliseconds.ToString() + " ms", LogMessageType.Information);
117 | }
118 | else
119 | WriteLog("failed : " + e.Error.Data, LogMessageType.Error);
120 | }
121 | }
122 |
123 | private void HandleProgressChanged(object sender, ProgressChangedEventArgs e)
124 | {
125 | BackgroundWorker worker = sender as BackgroundWorker;
126 |
127 | if (!(worker == null))
128 | {
129 | string msg = e.UserState as string;
130 |
131 | if (!string.IsNullOrWhiteSpace(msg))
132 | {
133 | string[] str = msg.Split('\n');
134 | foreach(string s in str)
135 | WriteLog(s, LogMessageType.Information);
136 | }
137 | }
138 | }
139 |
140 | #endregion
141 |
142 | private void exitToolStripMainMenu_Click(object sender, EventArgs e)
143 | {
144 | this.Close();
145 | }
146 |
147 | private void exitToolStripMenuItem_Click(object sender, EventArgs e)
148 | {
149 | this.Close();
150 | }
151 |
152 | private void openDwgFileToolStripMenuItem_Click(object sender, EventArgs e)
153 | {
154 | //string contents = "";
155 | ChangeFilter(Filter.DwgDxfFile);
156 | MultiselectFiles(false);
157 |
158 | if (openFileDialog.ShowDialog() == DialogResult.OK)
159 | {
160 | //Commands cmd = new Commands();
161 | //contents = cmd.ReadDwgFile(openFileDialog.FileName);
162 |
163 | ////Commands.ExtractObjectsFromFile();
164 | //if (!String.IsNullOrEmpty(contents))
165 | //{
166 | // MessageBox.Show("File reading successful.", "Read DWG File", MessageBoxButtons.OK, MessageBoxIcon.Information);
167 | // //listBoxFileContents.Items.Add(contents);
168 | //}
169 | //else
170 | //{
171 | // MessageBox.Show("File reading failed.", "Read DWG File", MessageBoxButtons.OK, MessageBoxIcon.Error);
172 | //}
173 | if (openFileDialog.FileName.Trim().Length > 0)
174 | {
175 | this._fileName = openFileDialog.FileName;
176 | MessageBox.Show("Got file name...", "Message", MessageBoxButtons.OK);
177 | }
178 | }
179 | }
180 |
181 | private void convertToPDFToolStripMenuItem_Click(object sender, EventArgs e)
182 | {
183 | if (IsAutocadRunning())
184 | {
185 | //DWGtoPDF.BuildList(@"C:\Users\amitp\Downloads\3D Files\dwg\New folder", true, false);
186 | //DWGtoPDF.Converttopdf();
187 | }
188 | }
189 |
190 | private void convertToMultisheetPDFToolStripMenuItem_Click(object sender, EventArgs e)
191 | {
192 | if (IsAutocadRunning())
193 | {
194 | MultiSheetsPdf.PlotPdf();
195 | }
196 | }
197 |
198 | private bool IsAutocadRunning()
199 | {
200 | if (_proceed == false)
201 | {
202 | MessageBox.Show("AutoCAD is not running, connect to AutoCAD first (connect->connect to AutoCAD)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
203 | WriteLog("AutoCAD is not running.", LogMessageType.Error);
204 | }
205 |
206 | return _proceed;
207 | }
208 |
209 | private void WriteLog(string msg, LogMessageType type)
210 | {
211 | string format = LogWriter.WriteLog(msg, type);
212 |
213 | switch (type)
214 | {
215 | case LogMessageType.Error:
216 | listBoxFileContents.Items.Add(format);
217 | break;
218 |
219 | case LogMessageType.Information:
220 | listBoxFileContents.Items.Add(format);
221 | break;
222 | }
223 | listBoxFileContents.Refresh();
224 | }
225 |
226 | private void connectToAutoCADToolStripMenuItem_Click(object sender, EventArgs e)
227 | {
228 | string autocadInfo = "";
229 |
230 | try
231 | {
232 | Connector connect = new Connector();
233 |
234 | WriteLog("Trying to launch AutoCAD...", LogMessageType.Information);
235 |
236 | _proceed = connect.ConnectToAutoCAD(out autocadInfo);
237 |
238 | AutoCADDocument doc = new AutoCADDocument();
239 |
240 | doc.OpenDocument(_fileName);
241 |
242 | doc.CloseDocument();
243 |
244 | if (_proceed == true)
245 | {
246 | MessageBox.Show("AutoCAD is running..." + autocadInfo, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
247 | WriteLog("AutoCAD is running now..." + autocadInfo, LogMessageType.Information);
248 | }
249 | else
250 | {
251 | MessageBox.Show("failed to launch AutoCAD..." + autocadInfo, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
252 | WriteLog("Could not launch AutoCAD......" + autocadInfo, LogMessageType.Error);
253 | }
254 |
255 | }
256 | catch (Exception ex)
257 | {
258 | MessageBox.Show(ex.Message, "Could not launch AutoCAD...", MessageBoxButtons.OK, MessageBoxIcon.Error);
259 | WriteLog("Could not launch AutoCAD......" + ex.Message, LogMessageType.Error);
260 | }
261 | }
262 |
263 | private void openDxfFileToolStripMenuItem_Click(object sender, EventArgs e)
264 | {
265 | //To-Do
266 | }
267 |
268 | private void accToolStripMenuItem_Click(object sender, EventArgs e)
269 | {
270 |
271 | if (!String.IsNullOrWhiteSpace(this._fileName))
272 | {
273 | Accoreconsole console = new Accoreconsole();
274 | StartWorker(console);
275 | }
276 | else
277 | {
278 | MessageBox.Show("Invalid file name !!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
279 | }
280 |
281 |
282 | }
283 |
284 | private void ChangeFilter(Filter filter)
285 | {
286 | switch (filter)
287 | {
288 | case Filter.DwgDxfFile:
289 | openFileDialog.Filter = "DWG Files|*.dwg|DXF Files|*.dxf";
290 | break;
291 |
292 | case Filter.PdfFile:
293 | openFileDialog.Filter = "PDF Files|*.pdf";
294 | break;
295 |
296 | case Filter.DwfFile:
297 | openFileDialog.Filter = "DWF Files|*.dwf";
298 | break;
299 | }
300 | }
301 |
302 | private void MultiselectFiles(bool val)
303 | {
304 | openFileDialog.Multiselect = val;
305 | }
306 |
307 | private void mergePDFsToolStripMenuItem_Click(object sender, EventArgs e)
308 | {
309 | string outPdfFileName = "MergedPdf.pdf";
310 | string error = "";
311 | ChangeFilter(Filter.PdfFile);
312 | MultiselectFiles(true);
313 |
314 | if (openFileDialog.ShowDialog() == DialogResult.OK)
315 | {
316 | if (openFileDialog.FileNames.Length >= 2)
317 | {
318 | List pdfFileNames = new List();
319 | pdfFileNames.AddRange(openFileDialog.FileNames);
320 | Accoreconsole console = new Accoreconsole();
321 | WriteLog("Task : Merge PDFs", LogMessageType.Information);
322 | WriteLog("PDF File/Files : ", LogMessageType.Information);
323 |
324 | for (int i = 0; i < pdfFileNames.Count; ++i)
325 | WriteLog(i + 1 + " : " + pdfFileNames[i], LogMessageType.Information);
326 |
327 | try
328 | {
329 | if (console.mergerPdfFiles(pdfFileNames, outPdfFileName, out error))
330 | WriteLog("Success : saved...", LogMessageType.Information);
331 | else
332 | WriteLog("Failed to merge pdf files : " + error, LogMessageType.Error);
333 |
334 | }
335 | catch (Exception ex)
336 | {
337 | WriteLog("Failed to save pdf file : " + error, LogMessageType.Error);
338 | WriteLog(ex.Message, LogMessageType.Error);
339 | }
340 | }
341 | }
342 | else
343 | {
344 | WriteLog("Select 2 or more pdf files...", LogMessageType.Error);
345 | }
346 | }
347 |
348 | private void buttonSaveLog_Click(object sender, EventArgs e)
349 | {
350 | string contents = "";
351 | if (listBoxFileContents.Items.Count >= 1)
352 | {
353 | if (saveFileDialog.ShowDialog() == DialogResult.OK)
354 | {
355 | WriteLog("Task : Save Log", LogMessageType.Information);
356 | WriteLog("Save File : " + saveFileDialog.FileName, LogMessageType.Information);
357 |
358 | foreach (string str in listBoxFileContents.Items)
359 | {
360 | contents += str + "\n";
361 | }
362 | File.WriteAllText(saveFileDialog.FileName, contents);
363 |
364 | if (File.Exists(saveFileDialog.FileName))
365 | WriteLog("Log file saved..." + saveFileDialog.FileName, LogMessageType.Information);
366 | else
367 | WriteLog("Couldn't save log file..." + saveFileDialog.FileName, LogMessageType.Information);
368 | }
369 | }
370 | }
371 |
372 | private void extractAllVectorContentsToolStripMenuItem_Click(object sender, EventArgs e)
373 | {
374 | string error = "";
375 |
376 | ChangeFilter(Filter.PdfFile);
377 | MultiselectFiles(false);
378 | openFileDialog.Title = "Select PDF File";
379 |
380 | if (openFileDialog.ShowDialog() == DialogResult.OK)
381 | {
382 | WriteLog("Task : Extract all vector contents form TrueView exported PDF", LogMessageType.Information);
383 | WriteLog("Open PDF File : " + openFileDialog.FileName, LogMessageType.Information);
384 |
385 | if (saveFileDialog.ShowDialog() == DialogResult.OK)
386 | {
387 | WriteLog("Output Text File : " + saveFileDialog.FileName, LogMessageType.Information);
388 |
389 | Accoreconsole console = new Accoreconsole();
390 |
391 | try
392 | {
393 | if (console.ExtractAllText(openFileDialog.FileName, saveFileDialog.FileName, out error))
394 | {
395 | WriteLog("Success : saved...", LogMessageType.Information);
396 | }
397 | else
398 | {
399 | WriteLog("Failed to extract text : " + error, LogMessageType.Error);
400 | }
401 | }
402 | catch (Exception ex)
403 | {
404 | WriteLog("Failed to save text file : " + error, LogMessageType.Error);
405 | WriteLog(ex.Message, LogMessageType.Error);
406 | }
407 | }
408 | }
409 | }
410 |
411 | #endregion
412 | }
413 |
414 | internal class LogWriter
415 | {
416 | public static string WriteLog(string msg, LogMessageType type)
417 | {
418 | string formattedOutput = string.Empty;
419 |
420 | switch (type)
421 | {
422 | case LogMessageType.Error:
423 | formattedOutput = "[" + DateTime.Now.ToString() + "]" + " - Error - " + msg;
424 | break;
425 |
426 | case LogMessageType.Information:
427 | formattedOutput = "[" + DateTime.Now.ToString() + "]" + " - Info - " + msg;
428 | break;
429 | }
430 |
431 | return formattedOutput;
432 | }
433 | }
434 | }
435 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 | 132, 17
125 |
126 |
127 | 265, 17
128 |
129 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AutocadDwgReaderTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AutocadDwgReaderTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0ff8931a-89a9-4b51-a6f4-5d341c752b2c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18444
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AutocadDwgReaderTest.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutocadDwgReaderTest.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18444
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AutocadDwgReaderTest.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/DebenuPDFLibrary64DLL1113.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amit-k-pathak/3D-Model-to-Pdf-Conversion-and-Text-Extraction/b2b55d093f86e116936c4d9e8a5ad4440a8593d0/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/DebenuPDFLibrary64DLL1113.dll
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/DebenuPDFLibraryDLL1113.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amit-k-pathak/3D-Model-to-Pdf-Conversion-and-Text-Extraction/b2b55d093f86e116936c4d9e8a5ad4440a8593d0/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/DebenuPDFLibraryDLL1113.dll
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/MuPDF_Basic_Operation_Dll_1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amit-k-pathak/3D-Model-to-Pdf-Conversion-and-Text-Extraction/b2b55d093f86e116936c4d9e8a5ad4440a8593d0/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/MuPDF_Basic_Operation_Dll_1.dll
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/MuPDF_Basic_Operation_Dll_1.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amit-k-pathak/3D-Model-to-Pdf-Conversion-and-Text-Extraction/b2b55d093f86e116936c4d9e8a5ad4440a8593d0/AutocadDwgReaderTest/AutocadDwgReaderTest/bin/Debug/MuPDF_Basic_Operation_Dll_1.pdb
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/DwgTextExtracter/DwgTextExtracter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F3977977-DDC8-4869-A8EA-66BF8386FF06}
8 | Library
9 | Properties
10 | DwgTextExtracter
11 | DwgTextExtracter
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | TRACE;DEBUG;_TEST
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcCoreMgd.dll
35 | False
36 |
37 |
38 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcDbMgd.dll
39 | False
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
61 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/DwgTextExtracter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DwgTextExtracter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DwgTextExtracter")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8376b60c-0dba-48c7-a4a7-ede71f36b36a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/DwgToPdfConverter/DWGtoPDF.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Autodesk.AutoCAD.ApplicationServices;
4 | using Autodesk.AutoCAD.EditorInput;
5 | using Autodesk.AutoCAD.Runtime;
6 | using System.IO;
7 | using System.Collections;
8 | using Autodesk.AutoCAD.PlottingServices;
9 | using Autodesk.AutoCAD.DatabaseServices;
10 | using Autodesk.AutoCAD.Publishing;
11 | using System.Text;
12 | using app = Autodesk.AutoCAD.ApplicationServices.Core.Application;
13 | using Autodesk.AutoCAD.ApplicationServices.Core;
14 |
15 |
16 |
17 | namespace DwgToPdfConverter
18 | {
19 | /* This class depends on AutoCAD Runtime
20 | //public class MultiSheetsPdf
21 | //{
22 | // private string dwgFile, pdfFile, dsdFile, outputDir;
23 | // private int sheetNum;
24 | // IEnumerable layouts;
25 |
26 | // private const string LOG = "publish.log";
27 |
28 | // public MultiSheetsPdf(string pdfFile, IEnumerable layouts)
29 | // {
30 | // Database db = HostApplicationServices.WorkingDatabase;
31 | // this.dwgFile = db.Filename;
32 | // this.pdfFile = pdfFile;
33 | // this.outputDir = Path.GetDirectoryName(this.pdfFile);
34 | // this.dsdFile = Path.ChangeExtension(this.pdfFile, "dsd");
35 | // this.layouts = layouts;
36 | // }
37 |
38 | // public void Publish()
39 | // {
40 | // if (TryCreateDSD())
41 | // {
42 | // Publisher publisher = Autodesk.AutoCAD.ApplicationServices.Application.Publisher;
43 | // PlotProgressDialog plotDlg = new PlotProgressDialog(false, this.sheetNum, true);
44 | // publisher.PublishDsd(this.dsdFile, plotDlg);
45 | // plotDlg.Destroy();
46 | // File.Delete(this.dsdFile);
47 | // }
48 | // }
49 |
50 | // private bool TryCreateDSD()
51 | // {
52 | // using (DsdData dsd = new DsdData())
53 | // using (DsdEntryCollection dsdEntries = CreateDsdEntryCollection(this.layouts))
54 | // {
55 | // if (dsdEntries == null || dsdEntries.Count <= 0) return false;
56 |
57 | // if (!Directory.Exists(this.outputDir))
58 | // Directory.CreateDirectory(this.outputDir);
59 |
60 | // this.sheetNum = dsdEntries.Count;
61 |
62 | // dsd.SetDsdEntryCollection(dsdEntries);
63 |
64 | // dsd.SetUnrecognizedData("PwdProtectPublishedDWF", "FALSE");
65 | // dsd.SetUnrecognizedData("PromptForPwd", "FALSE");
66 | // dsd.SheetType = SheetType.MultiDwf;
67 | // dsd.NoOfCopies = 1;
68 | // dsd.DestinationName = this.pdfFile;
69 | // dsd.IsHomogeneous = false;
70 | // dsd.LogFilePath = Path.Combine(this.outputDir, LOG);
71 |
72 | // PostProcessDSD(dsd);
73 |
74 | // return true;
75 | // }
76 | // }
77 |
78 | // private DsdEntryCollection CreateDsdEntryCollection(IEnumerable layouts)
79 | // {
80 | // DsdEntryCollection entries = new DsdEntryCollection();
81 |
82 | // foreach (Layout layout in layouts)
83 | // {
84 | // DsdEntry dsdEntry = new DsdEntry();
85 | // dsdEntry.DwgName = this.dwgFile;
86 | // dsdEntry.Layout = layout.LayoutName;
87 | // dsdEntry.Title = Path.GetFileNameWithoutExtension(this.dwgFile) + "-" + layout.LayoutName;
88 | // dsdEntry.Nps = layout.TabOrder.ToString();
89 | // entries.Add(dsdEntry);
90 | // }
91 | // return entries;
92 | // }
93 |
94 | // private void PostProcessDSD(DsdData dsd)
95 | // {
96 | // string str, newStr;
97 | // string tmpFile = Path.Combine(this.outputDir, "temp.dsd");
98 |
99 | // dsd.WriteDsd(tmpFile);
100 |
101 | // using (StreamReader reader = new StreamReader(tmpFile, Encoding.Default))
102 | // using (StreamWriter writer = new StreamWriter(this.dsdFile, false, Encoding.Default))
103 | // {
104 | // while (!reader.EndOfStream)
105 | // {
106 | // str = reader.ReadLine();
107 | // if (str.Contains("Has3DDWF"))
108 | // {
109 | // newStr = "Has3DDWF=0";
110 | // }
111 | // else if (str.Contains("OriginalSheetPath"))
112 | // {
113 | // newStr = "OriginalSheetPath=" + this.dwgFile;
114 | // }
115 | // else if (str.Contains("Type"))
116 | // {
117 | // newStr = "Type=6";
118 | // }
119 | // else if (str.Contains("OUT"))
120 | // {
121 | // newStr = "OUT=" + this.outputDir;
122 | // }
123 | // else if (str.Contains("IncludeLayer"))
124 | // {
125 | // newStr = "IncludeLayer=TRUE";
126 | // }
127 | // else if (str.Contains("PromptForDwfName"))
128 | // {
129 | // newStr = "PromptForDwfName=FALSE";
130 | // }
131 | // else if (str.Contains("LogFilePath"))
132 | // {
133 | // newStr = "LogFilePath=" + Path.Combine(this.outputDir, LOG);
134 | // }
135 | // else
136 | // {
137 | // newStr = str;
138 | // }
139 | // writer.WriteLine(newStr);
140 | // }
141 | // }
142 | // File.Delete(tmpFile);
143 | // }
144 |
145 | // [CommandMethod("PlotPdf")]
146 | // public static void PlotPdf()
147 | // {
148 | // Database db = HostApplicationServices.WorkingDatabase;
149 | // short bgp = (short)app.GetSystemVariable("BACKGROUNDPLOT");
150 | // try
151 | // {
152 | // app.SetSystemVariable("BACKGROUNDPLOT", 0);
153 | // using (Transaction tr = db.TransactionManager.StartTransaction())
154 | // {
155 | // List layouts = new List();
156 | // DBDictionary layoutDict = (DBDictionary)db.LayoutDictionaryId.GetObject(OpenMode.ForRead);
157 |
158 | // foreach (DBDictionaryEntry entry in layoutDict)
159 | // {
160 | // //if (entry.Key != "Model") //uncomment to skip model
161 | // {
162 | // layouts.Add((Layout)tr.GetObject(entry.Value, OpenMode.ForRead));
163 | // }
164 | // }
165 | // layouts.Sort((l1, l2) => l1.TabOrder.CompareTo(l2.TabOrder));
166 |
167 | // string filename = Path.ChangeExtension(db.Filename, "pdf");
168 |
169 | // MultiSheetsPdf plotter = new MultiSheetsPdf(filename, layouts);
170 | // plotter.Publish();
171 |
172 | // tr.Commit();
173 | // }
174 | // }
175 | // catch (System.Exception e)
176 | // {
177 | // Editor ed = app.DocumentManager.MdiActiveDocument.Editor;
178 | // ed.WriteMessage("\nError: {0}\n{1}", e.Message, e.StackTrace);
179 | // }
180 | // finally
181 | // {
182 | // app.SetSystemVariable("BACKGROUNDPLOT", bgp);
183 | // }
184 | // }
185 |
186 | //}
187 |
188 | */
189 |
190 | /* This class does not depends on AutoCAD Runtime and uses only core autocad logic*/
191 | public class MultiSheetsPdfUsingAccoreconsole
192 | {
193 | private string _dwgFile, _pdfFile, _dsdFile, _outputDir;
194 | private int _numberOfsheets;
195 | IEnumerable _layouts;
196 |
197 | private const string _logFile = "publish.log";
198 |
199 | public MultiSheetsPdfUsingAccoreconsole(string pdfFile, IEnumerable layouts)
200 | {
201 | this._dwgFile = HostApplicationServices.WorkingDatabase.Filename;
202 | this._pdfFile = pdfFile;
203 | this._outputDir = Path.GetDirectoryName(this._pdfFile);
204 | this._dsdFile = Path.ChangeExtension(this._pdfFile, "dsd");
205 | this._layouts = layouts;
206 | }
207 |
208 | public void Publish()
209 | {
210 | if (TryCreateDSD())
211 | {
212 | //Publisher publisher = Autodesk.AutoCAD.ApplicationServices.ApplicationServices.Application.Publisher;
213 | Publisher publisher = Autodesk.AutoCAD.ApplicationServices.Core.Application.Publisher;
214 | //publisher.PublishExecute(); --for printing with plotconfigs
215 |
216 | // Attach necessary event handlers
217 | //publisher.BeginPublishingSheet += new BeginPublishingSheetEventHandler(HandleBeginPublishingSheet);
218 | //publisher.EndPublish += new EndPublishEventHandler(HandleEndPublish);
219 | //publisher.CancelledOrFailedPublishing += new CancelledOrFailedPublishingEventHandler(HandleCancelledOrFailedPublish);
220 |
221 | PlotProgressDialog plotDlg = new PlotProgressDialog(false, this._numberOfsheets, true);
222 | //File.WriteAllText("D:\\sheets.txt", this.sheetNum.ToString()); //test
223 |
224 | publisher.PublishDsd(this._dsdFile, plotDlg);
225 | plotDlg.Destroy();
226 | File.Delete(this._dsdFile);
227 | }
228 | }
229 |
230 | //private void HandleCancelledOrFailedPublish(object sender, PublishEventArgs e)
231 | //{
232 | // app.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Error : publishing failed/cancelled...", e.ToString());
233 | //}
234 |
235 | //private void HandleEndPublish(object sender, PublishEventArgs e)
236 | //{
237 | // app.DocumentManager.MdiActiveDocument.Editor.WriteMessage("All publishing tasks finished...", e.ToString());
238 | //}
239 |
240 | //private void HandleBeginPublishingSheet(object sender, BeginPublishingSheetEventArgs e)
241 | //{
242 | // app.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Error : while publishing...", e.ToString());
243 | //}
244 |
245 | private bool TryCreateDSD()
246 | {
247 | using (DsdData dsd = new DsdData())
248 | using (DsdEntryCollection dsdEntries = CreateDsdEntryCollection(this._layouts))
249 | {
250 | if (dsdEntries == null || dsdEntries.Count <= 0) return false;
251 |
252 | if (!Directory.Exists(this._outputDir))
253 | Directory.CreateDirectory(this._outputDir);
254 |
255 | this._numberOfsheets = dsdEntries.Count;
256 |
257 | dsd.SetDsdEntryCollection(dsdEntries);
258 |
259 | dsd.SetUnrecognizedData("PwdProtectPublishedDWF", "FALSE");
260 | dsd.SetUnrecognizedData("PromptForPwd", "FALSE");
261 | //dsd.SheetType = SheetType.MultiDwf;
262 | dsd.SheetType = SheetType.MultiPdf; //previously MultiDwf -- check
263 | dsd.NoOfCopies = 1;
264 | dsd.DestinationName = this._pdfFile;
265 | dsd.IsHomogeneous = false;
266 | dsd.LogFilePath = Path.Combine(this._outputDir, _logFile);
267 |
268 | PostProcessDSD(dsd);
269 |
270 | return true;
271 | }
272 | }
273 |
274 | private DsdEntryCollection CreateDsdEntryCollection(IEnumerable layouts)
275 | {
276 | DsdEntryCollection entries = new DsdEntryCollection();
277 |
278 | foreach (Layout layout in layouts)
279 | {
280 | //layout.Initialize(); --//giving exception
281 | DsdEntry dsdEntry = new DsdEntry();
282 | dsdEntry.DwgName = this._dwgFile;
283 | dsdEntry.Layout = layout.LayoutName;
284 | //File.AppendAllText("D:\\layout_names.txt", layout.LayoutName); //test
285 | dsdEntry.Title = Path.GetFileNameWithoutExtension(this._dwgFile) + "-" + layout.LayoutName;
286 | dsdEntry.Nps = layout.TabOrder.ToString();
287 | entries.Add(dsdEntry);
288 | }
289 | return entries;
290 | }
291 |
292 | private void PostProcessDSD(DsdData dsd)
293 | {
294 | string str, newStr;
295 | string tmpFile = Path.Combine(this._outputDir, "temp.dsd");
296 |
297 | dsd.WriteDsd(tmpFile);
298 |
299 | using (StreamReader reader = new StreamReader(tmpFile, Encoding.Default))
300 | using (StreamWriter writer = new StreamWriter(this._dsdFile, false, Encoding.Default))
301 | {
302 | while (!reader.EndOfStream)
303 | {
304 | str = reader.ReadLine();
305 | if (str.Contains("Has3DDWF"))
306 | {
307 | newStr = "Has3DDWF=0";
308 | }
309 | else if (str.Contains("OriginalSheetPath"))
310 | {
311 | newStr = "OriginalSheetPath=" + this._dwgFile;
312 | }
313 | else if (str.Contains("Type"))
314 | {
315 | newStr = "Type=6";
316 | }
317 | else if (str.Contains("OUT"))
318 | {
319 | newStr = "OUT=" + this._outputDir;
320 | }
321 | else if (str.Contains("IncludeLayer"))
322 | {
323 | newStr = "IncludeLayer=TRUE";
324 | }
325 | else if (str.Contains("PromptForDwfName"))
326 | {
327 | newStr = "PromptForDwfName=FALSE";
328 | }
329 | else if (str.Contains("LogFilePath"))
330 | {
331 | newStr = "LogFilePath=" + Path.Combine(this._outputDir, _logFile);
332 | }
333 | else
334 | {
335 | newStr = str;
336 | }
337 | writer.WriteLine(newStr);
338 | }
339 | }
340 | File.Delete(tmpFile);
341 | }
342 |
343 | [CommandMethod("PublishAccore")]
344 | public static void PublishUsingAccoreConsole()
345 | {
346 | short bgp = (short)app.GetSystemVariable("BACKGROUNDPLOT");
347 |
348 | try
349 | {
350 | app.SetSystemVariable("BACKGROUNDPLOT", 0);
351 |
352 | using(Database db = HostApplicationServices.WorkingDatabase)
353 | {
354 | using (Transaction tr = db.TransactionManager.StartTransaction())
355 | {
356 | List layouts = new List();
357 | DBDictionary layoutDict = (DBDictionary)db.LayoutDictionaryId.GetObject(OpenMode.ForRead);
358 |
359 | //int i = 0; //test
360 |
361 | foreach (DBDictionaryEntry entry in layoutDict)
362 | {
363 | // if (entry.Key != "Model") //uncomment to skip model
364 | {
365 | layouts.Add((Layout)tr.GetObject(entry.Value, OpenMode.ForRead));
366 | //i++; //test
367 | }
368 | }
369 |
370 | //File.WriteAllText("d:\\debug.txt", i.ToString()); //test
371 | layouts.Sort((l1, l2) => l1.TabOrder.CompareTo(l2.TabOrder));
372 |
373 | string filename = Path.ChangeExtension(db.Filename, "pdf");
374 |
375 | MultiSheetsPdfUsingAccoreconsole plotter = new MultiSheetsPdfUsingAccoreconsole(filename, layouts);
376 | plotter.Publish();
377 |
378 | tr.Commit();
379 | }
380 | }
381 | }
382 | catch (System.Exception e)
383 | {
384 | app.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nError: {0}\n{1}", e.Message, e.StackTrace);
385 | }
386 | finally
387 | {
388 | app.SetSystemVariable("BACKGROUNDPLOT", bgp);
389 | }
390 | }
391 | }
392 | }
393 |
394 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/DwgToPdfConverter/DwgToPdfConverter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3A5D6519-A518-492C-BEB8-2F15001D4451}
8 | Library
9 | Properties
10 | DwgToPdfConverter
11 | DwgToPdfConverter
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 | true
34 | bin\x64\Debug\
35 | DEBUG;TRACE
36 | full
37 | x64
38 | prompt
39 | MinimumRecommendedRules.ruleset
40 |
41 |
42 | bin\x64\Release\
43 | TRACE
44 | true
45 | pdbonly
46 | x64
47 | prompt
48 | MinimumRecommendedRules.ruleset
49 |
50 |
51 |
52 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcCoreMgd.dll
53 |
54 |
55 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcDbMgd.dll
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
77 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/DwgToPdfConverter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DwgToPdfConverter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DwgToPdfConverter")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("bd7b1064-873f-4de4-b428-d91699f4905b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/AdnMeshData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using Autodesk.Revit.DB;
6 |
7 | namespace CustomExporterAdnMeshJson
8 | {
9 | ///
10 | /// The data format specifying one solid for the
11 | /// WebGL viewer, defining its centre, colour, id,
12 | /// triangular facets, their vertex coordinates,
13 | /// indices and normals.
14 | ///
15 | class AdnMeshData
16 | {
17 | int FacetCount { get; set; } // optional
18 | int VertexCount { get; set; } // optional
19 | int[] VertexCoords { get; set; }
20 | int[] VertexIndices { get; set; } // triangles
21 | double[] Normals { get; set; }
22 | int[] NormalIndices { get; set; } // not optional, one normal per vertex
23 | int[] Center { get; set; }
24 | int Color { get; set; }
25 | string Id { get; set; }
26 |
27 | ///
28 | /// Apply this factor to all point data when
29 | /// saving to JSON to accomodate the expected
30 | /// scaling.
31 | ///
32 | const double _export_factor = 0.002;
33 |
34 | public AdnMeshData(
35 | VertexLookupInt vertices,
36 | List vertexIndices,
37 | NormalLookupXyz normals,
38 | List normalIndices,
39 | PointInt center,
40 | Color color,
41 | double transparency,
42 | string id )
43 | {
44 | int n = vertexIndices.Count;
45 |
46 | Debug.Assert( 0 == (n % 3),
47 | "expected triples of 3D point vertex indices" );
48 |
49 | Debug.Assert( normalIndices.Count == n,
50 | "expected a normal for each vertex" );
51 |
52 | FacetCount = n / 3;
53 |
54 | n = vertices.Count;
55 | VertexCount = n;
56 | VertexCoords = new int[n * 3];
57 | int i = 0;
58 | foreach( PointInt p in vertices.Keys )
59 | {
60 | VertexCoords[i++] = p.X;
61 | VertexCoords[i++] = p.Y;
62 | VertexCoords[i++] = p.Z;
63 | }
64 | VertexIndices = vertexIndices.ToArray();
65 |
66 | n = normals.Count;
67 | Normals = new double[n * 3];
68 | i = 0;
69 | foreach( XYZ v in normals.Keys )
70 | {
71 | Normals[i++] = v.X;
72 | Normals[i++] = v.Y;
73 | Normals[i++] = v.Z;
74 | }
75 | NormalIndices = normalIndices.ToArray();
76 |
77 | Center = new int[3];
78 | i = 0;
79 | Center[i++] = center.X;
80 | Center[i++] = center.Y;
81 | Center[i] = center.Z;
82 |
83 | byte alpha = (byte) (
84 | ( 100 - transparency ) * 2.55555555 );
85 |
86 | Color = ConvertClr(
87 | color.Red, color.Green, color.Blue, alpha );
88 |
89 | Id = id;
90 | }
91 |
92 | ///
93 | /// Convert colour and transparency to
94 | /// the required integer format.
95 | ///
96 | static int ConvertClr( byte r, byte g, byte b, byte a )
97 | {
98 | return ( r << 24 ) + ( g << 16 ) + ( b << 8 ) + a;
99 | }
100 |
101 | public string ToJson()
102 | {
103 | // I did think of using a JSON serialiser,
104 | // either one of these two provided by the
105 | // .NET framework or one of the other libraries:
106 | // System.Runtime.Serialization.Json.DataContractJsonSerializer
107 | // System.Web.Script.Serialization.JavaScriptSerializer
108 | // However, reading this comparison and alternative
109 | // implementation, I decided to just write the couple
110 | // of lines myself.
111 | // http://procbits.com/2011/08/11/fridaythe13th-the-best-json-parser-for-silverlight-and-net
112 |
113 | string s = string.Format
114 | ( "\n \"FacetCount\":{0},"
115 | + "\n \"VertexCount\":{1},"
116 | + "\n \"VertexCoords\":[{2}],"
117 | + "\n \"VertexIndices\":[{3}],"
118 | + "\n \"Normals\":[{4}],"
119 | + "\n \"NormalIndices\":[{5}],"
120 | + "\n \"Center\":[{6}],"
121 | + "\n \"Color\":[{7}],"
122 | + "\n \"Id\":\"{8}\"",
123 | FacetCount,
124 | VertexCount,
125 | string.Join( ",", VertexCoords.Select( i => ( _export_factor * i ).ToString( "0.#" ) ).ToArray() ),
126 | string.Join( ",", VertexIndices.Select( i => i.ToString() ).ToArray() ),
127 | string.Join( ",", Normals.Select( a => a.ToString( "0.####" ) ).ToArray() ),
128 | string.Join( ",", NormalIndices.Select( i => i.ToString() ) ),
129 | string.Join( ",", Center.Select( i => ( _export_factor * i ).ToString( "0.#" ) ) ),
130 | Color,
131 | Id );
132 |
133 | return "\n{" + s + "\n}";
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/AutoCADCustomJsonExporter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {4EFE4654-706B-42E1-A88C-D71E2B34F66F}
8 | Library
9 | Properties
10 | JsonExporter
11 | JsonExporter
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcCoreMgd.dll
35 | False
36 |
37 |
38 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcDbMgd.dll
39 | False
40 |
41 |
42 | D:\Others\New folder (2)\Autodesk_ObjectARX_2016_Win_64_and_32_Bit\inc\AcMgd.dll
43 | False
44 |
45 |
46 | False
47 | bin\Debug\Newtonsoft.Json.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
72 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/CentroidVolume.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Autodesk.Revit.DB;
3 |
4 | namespace CustomExporterAdnMeshJson
5 | {
6 | ///
7 | /// Calculate and store the centroid and volume
8 | /// from a set of triangular facets.
9 | ///
10 | class CentroidVolume
11 | {
12 | XYZ _centroid;
13 | double _volume;
14 |
15 | public CentroidVolume()
16 | {
17 | Init();
18 | }
19 |
20 | public void Init()
21 | {
22 | _centroid = XYZ.Zero;
23 | _volume = 0.0;
24 | }
25 |
26 | public void AddTriangle( XYZ[] p )
27 | {
28 | double vol
29 | = p[0].X * ( p[1].Y * p[2].Z - p[2].Y * p[1].Z )
30 | + p[0].Y * ( p[1].Z * p[2].X - p[2].Z * p[1].X )
31 | + p[0].Z * ( p[1].X * p[2].Y - p[2].X * p[1].Y );
32 |
33 | _centroid += vol * ( p[0] + p[1] + p[2] );
34 | _volume += vol;
35 | }
36 |
37 | ///
38 | /// Set centroid coordinates and volume
39 | /// to their final values when completed.
40 | ///
41 | public void Complete()
42 | {
43 | _centroid /= 4 * _volume;
44 | _volume /= 6;
45 | }
46 |
47 | public XYZ Centroid
48 | {
49 | get
50 | {
51 | return _centroid;
52 | }
53 | }
54 |
55 | public double Volume
56 | {
57 | get
58 | {
59 | return _volume;
60 | }
61 | }
62 |
63 | override public string ToString()
64 | {
65 | return Util.RealString( _volume ) + "@"
66 | + Util.PointString( _centroid );
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/Command.cs:
--------------------------------------------------------------------------------
1 | #region Namespaces
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using Autodesk.Revit.ApplicationServices;
6 | using Autodesk.Revit.Attributes;
7 | using Autodesk.Revit.DB;
8 | using Autodesk.Revit.UI;
9 | using Autodesk.Revit.UI.Selection;
10 | using System.IO;
11 | #endregion
12 |
13 | namespace CustomExporterAdnMeshJson
14 | {
15 | ///
16 | /// ADN mesh data custom exporter
17 | /// external command mainline.
18 | ///
19 | [Transaction( TransactionMode.ReadOnly )]
20 | public class Command : IExternalCommand
21 | {
22 | public Result Execute(
23 | ExternalCommandData commandData,
24 | ref string message,
25 | ElementSet elements )
26 | {
27 | UIApplication uiapp = commandData.Application;
28 | UIDocument uidoc = uiapp.ActiveUIDocument;
29 | Application app = uiapp.Application;
30 | Document doc = uidoc.Document;
31 |
32 | // This command requires an active document
33 |
34 | if( null == uidoc )
35 | {
36 | message = "Please run this command in an active project document.";
37 | return Result.Failed;
38 | }
39 |
40 | View3D view = doc.ActiveView as View3D;
41 |
42 | if( null == view )
43 | {
44 | message = "Please run this command in a 3D view.";
45 | return Result.Failed;
46 | }
47 |
48 | // Instantiate our custom context
49 |
50 | ExportContextAdnMesh context
51 | = new ExportContextAdnMesh( doc );
52 |
53 | // Instantiate a custom exporter with it
54 |
55 | using( CustomExporter exporter
56 | = new CustomExporter( doc, context ) )
57 | {
58 | // Tell the exporter whether we need face info.
59 | // If not, it is better to exclude them, since
60 | // processing faces takes significant time and
61 | // memory. In any case, tessellated polymeshes
62 | // can be exported (and will be sent to the
63 | // context). Excluding faces just excludes the calls,
64 | // not the actual processing of face tessellation.
65 | // Meshes of the faces will still be received by
66 | // the context.
67 |
68 | exporter.IncludeFaces = false;
69 |
70 | exporter.Export( view );
71 | }
72 |
73 | // Save ADN mesh data in JSON format
74 |
75 | StreamWriter s = new StreamWriter(
76 | "C:/tmp/test.json" );
77 |
78 | s.Write( "[" );
79 |
80 | int i = 0;
81 |
82 | foreach( AdnMeshData d in context.MeshData )
83 | {
84 | if( 0 < i ) { s.Write( ',' ); }
85 |
86 | s.Write( d.ToJson() );
87 |
88 | ++i;
89 | }
90 |
91 | s.Write( "\n]\n" );
92 | s.Close();
93 |
94 | return Result.Succeeded;
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/Converter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Autodesk.AutoCAD.DatabaseServices;
7 | using Autodesk.AutoCAD.ApplicationServices;
8 | using Autodesk.AutoCAD.Runtime;
9 | using Newtonsoft.Json;
10 | using Autodesk.AutoCAD.Windows;
11 | using System.IO;
12 | using System.Windows;
13 |
14 |
15 | namespace JsonExporter
16 | {
17 | public class Converter
18 | {
19 | private Autodesk.AutoCAD.Windows.PaletteSet _3ps = null;
20 |
21 | private static Document _launchDoc = null;
22 |
23 | [JavaScriptCallback("GetSolids")]
24 | public string GetSolids(string jsonArgs)
25 | {
26 | var doc = GetActiveDocument(Application.DocumentManager);
27 |
28 | // If we didn't find a document, return
29 |
30 | if (doc == null)
31 | return "";
32 |
33 | // We could probably get away without locking the document
34 | // - as we only need to read - but it's good practice to
35 | // do it anyway
36 |
37 | using (var dl = doc.LockDocument())
38 | {
39 | var db = doc.Database;
40 | var ed = doc.Editor;
41 |
42 | // Capture our Extents3d objects in a list
43 |
44 | var sols = new List();
45 |
46 | using (var tr = doc.TransactionManager.StartTransaction())
47 | {
48 | // Start by getting the modelspace
49 |
50 | var ms =
51 | (BlockTableRecord)tr.GetObject(
52 | SymbolUtilityServices.GetBlockModelSpaceId(db),
53 | OpenMode.ForRead
54 | );
55 |
56 | // Get each Solid3d in modelspace and add its extents
57 | // to the list
58 |
59 | foreach (var id in ms)
60 | {
61 | var obj = tr.GetObject(id, OpenMode.ForRead);
62 | var sol = obj as Solid3d;
63 | if (sol != null)
64 | {
65 | sols.Add(sol.GeometricExtents);
66 | }
67 | }
68 | tr.Commit();
69 | }
70 | return GetSolidsString(sols);
71 | }
72 | }
73 |
74 | private Document GetActiveDocument(DocumentCollection dm)
75 | {
76 | // If we're called from an HTML document, the active
77 | // document may be null
78 |
79 | var doc = dm.MdiActiveDocument;
80 | if (doc == null)
81 | {
82 | doc = _launchDoc;
83 | }
84 | return doc;
85 | }
86 |
87 | // Helper function to build a JSON string containing our
88 | // sorted extents list
89 |
90 | private string GetSolidsString(List lst)
91 | {
92 | var sb = new StringBuilder("{\"retCode\":0, \"result\":[");
93 |
94 | bool first = true;
95 | foreach (var ext in lst)
96 | {
97 | if (first)
98 | first = false;
99 | else
100 | sb.Append(",");
101 |
102 | sb.Append(
103 | string.Format(
104 | "{{\"min\":{0},\"max\":{1}}}",
105 | JsonConvert.SerializeObject(ext.MinPoint),
106 | JsonConvert.SerializeObject(ext.MaxPoint)
107 | )
108 | );
109 | }
110 | sb.Append("]}");
111 |
112 | File.WriteAllText(@"D:\3dsolids.json", sb.ToString()); //test
113 |
114 | return sb.ToString();
115 | }
116 |
117 | [CommandMethod("THREEDOC")]
118 | public static void ThreeDocument()
119 | {
120 | _launchDoc = Application.DocumentManager.MdiActiveDocument;
121 | _launchDoc.BeginDocumentClose +=
122 | (s, e) => { _launchDoc = null; };
123 |
124 | Application.DocumentWindowCollection.AddDocumentWindow("Three.js Document", GetHtmlPathThree()
125 | );
126 | }
127 |
128 | [CommandMethod("THREE")]
129 | public void ThreePalette()
130 | {
131 | _launchDoc = null;
132 |
133 | _3ps =
134 | ShowPalette(
135 | _3ps,
136 | new Guid("9CEE43FF-FDD7-406A-89B2-6A48D4169F71"),
137 | "THREE",
138 | "Three.js Examples",
139 | GetHtmlPathThree()
140 | );
141 | }
142 |
143 | // Helper function to show a palette
144 |
145 | private PaletteSet ShowPalette(PaletteSet ps, Guid guid, string cmd, string title, Uri uri)
146 | {
147 | if (ps == null)
148 | {
149 | ps = new PaletteSet(cmd, guid);
150 | }
151 | else
152 | {
153 | if (ps.Visible)
154 | return ps;
155 | }
156 |
157 | if (ps.Count != 0)
158 | {
159 | ps[0].PaletteSet.Remove(0);
160 | }
161 |
162 | ps.Add(title, uri);
163 | ps.Visible = true;
164 |
165 | return ps;
166 | }
167 |
168 | // Helper function to get the path to our HTML files
169 |
170 | private static string GetHtmlPath()
171 | {
172 | // Use this approach if loading the HTML from the same
173 | // location as your .NET module
174 |
175 | //var asm = Assembly.GetExecutingAssembly();
176 | //return Path.GetDirectoryName(asm.Location) + "\\";
177 |
178 | return "http://through-the-interface.typepad.com/files/";
179 | }
180 |
181 | private static Uri GetHtmlPathThree()
182 | {
183 | return new Uri(GetHtmlPath() + "threesolids.html");
184 | }
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/ExportContextAdnMesh.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using Autodesk.Revit.DB;
5 |
6 | namespace CustomExporterAdnMeshJson
7 | {
8 | ///
9 | /// Custom exporter IExportContext implementation to
10 | /// capture ADN mesh data.
11 | ///
12 | class ExportContextAdnMesh : IExportContext
13 | {
14 | Document _doc;
15 |
16 | ///
17 | /// Stack of transformations for
18 | /// link and instance elements.
19 | ///
20 | Stack _transformationStack
21 | = new Stack();
22 |
23 | ///
24 | /// List of triangle vertices.
25 | ///
26 | VertexLookupInt _vertices = new VertexLookupInt();
27 |
28 | ///
29 | /// List of triangles, defined as
30 | /// triples of vertex indices.
31 | ///
32 | List _triangles = new List();
33 |
34 | ///
35 | /// List of normal vectors, defined by an index
36 | /// into the normal lookup for each triangle vertex.
37 | ///
38 | List _normalIndices = new List();
39 |
40 | NormalLookupXyz _normals = new NormalLookupXyz();
41 |
42 | ///
43 | /// Calculate center of gravity of current element.
44 | ///
45 | CentroidVolume _centroid_volume
46 | = new CentroidVolume();
47 |
48 | Color _color;
49 | double _transparency;
50 | List _data;
51 |
52 | public ExportContextAdnMesh( Document doc )
53 | {
54 | _doc = doc;
55 | _data = new List();
56 | _transformationStack.Push( Transform.Identity );
57 | }
58 |
59 | public AdnMeshData[] MeshData
60 | {
61 | get
62 | {
63 | return _data.ToArray();
64 | }
65 | }
66 |
67 | Transform CurrentTransform
68 | {
69 | get
70 | {
71 | return _transformationStack.Peek();
72 | }
73 | }
74 |
75 | ///
76 | /// Store a triangle, adding new vertices for it
77 | /// to our vertex lookup dictionary if needed and
78 | /// accumulating its volume and centroid contribution.
79 | ///
80 | void StoreTriangle(
81 | IList vertices,
82 | PolymeshFacet triangle,
83 | XYZ normal )
84 | {
85 | // Retrieve the three triangle vertices
86 |
87 | Transform currentTransform = CurrentTransform;
88 |
89 | XYZ[] p = new XYZ[] {
90 | currentTransform.OfPoint( vertices[triangle.V1] ),
91 | currentTransform.OfPoint( vertices[triangle.V2] ),
92 | currentTransform.OfPoint( vertices[triangle.V3] )
93 | };
94 |
95 | // Ensure the three are ordered counter-clockwise
96 |
97 | //XYZ v = p[1] - p[0];
98 | //XYZ w = p[2] - p[0];
99 |
100 | //Debug.Assert( Util.IsRightHanded( v, w, normal ),
101 | // "expected counter-clockwise vertex order" );
102 |
103 | // Centroid and volume calculation
104 |
105 | _centroid_volume.AddTriangle( p );
106 |
107 | // Store vertex, facet and normals
108 |
109 | for( int i = 0; i < 3; ++i )
110 | {
111 | PointInt q = new PointInt( p[i] );
112 |
113 | _triangles.Add( _vertices.AddVertex( q ) );
114 |
115 | _normalIndices.Add( _normals.AddNormal(
116 | currentTransform.OfVector( normal ) ) );
117 | }
118 | }
119 |
120 | public void Finish()
121 | {
122 | Debug.Print( "Finish" );
123 | }
124 |
125 | public bool IsCanceled()
126 | {
127 | return false;
128 | }
129 |
130 | public void OnDaylightPortal(
131 | DaylightPortalNode node )
132 | {
133 | throw new NotImplementedException();
134 | }
135 |
136 | public RenderNodeAction OnElementBegin(
137 | ElementId elementId )
138 | {
139 | string s = elementId.IntegerValue.ToString();
140 |
141 | Debug.Print( "ElementBegin id " + s );
142 |
143 | _vertices.Clear();
144 | _triangles.Clear();
145 | _normals.Clear();
146 | _normalIndices.Clear();
147 | _centroid_volume.Init();
148 |
149 | return RenderNodeAction.Proceed;
150 | }
151 |
152 | public void OnElementEnd( ElementId elementId )
153 | {
154 | Debug.Print( "ElementEnd" );
155 |
156 | // Set centroid coordinates to their final value
157 |
158 | _centroid_volume.Complete();
159 |
160 | string metadataId = _doc.GetElement(
161 | elementId ).UniqueId;
162 |
163 | AdnMeshData meshData = new AdnMeshData(
164 | _vertices, _triangles, _normals, _normalIndices,
165 | new PointInt( _centroid_volume.Centroid ),
166 | _color, _transparency, metadataId );
167 |
168 | _data.Add( meshData );
169 | }
170 |
171 | public RenderNodeAction OnFaceBegin( FaceNode node )
172 | {
173 | throw new NotImplementedException();
174 | }
175 |
176 | public void OnFaceEnd( FaceNode node )
177 | {
178 | throw new NotImplementedException();
179 | }
180 |
181 | public RenderNodeAction OnInstanceBegin(
182 | InstanceNode node )
183 | {
184 | FamilySymbol symbol = _doc.GetElement(
185 | node.GetSymbolId() ) as FamilySymbol;
186 |
187 | Debug.Assert( null != symbol,
188 | "expected valid family symbol" );
189 |
190 | Debug.Print( "InstanceBegin "
191 | + symbol.Category.Name + " : "
192 | + symbol.Family.Name + " : "
193 | + symbol.Name );
194 |
195 | _transformationStack.Push( CurrentTransform
196 | .Multiply( node.GetTransform() ) );
197 |
198 | return RenderNodeAction.Proceed;
199 | }
200 |
201 | public void OnInstanceEnd( InstanceNode node )
202 | {
203 | Debug.Print( "InstanceEnd" );
204 |
205 | _transformationStack.Pop();
206 | }
207 |
208 | public void OnLight( LightNode node )
209 | {
210 | throw new NotImplementedException();
211 | }
212 |
213 | public RenderNodeAction OnLinkBegin( LinkNode node )
214 | {
215 | _transformationStack.Push( CurrentTransform
216 | .Multiply( node.GetTransform() ) );
217 |
218 | throw new NotImplementedException();
219 | }
220 |
221 | public void OnLinkEnd( LinkNode node )
222 | {
223 | _transformationStack.Pop();
224 |
225 | throw new NotImplementedException();
226 | }
227 |
228 | public void OnMaterial( MaterialNode node )
229 | {
230 | Color c = node.Color;
231 | double t = node.Transparency;
232 |
233 | string s = string.Format( "({0},{1},{2})",
234 | c.Red, c.Green, c.Blue );
235 |
236 | Debug.Print( "Colour " + s + ", transparency "
237 | + t.ToString( "0.##" ) );
238 |
239 | _color = c;
240 | _transparency = t;
241 | }
242 |
243 | public void OnPolymesh( PolymeshTopology node )
244 | {
245 | int nPts = node.NumberOfPoints;
246 | int nFacets = node.NumberOfFacets;
247 |
248 | DistributionOfNormals distrib
249 | = node.DistributionOfNormals;
250 |
251 | Debug.Print( string.Format(
252 | "Polymesh {0} vertices {1} facets",
253 | nPts, nFacets ) );
254 |
255 | int iFacet = 0;
256 | int iPoint = 0;
257 |
258 | IList vertices = node.GetPoints();
259 | IList normals = node.GetNormals();
260 | XYZ normal;
261 |
262 | foreach( PolymeshFacet triangle in node.GetFacets() )
263 | {
264 | // Just grab one normal per facet; ignore the
265 | // three normals per point if they differ.
266 |
267 | if( DistributionOfNormals.OnePerFace == distrib )
268 | {
269 | normal = node.GetNormal( 0 );
270 | }
271 | else if( DistributionOfNormals.OnEachFacet
272 | == distrib )
273 | {
274 | normal = node.GetNormal( iFacet++ );
275 | }
276 | else
277 | {
278 | Debug.Assert( DistributionOfNormals
279 | .AtEachPoint == distrib, "what else?" );
280 |
281 | normal = node.GetNormal( triangle.V1 )
282 | + node.GetNormal( triangle.V2 )
283 | + node.GetNormal( triangle.V3 );
284 | normal /= 3.0;
285 | }
286 |
287 | StoreTriangle( vertices, triangle, normal );
288 | }
289 | }
290 |
291 | public void OnRPC( RPCNode node )
292 | {
293 | throw new NotImplementedException();
294 | }
295 |
296 | public RenderNodeAction OnViewBegin( ViewNode node )
297 | {
298 | View3D view = _doc.GetElement( node.ViewId )
299 | as View3D;
300 |
301 | Debug.Assert( null != view,
302 | "expected valid 3D view" );
303 |
304 | Debug.Print( "ViewBegin " + view.Name );
305 |
306 | return RenderNodeAction.Proceed;
307 | }
308 |
309 | public void OnViewEnd( ElementId elementId )
310 | {
311 | Debug.Print( "ViewEnd" );
312 | }
313 |
314 | public bool Start()
315 | {
316 | Debug.Print( "Start" );
317 | return true;
318 | }
319 | }
320 | }
321 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/NormalLookupXyz.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Autodesk.Revit.DB;
4 |
5 | namespace CustomExporterAdnMeshJson
6 | {
7 | ///
8 | /// A facet normal vector lookup class to avoid
9 | /// duplicate normal vector definitions.
10 | ///
11 | public class NormalLookupXyz : Dictionary
12 | {
13 | #region XyzVectorEqualityComparer
14 | ///
15 | /// Define equality for Revit XYZ vectors.
16 | ///
17 | class XyzVectorEqualityComparer : IEqualityComparer
18 | {
19 | const double _eps = 1.0e-9;
20 |
21 | public bool Equals( XYZ v, XYZ w )
22 | {
23 | return v.IsAlmostEqualTo( w,
24 | _eps );
25 | }
26 |
27 | public int GetHashCode( XYZ v )
28 | {
29 | return Util.PointString( v ).GetHashCode();
30 | }
31 | }
32 | #endregion // XyzVectorEqualityComparer
33 |
34 | public NormalLookupXyz()
35 | : base( new XyzVectorEqualityComparer() )
36 | {
37 | }
38 |
39 | ///
40 | /// Return the index of the given normal vector,
41 | /// adding a new entry if required.
42 | ///
43 | public int AddNormal( XYZ v )
44 | {
45 | return ContainsKey( v )
46 | ? this[v]
47 | : this[v] = Count;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/PointInt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Autodesk.Revit.DB;
3 |
4 | namespace CustomExporterAdnMeshJson
5 | {
6 | ///
7 | /// An integer-based 3D point class.
8 | ///
9 | class PointInt : IComparable
10 | {
11 | public int X { get; set; }
12 | public int Y { get; set; }
13 | public int Z { get; set; }
14 |
15 | //public PointInt( int x, int y, int z )
16 | //{
17 | // X = x;
18 | // Y = y;
19 | // Z = z;
20 | //}
21 |
22 | const double _feet_to_mm = 25.4 * 12;
23 |
24 | static int ConvertFeetToMillimetres( double d )
25 | {
26 | return (int) ( _feet_to_mm * d + 0.5 );
27 | }
28 |
29 | ///
30 | /// Create an integer-based point in millimetres
31 | /// from a given point in imperial coordinates.
32 | ///
33 | public PointInt( XYZ p )
34 | {
35 | X = ConvertFeetToMillimetres( p.X );
36 | Y = ConvertFeetToMillimetres( p.Y );
37 | Z = ConvertFeetToMillimetres( p.Z );
38 | }
39 |
40 | public int CompareTo( PointInt a )
41 | {
42 | int d = X - a.X;
43 |
44 | if( 0 == d )
45 | {
46 | d = Y - a.Y;
47 |
48 | if( 0 == d )
49 | {
50 | d = Z - a.Z;
51 | }
52 | }
53 | return d;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("JsonExporter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("JsonExporter")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("4cc3651e-5210-4545-9369-dca09bd7fc72")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Autodesk.Revit.DB;
3 |
4 | namespace CustomExporterAdnMeshJson
5 | {
6 | ///
7 | /// Utility methods.
8 | ///
9 | class Util
10 | {
11 | ///
12 | /// Return a string for a real number
13 | /// formatted to two decimal places.
14 | ///
15 | public static string RealString( double a )
16 | {
17 | return a.ToString( "0.##" );
18 | }
19 |
20 | ///
21 | /// Return a string for an XYZ point
22 | /// or vector with its coordinates
23 | /// formatted to two decimal places.
24 | ///
25 | public static string PointString( XYZ p )
26 | {
27 | return string.Format( "({0},{1},{2})",
28 | RealString( p.X ),
29 | RealString( p.Y ),
30 | RealString( p.Z ) );
31 | }
32 |
33 | ///
34 | /// Return the signed volume of the paralleliped
35 | /// spanned by the vectors a, b and c. In German,
36 | /// this is also known as Spatprodukt.
37 | ///
38 | public static double SignedParallelipedVolume(
39 | XYZ a,
40 | XYZ b,
41 | XYZ c )
42 | {
43 | return a.CrossProduct( b ).DotProduct( c );
44 | }
45 |
46 | ///
47 | /// Return true if the three vectors a, b and c
48 | /// form a right handed coordinate system, i.e.
49 | /// the signed volume of the paralleliped spanned
50 | /// by them is positive.
51 | ///
52 | public static bool IsRightHanded( XYZ a, XYZ b, XYZ c )
53 | {
54 | return 0 < SignedParallelipedVolume( a, b, c );
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/VertexLookupInt.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CustomExporterAdnMeshJson
7 | {
8 | ///
9 | /// A vertex lookup class to avoid
10 | /// duplicate vertex definitions.
11 | ///
12 | class VertexLookupInt : Dictionary
13 | {
14 | #region PointIntEqualityComparer
15 | ///
16 | /// Define equality for integer-based PointInt.
17 | ///
18 | class PointIntEqualityComparer : IEqualityComparer
19 | {
20 | public bool Equals( PointInt p, PointInt q )
21 | {
22 | return 0 == p.CompareTo( q );
23 | }
24 |
25 | public int GetHashCode( PointInt p )
26 | {
27 | return ( p.X.ToString()
28 | + "," + p.Y.ToString()
29 | + "," + p.Z.ToString() )
30 | .GetHashCode();
31 | }
32 | }
33 | #endregion // PointIntEqualityComparer
34 |
35 | public VertexLookupInt()
36 | : base( new PointIntEqualityComparer() )
37 | {
38 | }
39 |
40 | ///
41 | /// Return the index of the given vertex,
42 | /// adding a new entry if required.
43 | ///
44 | public int AddVertex( PointInt p )
45 | {
46 | return ContainsKey( p )
47 | ? this[p]
48 | : this[p] = Count;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/utils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.DatabaseServices;
8 | using Autodesk.AutoCAD.Geometry;
9 | using Autodesk.AutoCAD.Windows;
10 | using Newtonsoft.Json;
11 | namespace MyNamespace5
12 | {
13 | internal class MeshData
14 | {
15 | public double _dist;
16 | public string _handle;
17 | public Extents3d _exts;
18 | public Point3dCollection _vertices;
19 | public Int32Collection _faces;
20 | public string _color;
21 |
22 | public MeshData()
23 | {
24 | _dist = 1.0;
25 | _handle = String.Empty;
26 | _exts = new Extents3d();
27 | _vertices = new Point3dCollection();
28 | _faces = new Int32Collection();
29 | _color = String.Empty;
30 | }
31 |
32 | public MeshData(double dist, string handle, Extents3d exts, Point3dCollection vertices, Int32Collection faces, string color)
33 | {
34 | _dist = dist;
35 | _handle = handle;
36 | _exts = exts;
37 | _vertices = vertices;
38 | _faces = faces;
39 | _color = color;
40 | }
41 | }
42 |
43 | internal class Utils
44 | {
45 | // Helper to get the document a palette was launched from
46 | // in the case where the active document is null
47 |
48 | internal static Document GetActiveDocument(
49 | DocumentCollection dm, Document launchDoc = null
50 | )
51 | {
52 | // If we're called from an HTML document, the active
53 | // document may be null
54 |
55 | var doc = dm.MdiActiveDocument;
56 | if (doc == null)
57 | {
58 | doc = launchDoc;
59 | }
60 | return doc;
61 | }
62 |
63 | internal static string GetSolids(
64 | Document launchDoc, Point3d camPos)
65 | {
66 | var doc =
67 | Utils.GetActiveDocument(
68 | Application.DocumentManager,
69 | launchDoc
70 | );
71 |
72 | // If we didn't find a document, return
73 |
74 | if (doc == null)
75 | return "";
76 |
77 | // We could probably get away without locking the document
78 | // - as we only need to read - but it's good practice to
79 | // do it anyway
80 |
81 | using (var dl = doc.LockDocument())
82 | {
83 | var db = doc.Database;
84 | var ed = doc.Editor;
85 |
86 | var ids = new ObjectIdCollection();
87 |
88 | using (
89 | var tr = doc.TransactionManager.StartOpenCloseTransaction()
90 | )
91 | {
92 | // Start by getting the modelspace
93 |
94 | var ms =
95 | (BlockTableRecord)tr.GetObject(
96 | SymbolUtilityServices.GetBlockModelSpaceId(db),
97 | OpenMode.ForRead
98 | );
99 |
100 | // If in palette mode we can get the camera from the
101 | // Editor, otherwise we rely on what was provided when
102 | // the HTML document was launched
103 |
104 | if (launchDoc == null)
105 | {
106 | var view = ed.GetCurrentView();
107 | camPos = view.Target + view.ViewDirection;
108 | }
109 |
110 | // Get each Solid3d in modelspace and add its extents
111 | // to the sorted list keyed off the distance from the
112 | // closest face of the solid (not necessarily true,
113 | // but this only really is a crude approximation)
114 |
115 | foreach (var id in ms)
116 | {
117 | ids.Add(id);
118 | }
119 | tr.Commit();
120 | }
121 |
122 | var sols = SolidInfoForCollection(doc, camPos, ids);
123 |
124 | return SolidsString(sols);
125 | }
126 | }
127 |
128 | internal static List SolidInfoForCollection(Document doc, Point3d camPos, ObjectIdCollection ids)
129 | {
130 | var sols = new List();
131 |
132 | using (var tr = doc.TransactionManager.StartOpenCloseTransaction())
133 | {
134 | foreach (ObjectId id in ids)
135 | {
136 | Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity;
137 |
138 | // Entity handle to name the Three.js objects
139 | String hand = ent.Handle.ToString();
140 | Autodesk.AutoCAD.Colors.EntityColor clr = ent.EntityColor;
141 |
142 | // Entity color to use for the Three.js objects
143 | long b, g, r;
144 | if (ent.ColorIndex < 256)
145 | {
146 | System.Byte byt = System.Convert.ToByte(ent.ColorIndex);
147 | int rgb = Autodesk.AutoCAD.Colors.EntityColor.LookUpRgb(byt);
148 | b = (rgb & 0xffL);
149 | g = (rgb & 0xff00L) >> 8;
150 | r = rgb >> 16;
151 | }
152 | else
153 | {
154 | b = 127;
155 | g = 127;
156 | r = 127;
157 | }
158 | String entColor = "0x" + String.Format("{0:X2}{1:X2}{2:X2}", r, g, b);
159 |
160 | // Entity extents
161 | Extents3d ext = ent.GeometricExtents;
162 | var tmp = ext.MinPoint + 0.5 * (ext.MaxPoint - ext.MinPoint);
163 | Vector3d dir = ext.MaxPoint - ext.MinPoint;
164 | var mid = new Point3d(ext.MinPoint.X, tmp.Y, tmp.Z);
165 | var dist = camPos.DistanceTo(mid);
166 |
167 | if (id.ObjectClass.Name.Equals("AcDbSubDMesh"))
168 | {
169 | // Already a Mesh. Get the face info and clean it up
170 | // a bit to export it as a THREE.Face3 which only has three vertices
171 |
172 | var mesh = ent as SubDMesh;
173 |
174 | Point3dCollection threeVertices = new Point3dCollection();
175 | Autodesk.AutoCAD.Geometry.Int32Collection threeFaceInfo = new Autodesk.AutoCAD.Geometry.Int32Collection();
176 |
177 | Point3dCollection vertices = mesh.Vertices;
178 |
179 | int[] faceArr = mesh.FaceArray.ToArray();
180 | int[] edgeArr = mesh.EdgeArray.ToArray();
181 |
182 | Autodesk.AutoCAD.Geometry.Int32Collection faceVertices = new Autodesk.AutoCAD.Geometry.Int32Collection();
183 |
184 | int verticesInFace = 0;
185 | int facecnt = 0;
186 | for (int x = 0; x < faceArr.Length; facecnt++, x = x + verticesInFace + 1)
187 | {
188 | faceVertices.Clear();
189 |
190 | verticesInFace = faceArr[x];
191 | for (int y = x + 1; y <= x + verticesInFace; y++)
192 | {
193 | faceVertices.Add(faceArr[y]);
194 | }
195 |
196 | // Merging of mesh faces can result in faces with multiple vertices
197 | // A simple collinearity check can help remove those redundant vertices
198 | bool continueCollinearCheck = false;
199 | do
200 | {
201 | continueCollinearCheck = false;
202 | for (int index = 0; index < faceVertices.Count; index++)
203 | {
204 | int v1 = index;
205 | int v2 = (index + 1) >= faceVertices.Count ? (index + 1) - faceVertices.Count : index + 1;
206 | int v3 = (index + 2) >= faceVertices.Count ? (index + 2) - faceVertices.Count : index + 2;
207 |
208 | // Check collinear
209 | Point3d p1 = vertices[faceVertices[v1]];
210 | Point3d p2 = vertices[faceVertices[v2]];
211 | Point3d p3 = vertices[faceVertices[v3]];
212 |
213 | Vector3d vec1 = p1 - p2;
214 | Vector3d vec2 = p2 - p3;
215 | if (vec1.IsCodirectionalTo(vec2))
216 | {
217 | faceVertices.RemoveAt(v2);
218 | continueCollinearCheck = true;
219 | break;
220 | }
221 | }
222 | } while (continueCollinearCheck);
223 |
224 | if (faceVertices.Count == 3)
225 | {
226 | Point3d p1 = vertices[faceVertices[0]];
227 | Point3d p2 = vertices[faceVertices[1]];
228 | Point3d p3 = vertices[faceVertices[2]];
229 |
230 | if (!threeVertices.Contains(p1))
231 | threeVertices.Add(p1);
232 | threeFaceInfo.Add(threeVertices.IndexOf(p1));
233 |
234 | if (!threeVertices.Contains(p2))
235 | threeVertices.Add(p2);
236 | threeFaceInfo.Add(threeVertices.IndexOf(p2));
237 |
238 | if (!threeVertices.Contains(p3))
239 | threeVertices.Add(p3);
240 | threeFaceInfo.Add(threeVertices.IndexOf(p3));
241 | }
242 | else if (faceVertices.Count == 4)
243 | { // A face with 4 vertices, lets split it to
244 | // make it easier later to create a THREE.Face3
245 | Point3d p1 = vertices[faceVertices[0]];
246 | Point3d p2 = vertices[faceVertices[1]];
247 | Point3d p3 = vertices[faceVertices[2]];
248 |
249 | if (!threeVertices.Contains(p1))
250 | threeVertices.Add(p1);
251 | threeFaceInfo.Add(threeVertices.IndexOf(p1));
252 |
253 | if (!threeVertices.Contains(p2))
254 | threeVertices.Add(p2);
255 | threeFaceInfo.Add(threeVertices.IndexOf(p2));
256 |
257 | if (!threeVertices.Contains(p3))
258 | threeVertices.Add(p3);
259 | threeFaceInfo.Add(threeVertices.IndexOf(p3));
260 |
261 | p1 = vertices[faceVertices[2]];
262 | p2 = vertices[faceVertices[3]];
263 | p3 = vertices[faceVertices[0]];
264 |
265 | if (!threeVertices.Contains(p1))
266 | threeVertices.Add(p1);
267 | threeFaceInfo.Add(threeVertices.IndexOf(p1));
268 |
269 | if (!threeVertices.Contains(p2))
270 | threeVertices.Add(p2);
271 | threeFaceInfo.Add(threeVertices.IndexOf(p2));
272 |
273 | if (!threeVertices.Contains(p3))
274 | threeVertices.Add(p3);
275 | threeFaceInfo.Add(threeVertices.IndexOf(p3));
276 | }
277 | else
278 | {
279 | Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Face with more than 4 vertices will need triangulation to import in Three.js ");
280 | }
281 | }
282 |
283 | sols.Add(new MeshData(dist, hand, ext, threeVertices, threeFaceInfo, entColor));
284 | }
285 | else if(id.ObjectClass.Name.Equals("AcDb3dSolid"))
286 | {
287 | // Mesh the solid to export to Three.js
288 | Autodesk.AutoCAD.DatabaseServices.Solid3d sld = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Solid3d;
289 |
290 | MeshFaceterData mfd = new MeshFaceterData();
291 | // Only triangles
292 | mfd.FaceterMeshType = 2;
293 |
294 | // May need change based on how granular we want the mesh to be.
295 | mfd.FaceterMaxEdgeLength = dir.Length * 0.025;
296 |
297 | MeshDataCollection md = SubDMesh.GetObjectMesh(sld, mfd);
298 |
299 | Point3dCollection threeVertices = new Point3dCollection();
300 | Autodesk.AutoCAD.Geometry.Int32Collection threeFaceInfo = new Autodesk.AutoCAD.Geometry.Int32Collection();
301 |
302 | Point3dCollection vertices = md.VertexArray;
303 |
304 | int[] faceArr = md.FaceArray.ToArray();
305 |
306 | Autodesk.AutoCAD.Geometry.Int32Collection faceVertices = new Autodesk.AutoCAD.Geometry.Int32Collection();
307 |
308 | int verticesInFace = 0;
309 | int facecnt = 0;
310 | for (int x = 0; x < faceArr.Length; facecnt++, x = x + verticesInFace + 1)
311 | {
312 | faceVertices.Clear();
313 |
314 | verticesInFace = faceArr[x];
315 | for (int y = x + 1; y <= x + verticesInFace; y++)
316 | {
317 | faceVertices.Add(faceArr[y]);
318 | }
319 |
320 | if (faceVertices.Count == 3)
321 | {
322 | Point3d p1 = vertices[faceVertices[0]];
323 | Point3d p2 = vertices[faceVertices[1]];
324 | Point3d p3 = vertices[faceVertices[2]];
325 |
326 | if (!threeVertices.Contains(p1))
327 | threeVertices.Add(p1);
328 | threeFaceInfo.Add(threeVertices.IndexOf(p1));
329 |
330 | if (!threeVertices.Contains(p2))
331 | threeVertices.Add(p2);
332 | threeFaceInfo.Add(threeVertices.IndexOf(p2));
333 |
334 | if (!threeVertices.Contains(p3))
335 | threeVertices.Add(p3);
336 | threeFaceInfo.Add(threeVertices.IndexOf(p3));
337 | }
338 | }
339 |
340 | sols.Add(new MeshData(dist, hand, ext, threeVertices, threeFaceInfo, entColor));
341 |
342 | tr.Commit();
343 | }
344 | }
345 | }
346 | return sols;
347 | }
348 |
349 | // Helper function to build a JSON string containing a
350 | // sorted extents list
351 |
352 | internal static string SolidsString(
353 | List lst)
354 | {
355 | var sb = new StringBuilder("{\"retCode\":0, \"result\":[");
356 |
357 | var first = true;
358 | foreach (var data in lst)
359 | {
360 | if (!first)
361 | sb.Append(",");
362 |
363 | first = false;
364 | var hand = data._handle;
365 | var ext = data._exts;
366 | var vertices = data._vertices;
367 | var faces = data._faces;
368 | var color = data._color;
369 |
370 | sb.AppendFormat(
371 | "{{\"min\":{0},\"max\":{1},\"handle\":\"{2}\",\"vertices\":{3},\"faces\":{4},\"color\":\"{5}\"}}",
372 | JsonConvert.SerializeObject(ext.MinPoint),
373 | JsonConvert.SerializeObject(ext.MaxPoint),
374 | hand,
375 | JsonConvert.SerializeObject(vertices),
376 | JsonConvert.SerializeObject(faces),
377 | color
378 | );
379 | }
380 | sb.Append("]}");
381 |
382 | return sb.ToString();
383 | }
384 |
385 | // Helper function to build a JSON string containing a
386 | // list of handles
387 |
388 | internal static string GetHandleString(ObjectIdCollection _ids)
389 | {
390 | var sb = new StringBuilder("{\"handles\":[");
391 | bool first = true;
392 | foreach (ObjectId id in _ids)
393 | {
394 | if (!first)
395 | {
396 | sb.Append(",");
397 | }
398 |
399 | first = false;
400 |
401 | sb.AppendFormat(
402 | "{{\"handle\":\"{0}\"}}",
403 | id.Handle.ToString()
404 | );
405 | }
406 | sb.Append("]}");
407 | return sb.ToString();
408 | }
409 |
410 | // Helper function to show a palette
411 |
412 | internal static PaletteSet ShowPalette(
413 | PaletteSet ps, Guid guid, string cmd, string title, Uri uri,
414 | bool reload = false
415 | )
416 | {
417 | // If the reload flag is true we'll force an unload/reload
418 | // (this isn't strictly needed - given our refresh function -
419 | // but I've left it in for possible future use)
420 |
421 | if (reload && ps != null)
422 | {
423 | // Close the palette and make sure we process windows
424 | // messages, otherwise sizing is a problem
425 |
426 | ps.Close();
427 | System.Windows.Forms.Application.DoEvents();
428 | ps.Dispose();
429 | ps = null;
430 | }
431 |
432 | if (ps == null)
433 | {
434 | ps = new PaletteSet(cmd, guid);
435 | }
436 | else
437 | {
438 | if (ps.Visible)
439 | return ps;
440 | }
441 |
442 | if (ps.Count != 0)
443 | {
444 | ps.Remove(0);
445 | }
446 |
447 | ps.Add(title, uri);
448 | ps.Visible = true;
449 |
450 | return ps;
451 | }
452 |
453 | internal static Matrix3d Dcs2Wcs(AbstractViewTableRecord v)
454 | {
455 | return
456 | Matrix3d.Rotation(-v.ViewTwist, v.ViewDirection, v.Target) *
457 | Matrix3d.Displacement(v.Target - Point3d.Origin) *
458 | Matrix3d.PlaneToWorld(v.ViewDirection);
459 | }
460 |
461 | internal static Extents3d ScreenExtents(
462 | AbstractViewTableRecord vtr
463 | )
464 | {
465 | // Get the centre of the screen in WCS and use it
466 | // with the diagonal vector to add the corners to the
467 | // extents object
468 |
469 | var ext = new Extents3d();
470 | var vec = new Vector3d(0.5 * vtr.Width, 0.5 * vtr.Height, 0);
471 | var ctr =
472 | new Point3d(vtr.CenterPoint.X, vtr.CenterPoint.Y, 0);
473 | var dcs = Utils.Dcs2Wcs(vtr);
474 | ext.AddPoint((ctr + vec).TransformBy(dcs));
475 | ext.AddPoint((ctr - vec).TransformBy(dcs));
476 |
477 | return ext;
478 | }
479 |
480 | // Helper function to get the path to our HTML files
481 |
482 | internal static string GetHtmlPath()
483 | {
484 | // Use this approach if loading the HTML from the same
485 | // location as your .NET module
486 |
487 | //var asm = Assembly.GetExecutingAssembly();
488 | //return Path.GetDirectoryName(asm.Location) + "\\";
489 |
490 | return @"D:\KB_P\ThreeIntegration - Part1\MyTest1_Net\files\";
491 | }
492 | }
493 | }
494 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/JsonExporter/x.cs:
--------------------------------------------------------------------------------
1 | #region Assembly RevitAPI.dll, v4.0.30319
2 | // C:\Program Files\Autodesk\Revit 2014\RevitAPI.dll
3 | #endregion
4 |
5 | using System;
6 |
7 | namespace Autodesk.Revit.DB
8 | {
9 | // Summary:
10 | // An interface that is used in custom export to process a Revit model. An
11 | // instance of this class is passed in as a parameter of a CustomExporter.
12 | // The methods herein are then called at times of exporting entities of the
13 | // model.
14 | public interface IExportContext
15 | {
16 | // Summary:
17 | // This method is called at the very end of the export proces, after all entities
18 | // were processed (or after the process was cancelled).
19 | void Finish();
20 | //
21 | // Summary:
22 | // This method is queried at the begining of every element.
23 | //
24 | // Returns:
25 | // Return True if you wish to cancel the exporting process, or False otherwise.
26 | bool IsCanceled();
27 | //
28 | // Summary:
29 | // This method marks the beginning of export of a daylight portal.
30 | //
31 | // Parameters:
32 | // node:
33 | // A node describing the daylight portal object.
34 | void OnDaylightPortal( DaylightPortalNode node );
35 | //
36 | // Summary:
37 | // This method marks the beginning of an element to be exported
38 | //
39 | // Parameters:
40 | // elementId:
41 | // The Id of the element that is about to be processed
42 | //
43 | // Returns:
44 | // Return RenderNodeAction.Skip if you wish to skip exporting this element,
45 | // or return RenderNodeAction.Proceed otherwise.
46 | RenderNodeAction OnElementBegin( ElementId elementId );
47 | //
48 | // Summary:
49 | // This method marks the end of an element being exported
50 | //
51 | // Parameters:
52 | // elementId:
53 | // The Id of the element that has just been processed
54 | void OnElementEnd( ElementId elementId );
55 | //
56 | // Summary:
57 | // This method marks the beginning of a Face to be exported
58 | //
59 | // Parameters:
60 | // node:
61 | // An output node that represents a Face.
62 | //
63 | // Returns:
64 | // Return RenderNodeAction.Proceed if you wish to receive geometry (polymesh)
65 | // for this face, or return RenderNodeAction.Skip otherwise.
66 | //
67 | // Remarks:
68 | // Note that OnFaceBeging (as well as OnFaceEnd) is called only if the custom
69 | // exporter was set up to include faces in the output stream. See CustomExporter.IncudeFaces
70 | // for mode details.
71 | RenderNodeAction OnFaceBegin( FaceNode node );
72 | //
73 | // Summary:
74 | // This method marks the end of the current face being exported.
75 | //
76 | // Parameters:
77 | // node:
78 | // An output node that represents a Face.
79 | void OnFaceEnd( FaceNode node );
80 | //
81 | // Summary:
82 | // This method marks the beginning of a family instance to be exported
83 | //
84 | // Returns:
85 | // Return RenderNodeAction.Skip if you wish to skip processing this family instance,
86 | // or return RenderNodeAction.Proceed otherwise.
87 | RenderNodeAction OnInstanceBegin( InstanceNode node );
88 | //
89 | // Summary:
90 | // This method marks the end of a family instance being exported
91 | //
92 | // Parameters:
93 | // node:
94 | // An output node that represents a family instance.
95 | void OnInstanceEnd( InstanceNode node );
96 | //
97 | // Summary:
98 | // This method marks the beginning of export of a light object.
99 | //
100 | // Parameters:
101 | // node:
102 | // A node describing the light object.
103 | void OnLight( LightNode node );
104 | //
105 | // Summary:
106 | // This method marks the beginning of a link instance to be exported.
107 | //
108 | // Returns:
109 | // Return RenderNodeAction.Skip if you wish to skip processing this link instance,
110 | // or return RenderNodeAction.Proceed otherwise.
111 | RenderNodeAction OnLinkBegin( LinkNode node );
112 | //
113 | // Summary:
114 | // This method marks the end of a link instance being exported.
115 | //
116 | // Parameters:
117 | // node:
118 | // An output node that represents a Revit link.
119 | void OnLinkEnd( LinkNode node );
120 | //
121 | // Summary:
122 | // This method marks a change of the material.
123 | //
124 | // Parameters:
125 | // node:
126 | // A node describing the current material.
127 | void OnMaterial( MaterialNode node );
128 | //
129 | // Summary:
130 | // This method is called when a tessellated polymesh of a 3d face is being output.
131 | //
132 | // Parameters:
133 | // node:
134 | // A node representing topology of the polymesh
135 | void OnPolymesh( PolymeshTopology node );
136 | //
137 | // Summary:
138 | // This method marks the beginning of export of an RPC object.
139 | //
140 | // Parameters:
141 | // node:
142 | // A node with asset information about the RPC object.
143 | void OnRPC( RPCNode node );
144 | //
145 | // Summary:
146 | // This method marks the beginning of a 3D view to be exported
147 | //
148 | // Parameters:
149 | // node:
150 | // Geometry node associated with the view
151 | //
152 | // Returns:
153 | // Return RenderNodeAction.Skip if you wish to skip exporting this view, or
154 | // return RenderNodeAction.Proceed otherwise.
155 | RenderNodeAction OnViewBegin( ViewNode node );
156 | //
157 | // Summary:
158 | // This method marks the end of a 3D view being exported
159 | //
160 | // Parameters:
161 | // elementId:
162 | // The Id of the 3D view that has just been processed
163 | void OnViewEnd( ElementId elementId );
164 | //
165 | // Summary:
166 | // This method is called at the very start of the export proces, still before
167 | // the first entity of the model was send out.
168 | //
169 | // Returns:
170 | // Return True if you are ready to proceed with processing the export.
171 | bool Start();
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/Types/IScriptOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Types
8 | {
9 | public interface IScriptOptions
10 | {
11 | string outputDevice { get; set; }
12 | string paperSize { get; set; }
13 | string paperUnits { get; set; }
14 | string drawingOrientation { get; set; }
15 | string plotArea { get; set; }
16 | string plotScale { get; set; }
17 | string plotOffset { get; set; }
18 | string detailedPlotConfig { get; set; }
19 | string plotUpsideDown { get; set; }
20 | string plotWithStyles { get; set; }
21 | string plotStyleTable { get; set; }
22 | string plotWithLinewieghts { get; set; }
23 | string enterFileName { get; set; }
24 | string saveChanges { get; set; }
25 | string proceedWithplot { get; set; }
26 | string modelOrLayoutName { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/Types/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Types")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Types")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0509a34d-90cc-4068-90bf-1d62d74cba95")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutocadDwgReaderTest/Types/Types.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E7957AFD-CD65-4229-842B-2E73F9DEF7AD}
8 | Library
9 | Properties
10 | Types
11 | Types
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 3D-Model-to-Pdf-Conversion-and-Text-Extraction
2 | 3D Model(Autodesk DWG and DXF) to Pdf Conversion and Text Extraction using AutoCAD 2016 and AutoCAD API (ObjectARX)
3 |
4 | ## Project Dependencies
5 | [Autodesk AutoCAD 2016] (http://www.autodesk.com/education/free-software/autocad)
6 |
7 | ##Usage
8 | * Install Autodesk AutoCAD 2016 for Windows
9 | * Copy Scrits files into some folder (for example D:\Scripts)
10 | * Build and run the project
11 |
--------------------------------------------------------------------------------