├── Doc ├── STL_Export.chm └── LICENSE.txt ├── Source ├── AssemblyInfo.cs ├── Resources │ ├── STLExporter_32.png │ ├── STLExporter_64.ico │ ├── STLExporter_80.png │ ├── STLExport.addin │ ├── PackageContents.xml │ └── ADSKSTLExporterHelp.htm ├── settings.xml ├── STLExportCancelForm.cs ├── STLDialogManager.cs ├── STLExporterUI.cs ├── STLExportCommand.cs ├── STLExportCancelForm.Designer.cs ├── Properties │ ├── Resources.Designer.cs │ └── Resources.resx ├── Settings.cs ├── STLExportResource.Designer.cs ├── STLExportResource.resx ├── STLExportCancelForm.resx ├── STLExport.csproj ├── STLExportForm.Designer.cs ├── STLExportForm.cs ├── SaveData.cs ├── DataGenerator.cs └── STLExportForm.resx ├── ReadMe_files ├── themedata.thmx ├── filelist.xml └── colorschememapping.xml ├── Contributing.md ├── Description.json ├── README.md ├── STLExportSingle.sln ├── Setup └── Setup.isproj ├── .gitattributes ├── STLExport.sln └── .gitignore /Doc/STL_Export.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/revit-stl-extension/HEAD/Doc/STL_Export.chm -------------------------------------------------------------------------------- /Source/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/revit-stl-extension/HEAD/Source/AssemblyInfo.cs -------------------------------------------------------------------------------- /ReadMe_files/themedata.thmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/revit-stl-extension/HEAD/ReadMe_files/themedata.thmx -------------------------------------------------------------------------------- /Source/Resources/STLExporter_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/revit-stl-extension/HEAD/Source/Resources/STLExporter_32.png -------------------------------------------------------------------------------- /Source/Resources/STLExporter_64.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/revit-stl-extension/HEAD/Source/Resources/STLExporter_64.ico -------------------------------------------------------------------------------- /Source/Resources/STLExporter_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/revit-stl-extension/HEAD/Source/Resources/STLExporter_80.png -------------------------------------------------------------------------------- /ReadMe_files/filelist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ReadMe_files/colorschememapping.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Source/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | 9 | 10 | false 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Resources/STLExport.addin: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | STLExporter 5 | .\STLExport.dll 6 | 1f5b27ff-bc4a-42cd-bbaf-f3b4735f4a8a 7 | BIM.STLExport.STLExporterUI 8 | ADSK 9 | Autodesk, www.autodesk.com 10 | 11 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | ## How To Contribute 2 | * Fork the repository 3 | * Create your feature branch (`git checkout -b my-new-feature`) 4 | * Commit your changes (`git commit -am 'add some feature'`) 5 | * Push to your branch (`git push origin my-new-feature`) 6 | * Create a new Pull Request 7 | 8 | 9 | ## Guidelines 10 | * Please make sure to follow existing conventions and style in order to keep the code as readable as possible. 11 | * Please make sure your changes did not break any functionalities. 12 | * Please make sure to comment your changes. 13 | * Please make sure to update the readme file if needed. 14 | * Try to test for your changes as well. 15 | 16 | 17 | -------------------------------------------------------------------------------- /Description.json: -------------------------------------------------------------------------------- 1 | { 2 | "productMarketingInfo": { 3 | "version": "21.0.0.0", 4 | "localizedContent": [ 5 | { 6 | "langCode": "en-US", 7 | "shortDesc": "The STL Exporter is designed to produce a stereolithography file (STL) of your building model.", 8 | "longDesc": "The STL Exporter for use with Autodesk Revit is a proof-of-concept project designed to create an STL file from a 3D building information model, thereby enabling easier 3D printing. STL is a popular file format for stereo lithography (3D Printing) used for rapid prototyping and computer aided manufacturing. In the building space, it is used by architects and engineers to build 3D models. This is an add-in for Revit products that provides the ability to export geometric data from Revit to ASCII and Binary STL files." 9 | } 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | STL Extension for Autodesk® Revit® 2 | =========== 3 | 4 | The STL Extension for use with Autodesk® Revit® is a proof-of-concept project designed to create an STL file from a 3D building information model, thereby enabling easier 3D printing. STL is a popular file format for stereo lithography (3D Printing) used for rapid prototyping and computer aided manufacturing. 5 | 6 | In the building space, it is used by architects and engineers to build 3D models. This is an add-in for Revit products that provides the ability to export geometric data from Revit to ASCII and Binary STL files. 7 | 8 | ## General Usage Instructions 9 | Clicking on this application button on the UI, will open up a “Export STL” dialog. In the “General” tab of the “Export STL” dialog, select the file format you want to use. If you want to export link models, check “Include Link Models”. In the “Categories” tab, select the categories in which the models to be exported. 10 | 11 | ## Changelog 12 | *2021.0.0* 13 | - Update to support Autodesk® Revit® 2021 14 | 15 | *2020.0.0* 16 | - Update to support Autodesk® Revit® 2020 17 | 18 | *2019.0.0* 19 | - Update to support Autodesk® Revit® 2019 20 | 21 | *2018.0.0* 22 | - Update to support Autodesk® Revit® 2018 23 | 24 | ## Contributing 25 | See [Contributing.md](Contributing.md) for details. 26 | -------------------------------------------------------------------------------- /Source/Resources/PackageContents.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /STLExportSingle.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "STLExport", "Source\STLExport.csproj", "{23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | CD_ROM|Any CPU = CD_ROM|Any CPU 11 | Debug|Any CPU = Debug|Any CPU 12 | DVD-5|Any CPU = DVD-5|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | SingleImage|Any CPU = SingleImage|Any CPU 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 18 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 19 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 22 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 23 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 26 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.SingleImage|Any CPU.Build.0 = Release|Any CPU 27 | EndGlobalSection 28 | GlobalSection(SolutionProperties) = preSolution 29 | HideSolutionNode = FALSE 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Setup/Setup.isproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Express 6 | 7 | Debug 8 | $(Configuration) 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | STLExport 35 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95} 36 | 37 | 38 | -------------------------------------------------------------------------------- /Source/STLExportCancelForm.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Data; 24 | using System.Drawing; 25 | using System.Linq; 26 | using System.Text; 27 | using System.Windows.Forms; 28 | 29 | namespace BIM.STLExport 30 | { 31 | public partial class STLExportCancelForm : Form 32 | { 33 | private bool m_CancelProcess = false; 34 | 35 | public bool CancelProcess 36 | { 37 | get { return m_CancelProcess; } 38 | set { m_CancelProcess = value; } 39 | } 40 | 41 | /// 42 | /// Constructor. 43 | /// 44 | public STLExportCancelForm() 45 | { 46 | InitializeComponent(); 47 | } 48 | 49 | /// 50 | /// Cancel button click event. 51 | /// 52 | /// The sender. 53 | /// The event args. 54 | private void btnCancel_Click(object sender, EventArgs e) 55 | { 56 | m_CancelProcess = !m_CancelProcess; 57 | 58 | if (!m_CancelProcess) 59 | this.Close(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Source/STLDialogManager.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System; 21 | using System.Diagnostics; 22 | using System.Windows.Forms; 23 | 24 | namespace BIM.STLExport 25 | { 26 | /// 27 | /// Manager class for dialogs in the project. 28 | /// 29 | public class STLDialogManager 30 | { 31 | /// 32 | /// Pop up a standard SaveAs dialog. 33 | /// 34 | /// The filename return by SaveAs dialog. 35 | public static string SaveDialog() 36 | { 37 | // save file dialog options 38 | using (SaveFileDialog saveDialog = new SaveFileDialog()) 39 | { 40 | saveDialog.OverwritePrompt = true; 41 | saveDialog.AddExtension = true; 42 | saveDialog.DefaultExt = STLExportResource.SAVE_DIALOG_DEFAULT_FILE_EXTEND; 43 | saveDialog.Filter = STLExportResource.SAVE_DIALOG_FILE_FILTER; 44 | 45 | if (System.Windows.Forms.DialogResult.OK != saveDialog.ShowDialog()) 46 | { 47 | return String.Empty; 48 | } 49 | return saveDialog.FileName; 50 | } 51 | } 52 | 53 | /// 54 | /// Used to show error message when debug. 55 | /// 56 | /// The exception message. 57 | [Conditional("DEBUG")] 58 | public static void ShowDebug(string exception) 59 | { 60 | MessageBox.Show(exception, STLExportResource.MESSAGE_BOX_TITLE, 61 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Source/STLExporterUI.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Autodesk.Revit.UI; 6 | using System.IO; 7 | using System.Reflection; 8 | using System.Windows.Forms; 9 | using System.Windows.Media.Imaging; 10 | 11 | namespace BIM.STLExport 12 | { 13 | public class STLExporterUI : IExternalApplication 14 | { 15 | // Fields 16 | private static string AddInPath; 17 | 18 | // Methods 19 | static STLExporterUI() 20 | { 21 | AddInPath = typeof(STLExporterUI).Assembly.Location; 22 | } 23 | 24 | Result IExternalApplication.OnShutdown(UIControlledApplication application) 25 | { 26 | return Result.Succeeded; 27 | } 28 | 29 | Result IExternalApplication.OnStartup(UIControlledApplication application) 30 | { 31 | try 32 | { 33 | string str = "STL Exporter"; 34 | RibbonPanel panel = application.CreateRibbonPanel(str); 35 | string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 36 | PushButtonData data = new PushButtonData("STL Exporter for Revit", "STL Exporter for Revit", directoryName + @"\STLExport.dll", "BIM.STLExport.STLExportCommand"); 37 | PushButton button = panel.AddItem(data) as PushButton; 38 | button.LargeImage = LoadPNGImageFromResource("BIM.STLExport.Resources.STLExporter_32.png"); 39 | button.ToolTip = "The STL Exporter for Revit is designed to produce a stereolithography file (STL) of your building model."; 40 | button.LongDescription = "The STL Exporter for the Autodesk Revit Platform is a proof-of-concept project designed to create an STL file from a 3D building information model, thereby enabling easier 3D printing."; 41 | ContextualHelp help = new ContextualHelp(ContextualHelpType.ChmFile, directoryName + @"\Resources\ADSKSTLExporterHelp.htm"); 42 | button.SetContextualHelp(help); 43 | return Result.Succeeded; 44 | } 45 | catch (Exception exception) 46 | { 47 | MessageBox.Show(exception.ToString(), "STL Exporter for Revit"); 48 | return Result.Failed; 49 | } 50 | 51 | } 52 | 53 | private static System.Windows.Media.ImageSource LoadPNGImageFromResource(string imageResourceName) 54 | { 55 | PngBitmapDecoder decoder = new PngBitmapDecoder(Assembly.GetExecutingAssembly().GetManifestResourceStream(imageResourceName), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); 56 | return decoder.Frames[0]; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /STLExport.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "STLExport", "Source\STLExport.csproj", "{23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}" 7 | EndProject 8 | Project("{6141683F-8A12-4E36-9623-2EB02B2C2303}") = "Setup", "Setup\Setup.isproj", "{9C3F8462-1BF7-43C3-967A-0D71920918A3}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95} = {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | CD_ROM|Any CPU = CD_ROM|Any CPU 16 | Debug|Any CPU = Debug|Any CPU 17 | DVD-5|Any CPU = DVD-5|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | SingleImage|Any CPU = SingleImage|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU 23 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.CD_ROM|Any CPU.Build.0 = Release|Any CPU 24 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU 27 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.DVD-5|Any CPU.Build.0 = Debug|Any CPU 28 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU 31 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95}.SingleImage|Any CPU.Build.0 = Release|Any CPU 32 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.CD_ROM|Any CPU.ActiveCfg = CD_ROM 33 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.CD_ROM|Any CPU.Build.0 = CD_ROM 34 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.Debug|Any CPU.ActiveCfg = DVD-5 35 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.Debug|Any CPU.Build.0 = DVD-5 36 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.DVD-5|Any CPU.ActiveCfg = DVD-5 37 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.DVD-5|Any CPU.Build.0 = DVD-5 38 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.Release|Any CPU.ActiveCfg = SingleImage 39 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.Release|Any CPU.Build.0 = SingleImage 40 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.SingleImage|Any CPU.ActiveCfg = SingleImage 41 | {9C3F8462-1BF7-43C3-967A-0D71920918A3}.SingleImage|Any CPU.Build.0 = SingleImage 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /Source/STLExportCommand.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System.Windows.Forms; 21 | 22 | using Autodesk.Revit; 23 | using Autodesk.Revit.Attributes; 24 | using Autodesk.Revit.DB; 25 | using Autodesk.Revit.UI; 26 | 27 | namespace BIM.STLExport 28 | { 29 | /// 30 | /// Class STLExportCommand is the entry of the AddIn program and contains the method to save STL file. 31 | /// 32 | [Regeneration(RegenerationOption.Manual)] 33 | [Transaction(TransactionMode.ReadOnly)] 34 | public class STLExportCommand : IExternalCommand 35 | { 36 | /// 37 | /// The application object for the active instance of Autodesk Revit. 38 | /// 39 | private Autodesk.Revit.UI.UIApplication m_Revit; 40 | 41 | /// 42 | /// Implement the member of IExternalCommand Execute. 43 | /// 44 | /// 45 | /// The application object for the active instance of Autodesk Revit. 46 | /// 47 | /// 48 | /// A message that can be set by the external command and displayed in case of error. 49 | /// 50 | /// 51 | /// A set of elements that can be displayed if an error occurs. 52 | /// 53 | /// 54 | /// A value that signifies if yout command was successful, failed or the user wishes to cancel. 55 | /// 56 | public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, 57 | ref string message, ElementSet elements) 58 | { 59 | m_Revit = commandData.Application; 60 | 61 | ///pop up the STL export form 62 | using (STLExportForm exportForm = new STLExportForm(m_Revit)) 63 | { 64 | if (DialogResult.Cancel == exportForm.ShowDialog()) 65 | { 66 | return Autodesk.Revit.UI.Result.Cancelled; 67 | } 68 | } 69 | return Autodesk.Revit.UI.Result.Succeeded; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Source/STLExportCancelForm.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | namespace BIM.STLExport 21 | { 22 | partial class STLExportCancelForm 23 | { 24 | /// 25 | /// Required designer variable. 26 | /// 27 | private System.ComponentModel.IContainer components = null; 28 | 29 | /// 30 | /// Clean up any resources being used. 31 | /// 32 | /// True if managed resources should be disposed; otherwise, false. 33 | protected override void Dispose(bool disposing) 34 | { 35 | if (disposing && (components != null)) 36 | { 37 | components.Dispose(); 38 | } 39 | base.Dispose(disposing); 40 | } 41 | 42 | #region Windows Form Designer generated code 43 | 44 | /// 45 | /// Required method for Designer support - do not modify 46 | /// the contents of this method with the code editor. 47 | /// 48 | private void InitializeComponent() 49 | { 50 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(STLExportCancelForm)); 51 | this.btnCancel = new System.Windows.Forms.Button(); 52 | this.SuspendLayout(); 53 | // 54 | // btnCancel 55 | // 56 | resources.ApplyResources(this.btnCancel, "btnCancel"); 57 | this.btnCancel.Name = "btnCancel"; 58 | this.btnCancel.UseVisualStyleBackColor = true; 59 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 60 | // 61 | // STLExportCancelForm 62 | // 63 | resources.ApplyResources(this, "$this"); 64 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 65 | this.ControlBox = false; 66 | this.Controls.Add(this.btnCancel); 67 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 68 | this.Name = "STLExportCancelForm"; 69 | this.ResumeLayout(false); 70 | 71 | } 72 | 73 | #endregion 74 | 75 | private System.Windows.Forms.Button btnCancel; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Source/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 BIM.STLExport.Properties { 12 | using System; 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 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BIM.STLExport.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap STLExporter_32 { 67 | get { 68 | object obj = ResourceManager.GetObject("STLExporter_32", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Source/Settings.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System.Collections.Generic; 21 | using Category = Autodesk.Revit.DB.Category; 22 | using Autodesk.Revit.DB; 23 | 24 | namespace BIM.STLExport 25 | { 26 | /// 27 | /// The file format of STL. 28 | /// 29 | public enum SaveFormat 30 | { 31 | Binary = 0, 32 | ASCII 33 | } 34 | 35 | /// 36 | /// The range of elements to be exported. 37 | /// 38 | public enum ElementsExportRange 39 | { 40 | All = 0, 41 | OnlyVisibleOnes 42 | } 43 | 44 | /// 45 | /// Settings made by user to export. 46 | /// 47 | public struct Settings 48 | { 49 | private SaveFormat m_SaveFormat; 50 | private ElementsExportRange m_ExportRange; 51 | private bool m_IncludeLinkedModels; 52 | private bool m_exportColor; 53 | private bool m_exportSharedCoordinates; 54 | private List m_SelectedCategories; 55 | private ForgeTypeId m_Units; 56 | 57 | /// 58 | /// Binary or ASCII STL file. 59 | /// 60 | public SaveFormat SaveFormat 61 | { 62 | get 63 | { 64 | return m_SaveFormat; 65 | } 66 | } 67 | 68 | /// 69 | /// The range of elements to be exported. 70 | /// 71 | public ElementsExportRange ExportRange 72 | { 73 | get 74 | { 75 | return m_ExportRange; 76 | } 77 | } 78 | 79 | /// 80 | /// Include linked models. 81 | /// 82 | public bool IncludeLinkedModels 83 | { 84 | get 85 | { 86 | return m_IncludeLinkedModels; 87 | } 88 | } 89 | 90 | /// 91 | /// Export Color. 92 | /// 93 | public bool ExportColor 94 | { 95 | get 96 | { 97 | return m_exportColor; 98 | } 99 | } 100 | 101 | /// 102 | /// Export point in shared coordinates. 103 | /// 104 | public bool ExportSharedCoordinates 105 | { 106 | get 107 | { 108 | return m_exportSharedCoordinates; 109 | } 110 | } 111 | 112 | /// 113 | /// Include selected categories. 114 | /// 115 | public List SelectedCategories 116 | { 117 | get 118 | { 119 | return m_SelectedCategories; 120 | } 121 | } 122 | 123 | public ForgeTypeId Units 124 | { 125 | get 126 | { 127 | return m_Units; 128 | } 129 | } 130 | 131 | /// 132 | /// Constructor. 133 | /// 134 | /// The file format. 135 | /// The export range. 136 | public Settings(SaveFormat saveFormat, ElementsExportRange exportRange) 137 | { 138 | m_SaveFormat = saveFormat; 139 | m_ExportRange = exportRange; 140 | m_IncludeLinkedModels = false; 141 | m_exportColor = false; 142 | m_exportSharedCoordinates = false; 143 | m_SelectedCategories = new List(); 144 | m_Units = new ForgeTypeId(); 145 | } 146 | 147 | /// 148 | /// Constructor. 149 | /// 150 | /// The file format. 151 | /// The export range. 152 | /// True to include linked models, false otherwise. 153 | /// The selected categories to be included. 154 | public Settings(SaveFormat saveFormat, ElementsExportRange exportRange, bool includeLinkedModels,bool exportColor,bool exportSharedCoordinates, 155 | List selectedCategories, ForgeTypeId units) 156 | { 157 | m_SaveFormat = saveFormat; 158 | m_ExportRange = exportRange; 159 | m_IncludeLinkedModels = includeLinkedModels; 160 | m_exportColor = exportColor; 161 | m_exportSharedCoordinates = exportSharedCoordinates; 162 | m_SelectedCategories = selectedCategories; 163 | m_Units = units; 164 | } 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /Source/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 | 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 | 122 | ..\Resources\STLExporter_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /Source/STLExportResource.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 BIM.STLExport { 12 | using System; 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 STLExportResource { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal STLExportResource() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BIM.STLExport.STLExportResource", typeof(STLExportResource).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to STLFile was not saved.. 65 | /// 66 | internal static string CANCEL_FILE_NOT_SAVED { 67 | get { 68 | return ResourceManager.GetString("CANCEL_FILE_NOT_SAVED", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Occur an unknown error,the application will be terminated.. 74 | /// 75 | internal static string ERR_EXCEPTION { 76 | get { 77 | return ResourceManager.GetString("ERR_EXCEPTION", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to File is ReadOnly.. 83 | /// 84 | internal static string ERR_FILE_READONLY { 85 | get { 86 | return ResourceManager.GetString("ERR_FILE_READONLY", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to Occur an IO error,the application will be terminated.. 92 | /// 93 | internal static string ERR_IO_EXCEPTION { 94 | get { 95 | return ResourceManager.GetString("ERR_IO_EXCEPTION", resourceCulture); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized string similar to There is no solid in this document.. 101 | /// 102 | internal static string ERR_NOSOLID { 103 | get { 104 | return ResourceManager.GetString("ERR_NOSOLID", resourceCulture); 105 | } 106 | } 107 | 108 | /// 109 | /// Looks up a localized string similar to Save STLFile has failed.. 110 | /// 111 | internal static string ERR_SAVE_FILE_FAILED { 112 | get { 113 | return ResourceManager.GetString("ERR_SAVE_FILE_FAILED", resourceCulture); 114 | } 115 | } 116 | 117 | /// 118 | /// Looks up a localized string similar to Make sure you have the required permission to read or write files.. 119 | /// 120 | internal static string ERR_SECURITY_EXCEPTION { 121 | get { 122 | return ResourceManager.GetString("ERR_SECURITY_EXCEPTION", resourceCulture); 123 | } 124 | } 125 | 126 | /// 127 | /// Looks up a localized string similar to STL Exporter. 128 | /// 129 | internal static string MESSAGE_BOX_TITLE { 130 | get { 131 | return ResourceManager.GetString("MESSAGE_BOX_TITLE", resourceCulture); 132 | } 133 | } 134 | 135 | /// 136 | /// Looks up a localized string similar to .stl. 137 | /// 138 | internal static string SAVE_DIALOG_DEFAULT_FILE_EXTEND { 139 | get { 140 | return ResourceManager.GetString("SAVE_DIALOG_DEFAULT_FILE_EXTEND", resourceCulture); 141 | } 142 | } 143 | 144 | /// 145 | /// Looks up a localized string similar to stl files (*.stl)|*.stl|All files (*.*)|*.*. 146 | /// 147 | internal static string SAVE_DIALOG_FILE_FILTER { 148 | get { 149 | return ResourceManager.GetString("SAVE_DIALOG_FILE_FILTER", resourceCulture); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized string similar to Warning: All linked models must use the same Project Location Position as the host model. 155 | /// 156 | internal static string WARN_PROJECT_POSITION { 157 | get { 158 | return ResourceManager.GetString("WARN_PROJECT_POSITION", resourceCulture); 159 | } 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /Source/STLExportResource.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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | STLFile was not saved. 122 | 123 | 124 | Occur an unknown error,the application will be terminated. 125 | 126 | 127 | File is ReadOnly. 128 | 129 | 130 | Occur an IO error,the application will be terminated. 131 | 132 | 133 | There is no solid in this document. 134 | 135 | 136 | Save STLFile has failed. 137 | 138 | 139 | Make sure you have the required permission to read or write files. 140 | 141 | 142 | STL Exporter 143 | 144 | 145 | .stl 146 | 147 | 148 | stl files (*.stl)|*.stl|All files (*.*)|*.* 149 | 150 | 151 | Warning: All linked models must use the same Project Location Position as the host model 152 | 153 | -------------------------------------------------------------------------------- /Source/STLExportCancelForm.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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | 107, 35 123 | 124 | 125 | 75, 23 126 | 127 | 128 | 129 | 0 130 | 131 | 132 | Cancel 133 | 134 | 135 | btnCancel 136 | 137 | 138 | System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 139 | 140 | 141 | $this 142 | 143 | 144 | 0 145 | 146 | 147 | True 148 | 149 | 150 | 6, 13 151 | 152 | 153 | 292, 83 154 | 155 | 156 | 157 | CenterScreen 158 | 159 | 160 | Exporting STL 161 | 162 | 163 | STLExportCancelForm 164 | 165 | 166 | System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 167 | 168 | -------------------------------------------------------------------------------- /Source/Resources/ADSKSTLExporterHelp.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Revit Exchange - STL Exporter for Revit Help 6 | 7 | 8 | 50 | 51 |
52 |
53 |

STL Exporter for Revit

54 |

The STL Exporter for Revit is designed to produce a stereolithography file (STL) of your building model.

55 |
56 | 57 | 68 | 69 |

Getting Started

70 |
71 |
Icon
72 |
STL Exporter for Revit
73 |
74 |

75 | The STL Exporter for the Autodesk Revit Platform is a proof-of-concept project designed to create an STL file from a 3D building information model, 76 | thereby enabling easier 3D printing. STL is a popular file format for stereolithography (3D Printing) used for rapid prototyping and computer 77 | aided manufacturing. In the building space, it is used by architects and engineers to build 3D models. This is an add-in for Revit products that provides 78 | the ability to export geometric data from Revit to ASCII and Binary STL files. 79 |

80 |
81 |
82 |
83 |

Usage

84 |

Clicking on this application button on the UI, will open up a “Export STL” dialog. In the “General” tab of the “Export STL” dialog, select the file format you want to use. If you want to export link models, check “Include Link Models”.

85 |

In the “Categories” tab, select the categories in which the models to be exported.

86 |

Detailed help file can be accessed here

87 |

Installation and Uninstallation

88 |

89 | The installer that ran when you downloaded this plug-in from Revit Exchange 90 | has already installed the plug-in. You will need to restart Revit to activate 91 | the plug-in. 92 |

93 |

94 | To uninstall this plug-in, exit Revit if you are currenting running it, 95 | simply rerun the installer by downloading it again 96 | from Exchange, and select the 'Uninstall' button, or you can uninstall it from 97 | 'Settings\Apps\Apps & Features' (Windows 10) or 98 | 'Control Panel\Programs\Programs and Features' (Windows 7) just as you would 99 | uninstall any other application from your system. 100 |

101 | 102 |

Additional Information

103 |

104 | The source code for this application is available as open source, on Github. 105 | https://github.com/Autodesk/revit-stl-extension 106 |

107 | 108 |

Known Issues

109 |

None

110 |

Contact

111 |

Autodesk. Please visit us at: https://www.autodesk.com/

112 |

113 | Autodesk, Inc., is a leader in 3D design, engineering and entertainment software. Customers across the manufacturing, architecture, 114 | building, construction, and media and entertainment industries—including the last 16 Academy Award winners for Best Visual Effects—use 115 | Autodesk software to design, visualize, and simulate their ideas before they’re ever built or created. From blockbuster visual effects 116 | and buildings that create their own energy to electric cars and the batteries that power them, the work of our 3D software customers is everywhere you look. 117 |

118 |

119 | Through our apps for iPhone, iPad, iPod, and Android, we’re also making design technology accessible to professional designers as well as 120 | amateur designers, homeowners, students, and casual creators. Whether it’s a kid looking to build a new contraption, a seasoned pro sketching out 121 | a great new idea, or someone who just wants to amp up their creative output, we’re taking technology originally built for movie studios, automakers, 122 | and architectural firms, and making it available to anyone who wants to create and share their ideas with the world. 123 |

124 |

Since its introduction of AutoCAD software in 1982, Autodesk continues to develop the broadest portfolio of state-of-the-art 3D software for global markets.

125 |

Support Information

126 |

Autodesk Services & Support Center: https://knowledge.autodesk.com/support

127 |

Login to subscription customer: https://accounts.autodesk.com/Authentication/LogOn

128 |

To learn more about subscription: https://www.autodesk.com/subscription

129 |

or if you have an inquiry specific to this add-in, send us an e-mail to: Revit.apps@autodesk.com

130 |

Version History

131 | 132 |
133 |
2021.0.0
134 |
Added support for Revit 2021
135 |
136 |
137 |
2020.0.0
138 |
Added support for Revit 2020
139 |
140 |
141 |
2019.0.0
142 |
Added support for Revit 2019
143 |
144 |
145 |
2018.0.0
146 |
Added support for Revit 2018
147 |
148 |
149 |
2017.0.0
150 |
Added support for Revit 2017
151 |
152 |
153 |
2016.0.0
154 |
Added support for Revit 2016
155 |
156 |
157 |
2015.0.0
158 |
Added support for Revit 2015
159 |
160 |
161 |
2014.0.0
162 |
Added support for Revit 2014
163 |
164 |
165 |
2013.0.0
166 |
Initial release for Revit 2013
167 |
168 | 169 | 170 | -------------------------------------------------------------------------------- /Source/STLExport.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Local 5 | 9.0.30729 6 | 2.0 7 | {23F3F6FA-7A67-4D7E-983D-F2464DBE6C95} 8 | Debug 9 | AnyCPU 10 | 11 | 12 | 13 | 14 | STLExport 15 | 16 | 17 | JScript 18 | Grid 19 | IE50 20 | false 21 | Library 22 | BIM.STLExport 23 | OnBuildSuccess 24 | 25 | 26 | 27 | 28 | 29 | 30 | 4.0 31 | v4.8 32 | false 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | publish\ 42 | true 43 | Disk 44 | false 45 | Foreground 46 | 7 47 | Days 48 | false 49 | false 50 | true 51 | 0 52 | 1.0.0.%2a 53 | false 54 | true 55 | 56 | 57 | 58 | 59 | bin\Debug\ 60 | false 61 | 285212672 62 | false 63 | 64 | 65 | DEBUG;TRACE 66 | 67 | 68 | true 69 | 4096 70 | false 71 | 72 | 73 | false 74 | false 75 | false 76 | false 77 | 4 78 | full 79 | prompt 80 | AllRules.ruleset 81 | false 82 | 83 | 84 | bin\Release\ 85 | false 86 | 285212672 87 | false 88 | 89 | 90 | TRACE 91 | 92 | 93 | false 94 | 4096 95 | false 96 | 97 | 98 | true 99 | false 100 | false 101 | false 102 | 4 103 | none 104 | prompt 105 | AllRules.ruleset 106 | false 107 | 108 | 109 | 110 | 111 | ..\..\..\r2021\revit\Releasex64\RevitAPI.dll 112 | 113 | 114 | ..\..\..\r2021\revit\Releasex64\RevitAPIUI.dll 115 | 116 | 117 | System 118 | 119 | 120 | 3.5 121 | 122 | 123 | System.Data 124 | 125 | 126 | System.Drawing 127 | 128 | 129 | System.Windows.Forms 130 | 131 | 132 | 133 | System.XML 134 | 135 | 136 | 137 | 138 | 139 | Code 140 | 141 | 142 | Code 143 | 144 | 145 | True 146 | True 147 | Resources.resx 148 | 149 | 150 | Code 151 | 152 | 153 | 154 | Code 155 | 156 | 157 | Form 158 | 159 | 160 | STLExportCancelForm.cs 161 | 162 | 163 | Code 164 | 165 | 166 | 167 | Form 168 | 169 | 170 | STLExportForm.cs 171 | 172 | 173 | True 174 | True 175 | STLExportResource.resx 176 | 177 | 178 | ResXFileCodeGenerator 179 | Resources.Designer.cs 180 | Designer 181 | 182 | 183 | STLExportCancelForm.cs 184 | 185 | 186 | STLExportForm.cs 187 | 188 | 189 | Designer 190 | ResXFileCodeGenerator 191 | STLExportResource.Designer.cs 192 | 193 | 194 | 195 | 196 | False 197 | .NET Framework 3.5 SP1 Client Profile 198 | false 199 | 200 | 201 | False 202 | .NET Framework 2.0 %28x86%29 203 | true 204 | 205 | 206 | False 207 | .NET Framework 3.0 %28x86%29 208 | false 209 | 210 | 211 | False 212 | .NET Framework 3.5 213 | false 214 | 215 | 216 | False 217 | .NET Framework 3.5 SP1 218 | false 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /Source/STLExportForm.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | namespace BIM.STLExport 21 | { 22 | partial class STLExportForm 23 | { 24 | /// 25 | /// Required designer variable. 26 | /// 27 | private System.ComponentModel.IContainer components = null; 28 | 29 | /// 30 | /// Clean up any resources being used. 31 | /// 32 | /// true if managed resources should be disposed; otherwise, false. 33 | protected override void Dispose(bool disposing) 34 | { 35 | if (disposing && (components != null)) 36 | { 37 | components.Dispose(); 38 | } 39 | base.Dispose(disposing); 40 | } 41 | 42 | #region Windows Form Designer generated code 43 | 44 | /// 45 | /// Required method for Designer support - do not modify 46 | /// the contents of this method with the code editor. 47 | /// 48 | private void InitializeComponent() 49 | { 50 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(STLExportForm)); 51 | this.btnCancel = new System.Windows.Forms.Button(); 52 | this.btnHelp = new System.Windows.Forms.Button(); 53 | this.btnSave = new System.Windows.Forms.Button(); 54 | this.tabControl1 = new System.Windows.Forms.TabControl(); 55 | this.tpGeneral = new System.Windows.Forms.TabPage(); 56 | this.cbExportColor = new System.Windows.Forms.CheckBox(); 57 | this.comboBox_DUT = new System.Windows.Forms.ComboBox(); 58 | this.label1 = new System.Windows.Forms.Label(); 59 | this.cbIncludeLinked = new System.Windows.Forms.CheckBox(); 60 | this.gbSTLFormat = new System.Windows.Forms.GroupBox(); 61 | this.rbAscii = new System.Windows.Forms.RadioButton(); 62 | this.rbBinary = new System.Windows.Forms.RadioButton(); 63 | this.tpCategories = new System.Windows.Forms.TabPage(); 64 | this.btnCheckNone = new System.Windows.Forms.Button(); 65 | this.btnCheckAll = new System.Windows.Forms.Button(); 66 | this.cbExportSharedCoordinates = new System.Windows.Forms.CheckBox(); 67 | this.tvCategories = new System.Windows.Forms.TreeView(); 68 | this.tabControl1.SuspendLayout(); 69 | this.tpGeneral.SuspendLayout(); 70 | this.gbSTLFormat.SuspendLayout(); 71 | this.tpCategories.SuspendLayout(); 72 | this.SuspendLayout(); 73 | // 74 | // btnCancel 75 | // 76 | resources.ApplyResources(this.btnCancel, "btnCancel"); 77 | this.btnCancel.Name = "btnCancel"; 78 | this.btnCancel.UseVisualStyleBackColor = true; 79 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 80 | // 81 | // btnHelp 82 | // 83 | resources.ApplyResources(this.btnHelp, "btnHelp"); 84 | this.btnHelp.Name = "btnHelp"; 85 | this.btnHelp.UseVisualStyleBackColor = true; 86 | this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click); 87 | // 88 | // btnSave 89 | // 90 | resources.ApplyResources(this.btnSave, "btnSave"); 91 | this.btnSave.Name = "btnSave"; 92 | this.btnSave.UseVisualStyleBackColor = true; 93 | this.btnSave.Click += new System.EventHandler(this.btnSave_Click); 94 | // 95 | // tabControl1 96 | // 97 | this.tabControl1.Controls.Add(this.tpGeneral); 98 | this.tabControl1.Controls.Add(this.tpCategories); 99 | resources.ApplyResources(this.tabControl1, "tabControl1"); 100 | this.tabControl1.Name = "tabControl1"; 101 | this.tabControl1.SelectedIndex = 0; 102 | // 103 | // tpGeneral 104 | // 105 | this.tpGeneral.BackColor = System.Drawing.SystemColors.Control; 106 | this.tpGeneral.Controls.Add(this.cbExportSharedCoordinates); 107 | this.tpGeneral.Controls.Add(this.cbExportColor); 108 | this.tpGeneral.Controls.Add(this.comboBox_DUT); 109 | this.tpGeneral.Controls.Add(this.label1); 110 | this.tpGeneral.Controls.Add(this.cbIncludeLinked); 111 | this.tpGeneral.Controls.Add(this.gbSTLFormat); 112 | resources.ApplyResources(this.tpGeneral, "tpGeneral"); 113 | this.tpGeneral.Name = "tpGeneral"; 114 | // 115 | // cbExportColor 116 | // 117 | resources.ApplyResources(this.cbExportColor, "cbExportColor"); 118 | this.cbExportColor.Name = "cbExportColor"; 119 | this.cbExportColor.UseVisualStyleBackColor = true; 120 | // 121 | // comboBox_DUT 122 | // 123 | this.comboBox_DUT.FormattingEnabled = true; 124 | resources.ApplyResources(this.comboBox_DUT, "comboBox_DUT"); 125 | this.comboBox_DUT.Name = "comboBox_DUT"; 126 | // 127 | // label1 128 | // 129 | resources.ApplyResources(this.label1, "label1"); 130 | this.label1.Name = "label1"; 131 | // 132 | // cbIncludeLinked 133 | // 134 | resources.ApplyResources(this.cbIncludeLinked, "cbIncludeLinked"); 135 | this.cbIncludeLinked.Name = "cbIncludeLinked"; 136 | this.cbIncludeLinked.UseVisualStyleBackColor = true; 137 | this.cbIncludeLinked.CheckedChanged += new System.EventHandler(this.cbIncludeLinked_CheckedChanged); 138 | // 139 | // gbSTLFormat 140 | // 141 | this.gbSTLFormat.Controls.Add(this.rbAscii); 142 | this.gbSTLFormat.Controls.Add(this.rbBinary); 143 | resources.ApplyResources(this.gbSTLFormat, "gbSTLFormat"); 144 | this.gbSTLFormat.Name = "gbSTLFormat"; 145 | this.gbSTLFormat.TabStop = false; 146 | // 147 | // rbAscii 148 | // 149 | resources.ApplyResources(this.rbAscii, "rbAscii"); 150 | this.rbAscii.Name = "rbAscii"; 151 | this.rbAscii.UseVisualStyleBackColor = true; 152 | // 153 | // rbBinary 154 | // 155 | this.rbBinary.Checked = true; 156 | resources.ApplyResources(this.rbBinary, "rbBinary"); 157 | this.rbBinary.Name = "rbBinary"; 158 | this.rbBinary.TabStop = true; 159 | this.rbBinary.UseVisualStyleBackColor = true; 160 | this.rbBinary.CheckedChanged += new System.EventHandler(this.rbExportFormat_CheckedChanged); 161 | // 162 | // tpCategories 163 | // 164 | this.tpCategories.BackColor = System.Drawing.SystemColors.Control; 165 | this.tpCategories.Controls.Add(this.tvCategories); 166 | this.tpCategories.Controls.Add(this.btnCheckNone); 167 | this.tpCategories.Controls.Add(this.btnCheckAll); 168 | resources.ApplyResources(this.tpCategories, "tpCategories"); 169 | this.tpCategories.Name = "tpCategories"; 170 | // 171 | // btnCheckNone 172 | // 173 | resources.ApplyResources(this.btnCheckNone, "btnCheckNone"); 174 | this.btnCheckNone.Name = "btnCheckNone"; 175 | this.btnCheckNone.UseVisualStyleBackColor = true; 176 | this.btnCheckNone.Click += new System.EventHandler(this.btnCheckNone_Click); 177 | // 178 | // btnCheckAll 179 | // 180 | resources.ApplyResources(this.btnCheckAll, "btnCheckAll"); 181 | this.btnCheckAll.Name = "btnCheckAll"; 182 | this.btnCheckAll.UseVisualStyleBackColor = true; 183 | this.btnCheckAll.Click += new System.EventHandler(this.btnCheckAll_Click); 184 | // 185 | // cbExportSharedCoordinates 186 | // 187 | resources.ApplyResources(this.cbExportSharedCoordinates, "cbExportSharedCoordinates"); 188 | this.cbExportSharedCoordinates.Name = "cbExportSharedCoordinates"; 189 | this.cbExportSharedCoordinates.UseVisualStyleBackColor = true; 190 | // 191 | // tvCategories 192 | // 193 | this.tvCategories.CheckBoxes = true; 194 | resources.ApplyResources(this.tvCategories, "tvCategories"); 195 | this.tvCategories.Name = "tvCategories"; 196 | // 197 | // STLExportForm 198 | // 199 | resources.ApplyResources(this, "$this"); 200 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 201 | this.Controls.Add(this.tabControl1); 202 | this.Controls.Add(this.btnSave); 203 | this.Controls.Add(this.btnHelp); 204 | this.Controls.Add(this.btnCancel); 205 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 206 | this.MaximizeBox = false; 207 | this.MinimizeBox = false; 208 | this.Name = "STLExportForm"; 209 | this.tabControl1.ResumeLayout(false); 210 | this.tpGeneral.ResumeLayout(false); 211 | this.tpGeneral.PerformLayout(); 212 | this.gbSTLFormat.ResumeLayout(false); 213 | this.tpCategories.ResumeLayout(false); 214 | this.ResumeLayout(false); 215 | 216 | } 217 | 218 | #endregion 219 | 220 | private System.Windows.Forms.Button btnCancel; 221 | private System.Windows.Forms.Button btnHelp; 222 | private System.Windows.Forms.Button btnSave; 223 | private System.Windows.Forms.TabControl tabControl1; 224 | private System.Windows.Forms.TabPage tpGeneral; 225 | private System.Windows.Forms.TabPage tpCategories; 226 | private System.Windows.Forms.CheckBox cbIncludeLinked; 227 | private System.Windows.Forms.GroupBox gbSTLFormat; 228 | private System.Windows.Forms.RadioButton rbAscii; 229 | private System.Windows.Forms.RadioButton rbBinary; 230 | private System.Windows.Forms.Button btnCheckNone; 231 | private System.Windows.Forms.Button btnCheckAll; 232 | private System.Windows.Forms.ComboBox comboBox_DUT; 233 | private System.Windows.Forms.Label label1; 234 | private System.Windows.Forms.CheckBox cbExportColor; 235 | private System.Windows.Forms.CheckBox cbExportSharedCoordinates; 236 | private System.Windows.Forms.TreeView tvCategories; 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Roslyn cache directories 20 | *.ide/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | 100 | # MightyMoose 101 | *.mm.* 102 | AutoTest.Net/ 103 | 104 | # Web workbench (sass) 105 | .sass-cache/ 106 | 107 | # Installshield output folder 108 | [Ee]xpress/ 109 | 110 | # DocProject is a documentation generator add-in 111 | DocProject/buildhelp/ 112 | DocProject/Help/*.HxT 113 | DocProject/Help/*.HxC 114 | DocProject/Help/*.hhc 115 | DocProject/Help/*.hhk 116 | DocProject/Help/*.hhp 117 | DocProject/Help/Html2 118 | DocProject/Help/html 119 | 120 | # Click-Once directory 121 | publish/ 122 | 123 | # Publish Web Output 124 | *.[Pp]ublish.xml 125 | *.azurePubxml 126 | ## TODO: Comment the next line if you want to checkin your 127 | ## web deploy settings but do note that will include unencrypted 128 | ## passwords 129 | #*.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/* 133 | ## TODO: If the tool you use requires repositories.config 134 | ## uncomment the next line 135 | #!packages/repositories.config 136 | 137 | # Enable "build/" folder in the NuGet Packages folder since 138 | # NuGet packages use it for MSBuild targets. 139 | # This line needs to be after the ignore of the build folder 140 | # (and the packages folder if the line above has been uncommented) 141 | !packages/build/ 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # LightSwitch generated files 187 | GeneratedArtifacts/ 188 | _Pvt_Extensions/ 189 | ModelManifest.xml 190 | /.svn/pristine/00/00fb5f63715bea864c82bd5ae8d5a45eb0893f3e.svn-base 191 | /.svn/entries 192 | /.svn/format 193 | /.svn/pristine/01/01f64d59c817e90c0d5afc124c6be63fdd76d12a.svn-base 194 | /.svn/pristine/04/04461c0e4ccb6c92740b477af3a799cd0d89335b.svn-base 195 | /.svn/pristine/05/05348e245b6123c0b78e30d0859d0d46349fdf0f.svn-base 196 | /.svn/pristine/08/0868d0717e1708c2be744901cc491543cb5b9b09.svn-base 197 | /.svn/pristine/09/096d2dca6e2927fe0d180a4965d7f276f3ae96e1.svn-base 198 | /.svn/pristine/0f/0fdb6af065eb38a996088591252e9fd26a6908ab.svn-base 199 | /.svn/pristine/10/10d148d18b9fcaaa221e9ead8f774a835dd5a835.svn-base 200 | /.svn/pristine/14/1432b182607daa87e985a15f65a77cc86e33a9b4.svn-base 201 | /.svn/pristine/1a/1a975bdd4f6858ee7d4be2e1471a9f2b79408fa5.svn-base 202 | /.svn/pristine/1d/1d3f822b532662ece473242420c77fd416b508b6.svn-base 203 | /.svn/pristine/27/2739b6db8351474945e6755eabb959cb1bdb7379.svn-base 204 | /.svn/pristine/29/298cdcc611b8f9c86a463efbacac9e80187f3b2b.svn-base 205 | /.svn/pristine/33/33b166cc5618f720a68716682cdc3b0caae96a4c.svn-base 206 | /.svn/pristine/36/3659f9fbe9fa24e36e212180dd0c28e6051a7cf1.svn-base 207 | /.svn/pristine/36/36f8c8d9b10dea59469ec0882b7f611143790af8.svn-base 208 | /.svn/pristine/3a/3a84fa2b8778766682b733f3c23a073888399eb6.svn-base 209 | /.svn/pristine/3b/3b6b1e50a146cdd97196c7926ede700530396010.svn-base 210 | /.svn/pristine/41/417bc276e75974bd28f70ece7e6c529ee834aa5d.svn-base 211 | /.svn/pristine/4b/4b3c389848c686910030161aadb56b2e58970d73.svn-base 212 | /.svn/pristine/4c/4c4f8d4b6e9e028aecb518d8e3467a9fd188c774.svn-base 213 | /.svn/pristine/4e/4e6805953cb6fddd9c908323a5bb4b954b27d476.svn-base 214 | /.svn/pristine/4e/4e984e208fb238c0e231daed761aa01f766500e8.svn-base 215 | /.svn/pristine/53/531ad71f54c15bafcb6337314e477f7512408fca.svn-base 216 | /.svn/pristine/55/55260041bb854fd5816894030b1f49e1581d1b04.svn-base 217 | /.svn/pristine/5d/5d27923e09b68fcef7408b14b13c3c940f1f8ddf.svn-base 218 | /.svn/pristine/67/67ca4059268f3c0ac5667b65ed210cb5ac8c8532.svn-base 219 | /.svn/pristine/6c/6c4cc062c847f5ceb0dfa70d53d12b28b1342aac.svn-base 220 | /.svn/pristine/6c/6c74170ddf34ab8a4fbebc059d2411e553387997.svn-base 221 | /.svn/pristine/70/70ae7e42a825f546ceddcd59608d9ee5aac13e11.svn-base 222 | /.svn/pristine/72/72b0ffa032e90aad285cbb7bc783561a73e83052.svn-base 223 | /.svn/pristine/75/75e8b78644e75d8c1014199ec6b8f4e976ec72d3.svn-base 224 | /.svn/pristine/76/7605bf46fb102bd83f94dd07db36ceed5c67ca13.svn-base 225 | /.svn/pristine/79/79df74541550a21771181b4e8244f40b1f02f264.svn-base 226 | /.svn/pristine/7b/7bb0890255fcbc97603043ca283eaf0b20b1103d.svn-base 227 | /.svn/pristine/7d/7d7285fb4d64b71c400714bc79923896f292e169.svn-base 228 | /.svn/pristine/7d/7d8faca7689cce563f943aa0223b625b35dc517a.svn-base 229 | /.svn/pristine/84/84e09124db9a31135f61ea4b934e4a632c88f650.svn-base 230 | /.svn/pristine/8e/8e97ae4eecfc02d088121ec94af11fccde7f9dd5.svn-base 231 | /.svn/pristine/96/96e1225c60253e86b4014073ce3719f62373f6bd.svn-base 232 | /.svn/pristine/97/976eeba5eac2d4f5b9752878590e9440c720b5ee.svn-base 233 | /.svn/pristine/9e/9e731df46a993fddf3df1c2cf8974fe8482a75b6.svn-base 234 | /.svn/pristine/9e/9eb07cb6170cbae1bd15fd5fb0e6c120ea6f2029.svn-base 235 | /.svn/pristine/a4/a42fba1ae41089d3ebabc4d428b08440b6165f3e.svn-base 236 | /.svn/pristine/ae/ae9e8909335a5fde1aa702aaafa9fc338103a1b6.svn-base 237 | /.svn/pristine/b0/b026b7f9b6d415e122b6c8de6766c5b47de389cb.svn-base 238 | /.svn/pristine/b0/b04b462229218dda152c3de22cfdf980fc0d0a69.svn-base 239 | /.svn/pristine/b2/b2e4a1b1ed190c1e81a120ce1be5ea3e1bbd4abf.svn-base 240 | /.svn/pristine/bd/bdc82ac6bceb8f95796e891b5741d9397710305c.svn-base 241 | /.svn/pristine/bf/bf3f2e799513bd5d5f4d50c0ccbcd1ec8f84bc5b.svn-base 242 | /.svn/pristine/c0/c01620e33c24d159fc8cb038f9556c07aba84e70.svn-base 243 | /.svn/pristine/c1/c18da074e703890c42222ba56aa16500cf306eb9.svn-base 244 | /.svn/pristine/c5/c52c61d66782d44d86b64f3c0e7b30bfd5ca6b25.svn-base 245 | /.svn/pristine/c9/c93bee10653ab9db90a0286e2e7d2b7b4d43bf06.svn-base 246 | /.svn/pristine/ca/ca95f171451c436acc967355b6138cb95ee8f722.svn-base 247 | /.svn/pristine/d0/d0199d558af540e31b70a49a3a47d8ae22baf670.svn-base 248 | /.svn/pristine/d0/d0c9c33b524500c57aa56dab00b53748a9cea443.svn-base 249 | /.svn/pristine/d3/d33822d7a8bcdd415c0495a81731709315eb81e3.svn-base 250 | /.svn/pristine/d9/d9e948f06686e9f185d811eda82d4aaa0975cee4.svn-base 251 | /.svn/pristine/e3/e344591b579491d7cd2f480288cdb6f9a3ccdc06.svn-base 252 | /.svn/pristine/e6/e64145a78018b22574561ca0927f1e76e3fe8ee7.svn-base 253 | /.svn/pristine/ea/ead1f4db767e6c850f41dad568f45b543b4c3960.svn-base 254 | /.svn/pristine/ee/ee53f8a279fc75438857dc6b03968d0d95d3688a.svn-base 255 | /.svn/pristine/ee/ee620035fac7e10f0154cc61dd6eedfefc281f3e.svn-base 256 | /.svn/pristine/ee/ee8e0a6cd43c56ff4c4e843928aa1b5f098e70f0.svn-base 257 | /.svn/pristine/f4/f4d8da8684b5c71dc66e99c26441b7d61894fe1f.svn-base 258 | /.svn/pristine/fa/fa451d32623d165416293621ddc649c734a261ef.svn-base 259 | /.svn/pristine/fd/fd0329a796202c684a3cd9abdb58ed74d5f0c5f9.svn-base 260 | /.svn/wc.db 261 | /release2013/.svn/entries 262 | /release2013/.svn/format 263 | /release2013/.svn/pristine/00/00fb5f63715bea864c82bd5ae8d5a45eb0893f3e.svn-base 264 | /release2013/.svn/pristine/04/04461c0e4ccb6c92740b477af3a799cd0d89335b.svn-base 265 | /release2013/.svn/pristine/08/0868d0717e1708c2be744901cc491543cb5b9b09.svn-base 266 | /release2013/.svn/pristine/14/1432b182607daa87e985a15f65a77cc86e33a9b4.svn-base 267 | /release2013/.svn/pristine/1a/1a975bdd4f6858ee7d4be2e1471a9f2b79408fa5.svn-base 268 | /release2013/.svn/pristine/29/298cdcc611b8f9c86a463efbacac9e80187f3b2b.svn-base 269 | /release2013/.svn/pristine/33/33b166cc5618f720a68716682cdc3b0caae96a4c.svn-base 270 | /release2013/.svn/pristine/36/36f8c8d9b10dea59469ec0882b7f611143790af8.svn-base 271 | /release2013/.svn/pristine/38/38bfa05d459a58b1820316db849a11a83b055d22.svn-base 272 | /release2013/.svn/pristine/3a/3a84fa2b8778766682b733f3c23a073888399eb6.svn-base 273 | /release2013/.svn/pristine/41/417bc276e75974bd28f70ece7e6c529ee834aa5d.svn-base 274 | /release2013/.svn/pristine/4c/4c4f8d4b6e9e028aecb518d8e3467a9fd188c774.svn-base 275 | /release2013/.svn/pristine/4c/4c532c9f3ccb00df92119b2d948401344c5c34a3.svn-base 276 | /release2013/.svn/pristine/55/55260041bb854fd5816894030b1f49e1581d1b04.svn-base 277 | /release2013/.svn/pristine/72/72b0ffa032e90aad285cbb7bc783561a73e83052.svn-base 278 | /release2013/.svn/pristine/79/79df74541550a21771181b4e8244f40b1f02f264.svn-base 279 | /release2013/.svn/pristine/7d/7da1167dd4e7099d2d4cf464981bab6c46c7e707.svn-base 280 | /release2013/.svn/pristine/93/93a0a38db7b132d97bf4bb86780a6d4cb4bdbae0.svn-base 281 | /release2013/.svn/pristine/96/96e1225c60253e86b4014073ce3719f62373f6bd.svn-base 282 | /release2013/.svn/pristine/9b/9bcb2f7534900494da5e8444b46388a3275beafa.svn-base 283 | /release2013/.svn/pristine/ae/ae9e8909335a5fde1aa702aaafa9fc338103a1b6.svn-base 284 | /release2013/.svn/pristine/ae/aebd0c8f1b746ce1d11149e8a0ef345a8a0b50ba.svn-base 285 | /release2013/.svn/pristine/b0/b04b462229218dda152c3de22cfdf980fc0d0a69.svn-base 286 | /release2013/.svn/pristine/b2/b2e4a1b1ed190c1e81a120ce1be5ea3e1bbd4abf.svn-base 287 | /release2013/.svn/pristine/bd/bdc82ac6bceb8f95796e891b5741d9397710305c.svn-base 288 | /release2013/.svn/pristine/bf/bf3f2e799513bd5d5f4d50c0ccbcd1ec8f84bc5b.svn-base 289 | /release2013/.svn/pristine/c0/c01620e33c24d159fc8cb038f9556c07aba84e70.svn-base 290 | /release2013/.svn/pristine/c5/c52c61d66782d44d86b64f3c0e7b30bfd5ca6b25.svn-base 291 | /release2013/.svn/pristine/c9/c93bee10653ab9db90a0286e2e7d2b7b4d43bf06.svn-base 292 | /release2013/.svn/pristine/ca/ca95f171451c436acc967355b6138cb95ee8f722.svn-base 293 | /release2013/.svn/pristine/ca/cabd8302cc9072b54512f8edfcee10f82358afe2.svn-base 294 | /release2013/.svn/pristine/d0/d0c9c33b524500c57aa56dab00b53748a9cea443.svn-base 295 | /release2013/.svn/pristine/d3/d33822d7a8bcdd415c0495a81731709315eb81e3.svn-base 296 | /release2013/.svn/pristine/d9/d9e948f06686e9f185d811eda82d4aaa0975cee4.svn-base 297 | /release2013/.svn/pristine/e6/e64145a78018b22574561ca0927f1e76e3fe8ee7.svn-base 298 | /release2013/.svn/pristine/ee/ee53f8a279fc75438857dc6b03968d0d95d3688a.svn-base 299 | /release2013/.svn/pristine/f9/f98220adc94a8454d49c4aeadf55a7f255215b9e.svn-base 300 | /release2013/.svn/pristine/fa/fa451d32623d165416293621ddc649c734a261ef.svn-base 301 | /release2013/.svn/wc.db 302 | -------------------------------------------------------------------------------- /Source/STLExportForm.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Data; 24 | using System.Drawing; 25 | using System.Linq; 26 | using System.Text; 27 | using System.Windows.Forms; 28 | 29 | using Autodesk.Revit; 30 | using Category = Autodesk.Revit.DB.Category; 31 | using Autodesk.Revit.DB; 32 | 33 | namespace BIM.STLExport 34 | { 35 | public partial class STLExportForm : System.Windows.Forms.Form 36 | { 37 | private DataGenerator m_Generator = null; 38 | private SortedDictionary m_CategoryList = new SortedDictionary(); 39 | private SortedDictionary m_DisplayUnits = new SortedDictionary(); 40 | private static ForgeTypeId m_SelectedDUT = new ForgeTypeId(); 41 | 42 | readonly Autodesk.Revit.UI.UIApplication m_Revit = null; 43 | 44 | /// 45 | /// Constructor. 46 | /// 47 | /// The revit application. 48 | public STLExportForm(Autodesk.Revit.UI.UIApplication revit) 49 | { 50 | InitializeComponent(); 51 | m_Revit = revit; 52 | 53 | // get new data generator 54 | m_Generator = new DataGenerator(m_Revit.Application, m_Revit.ActiveUIDocument.Document, m_Revit.ActiveUIDocument.Document.ActiveView); 55 | 56 | // scan for categories to populate category list 57 | m_CategoryList = m_Generator.ScanCategories(true); 58 | 59 | foreach (Category category in m_CategoryList.Values) 60 | { 61 | TreeNode treeNode = GetChildNode(category,m_Revit.ActiveUIDocument.Document.ActiveView); 62 | if (treeNode != null) 63 | tvCategories.Nodes.Add(treeNode); 64 | } 65 | 66 | string unitName = "Use Internal: Feet"; 67 | m_DisplayUnits.Add(unitName, new ForgeTypeId()); 68 | int selectedIndex = comboBox_DUT.Items.Add(unitName); 69 | if (m_SelectedDUT.Empty()) 70 | comboBox_DUT.SelectedIndex = selectedIndex; 71 | 72 | Units currentUnits = m_Revit.ActiveUIDocument.Document.GetUnits(); 73 | ForgeTypeId currentDut = currentUnits.GetFormatOptions(SpecTypeId.Length).GetUnitTypeId(); 74 | unitName = "Use Current: " + LabelUtils.GetLabelForUnit(currentDut); 75 | m_DisplayUnits.Add(unitName, currentDut); 76 | selectedIndex = comboBox_DUT.Items.Add(unitName); 77 | if (m_SelectedDUT == currentDut) 78 | comboBox_DUT.SelectedIndex = selectedIndex; 79 | 80 | foreach (ForgeTypeId dut in UnitUtils.GetValidUnits(SpecTypeId.Length)) 81 | { 82 | if (currentDut == dut) 83 | continue; 84 | unitName = LabelUtils.GetLabelForUnit(dut); 85 | m_DisplayUnits.Add(unitName, dut); 86 | selectedIndex = comboBox_DUT.Items.Add(unitName); 87 | if (m_SelectedDUT == dut) 88 | comboBox_DUT.SelectedIndex = selectedIndex; 89 | } 90 | 91 | // initialize the UI differently for Families 92 | if (revit.ActiveUIDocument.Document.IsFamilyDocument) 93 | { 94 | cbIncludeLinked.Enabled = false; 95 | tvCategories.Enabled = false; 96 | btnCheckAll.Enabled = false; 97 | btnCheckNone.Enabled = false; 98 | } 99 | } 100 | 101 | /// 102 | /// Get all subcategory. 103 | /// 104 | /// 105 | /// Current view. 106 | /// 107 | private TreeNode GetChildNode(Category category,Autodesk.Revit.DB.View view) 108 | { 109 | if(category == null) 110 | return null; 111 | 112 | if (!category.get_AllowsVisibilityControl(view)) 113 | return null; 114 | 115 | TreeNode treeNode = new TreeNode(category.Name); 116 | treeNode.Tag = category; 117 | treeNode.Checked = true; 118 | 119 | if(category.SubCategories.Size == 0) 120 | { 121 | return treeNode; 122 | } 123 | 124 | foreach (Category subCategory in category.SubCategories) 125 | { 126 | TreeNode child = GetChildNode(subCategory,view); 127 | if(child !=null) 128 | treeNode.Nodes.Add(child); 129 | } 130 | 131 | return treeNode; 132 | } 133 | 134 | /// 135 | /// Help button click event. 136 | /// 137 | /// The sender. 138 | /// The event args. 139 | private void btnHelp_Click(object sender, EventArgs e) 140 | { 141 | string helpfile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); 142 | helpfile = System.IO.Path.Combine(helpfile, "STL_Export.chm"); 143 | 144 | if (System.IO.File.Exists(helpfile) == false) 145 | { 146 | MessageBox.Show("Help File " + helpfile + " NOT FOUND!"); 147 | return; 148 | } 149 | 150 | Help.ShowHelp(this, "file://" + helpfile); 151 | 152 | } 153 | 154 | /// 155 | /// Save button click event. 156 | /// 157 | /// The sender. 158 | /// The event args. 159 | private void btnSave_Click(object sender, EventArgs e) 160 | { 161 | string fileName = STLDialogManager.SaveDialog(); 162 | 163 | if (!string.IsNullOrEmpty(fileName)) 164 | { 165 | SaveFormat saveFormat; 166 | if (rbBinary.Checked) 167 | { 168 | saveFormat = SaveFormat.Binary; 169 | } 170 | else 171 | { 172 | saveFormat = SaveFormat.ASCII; 173 | } 174 | 175 | ElementsExportRange exportRange; 176 | 177 | exportRange = ElementsExportRange.OnlyVisibleOnes; 178 | 179 | // get selected categories from the category list 180 | List selectedCategories = new List(); 181 | 182 | // only for projects 183 | if (m_Revit.ActiveUIDocument.Document.IsFamilyDocument == false) 184 | { 185 | foreach (TreeNode treeNode in tvCategories.Nodes) 186 | { 187 | AddSelectedTreeNode(treeNode, selectedCategories); 188 | } 189 | } 190 | 191 | ForgeTypeId dup = m_DisplayUnits[comboBox_DUT.Text]; 192 | m_SelectedDUT = dup; 193 | 194 | // create settings object to save setting information 195 | Settings aSetting = new Settings(saveFormat, exportRange, cbIncludeLinked.Checked,cbExportColor.Checked,cbExportSharedCoordinates.Checked, selectedCategories, dup); 196 | 197 | // save Revit document's triangular data in a temporary file 198 | m_Generator = new DataGenerator(m_Revit.Application, m_Revit.ActiveUIDocument.Document, m_Revit.ActiveUIDocument.Document.ActiveView); 199 | DataGenerator.GeneratorStatus succeed = m_Generator.SaveSTLFile(fileName, aSetting); 200 | 201 | if (succeed == DataGenerator.GeneratorStatus.FAILURE) 202 | { 203 | this.DialogResult = DialogResult.Cancel; 204 | MessageBox.Show(STLExportResource.ERR_SAVE_FILE_FAILED, STLExportResource.MESSAGE_BOX_TITLE, 205 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 206 | } 207 | else if (succeed == DataGenerator.GeneratorStatus.CANCEL) 208 | { 209 | this.DialogResult = DialogResult.Cancel; 210 | MessageBox.Show(STLExportResource.CANCEL_FILE_NOT_SAVED, STLExportResource.MESSAGE_BOX_TITLE, 211 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 212 | } 213 | 214 | this.DialogResult = DialogResult.OK; 215 | 216 | this.Close(); 217 | } 218 | else 219 | { 220 | MessageBox.Show(STLExportResource.CANCEL_FILE_NOT_SAVED, STLExportResource.MESSAGE_BOX_TITLE, 221 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 222 | } 223 | } 224 | 225 | /// 226 | /// Add selected category into dictionary. 227 | /// 228 | /// 229 | /// 230 | private void AddSelectedTreeNode(TreeNode treeNode,List selectedCategories) 231 | { 232 | if (treeNode.Checked) 233 | selectedCategories.Add((Category)treeNode.Tag); 234 | 235 | if(treeNode.Nodes.Count != 0) 236 | { 237 | foreach(TreeNode child in treeNode.Nodes) 238 | { 239 | AddSelectedTreeNode(child, selectedCategories); 240 | } 241 | } 242 | } 243 | 244 | /// 245 | /// Cancel button click event. 246 | /// 247 | /// The sender. 248 | /// The event args. 249 | private void btnCancel_Click(object sender, EventArgs e) 250 | { 251 | this.DialogResult = DialogResult.Cancel; 252 | this.Close(); 253 | } 254 | 255 | /// 256 | /// Check all button click event, checks all categories in the category list. 257 | /// 258 | /// The sender. 259 | /// The event args. 260 | private void btnCheckAll_Click(object sender, EventArgs e) 261 | { 262 | foreach (TreeNode treeNode in tvCategories.Nodes) 263 | { 264 | SetCheckedforTreeNode(treeNode,true); 265 | } 266 | } 267 | 268 | /// 269 | /// Check none click event, unchecks all categories in the category list. 270 | /// 271 | /// The sender. 272 | /// The event args. 273 | private void btnCheckNone_Click(object sender, EventArgs e) 274 | { 275 | foreach (TreeNode treeNode in tvCategories.Nodes) 276 | { 277 | SetCheckedforTreeNode(treeNode,false); 278 | } 279 | } 280 | 281 | /// 282 | /// Set the checked property of treenode to true or false. 283 | /// 284 | /// The tree node. 285 | /// Checked or not. 286 | private void SetCheckedforTreeNode(TreeNode treeNode,bool selected) 287 | { 288 | treeNode.Checked = selected; 289 | if (treeNode.Nodes.Count != 0) 290 | { 291 | foreach (TreeNode child in treeNode.Nodes) 292 | { 293 | SetCheckedforTreeNode(child, selected); 294 | } 295 | } 296 | } 297 | 298 | /// 299 | /// Included linked models click event. 300 | /// 301 | /// The sender. 302 | /// The event args. 303 | private void cbIncludeLinked_CheckedChanged(object sender, EventArgs e) 304 | { 305 | if (cbIncludeLinked.Checked == true) 306 | { 307 | MessageBox.Show(STLExportResource.WARN_PROJECT_POSITION, STLExportResource.MESSAGE_BOX_TITLE, 308 | MessageBoxButtons.OK, MessageBoxIcon.Warning); 309 | } 310 | } 311 | 312 | private void rbExportFormat_CheckedChanged(object sender, EventArgs e) 313 | { 314 | cbExportColor.Enabled = rbBinary.Checked; 315 | } 316 | 317 | } 318 | } 319 | -------------------------------------------------------------------------------- /Source/SaveData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System; 21 | using System.IO; 22 | using System.Text; 23 | using System.Security; 24 | using System.Windows.Forms; 25 | 26 | namespace BIM.STLExport 27 | { 28 | /// 29 | /// Base class providing interface to save data to STL file. 30 | /// 31 | public abstract class SaveData : IDisposable 32 | { 33 | // stl file name 34 | protected string m_FileName = string.Empty; 35 | // file format: Binary or ASCII 36 | protected SaveFormat m_SaveFormat = SaveFormat.Binary; 37 | // total triangular number in the model 38 | protected int m_TriangularNumber = 0; 39 | 40 | /// 41 | /// Number of triangulars. 42 | /// 43 | public int TriangularNumber 44 | { 45 | get { return m_TriangularNumber; } 46 | set { m_TriangularNumber = value; } 47 | } 48 | 49 | /// 50 | /// Constructor. 51 | /// 52 | /// STL file name. 53 | /// File format. 54 | public SaveData(string fileName, SaveFormat format) 55 | { 56 | m_FileName = fileName; 57 | m_SaveFormat = format; 58 | } 59 | 60 | /// 61 | /// Close file here if user forget it. 62 | /// 63 | public virtual void Dispose() 64 | { 65 | CloseFile(); 66 | } 67 | 68 | /// 69 | /// Interface to create file. 70 | /// 71 | /// True if succeeded, false if failed. 72 | public abstract bool CreateFile(); 73 | 74 | /// 75 | /// Interface to write one section include normal and vertex. 76 | /// 77 | /// Facet normal. 78 | /// Vertex array. 79 | /// True if succeeded, false if failed. 80 | public abstract bool WriteSection(Autodesk.Revit.DB.XYZ normal, double[] vertexArr); 81 | 82 | /// 83 | /// Add triangular number section. 84 | /// 85 | /// True if succeeded, false if failed. 86 | public abstract bool AddTriangularNumberSection(); 87 | 88 | /// 89 | /// Close file handle. 90 | /// 91 | /// True if succeeded, false if failed. 92 | public abstract bool CloseFile(); 93 | } 94 | 95 | /// 96 | /// Save date to binary stl file. 97 | /// 98 | public class SaveDataAsBinary : SaveData 99 | { 100 | FileStream fileWriteStream = null; 101 | BinaryWriter binaryWriter = null; 102 | 103 | private Autodesk.Revit.DB.Color m_color = null; 104 | 105 | /// 106 | /// Color of trangle mesh to export in Binary format. 107 | /// 108 | public Autodesk.Revit.DB.Color Color 109 | { 110 | set { m_color = value; } 111 | } 112 | 113 | /// 114 | /// Constructor 115 | /// 116 | /// STL file name. 117 | /// File format. 118 | public SaveDataAsBinary(string fileName, SaveFormat format) 119 | : base(fileName, format) 120 | { 121 | } 122 | 123 | /// 124 | /// Implement interface of creating a file. 125 | /// 126 | /// True if succeeded, false if failed. 127 | public override bool CreateFile() 128 | { 129 | bool succeed = true; 130 | try 131 | { 132 | FileAttributes fileAttribute = FileAttributes.Normal; 133 | 134 | if (File.Exists(m_FileName)) 135 | { 136 | fileAttribute = File.GetAttributes(m_FileName); 137 | FileAttributes tempAtt = fileAttribute & FileAttributes.ReadOnly; 138 | if (FileAttributes.ReadOnly == tempAtt) 139 | { 140 | MessageBox.Show(STLExportResource.ERR_FILE_READONLY, STLExportResource.MESSAGE_BOX_TITLE, 141 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 142 | return false; 143 | } 144 | File.Delete(m_FileName); 145 | } 146 | 147 | fileWriteStream = new FileStream(m_FileName, FileMode.Create); 148 | fileAttribute = File.GetAttributes(m_FileName) | fileAttribute; 149 | File.SetAttributes(m_FileName, fileAttribute); 150 | binaryWriter = new BinaryWriter(fileWriteStream); 151 | 152 | binaryWriter.BaseStream.Seek(0, SeekOrigin.Begin); 153 | 154 | // write 80 bytes to STL file as the STL file entity name 155 | // and preserve 4 bytes space for Triangular Number Section 156 | byte[] entityName = new byte[84]; 157 | entityName[0] = (byte)/*MSG0*/'n'; 158 | entityName[1] = (byte)/*MSG0*/'a'; 159 | entityName[2] = (byte)/*MSG0*/'m'; 160 | entityName[3] = (byte)/*MSG0*/'e'; 161 | for (int i = 4; i < 84; i++) 162 | { 163 | entityName[i] = (byte)/*MSG0*/'\0'; 164 | } 165 | binaryWriter.Write(entityName); 166 | } 167 | catch (SecurityException) 168 | { 169 | MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 170 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 171 | succeed = false; 172 | } 173 | catch (IOException) 174 | { 175 | MessageBox.Show(STLExportResource.ERR_IO_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 176 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 177 | succeed = false; 178 | } 179 | catch (Exception) 180 | { 181 | MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 182 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 183 | succeed = false; 184 | } 185 | return succeed; 186 | } 187 | 188 | /// 189 | /// Implement interface of closing the file. 190 | /// 191 | /// True if succeeded, false if failed. 192 | public override bool CloseFile() 193 | { 194 | bool succeed = true; 195 | if (null != binaryWriter) 196 | { 197 | binaryWriter.Close(); 198 | binaryWriter = null; 199 | } 200 | if (null != fileWriteStream) 201 | { 202 | fileWriteStream.Close(); 203 | fileWriteStream = null; 204 | } 205 | return succeed; 206 | } 207 | 208 | /// 209 | /// Implement interface of writing one section include normal and vertex. 210 | /// 211 | /// Facet normal. 212 | /// Vertex array. 213 | /// True if succeeded, false if failed. 214 | public override bool WriteSection(Autodesk.Revit.DB.XYZ normal, double[] vertexArr) 215 | { 216 | bool succeed = true; 217 | try 218 | { 219 | // write 3 float numbers to stl file using 12 bytes. 220 | for (int j = 0; j < 3; j++) 221 | { 222 | binaryWriter.Write((float)normal[j]); 223 | } 224 | 225 | for (int i = 0; i < 9; i++) 226 | { 227 | binaryWriter.Write((float)vertexArr[i]); 228 | } 229 | 230 | // add color to stl file using two bytes. 231 | if(m_color!=null) 232 | binaryWriter.Write((UInt16)(((m_color.Red) >>3) | (((m_color.Green) >>3)<<5) | (((m_color.Blue)>>3)<<10))); 233 | else 234 | { 235 | // add two spaces to stl file using two bytes. 236 | byte[] anotherSpace = new byte[2]; 237 | anotherSpace[0] = (byte)/*MSG0*/'\0'; 238 | anotherSpace[1] = (byte)/*MSG0*/'\0'; 239 | binaryWriter.Write(anotherSpace); 240 | } 241 | } 242 | catch (SecurityException) 243 | { 244 | MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 245 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 246 | succeed = false; 247 | } 248 | catch (IOException) 249 | { 250 | MessageBox.Show(STLExportResource.ERR_IO_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 251 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 252 | succeed = false; 253 | } 254 | catch (Exception) 255 | { 256 | MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 257 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 258 | succeed = false; 259 | } 260 | return succeed; 261 | } 262 | 263 | /// 264 | /// Implement interface of adding triangular number section. 265 | /// 266 | /// True if succeeded, false if failed. 267 | public override bool AddTriangularNumberSection() 268 | { 269 | bool succeed = true; 270 | try 271 | { 272 | binaryWriter.BaseStream.Seek(80, SeekOrigin.Begin); 273 | 274 | //write the tringle number to the STL file using 4 bytes. 275 | binaryWriter.Write(m_TriangularNumber); 276 | } 277 | catch (SecurityException) 278 | { 279 | MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 280 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 281 | succeed = false; 282 | } 283 | catch (IOException) 284 | { 285 | MessageBox.Show(STLExportResource.ERR_IO_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 286 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 287 | succeed = false; 288 | } 289 | catch (Exception) 290 | { 291 | MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 292 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 293 | succeed = false; 294 | } 295 | return succeed; 296 | } 297 | 298 | } 299 | 300 | /// 301 | /// Save data to ASCII stl file. 302 | /// 303 | public class SaveDataAsAscII : SaveData 304 | { 305 | StreamWriter stlFile = null; 306 | 307 | /// 308 | /// Constructor 309 | /// 310 | /// STL file name. 311 | /// File format. 312 | public SaveDataAsAscII(string fileName, SaveFormat format) 313 | : base(fileName, format) 314 | { 315 | } 316 | 317 | /// 318 | /// Implement interface of creating a file. 319 | /// 320 | /// True if succeeded, false if failed. 321 | public override bool CreateFile() 322 | { 323 | bool succeed = true; 324 | try 325 | { 326 | FileAttributes fileAttribute = FileAttributes.Normal; 327 | 328 | if (File.Exists(m_FileName)) 329 | { 330 | fileAttribute = File.GetAttributes(m_FileName); 331 | FileAttributes tempAtt = fileAttribute & FileAttributes.ReadOnly; 332 | if (FileAttributes.ReadOnly == tempAtt) 333 | { 334 | MessageBox.Show(STLExportResource.ERR_FILE_READONLY, STLExportResource.MESSAGE_BOX_TITLE, 335 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 336 | return false; 337 | } 338 | File.Delete(m_FileName); 339 | } 340 | 341 | stlFile = new StreamWriter(m_FileName); 342 | fileAttribute = File.GetAttributes(m_FileName) | fileAttribute; 343 | File.SetAttributes(m_FileName, fileAttribute); 344 | 345 | stlFile.WriteLine(/*MSG0*/"solid ascii"); //file header 346 | } 347 | catch (SecurityException) 348 | { 349 | MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 350 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 351 | succeed = false; 352 | } 353 | catch (IOException) 354 | { 355 | MessageBox.Show(STLExportResource.ERR_IO_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 356 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 357 | succeed = false; 358 | } 359 | catch (Exception) 360 | { 361 | MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 362 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 363 | succeed = false; 364 | } 365 | return succeed; 366 | } 367 | 368 | /// 369 | /// Implement interface of closing the file. 370 | /// 371 | /// True if succeeded, false if failed. 372 | public override bool CloseFile() 373 | { 374 | bool succeed = true; 375 | if (null != stlFile) 376 | { 377 | stlFile.Close(); 378 | stlFile = null; 379 | } 380 | return succeed; 381 | } 382 | 383 | /// 384 | /// Implement interface of writing one section include normal and vertex. 385 | /// 386 | /// Facet normal. 387 | /// Vertex array. 388 | /// True if succeeded, false if failed. 389 | public override bool WriteSection(Autodesk.Revit.DB.XYZ normal, double[] vertexArr) 390 | { 391 | bool succeed = true; 392 | try 393 | { 394 | StringBuilder normalSb = new StringBuilder(/*MSG0*/" facet normal "); 395 | 396 | for (int j = 0; j < 3; j++) 397 | { 398 | normalSb.Append(normal[j]).Append(/*MSG0*/" "); 399 | } 400 | stlFile.WriteLine(normalSb); 401 | stlFile.WriteLine(/*MSG0*/" outer loop"); 402 | for (int i = 0; i < 3; i++) 403 | { 404 | StringBuilder vertexSb = new StringBuilder(/*MSG0*/" vertex "); 405 | 406 | for (int j = 0; j < 3; j++) 407 | { 408 | vertexSb.Append(vertexArr[i * 3 + j]).Append(/*MSG0*/" "); 409 | } 410 | 411 | stlFile.WriteLine(vertexSb); 412 | } 413 | stlFile.WriteLine(/*MSG0*/" endloop"); 414 | stlFile.WriteLine(/*MSG0*/" endfacet"); 415 | } 416 | catch (SecurityException) 417 | { 418 | MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 419 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 420 | succeed = false; 421 | } 422 | catch (IOException) 423 | { 424 | MessageBox.Show(STLExportResource.ERR_IO_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 425 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 426 | succeed = false; 427 | } 428 | catch (Exception) 429 | { 430 | MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 431 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 432 | succeed = false; 433 | } 434 | return succeed; 435 | } 436 | 437 | /// 438 | /// ASCII doesn't need to add triangular number 439 | /// 440 | public override bool AddTriangularNumberSection() 441 | { 442 | // ASCII doesn't need to add triangular number 443 | throw new NotImplementedException("ASCII doesn't need to add triangular number"); 444 | } 445 | } 446 | } 447 | -------------------------------------------------------------------------------- /Source/DataGenerator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // STL exporter library: this library works with Autodesk(R) Revit(R) to export an STL file containing model geometry. 3 | // Copyright (C) 2013 Autodesk, Inc. 4 | // 5 | // This library is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU Lesser General Public 7 | // License as published by the Free Software Foundation; either 8 | // version 2.1 of the License, or (at your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | // Lesser General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public 16 | // License along with this library; if not, write to the Free Software 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | // 19 | 20 | using System; 21 | using System.IO; 22 | using System.Collections; 23 | using System.Collections.Generic; 24 | using System.Diagnostics; 25 | using System.Linq; 26 | using System.Security; 27 | using System.Windows.Forms; 28 | 29 | using Autodesk.Revit; 30 | using Autodesk.Revit.DB; 31 | 32 | using RevitApplication = Autodesk.Revit.ApplicationServices.Application; 33 | using GeometryElement = Autodesk.Revit.DB.GeometryElement; 34 | using GeometryOptions = Autodesk.Revit.DB.Options; 35 | using GeometryInstance = Autodesk.Revit.DB.GeometryInstance; 36 | using RevitView = Autodesk.Revit.DB.View; 37 | 38 | namespace BIM.STLExport 39 | { 40 | /// 41 | /// Generate triangular data and save them in a temporary file. 42 | /// 43 | public class DataGenerator 44 | { 45 | public enum GeneratorStatus { SUCCESS, FAILURE, CANCEL }; 46 | 47 | private SaveData m_Writer; 48 | private readonly RevitApplication m_RevitApp; 49 | private readonly Document m_ActiveDocument; 50 | private readonly RevitView m_ActiveView; 51 | private int m_TriangularNumber; 52 | private GeometryOptions m_ViewOptions; 53 | private SortedDictionary m_Categories; 54 | private Settings m_Settings; 55 | private STLExportCancelForm m_StlExportCancel = new STLExportCancelForm(); 56 | 57 | /// 58 | /// Number of triangles in exported Revit document. 59 | /// 60 | public int TriangularNumber 61 | { 62 | get 63 | { 64 | return m_TriangularNumber; 65 | } 66 | } 67 | 68 | /// 69 | /// Constructor. 70 | /// 71 | /// 72 | /// The application object for the active instance of Autodesk Revit. 73 | /// 74 | public DataGenerator(RevitApplication revitApp, Document doc, RevitView view) 75 | { 76 | //initialize the member variable 77 | if (revitApp != null) 78 | { 79 | m_RevitApp = revitApp; 80 | m_ActiveDocument = doc; 81 | m_ActiveView = view; 82 | 83 | m_ViewOptions = m_RevitApp.Create.NewGeometryOptions(); 84 | m_ViewOptions.View = m_ActiveView; 85 | } 86 | } 87 | 88 | /// 89 | /// Save active Revit document as STL file according to customer's settings. 90 | /// 91 | /// The name of the STL file to be saved. 92 | /// Settings for save operation. 93 | /// Successful or failed. 94 | public GeneratorStatus SaveSTLFile(string fileName, Settings settings) 95 | { 96 | m_Settings = settings; 97 | 98 | try 99 | { 100 | 101 | m_StlExportCancel.Show(); 102 | 103 | // save data in certain STL file 104 | if (SaveFormat.Binary == settings.SaveFormat) 105 | { 106 | m_Writer = new SaveDataAsBinary(fileName, settings.SaveFormat); 107 | } 108 | else 109 | { 110 | m_Writer = new SaveDataAsAscII(fileName, settings.SaveFormat); 111 | } 112 | 113 | m_Writer.CreateFile(); 114 | ScanElement(settings.ExportRange); 115 | 116 | System.Windows.Forms.Application.DoEvents(); 117 | 118 | if (m_StlExportCancel.CancelProcess == true) 119 | { 120 | m_StlExportCancel.Close(); 121 | return GeneratorStatus.CANCEL; 122 | } 123 | 124 | if (0 == m_TriangularNumber) 125 | { 126 | MessageBox.Show(STLExportResource.ERR_NOSOLID, STLExportResource.MESSAGE_BOX_TITLE, 127 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 128 | 129 | m_StlExportCancel.Close(); 130 | return GeneratorStatus.FAILURE; 131 | } 132 | 133 | if (SaveFormat.Binary == settings.SaveFormat) 134 | { 135 | // add triangular number to STL file 136 | m_Writer.TriangularNumber = m_TriangularNumber; 137 | m_Writer.AddTriangularNumberSection(); 138 | } 139 | m_Writer.CloseFile(); 140 | } 141 | catch (SecurityException) 142 | { 143 | MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 144 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 145 | 146 | m_StlExportCancel.Close(); 147 | return GeneratorStatus.FAILURE; 148 | } 149 | catch (Exception) 150 | { 151 | MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, 152 | MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 153 | 154 | m_StlExportCancel.Close(); 155 | return GeneratorStatus.FAILURE; 156 | } 157 | 158 | m_StlExportCancel.Close(); 159 | return GeneratorStatus.SUCCESS; 160 | } 161 | 162 | /// 163 | /// Scans all elements in the active document and creates a list of 164 | /// the categories of those elements. 165 | /// 166 | /// Sorted dictionary of categories. 167 | public SortedDictionary ScanCategories() 168 | { 169 | m_Categories = new SortedDictionary(); 170 | 171 | // get all elements in the active document 172 | FilteredElementCollector filterCollector = new FilteredElementCollector(m_ActiveDocument); 173 | 174 | filterCollector.WhereElementIsNotElementType(); 175 | 176 | FilteredElementIterator iterator = filterCollector.GetElementIterator(); 177 | 178 | // create sorted dictionary of the categories of the elements 179 | while (iterator.MoveNext()) 180 | { 181 | Element element = iterator.Current; 182 | 183 | if (element.Category != null) 184 | { 185 | if (!m_Categories.ContainsKey(element.Category.Name)) 186 | { 187 | m_Categories.Add(element.Category.Name, element.Category); 188 | } 189 | } 190 | } 191 | 192 | return m_Categories; 193 | } 194 | 195 | /// 196 | /// Gets all categores in all open documents if allCategories is true 197 | /// or the categories of the elements in the active document if allCategories 198 | /// is set to false. 199 | /// 200 | /// True to get all categores in all open documents, 201 | /// false to get the categories of the elements in the active document. 202 | /// Sorted dictionary of categories. 203 | public SortedDictionary ScanCategories(bool allCategories) 204 | { 205 | if (!allCategories) 206 | { 207 | return ScanCategories(); 208 | } 209 | else 210 | { 211 | // get and return all categories 212 | SortedDictionary sortedCategories = new SortedDictionary(); 213 | 214 | // scan the active document for categories 215 | foreach (Category category in m_ActiveDocument.Settings.Categories) 216 | { 217 | 218 | if (!sortedCategories.ContainsKey(category.Name)) 219 | sortedCategories.Add(category.Name, category); 220 | } 221 | 222 | // if linked models exist scan for categories 223 | List linkedDocs = GetLinkedModels(); 224 | 225 | foreach (Document linkedDoc in linkedDocs) 226 | { 227 | foreach (Category category in linkedDoc.Settings.Categories) 228 | { 229 | if (!sortedCategories.ContainsKey(category.Name)) 230 | sortedCategories.Add(category.Name, category); 231 | } 232 | } 233 | 234 | return sortedCategories; 235 | } 236 | } 237 | 238 | /// 239 | /// Get every Element in all open documents. 240 | /// 241 | /// 242 | /// The range of elements to be exported. 243 | /// 244 | private void ScanElement(ElementsExportRange exportRange) 245 | { 246 | List documents = new List(); 247 | 248 | // active document should be the first docuemnt in the list 249 | documents.Add(m_ActiveDocument); 250 | 251 | // figure out if we need to get linked models 252 | if (m_Settings.IncludeLinkedModels) 253 | { 254 | List linkedDocList = GetLinkedModels(); 255 | documents.AddRange(linkedDocList); 256 | } 257 | 258 | foreach (Document doc in documents) 259 | { 260 | FilteredElementCollector collector = null; 261 | 262 | if (ElementsExportRange.OnlyVisibleOnes == exportRange) 263 | { 264 | // find the view having the same name of ActiveView.Name in active and linked model documents. 265 | ElementId viewId = FindView(doc, m_ActiveView.Name); 266 | 267 | if (viewId != ElementId.InvalidElementId) 268 | collector = new FilteredElementCollector(doc, viewId); 269 | else 270 | collector = new FilteredElementCollector(doc); 271 | } 272 | else 273 | { 274 | collector = new FilteredElementCollector(doc); 275 | } 276 | 277 | collector.WhereElementIsNotElementType(); 278 | 279 | FilteredElementIterator iterator = collector.GetElementIterator(); 280 | 281 | while (iterator.MoveNext()) 282 | { 283 | System.Windows.Forms.Application.DoEvents(); 284 | 285 | if (m_StlExportCancel.CancelProcess == true) 286 | return; 287 | 288 | Element element = iterator.Current; 289 | 290 | // check if element's category is in the list, if it is continue. 291 | // if there are no selected categories, take anything. 292 | if (m_Settings.SelectedCategories.Count > 0) 293 | { 294 | if (element.Category == null) 295 | { 296 | continue; 297 | } 298 | else 299 | { 300 | IEnumerable cats = from cat in m_Settings.SelectedCategories 301 | where cat.Id == element.Category.Id 302 | select cat; 303 | 304 | if (cats.Count() == 0) 305 | { 306 | continue; 307 | } 308 | } 309 | } 310 | 311 | // get the GeometryElement of the element 312 | GeometryElement geometry = null; 313 | geometry = element.get_Geometry(m_ViewOptions); 314 | 315 | if (null == geometry) 316 | { 317 | continue; 318 | } 319 | 320 | // get the solids in GeometryElement 321 | ScanGeomElement(doc,geometry, null); 322 | } 323 | } 324 | } 325 | 326 | /// 327 | /// Get view by view name. 328 | /// 329 | /// The document to find the view. 330 | /// The view name. 331 | /// The element id of the view found. 332 | private ElementId FindView(Document doc, string activeViewName) 333 | { 334 | FilteredElementCollector collector = new FilteredElementCollector(doc); 335 | collector.OfClass(typeof(RevitView)); 336 | 337 | IEnumerable selectedView = from view in collector.ToList() 338 | where view.Name == activeViewName 339 | select view; 340 | 341 | if (selectedView.Count() > 0) 342 | { 343 | return (selectedView.First() as RevitView).Id; 344 | } 345 | 346 | return ElementId.InvalidElementId; 347 | } 348 | 349 | /// 350 | /// Scan GeometryElement to collect triangles. 351 | /// 352 | /// The geometry element. 353 | /// The transformation. 354 | private void ScanGeomElement(Document document, GeometryElement geometry, Transform transform) 355 | { 356 | //get all geometric primitives contained in the GeometryElement 357 | foreach (GeometryObject gObject in geometry) 358 | { 359 | // if the type of the geometric primitive is Solid 360 | Solid solid = gObject as Solid; 361 | if (null != solid) 362 | { 363 | ScanSolid(document,solid, transform); 364 | continue; 365 | } 366 | 367 | // if the type of the geometric primitive is instance 368 | GeometryInstance instance = gObject as GeometryInstance; 369 | if (null != instance) 370 | { 371 | ScanGeometryInstance(document, instance, transform); 372 | continue; 373 | } 374 | 375 | GeometryElement geomElement = gObject as GeometryElement; 376 | if (null != geomElement) 377 | { 378 | ScanGeomElement(document,geomElement, transform); 379 | } 380 | } 381 | } 382 | 383 | /// 384 | /// Scan GeometryInstance to collect triangles. 385 | /// 386 | /// The geometry instance. 387 | /// The transformation. 388 | private void ScanGeometryInstance(Document document, GeometryInstance instance, Transform transform) 389 | { 390 | GeometryElement instanceGeometry = instance.SymbolGeometry; 391 | if (null == instanceGeometry) 392 | { 393 | return; 394 | } 395 | Transform newTransform; 396 | if (null == transform) 397 | { 398 | newTransform = instance.Transform; 399 | } 400 | else 401 | { 402 | newTransform = transform.Multiply(instance.Transform); // get a transformation of the affine 3-space 403 | } 404 | 405 | // get all geometric primitives contained in the GeometryElement 406 | ScanGeomElement(document,instanceGeometry, newTransform); 407 | } 408 | 409 | /// 410 | /// Scan Solid to collect triangles. 411 | /// 412 | /// The solid. 413 | /// The transformation. 414 | private void ScanSolid(Document document, Solid solid, Transform transform) 415 | { 416 | GetTriangular(document, solid, transform); // get triangles in the solid 417 | } 418 | 419 | /// 420 | /// Get triangles in a solid with transform. 421 | /// 422 | /// The solid contains triangulars 423 | /// The transformation. 424 | private void GetTriangular(Document document, Solid solid, Transform transform) 425 | { 426 | // a solid has many faces 427 | FaceArray faces = solid.Faces; 428 | bool hasTransform = (null != transform); 429 | if (0 == faces.Size) 430 | { 431 | return; 432 | } 433 | 434 | foreach (Face face in faces) 435 | { 436 | if (face.Visibility != Visibility.Visible) 437 | { 438 | continue; 439 | } 440 | Mesh mesh = face.Triangulate(); 441 | if (null == mesh) 442 | { 443 | continue; 444 | } 445 | 446 | m_TriangularNumber += mesh.NumTriangles; 447 | 448 | PlanarFace planarFace = face as PlanarFace; 449 | 450 | // write face to stl file 451 | // a face has a mesh, all meshes are made of triangles 452 | for (int ii = 0; ii < mesh.NumTriangles; ii++) 453 | { 454 | MeshTriangle triangular = mesh.get_Triangle(ii); 455 | double[] xyz = new double[9]; 456 | Autodesk.Revit.DB.XYZ normal = new Autodesk.Revit.DB.XYZ(); 457 | try 458 | { 459 | Autodesk.Revit.DB.XYZ[] triPnts = new Autodesk.Revit.DB.XYZ[3]; 460 | for (int n = 0; n < 3; ++n) 461 | { 462 | double x, y, z; 463 | Autodesk.Revit.DB.XYZ point = triangular.get_Vertex(n); 464 | if (hasTransform) 465 | { 466 | point = transform.OfPoint(point); 467 | } 468 | if (m_Settings.ExportSharedCoordinates) 469 | { 470 | ProjectPosition ps = document.ActiveProjectLocation.GetProjectPosition(point); 471 | x = ps.EastWest; 472 | y = ps.NorthSouth; 473 | z = ps.Elevation; 474 | } 475 | else 476 | { 477 | x = point.X; 478 | y = point.Y; 479 | z = point.Z; 480 | } 481 | if (!m_Settings.Units.Empty()) 482 | { 483 | xyz[3 * n] = UnitUtils.ConvertFromInternalUnits(x, m_Settings.Units); 484 | xyz[3 * n + 1] = UnitUtils.ConvertFromInternalUnits(y, m_Settings.Units); 485 | xyz[3 * n + 2] = UnitUtils.ConvertFromInternalUnits(z, m_Settings.Units); 486 | } 487 | else 488 | { 489 | xyz[3 * n] = x; 490 | xyz[3 * n + 1] = y; 491 | xyz[3 * n + 2] = z; 492 | } 493 | 494 | var mypoint = new XYZ(xyz[3 * n], xyz[3 * n + 1], xyz[3 * n + 2]); 495 | triPnts[n] = mypoint; 496 | } 497 | 498 | Autodesk.Revit.DB.XYZ pnt1 = triPnts[1] - triPnts[0]; 499 | normal = pnt1.CrossProduct(triPnts[2] - triPnts[1]); 500 | } 501 | catch (Exception ex) 502 | { 503 | m_TriangularNumber--; 504 | STLDialogManager.ShowDebug(ex.Message); 505 | continue; 506 | } 507 | 508 | if (m_Writer is SaveDataAsBinary && m_Settings.ExportColor) 509 | { 510 | Material material = document.GetElement(face.MaterialElementId) as Material; 511 | if(material!=null) 512 | ((SaveDataAsBinary)m_Writer).Color = material.Color; 513 | } 514 | 515 | m_Writer.WriteSection(normal, xyz); 516 | } 517 | } 518 | } 519 | 520 | /// 521 | /// Scans and returns the documents linked to the current model. 522 | /// 523 | /// List of linked documents. 524 | private List GetLinkedModels() 525 | { 526 | List linkedDocs = new List(); 527 | 528 | try 529 | { 530 | // scan the current model looking for Revit links 531 | List linkedElements = FindLinkedModelElements(); 532 | 533 | foreach (Element linkedElem in linkedElements) 534 | { 535 | RevitLinkType linkType = linkedElem as RevitLinkType; 536 | 537 | if (linkType != null) 538 | { 539 | // now look that up in the open documents 540 | foreach (Document openedDoc in m_RevitApp.Documents) 541 | { 542 | if (Path.GetFileNameWithoutExtension(openedDoc.Title).ToUpper() == Path.GetFileNameWithoutExtension(linkType.Name).ToUpper()) 543 | linkedDocs.Add(openedDoc); 544 | } 545 | } 546 | } 547 | } 548 | catch (Exception ex) 549 | { 550 | STLDialogManager.ShowDebug(ex.Message); 551 | } 552 | 553 | return linkedDocs; 554 | 555 | } 556 | 557 | /// 558 | /// Scan model and return linked model elements. 559 | /// 560 | /// List of linked model elements. 561 | private List FindLinkedModelElements() 562 | { 563 | Document doc = m_ActiveDocument; 564 | 565 | FilteredElementCollector linksCollector = new FilteredElementCollector(doc); 566 | List linkElements = linksCollector.WherePasses(new ElementCategoryFilter(BuiltInCategory.OST_RvtLinks)).ToList(); 567 | 568 | FilteredElementCollector familySymbolCollector = new FilteredElementCollector(doc); 569 | linkElements.AddRange(familySymbolCollector.OfClass(typeof(Autodesk.Revit.DB.FamilySymbol)).ToList()); 570 | 571 | return linkElements; 572 | } 573 | 574 | /// 575 | /// Initializes the Cancel form. 576 | /// 577 | private void StartCancelForm() 578 | { 579 | STLExportCancelForm stlCancel = new STLExportCancelForm(); 580 | stlCancel.Show(); 581 | } 582 | } 583 | } 584 | -------------------------------------------------------------------------------- /Source/STLExportForm.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 | 122 | 302, 396 123 | 124 | 125 | 90, 30 126 | 127 | 128 | 129 | 0 130 | 131 | 132 | Cancel 133 | 134 | 135 | btnCancel 136 | 137 | 138 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 139 | 140 | 141 | $this 142 | 143 | 144 | 3 145 | 146 | 147 | 148 | NoControl 149 | 150 | 151 | 12, 396 152 | 153 | 154 | 90, 30 155 | 156 | 157 | 1 158 | 159 | 160 | Help 161 | 162 | 163 | btnHelp 164 | 165 | 166 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 167 | 168 | 169 | $this 170 | 171 | 172 | 2 173 | 174 | 175 | NoControl 176 | 177 | 178 | 206, 396 179 | 180 | 181 | 90, 30 182 | 183 | 184 | 2 185 | 186 | 187 | Save 188 | 189 | 190 | btnSave 191 | 192 | 193 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 194 | 195 | 196 | $this 197 | 198 | 199 | 1 200 | 201 | 202 | NoControl 203 | 204 | 205 | 23, 174 206 | 207 | 208 | 326, 44 209 | 210 | 211 | 5 212 | 213 | 214 | Export in Shared Coordinates 215 | 216 | 217 | cbExportSharedCoordinates 218 | 219 | 220 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 221 | 222 | 223 | tpGeneral 224 | 225 | 226 | 0 227 | 228 | 229 | NoControl 230 | 231 | 232 | 23, 144 233 | 234 | 235 | 326, 44 236 | 237 | 238 | 4 239 | 240 | 241 | Export Color 242 | 243 | 244 | cbExportColor 245 | 246 | 247 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 248 | 249 | 250 | tpGeneral 251 | 252 | 253 | 1 254 | 255 | 256 | 63, 237 257 | 258 | 259 | 211, 21 260 | 261 | 262 | 3 263 | 264 | 265 | comboBox_DUT 266 | 267 | 268 | System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 269 | 270 | 271 | tpGeneral 272 | 273 | 274 | 2 275 | 276 | 277 | True 278 | 279 | 280 | 20, 245 281 | 282 | 283 | 34, 13 284 | 285 | 286 | 2 287 | 288 | 289 | Units: 290 | 291 | 292 | label1 293 | 294 | 295 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 296 | 297 | 298 | tpGeneral 299 | 300 | 301 | 3 302 | 303 | 304 | 23, 114 305 | 306 | 307 | 326, 44 308 | 309 | 310 | 1 311 | 312 | 313 | Include Linked Models 314 | 315 | 316 | cbIncludeLinked 317 | 318 | 319 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 320 | 321 | 322 | tpGeneral 323 | 324 | 325 | 4 326 | 327 | 328 | 167, 19 329 | 330 | 331 | 104, 48 332 | 333 | 334 | 1 335 | 336 | 337 | ASCII 338 | 339 | 340 | rbAscii 341 | 342 | 343 | System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 344 | 345 | 346 | gbSTLFormat 347 | 348 | 349 | 0 350 | 351 | 352 | 40, 19 353 | 354 | 355 | 104, 48 356 | 357 | 358 | 0 359 | 360 | 361 | Binary 362 | 363 | 364 | rbBinary 365 | 366 | 367 | System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 368 | 369 | 370 | gbSTLFormat 371 | 372 | 373 | 1 374 | 375 | 376 | 23, 21 377 | 378 | 379 | 326, 73 380 | 381 | 382 | 0 383 | 384 | 385 | STL Format 386 | 387 | 388 | gbSTLFormat 389 | 390 | 391 | System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 392 | 393 | 394 | tpGeneral 395 | 396 | 397 | 5 398 | 399 | 400 | 4, 22 401 | 402 | 403 | 3, 3, 3, 3 404 | 405 | 406 | 367, 324 407 | 408 | 409 | 0 410 | 411 | 412 | General 413 | 414 | 415 | tpGeneral 416 | 417 | 418 | System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 419 | 420 | 421 | tabControl1 422 | 423 | 424 | 0 425 | 426 | 427 | 6, 6 428 | 429 | 430 | 355, 266 431 | 432 | 433 | 4 434 | 435 | 436 | tvCategories 437 | 438 | 439 | System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 440 | 441 | 442 | tpCategories 443 | 444 | 445 | 0 446 | 447 | 448 | 261, 278 449 | 450 | 451 | 100, 40 452 | 453 | 454 | 2 455 | 456 | 457 | Check None 458 | 459 | 460 | btnCheckNone 461 | 462 | 463 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 464 | 465 | 466 | tpCategories 467 | 468 | 469 | 1 470 | 471 | 472 | 155, 278 473 | 474 | 475 | 100, 40 476 | 477 | 478 | 1 479 | 480 | 481 | Check All 482 | 483 | 484 | btnCheckAll 485 | 486 | 487 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 488 | 489 | 490 | tpCategories 491 | 492 | 493 | 2 494 | 495 | 496 | 4, 22 497 | 498 | 499 | 3, 3, 3, 3 500 | 501 | 502 | 367, 324 503 | 504 | 505 | 1 506 | 507 | 508 | Categories 509 | 510 | 511 | tpCategories 512 | 513 | 514 | System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 515 | 516 | 517 | tabControl1 518 | 519 | 520 | 1 521 | 522 | 523 | 12, 12 524 | 525 | 526 | 375, 350 527 | 528 | 529 | 3 530 | 531 | 532 | tabControl1 533 | 534 | 535 | System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 536 | 537 | 538 | $this 539 | 540 | 541 | 0 542 | 543 | 544 | True 545 | 546 | 547 | 96, 96 548 | 549 | 550 | 404, 441 551 | 552 | 553 | CenterScreen 554 | 555 | 556 | Export STL 557 | 558 | 559 | STLExportForm 560 | 561 | 562 | System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 563 | 564 | -------------------------------------------------------------------------------- /Doc/LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | 459 | END OF TERMS AND CONDITIONS --------------------------------------------------------------------------------