├── .gitignore ├── .nuke ├── build.schema.json └── parameters.json ├── CHANGELOG.md ├── CONTRIBUTING.md ├── GitVersion.yml ├── InventorShims.sln ├── LICENSE ├── README.md ├── build.cmd ├── build.ps1 ├── build.sh ├── build ├── .editorconfig ├── .gitignore ├── Build.cs ├── Configuration.cs ├── Directory.Build.props ├── Directory.Build.targets ├── Properties │ └── launchSettings.json ├── _build.csproj ├── _build.csproj.DotSettings ├── build-docs-serve.bat ├── build-docs.bat └── replace-code-tags.ps1 ├── docfx ├── api │ ├── .gitignore │ └── index.md ├── articles │ ├── Contributing.md │ ├── changelog.md │ ├── quick-start.md │ └── toc.yml ├── docfx.json ├── index.md ├── templates │ └── inventor-shims │ │ ├── favicon.ico │ │ └── logo.svg └── toc.yml ├── docs ├── api │ ├── InventorShims.ApplicationShim.html │ ├── InventorShims.AttributeShim.html │ ├── InventorShims.Conversions.html │ ├── InventorShims.DocumentShim.html │ ├── InventorShims.DrawingDocumentShim.html │ ├── InventorShims.ExternalRuleDirectories.html │ ├── InventorShims.ParameterShim.html │ ├── InventorShims.PathShim.html │ ├── InventorShims.PropertyShim.html │ ├── InventorShims.StringShim.html │ ├── InventorShims.TranslatorShim.DwgExporter.html │ ├── InventorShims.TranslatorShim.PdfExporter.html │ ├── InventorShims.TranslatorShim.StepExporter.html │ ├── InventorShims.TranslatorShim.StepImporter.html │ ├── InventorShims.TranslatorShim.StepProtocolEnum.html │ ├── InventorShims.TranslatorShim.StlExporter.html │ ├── InventorShims.TranslatorShim.StlResolutionEnum.html │ ├── InventorShims.TranslatorShim.html │ ├── InventorShims.UiShim.html │ ├── InventorShims.html │ ├── index.html │ └── toc.html ├── articles │ ├── Contributing.html │ ├── changelog.html │ ├── contribution-guidelines.html │ ├── quick-start.html │ └── toc.html ├── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── index.html ├── logo.svg ├── manifest.json ├── search-stopwords.json ├── styles │ ├── docfx.css │ ├── docfx.js │ ├── docfx.vendor.css │ ├── docfx.vendor.js │ ├── lunr.js │ ├── lunr.min.js │ ├── main.css │ ├── main.js │ └── search-worker.js ├── toc.html └── xrefmap.yml ├── images └── InventorCode-brackets-logo-64x64.png ├── samples ├── IEnumerable-change-iprops-of-selected.vb ├── IEnumerable-change-parameter-of-all-referenced-docs.vb ├── ParameterShim-samples.vb ├── PathShim-samples.vb └── change-iprops-of-selected.vb ├── src └── InventorShims │ ├── ApplicationShim.cs │ ├── AttributeShim.cs │ ├── Conversions.cs │ ├── DocumentShim.cs │ ├── DrawingViewShim.vb │ ├── ExternalRuleDirectories.cs │ ├── GlobalSuppressions.cs │ ├── InventorShims.csproj │ ├── ObjectShim.vb │ ├── ParameterShim.cs │ ├── PathShim.cs │ ├── PropertyShim.cs │ ├── Research │ ├── ListIprops.vb │ └── Property Info.txt │ ├── StringShim.cs │ ├── TranslatorShim │ ├── DwgExporter.cs │ ├── PdfExporter.cs │ ├── StepExporter.cs │ ├── StepImporter.cs │ ├── StepProtocolEnum.cs │ ├── StlExporter.cs │ ├── StlResolutionEnum.cs │ └── TranslatorData.cs │ ├── UiShim.cs │ └── WinMacros.cs └── tests ├── GetDocumentFromObject.tests ├── App.config ├── GetDocumentFromObject.tests.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── Inventor.test.config ├── Templates │ ├── Sheet Metal.ipt │ ├── Standard.iam │ ├── Standard.idw │ ├── Standard.inest │ ├── Standard.ipn │ ├── Standard.ipt │ ├── Weldment.iam │ └── standard.dwg └── Test.ipj ├── InventorShims.iLogic.tests ├── DocumentType.Test.vb ├── DrawingDocumentExtensionsTests.vb ├── Iproperty SpeedTest.vb ├── ListIprops.vb ├── PropertyShim.GetProperty.SpeedTest Results.md ├── SpeedTest Results - try vs GetPropsInfo.md ├── SpeedTest.vb ├── Timer.vb ├── iProperty.GetProperty SpeedTest.vb ├── iProperty.GetProperty.SpeedTest custom property.vb ├── iProperty.GetProperty.SpeedTest no parameter.vb └── iProperty.Unit Tests.vb └── InventorShims.tests ├── ApplicationShimTests.cs ├── AttributeShimTests.cs ├── DocumentShimTests.cs ├── ExternalRuleDirectoriesTests.cs ├── GetDocumentFromObjectTests.cs ├── InventorShims.tests.csproj ├── ParameterShimTests.cs ├── PathShimTests.cs ├── Properties └── AssemblyInfo.cs ├── PropertyShimsTests.cs ├── TestDocuments.cs ├── TestUtilities.cs └── packages.config /.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 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | docfx/log.txt 214 | tests/Inventor.test.config/OldVersions 215 | 216 | .cr 217 | .nuke/temp 218 | -------------------------------------------------------------------------------- /.nuke/build.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "Build Schema", 4 | "$ref": "#/definitions/build", 5 | "definitions": { 6 | "build": { 7 | "type": "object", 8 | "properties": { 9 | "Configuration": { 10 | "type": "string", 11 | "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", 12 | "enum": [ 13 | "Debug", 14 | "Release" 15 | ] 16 | }, 17 | "Continue": { 18 | "type": "boolean", 19 | "description": "Indicates to continue a previously failed build attempt" 20 | }, 21 | "GitHubAuthenticationToken": { 22 | "type": "string" 23 | }, 24 | "Help": { 25 | "type": "boolean", 26 | "description": "Shows the help text for this build assembly" 27 | }, 28 | "Host": { 29 | "type": "string", 30 | "description": "Host for execution. Default is 'automatic'", 31 | "enum": [ 32 | "AppVeyor", 33 | "AzurePipelines", 34 | "Bamboo", 35 | "Bitrise", 36 | "GitHubActions", 37 | "GitLab", 38 | "Jenkins", 39 | "Rider", 40 | "SpaceAutomation", 41 | "TeamCity", 42 | "Terminal", 43 | "TravisCI", 44 | "VisualStudio", 45 | "VSCode" 46 | ] 47 | }, 48 | "MyGetApiKey": { 49 | "type": "string" 50 | }, 51 | "MyGetSource": { 52 | "type": "string" 53 | }, 54 | "NoLogo": { 55 | "type": "boolean", 56 | "description": "Disables displaying the NUKE logo" 57 | }, 58 | "Partition": { 59 | "type": "string", 60 | "description": "Partition to use on CI" 61 | }, 62 | "Plan": { 63 | "type": "boolean", 64 | "description": "Shows the execution plan (HTML)" 65 | }, 66 | "Profile": { 67 | "type": "array", 68 | "description": "Defines the profiles to load", 69 | "items": { 70 | "type": "string" 71 | } 72 | }, 73 | "Root": { 74 | "type": "string", 75 | "description": "Root directory during build execution" 76 | }, 77 | "Skip": { 78 | "type": "array", 79 | "description": "List of targets to be skipped. Empty list skips all dependencies", 80 | "items": { 81 | "type": "string", 82 | "enum": [ 83 | "Clean", 84 | "Compile", 85 | "Pack", 86 | "Push", 87 | "Restore" 88 | ] 89 | } 90 | }, 91 | "Solution": { 92 | "type": "string", 93 | "description": "Path to a solution file that is automatically loaded" 94 | }, 95 | "Target": { 96 | "type": "array", 97 | "description": "List of targets to be invoked. Default is '{default_target}'", 98 | "items": { 99 | "type": "string", 100 | "enum": [ 101 | "Clean", 102 | "Compile", 103 | "Pack", 104 | "Push", 105 | "Restore" 106 | ] 107 | } 108 | }, 109 | "Verbosity": { 110 | "type": "string", 111 | "description": "Logging verbosity during build execution. Default is 'Normal'", 112 | "enum": [ 113 | "Minimal", 114 | "Normal", 115 | "Quiet", 116 | "Verbose" 117 | ] 118 | } 119 | } 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /.nuke/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./build.schema.json", 3 | "Solution": "InventorShims.sln" 4 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [2.0.0](https://github.com/InventorCode/InventorShims/releases/tag/v2.0.0) (2022-01-??) 2 | 3 | ### Added 4 | 5 | - PropertyShim extension methods now work on the following document types: 6 | - PartDocument 7 | - AssemblyDocument 8 | - DrawingDocument 9 | - PresentationDocument 10 | 11 | - ParameterShim extension methods now work with the following document types: 12 | - PartDocument 13 | - AssemblyDocument 14 | - DrawingDocument 15 | - Ilogic code samples for some of the added extension methods. 16 | - Extension methods for use with LINQ and fluent design. 17 | 18 | #### New general extension methods: 19 | 20 | |extension method|on object|returns| 21 | |---|---|---| 22 | |IsContentCenter|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|bool| 23 | |IsCustomContentCenter|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|bool| 24 | 25 | #### New IEnumerable Providers 26 | 27 | |extension method|on object|returns| 28 | |---|---|---| 29 | |EnumerateDocuments|SelectSet|IEnumerable\| 30 | |EnumerateDocuments|IEnumerable\|IEnumerable\| 31 | |EnumerateAllReferencedDocuments|Document|IEnumerable\| 32 | |EnumerateAllReferencedDocuments|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 33 | |EnumerateReferencedDocuments|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 34 | |EnumerateReferencingDocuments|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 35 | |EnumerateReferencedDocumentDescriptors|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 36 | |EnumerateAllLeafOccurrencesDocumentDescriptors|AssemblyDocument|IEnumerable\| 37 | |EnumerateParameters|Document, PartDocument, AssemblyDocument, DrawingDocument|IEnumerable\| 38 | 39 | #### New IEnumerable Filters 40 | 41 | |extension method|on object|returns| 42 | |---|---|---| 43 | |AssemblyDocuments|IEnumerable\|IEnumerable\| 44 | |DrawingDocuments|IEnumerable\|IEnumerable\| 45 | |PresentationDocuments|IEnumerable\|IEnumerable\| 46 | |PartDocuments|IEnumerable\|IEnumerable\| 47 | |RemoveAssemblyDocuments|IEnumerable\|IEnumerable\| 48 | |RemoveDrawingDocuments|IEnumerable\|IEnumerable\| 49 | |RemovePresentationDocuments|IEnumerable\|IEnumerable\| 50 | |RemovePartDocuments|IEnumerable\|IEnumerable\| 51 | |RemoveNonNativeDocuments|IEnumerable\|IEnumerable\| 52 | 53 | ### Changed 54 | - .Net Framework version bumped to 4.8 55 | ## [1.3.1](https://github.com/InventorCode/InventorShims/releases/tag/1.3.1) (2021-09-03) 56 | 57 | ### Added 58 | - ExternalRuleDirectories object now implements the IDisposable interface, allowing the using keyword. 59 | - ExternalRuleDirectories documentation. 60 | - Updated Nuke Build system. 61 | 62 | ### Changed 63 | - Integration test project "InventorShims.tests" now uses the NUnit test framework. 64 | - Refactored some duplicate tests into TestCases. 65 | - Refactored Inventor document creation routines to TestUtilities.cs. 66 | - Nuke build updated to Nuke 5.3.0 67 | - Nuget packages for build project updated. 68 | - Nuke build targets updated/created: 69 | - Nuke Compile 70 | - Nuke Pack 71 | - Nuke Push 72 | - Nuke BuildDocumentation 73 | - Nuke PublishGitHubRelease 74 | - InventorShims.manual tests changed to InventorShims.ilogic.tests. Removed VS project associated with this. 75 | 76 | ### Fixed 77 | - ExternalRuleDirectories.Add was not adding entires properly. 78 | - ExternalRuleDirectories.Remove was not removing entires properly. 79 | 80 | ### Removed 81 | - InventorShims-vb project has been removed. 82 | - Errant NewtonSoft.Json package reference 83 | 84 | ## [1.2.0](https://github.com/InventorCode/InventorShims/releases/tag/1.2.0) (2021-08-15) 85 | 86 | ### Added 87 | - ExternalRuleDirectories object allows you to manipulate the iLogic Addin's list of External Rules Directories in a more straightforward manner. 88 | 89 | ### Fixed 90 | - Added conventional commits keywords to gitversion configuration. 91 | 92 | 93 | ## [1.1.1](https://github.com/InventorCode/InventorShims/releases/tag/v1.1.1) (2021-02-11) 94 | 95 | ### Chore 96 | 97 | * remove ILMerge nuget package 98 | 99 | ### Docs 100 | 101 | * rebuild 102 | * remove InventorShims-vb 103 | 104 | 105 | ## [v1.1.0](https://github.com/InventorCode/InventorShims/releases/tag/v1.1.0) (2021-02-11) 106 | 107 | ### Chore 108 | 109 | * update nuget config, changelog, versions 110 | * add nuspec 111 | * add logo for nuget package 112 | * Removed InventorShims-vs from builds 113 | * renamed InventorShims-cs to InventorShims 114 | 115 | ### Docs 116 | 117 | * added initial changelog 118 | * removed reference to pre-release state. 119 | * Updated API docs link in readme 120 | * Added samples to ParameterShim, added more to the class description. 121 | * Added ParameterShim and PathShim samples. 122 | 123 | ### Feat 124 | 125 | * added git-chglog config 126 | * ParameterIsWritable string signature added 127 | * ParameterIsWritable now acts as an extension method 128 | 129 | ### Style 130 | 131 | * remove whitespace 132 | 133 | ### Test 134 | 135 | * Added ParameterIsWritable unit tests. 136 | 137 | ## [v1.0.0](https://github.com/InventorCode/InventorShims/releases/tag/v1.0.0) (2021-01-17) 138 | 139 | ### Build 140 | 141 | * v1.0.0 142 | 143 | ### Docs 144 | 145 | * new build 146 | * Added Conventional Commits as the commit format guideline. 147 | * added --force to docfx rebuild. Added new template reference for icons 148 | * added logo and favicon 149 | * rebuilt with manual fix for "view source" error 150 | * Added an ilogic rule sample 151 | * tentative fix for "View Source" in docfx not working. 152 | 153 | ### Feat 154 | 155 | * AttributeShim methods are now extension methods. 156 | 157 | ### Fix 158 | 159 | * fixed typoe in sample. Added commented out msgbox call. 160 | * GetDocumentFromObject for kDrawingDurveSegmentObject 161 | 162 | ### Refactor 163 | 164 | * added error handling to SaveSilently() method 165 | * PathShim moved to C# 166 | * added todo for ittermittent bug in test 167 | 168 | ### Test 169 | 170 | * Added debug statements to GetDocumentsFromSelectSet() 171 | * GetDocumentFromObject.tests updated 172 | * ApplicationShim tests now wait for Inventor processes to finish. 173 | 174 | ### Tests 175 | 176 | * modified for newest PathShim.cs 177 | 178 | ## [v0.1.0](https://github.com/InventorCode/InventorShims/releases/tag/v0.1.0) (2020-12-25) 179 | 180 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Contributions 2 | 3 | Contributions of any type are welcome! If you want to help... 4 | 5 | * Please drop into [issues](https://github.com/InventorCode/InventorShims/issues) and see if there are any outstanding ones that you would like to tackle. 6 | * Add any issues you want and we can discuss. 7 | * Fork the code and add some functionality! 8 | 9 | If you want to contribute, the process proceeds as follows: 10 | 11 | 1. fork the repo 12 | 2. create a new feature branch in your forked repo 13 | 3. make changes 14 | 4. commit your work 15 | 5. then issue a pull request back to this repo (upstream) for a code review. 16 | 17 | 18 | ### Branch Guidance 19 | 20 | *Master* will be the main repository branch; this branch will contain the most up-to-date code. All short-lived branches will be merged back into *Master* after a code review by repo maintainers. 21 | 22 | The following branch names are suggested for short-lived branches... 23 | 24 | * feature/xx 25 | * bugfix/xx 26 | * issue/xx 27 | * username/xx 28 | 29 | ### Dependencies for Build 30 | 31 | * Visual Studio Compatible IDE 32 | * .Net 4.7 (for Inventor 2020 support) 33 | * Inventor 2021 SDK installation (minimum) 34 | 35 | ### Build 36 | 37 | Builds may be run by opening powershell or cmd in the repo folder and entering the following commands: 38 | 39 | * `Nuke`, or 40 | * `Nuke compile` 41 | 42 | ### Version Numbers 43 | 44 | Versioning will follow [Sematic Versioning](https://semver.org/) once version 1.0.0 is released. The version numbers will follow the format `MAJOR.MINOR.PATCH` where: 45 | 46 | * MAJOR - incompatible API changes 47 | * MINOR - added functionality in a backwards compatible manner 48 | * PATCH - backwards compatible bug fixes 49 | 50 | ### Commit Guidelines 51 | 52 | [Conventional Commits](https://www.conventionalcommits.org/en) will be used as the commit message guidelines. Following these simple guidelines will ensure commit message consistency that simplifies changelog generation and version number management. Contributors are encouraged to visit the page and read the tutorial and spec. Pull requests are expected to follow this convention. 53 | 54 | A simple, breezy tutorial follows... commit messages should be in the form "KEYWORD: message". Commit may have multiple lines. Try to keep each commit to a single keyword. This keyword is one of the following: 55 | 56 | - build 57 | - chore 58 | - ci 59 | - docs 60 | - feat 61 | - fix 62 | - refactor 63 | - revert 64 | - style 65 | - test 66 | 67 | Breaking changes in the codebase are denoted by an exclamation mark after a keyword, such as: 68 | 69 | - feat! 70 | - fix! 71 | - etc... 72 | 73 | A footer ```BREAKING CHANGE:``` should also be included in the commit message for human readability, but is not strictly required. 74 | 75 | ### License 76 | 77 | This code is under an MIT license. -------------------------------------------------------------------------------- /GitVersion.yml: -------------------------------------------------------------------------------- 1 | assembly-versioning-scheme: MajorMinorPatch 2 | mode: ContinuousDeployment 3 | branches: {} 4 | ignore: 5 | sha: [] 6 | merge-message-formats: {} 7 | major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" 8 | minor-version-bump-message: "^(feat)(\\([\\w\\s]*\\))?:" 9 | patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?:" -------------------------------------------------------------------------------- /InventorShims.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InventorShims", "src\InventorShims\InventorShims.csproj", "{DE9044A0-4809-4828-ADEE-FA787925CBCF}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InventorShims.tests", "tests\InventorShims.tests\InventorShims.tests.csproj", "{9A4C4253-55EA-4218-9FE0-9E473562A096}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetDocumentFromObject.tests", "tests\GetDocumentFromObject.tests\GetDocumentFromObject.tests.csproj", "{E3FBC284-4903-491E-9665-DD34D1A0D5B0}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{91A98655-F383-438E-A3DA-2D41BB1A59C7}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {DE9044A0-4809-4828-ADEE-FA787925CBCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {DE9044A0-4809-4828-ADEE-FA787925CBCF}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {DE9044A0-4809-4828-ADEE-FA787925CBCF}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {DE9044A0-4809-4828-ADEE-FA787925CBCF}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {9A4C4253-55EA-4218-9FE0-9E473562A096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {9A4C4253-55EA-4218-9FE0-9E473562A096}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {9A4C4253-55EA-4218-9FE0-9E473562A096}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {E3FBC284-4903-491E-9665-DD34D1A0D5B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {E3FBC284-4903-491E-9665-DD34D1A0D5B0}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {91A98655-F383-438E-A3DA-2D41BB1A59C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {91A98655-F383-438E-A3DA-2D41BB1A59C7}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(ExtensibilityGlobals) = postSolution 36 | SolutionGuid = {D0142C3F-8FC5-4CCE-8CD9-BBE7789B1A82} 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 InventorCode 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # InventorShims 2 | 3 | ## About 4 | 5 | This is an unofficial collection of extension APIs for Autodesk Inventor. The goal is to present developers and iLogic users with the following: 6 | 7 | * Code that promises to be routinely and consistently useful, 8 | * Additional API functionality that is not included in Inventor's public APIs, or 9 | * Improved functionality of stock API objects/methods. This may include: 10 | * simplified access to API objects, functions, and values, 11 | * functions designed to reduce boilerplate code, 12 | * more advanced management of API objects, and 13 | * better error handling outcomes. E.g. an example is an iproperty access method that will not throw an exception when a non-present property is accessed. 14 | 15 | The minimum supported version of Inventor will be 2020. 16 | 17 | ## Documentation 18 | 19 | Find the detailed API Documentation at [InventorShims API Docs](https://inventorcode.github.io/InventorShims/api/InventorShims.html). This documentation is built using DocFX; the documentation source is at [/docfx/](https://github.com/InventorCode/InventorShims/tree/master/docfx). 20 | 21 | For general documentation see the [Quick-Start Guide](https://inventorcode.github.io/InventorShims/articles/quick-start.html). 22 | 23 | ## Getting Started 24 | 25 | First off, you'll want to download or build a copy of the InventorShims.dll file. There are several options available: 26 | 27 | 1. Include the [InventorShims nuget package](https://www.nuget.org/packages/InventorShims/) in your .net project. 28 | 2. Visit the [Releases page](https://github.com/InventorCode/InventorShims/releases) and downld the compiled InventorShims.dll and referenceit in your Inventor iLogic or add-in code. This will allow you to access the entirety of the InventorShims API. 29 | 3. Clone this repo and building the dll yourself. 30 | 4. Copy out the methods, classes, or modules that are useful and including those in your own code. 31 | 5. Use the code in this package as reference material or examples. 32 | 33 | ## How to Use 34 | 35 | * For iLogic, add the following code in your iLogic rule header: 36 | 37 | ```VB 38 | AddReference "C:\Path\To\File\InventorShims.dll" 39 | Imports InventorShims 40 | 41 | 'Add your code here, include InventorShims API functions as you need... 42 | ``` 43 | * For add-in development, add the InventorShims.dll as a reference to your project. 44 | * Visit the [InventorShims API Documentation](https://inventorcode.github.io/InventorShims/) for a more detailed guide. 45 | 46 | ## License 47 | 48 | This code is under an MIT license. 49 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | :; set -eo pipefail 2 | :; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) 3 | :; ${SCRIPT_DIR}/build.sh "$@" 4 | :; exit $? 5 | 6 | @ECHO OFF 7 | powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* 8 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param( 3 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 4 | [string[]]$BuildArguments 5 | ) 6 | 7 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" 8 | 9 | Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } 10 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 11 | 12 | ########################################################################### 13 | # CONFIGURATION 14 | ########################################################################### 15 | 16 | $BuildProjectFile = "$PSScriptRoot\build\_build.csproj" 17 | $TempDirectory = "$PSScriptRoot\\.nuke\temp" 18 | 19 | $DotNetGlobalFile = "$PSScriptRoot\\global.json" 20 | $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" 21 | $DotNetChannel = "Current" 22 | 23 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 24 | $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 25 | $env:DOTNET_MULTILEVEL_LOOKUP = 0 26 | 27 | ########################################################################### 28 | # EXECUTION 29 | ########################################################################### 30 | 31 | function ExecSafe([scriptblock] $cmd) { 32 | & $cmd 33 | if ($LASTEXITCODE) { exit $LASTEXITCODE } 34 | } 35 | 36 | # If dotnet CLI is installed globally and it matches requested version, use for execution 37 | if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` 38 | $(dotnet --version) -and $LASTEXITCODE -eq 0) { 39 | $env:DOTNET_EXE = (Get-Command "dotnet").Path 40 | } 41 | else { 42 | # Download install script 43 | $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" 44 | New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null 45 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 46 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) 47 | 48 | # If global.json exists, load expected version 49 | if (Test-Path $DotNetGlobalFile) { 50 | $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) 51 | if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { 52 | $DotNetVersion = $DotNetGlobal.sdk.version 53 | } 54 | } 55 | 56 | # Install by channel or version 57 | $DotNetDirectory = "$TempDirectory\dotnet-win" 58 | if (!(Test-Path variable:DotNetVersion)) { 59 | ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } 60 | } else { 61 | ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } 62 | } 63 | $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" 64 | } 65 | 66 | Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" 67 | 68 | ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } 69 | ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } 70 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bash --version 2>&1 | head -n 1 4 | 5 | set -eo pipefail 6 | SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) 7 | 8 | ########################################################################### 9 | # CONFIGURATION 10 | ########################################################################### 11 | 12 | BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" 13 | TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" 14 | 15 | DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" 16 | DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" 17 | DOTNET_CHANNEL="Current" 18 | 19 | export DOTNET_CLI_TELEMETRY_OPTOUT=1 20 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 21 | export DOTNET_MULTILEVEL_LOOKUP=0 22 | 23 | ########################################################################### 24 | # EXECUTION 25 | ########################################################################### 26 | 27 | function FirstJsonValue { 28 | perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" 29 | } 30 | 31 | # If dotnet CLI is installed globally and it matches requested version, use for execution 32 | if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then 33 | export DOTNET_EXE="$(command -v dotnet)" 34 | else 35 | # Download install script 36 | DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" 37 | mkdir -p "$TEMP_DIRECTORY" 38 | curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" 39 | chmod +x "$DOTNET_INSTALL_FILE" 40 | 41 | # If global.json exists, load expected version 42 | if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then 43 | DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") 44 | if [[ "$DOTNET_VERSION" == "" ]]; then 45 | unset DOTNET_VERSION 46 | fi 47 | fi 48 | 49 | # Install by channel or version 50 | DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" 51 | if [[ -z ${DOTNET_VERSION+x} ]]; then 52 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path 53 | else 54 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path 55 | fi 56 | export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" 57 | fi 58 | 59 | echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" 60 | 61 | "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet 62 | "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" 63 | -------------------------------------------------------------------------------- /build/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | dotnet_style_qualification_for_field = false:warning 3 | dotnet_style_qualification_for_property = false:warning 4 | dotnet_style_qualification_for_method = false:warning 5 | dotnet_style_qualification_for_event = false:warning 6 | dotnet_style_require_accessibility_modifiers = never:warning 7 | 8 | csharp_style_expression_bodied_methods = true:silent 9 | csharp_style_expression_bodied_properties = true:warning 10 | csharp_style_expression_bodied_indexers = true:warning 11 | csharp_style_expression_bodied_accessors = true:warning 12 | -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /build/Configuration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using Nuke.Common.Tooling; 5 | 6 | [TypeConverter(typeof(TypeConverter))] 7 | public class Configuration : Enumeration 8 | { 9 | public static Configuration Debug = new Configuration { Value = nameof(Debug) }; 10 | public static Configuration Release = new Configuration { Value = nameof(Release) }; 11 | 12 | public static implicit operator string(Configuration configuration) 13 | { 14 | return configuration.Value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /build/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "_build": { 4 | "commandName": "Project", 5 | "commandLineArgs": "push" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /build/_build.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | CS0649;CS0169 8 | .. 9 | .. 10 | 1 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /build/_build.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | DO_NOT_SHOW 3 | DO_NOT_SHOW 4 | DO_NOT_SHOW 5 | DO_NOT_SHOW 6 | Implicit 7 | Implicit 8 | ExpressionBody 9 | 0 10 | NEXT_LINE 11 | True 12 | False 13 | 120 14 | IF_OWNER_IS_SINGLE_LINE 15 | WRAP_IF_LONG 16 | False 17 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 18 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> 19 | True 20 | True 21 | True 22 | True 23 | True 24 | True 25 | True 26 | True 27 | -------------------------------------------------------------------------------- /build/build-docs-serve.bat: -------------------------------------------------------------------------------- 1 | REM Requires docfx installed to work... 2 | 3 | docfx ../docfx/docfx.json --force -t default,../docfx/templates/inventor-shims --serve -------------------------------------------------------------------------------- /build/build-docs.bat: -------------------------------------------------------------------------------- 1 | REM Requires docfx installed to work... 2 | 3 | docfx ../docfx/docfx.json --force -t default,../docfx/templates/inventor-shims 4 | PowerShell.exe -Command "& './replace-code-tags.ps1'" -------------------------------------------------------------------------------- /build/replace-code-tags.ps1: -------------------------------------------------------------------------------- 1 | #Convert html tags... 2 | $projectRoot = (get-item $PSScriptRoot ).parent.FullName 3 | $docsFiles = Get-ChildItem "$projectRoot\docs\" *.html -rec 4 | foreach ($file in $docsFiles) 5 | { 6 | (Get-Content $file.PSPath) | 7 | Foreach-Object { $_ -replace "
", "
" } | 8 | Set-Content $file.PSPath 9 | } -------------------------------------------------------------------------------- /docfx/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /docfx/api/index.md: -------------------------------------------------------------------------------- 1 | # PLACEHOLDER 2 | TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! 3 | -------------------------------------------------------------------------------- /docfx/articles/Contributing.md: -------------------------------------------------------------------------------- 1 | ### Contributions 2 | 3 | Contributions of any type are welcome! If you want to help... 4 | 5 | * Please drop into [issues](https://github.com/InventorCode/InventorShims/issues) and see if there are any outstanding ones that you would like to tackle. 6 | * Add any issues you want and we can discuss. 7 | * Fork the code and add some functionality! 8 | 9 | If you want to contribute, the process proceeds as follows: 10 | 11 | 1. fork the repo 12 | 2. create a new feature branch in your forked repo 13 | 3. make changes 14 | 4. commit your work 15 | 5. then issue a pull request back to this repo (upstream) for a code review. 16 | 17 | 18 | ### Branch Guidance 19 | 20 | *Master* will be the main repository branch; this branch will contain the most up-to-date code. All short-lived branches will be merged back into *Master* after a code review by repo maintainers. 21 | 22 | The following branch names are suggested for short-lived branches... 23 | 24 | * feature/xx 25 | * bugfix/xx 26 | * issue/xx 27 | * username/xx 28 | 29 | ### Dependencies for Build 30 | 31 | * Visual Studio Compatible IDE 32 | * .Net 4.7 (for Inventor 2020 support) 33 | * Inventor 2021 SDK installation (minimum) 34 | 35 | ### Build 36 | 37 | Builds may be run by opening powershell or cmd in the repo folder and entering the following commands: 38 | 39 | * `Nuke`, or 40 | * `Nuke compile` 41 | 42 | ### Version Numbers 43 | 44 | Versioning will follow [Sematic Versioning](https://semver.org/) once version 1.0.0 is released. The version numbers will follow the format `MAJOR.MINOR.PATCH` where: 45 | 46 | * MAJOR - incompatible API changes 47 | * MINOR - added functionality in a backwards compatible manner 48 | * PATCH - backwards compatible bug fixes 49 | 50 | ### Commit Guidelines 51 | 52 | [Conventional Commits](https://www.conventionalcommits.org/en) will be used as the commit message guidelines. Following these simple guidelines will ensure commit message consistency that simplifies changelog generation and version number management. Contributors are encouraged to visit the page and read the tutorial and spec. Pull requests are expected to follow this convention. 53 | 54 | A simple, breezy tutorial follows... commit messages should be in the form "KEYWORD: message". Commit may have multiple lines. Try to keep each commit to a single keyword. This keyword is one of the following: 55 | 56 | - build 57 | - chore 58 | - ci 59 | - docs 60 | - feat 61 | - fix 62 | - refactor 63 | - revert 64 | - style 65 | - test 66 | 67 | Breaking changes in the codebase are denoted by an exclamation mark after a keyword, such as: 68 | 69 | - feat! 70 | - fix! 71 | - etc... 72 | 73 | A footer ```BREAKING CHANGE:``` should also be included in the commit message for human readability, but is not strictly required. 74 | 75 | ### License 76 | 77 | This code is under an MIT license. -------------------------------------------------------------------------------- /docfx/articles/changelog.md: -------------------------------------------------------------------------------- 1 | ## [2.0.0](https://github.com/InventorCode/InventorShims/releases/tag/v2.0.0) (2022-01-??) 2 | 3 | ### Added 4 | 5 | - PropertyShim extension methods now work on the following document types: 6 | - PartDocument 7 | - AssemblyDocument 8 | - DrawingDocument 9 | - PresentationDocument 10 | 11 | - ParameterShim extension methods now work with the following document types: 12 | - PartDocument 13 | - AssemblyDocument 14 | - DrawingDocument 15 | - Ilogic code samples for some of the added extension methods. 16 | - Extension methods for use with LINQ and fluent design. 17 | 18 | #### New general extension methods: 19 | 20 | |extension method|on object|returns| 21 | |---|---|---| 22 | |IsContentCenter|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|bool| 23 | |IsCustomContentCenter|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|bool| 24 | 25 | #### New IEnumerable Providers 26 | 27 | |extension method|on object|returns| 28 | |---|---|---| 29 | |EnumerateDocuments|SelectSet|IEnumerable\| 30 | |EnumerateDocuments|IEnumerable\|IEnumerable\| 31 | |EnumerateAllReferencedDocuments|Document|IEnumerable\| 32 | |EnumerateAllReferencedDocuments|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 33 | |EnumerateReferencedDocuments|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 34 | |EnumerateReferencingDocuments|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 35 | |EnumerateReferencedDocumentDescriptors|Document, PartDocument, AssemblyDocument, DrawingDocument, PresentationDocument|IEnumerable\| 36 | |EnumerateAllLeafOccurrencesDocumentDescriptors|AssemblyDocument|IEnumerable\| 37 | |EnumerateParameters|Document, PartDocument, AssemblyDocument, DrawingDocument|IEnumerable\| 38 | 39 | #### New IEnumerable Filters 40 | 41 | |extension method|on object|returns| 42 | |---|---|---| 43 | |AssemblyDocuments|IEnumerable\|IEnumerable\| 44 | |DrawingDocuments|IEnumerable\|IEnumerable\| 45 | |PresentationDocuments|IEnumerable\|IEnumerable\| 46 | |PartDocuments|IEnumerable\|IEnumerable\| 47 | |RemoveAssemblyDocuments|IEnumerable\|IEnumerable\| 48 | |RemoveDrawingDocuments|IEnumerable\|IEnumerable\| 49 | |RemovePresentationDocuments|IEnumerable\|IEnumerable\| 50 | |RemovePartDocuments|IEnumerable\|IEnumerable\| 51 | |RemoveNonNativeDocuments|IEnumerable\|IEnumerable\| 52 | 53 | ### Changed 54 | - .Net Framework version bumped to 4.8 55 | ## [1.3.1](https://github.com/InventorCode/InventorShims/releases/tag/1.3.1) (2021-09-03) 56 | 57 | ### Added 58 | - ExternalRuleDirectories object now implements the IDisposable interface, allowing the using keyword. 59 | - ExternalRuleDirectories documentation. 60 | - Updated Nuke Build system. 61 | 62 | ### Changed 63 | - Integration test project "InventorShims.tests" now uses the NUnit test framework. 64 | - Refactored some duplicate tests into TestCases. 65 | - Refactored Inventor document creation routines to TestUtilities.cs. 66 | - Nuke build updated to Nuke 5.3.0 67 | - Nuget packages for build project updated. 68 | - Nuke build targets updated/created: 69 | - Nuke Compile 70 | - Nuke Pack 71 | - Nuke Push 72 | - Nuke BuildDocumentation 73 | - Nuke PublishGitHubRelease 74 | - InventorShims.manual tests changed to InventorShims.ilogic.tests. Removed VS project associated with this. 75 | 76 | ### Fixed 77 | - ExternalRuleDirectories.Add was not adding entires properly. 78 | - ExternalRuleDirectories.Remove was not removing entires properly. 79 | 80 | ### Removed 81 | - InventorShims-vb project has been removed. 82 | - Errant NewtonSoft.Json package reference 83 | 84 | ## [1.2.0](https://github.com/InventorCode/InventorShims/releases/tag/1.2.0) (2021-08-15) 85 | 86 | ### Added 87 | - ExternalRuleDirectories object allows you to manipulate the iLogic Addin's list of External Rules Directories in a more straightforward manner. 88 | 89 | ### Fixed 90 | - Added conventional commits keywords to gitversion configuration. 91 | 92 | 93 | ## [1.1.1](https://github.com/InventorCode/InventorShims/releases/tag/v1.1.1) (2021-02-11) 94 | 95 | ### Chore 96 | 97 | * remove ILMerge nuget package 98 | 99 | ### Docs 100 | 101 | * rebuild 102 | * remove InventorShims-vb 103 | 104 | 105 | ## [v1.1.0](https://github.com/InventorCode/InventorShims/releases/tag/v1.1.0) (2021-02-11) 106 | 107 | ### Chore 108 | 109 | * update nuget config, changelog, versions 110 | * add nuspec 111 | * add logo for nuget package 112 | * Removed InventorShims-vs from builds 113 | * renamed InventorShims-cs to InventorShims 114 | 115 | ### Docs 116 | 117 | * added initial changelog 118 | * removed reference to pre-release state. 119 | * Updated API docs link in readme 120 | * Added samples to ParameterShim, added more to the class description. 121 | * Added ParameterShim and PathShim samples. 122 | 123 | ### Feat 124 | 125 | * added git-chglog config 126 | * ParameterIsWritable string signature added 127 | * ParameterIsWritable now acts as an extension method 128 | 129 | ### Style 130 | 131 | * remove whitespace 132 | 133 | ### Test 134 | 135 | * Added ParameterIsWritable unit tests. 136 | 137 | ## [v1.0.0](https://github.com/InventorCode/InventorShims/releases/tag/v1.0.0) (2021-01-17) 138 | 139 | ### Build 140 | 141 | * v1.0.0 142 | 143 | ### Docs 144 | 145 | * new build 146 | * Added Conventional Commits as the commit format guideline. 147 | * added --force to docfx rebuild. Added new template reference for icons 148 | * added logo and favicon 149 | * rebuilt with manual fix for "view source" error 150 | * Added an ilogic rule sample 151 | * tentative fix for "View Source" in docfx not working. 152 | 153 | ### Feat 154 | 155 | * AttributeShim methods are now extension methods. 156 | 157 | ### Fix 158 | 159 | * fixed typoe in sample. Added commented out msgbox call. 160 | * GetDocumentFromObject for kDrawingDurveSegmentObject 161 | 162 | ### Refactor 163 | 164 | * added error handling to SaveSilently() method 165 | * PathShim moved to C# 166 | * added todo for ittermittent bug in test 167 | 168 | ### Test 169 | 170 | * Added debug statements to GetDocumentsFromSelectSet() 171 | * GetDocumentFromObject.tests updated 172 | * ApplicationShim tests now wait for Inventor processes to finish. 173 | 174 | ### Tests 175 | 176 | * modified for newest PathShim.cs 177 | 178 | ## [v0.1.0](https://github.com/InventorCode/InventorShims/releases/tag/v0.1.0) (2020-12-25) 179 | 180 | -------------------------------------------------------------------------------- /docfx/articles/quick-start.md: -------------------------------------------------------------------------------- 1 | ### Getting Started 2 | 3 | First off, you'll want to get or build a copy of the InventorShims.dll file, or (or advanced users) extract whatever source code you want. There are several ways to do this: 4 | 5 | 1. The simplest method is to visit the [Releases page](https://github.com/InventorCode/InventorShims/releases), and download the compiled InventorShims.dll file to your computer and reference it in your Inventor iLogic or add-in code. This will allow you to access the entirety of the InventorShims API. 6 | 2. By cloning this repo and building the dll yourself. 7 | 3. By installing the (forthcoming) nuget package for use in Visual Studio. 8 | 4. By copying out the methods, classes, or modules that are useful and including those in your own vb or C# code-base. 9 | 5. By using the code in this package as reference material and examples to build your own solution. 10 | 11 | 12 | ### How to Use in iLogic 13 | 14 | We'll look at the most simple (#1) method below, coding in iLogic. 15 | 16 | - Place the InventorShims.dll somewhere your Inventor application can access it. You may need to add this location to Inventor's External Rules Directory. 17 | - Place the following in your iLogic rule's header: 18 | 19 | ```VB 20 | AddReference "InventorShims.dll" 21 | Imports InventorShims 22 | ``` 23 | 24 | - If the path to the InventorShims.dll is not in one of Inventor's external rules directories, you can still reference it by providing the full path to the dll file... 25 | 26 | ```VB 27 | AddReference "C:\Path\To\The\InventorShims.dll" 28 | Imports InventorShims 29 | ``` 30 | 31 | - And that's it! Now you can access the API from your iLogic code. Call functions such as: 32 | 33 | ```VB 34 | PathShim.IsLibraryPath("C:\This\Is\A\Test", ThisApplication) 35 | ``` 36 | 37 | - View the documentation pages for the API. You can include just a portion of the API at a time if you want. For example, if you want to add an include to the iProperty set of functions, your include statement would look like `Imports InventorShims.iProperty` 38 | 39 | 40 | * For add-in development, add the InventorShims.dll as a reference to your project. 41 | * Visit the [InventorShims API Documentation](https://inventorcode.github.io/InventorShims/) for a more detailed guide. 42 | -------------------------------------------------------------------------------- /docfx/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Quick Start Guide 2 | href: quick-start.md 3 | - name: Contribution Guidelines 4 | href: Contributing.md 5 | - name: Changelog 6 | href: changelog.md 7 | -------------------------------------------------------------------------------- /docfx/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "InventorShims/**.csproj" 8 | ], 9 | "src": "../src" 10 | } 11 | ], 12 | "dest": "api", 13 | "disableGitFeatures": false, 14 | "disableDefaultFilter": false 15 | } 16 | ], 17 | "build": { 18 | "content": [ 19 | { 20 | "files": [ 21 | "api/**.yml", 22 | "api/index.md" 23 | ] 24 | }, 25 | { 26 | "files": [ 27 | "articles/**.md", 28 | "articles/**/toc.yml", 29 | "toc.yml", 30 | "*.md" 31 | ] 32 | } 33 | ], 34 | "resource": [ 35 | { 36 | "files": [ 37 | "images/**" 38 | ] 39 | } 40 | ], 41 | "overwrite": [ 42 | { 43 | "files": [ 44 | "apidoc/**.md" 45 | ], 46 | "exclude": [ 47 | "obj/**", 48 | "_site/**" 49 | ] 50 | } 51 | ], 52 | "dest": "../docs", 53 | "globalMetadataFiles": [], 54 | "fileMetadataFiles": [], 55 | "template": [ 56 | "default", 57 | "inventor-shims" 58 | ], 59 | "postProcessors": [], 60 | "markdownEngineName": "markdig", 61 | "noLangKeyword": false, 62 | "keepFileLink": false, 63 | "cleanupCacheHistory": true, 64 | "disableGitFeatures": false, 65 | "globalMetadata": { 66 | "_appTitle": "InventorShims Documentation", 67 | "_gitContribute": { 68 | "repo": "https://github.com/InventorCode/InventorShims.git", 69 | "branch": "master", 70 | "apiSpecFolder": "docs-ref-overwrite" 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /docfx/index.md: -------------------------------------------------------------------------------- 1 | # InventorShims Documentation 2 | 3 | ### About 4 | 5 | InventorShims is an unofficial collection of extension APIs for Autodesk Inventor. In case you've zoomed by the project page, you can find it here: [InventorShims](https://github.com/InventorCode/InventorShims). 6 | 7 | The following are the stated goals of this API, and will be used to determine what is included in the code-base: 8 | 9 | * Functionality that promises to be routinely and consistently useful, 10 | * Additional API functionality that is not included in Inventor's public APIs, or 11 | * Improved functionality of stock API objects/methods. This may include: 12 | * simplified access to API objects, functions, and values, 13 | * functions designed to reduce boilerplate code, 14 | * improved management of stock API objects or behavior, or 15 | * better error handling outcomes (fail gracefully). 16 | 17 | The minimum supported version of Inventor will be 2020. 18 | 19 | ### Get Started 20 | 21 | You can visit the other docs on this site to learn more about the API, how to use it, and how to report issues and bugs. To get started immediately, visit the [Quick Start](articles/quick-start.md) page to learn how start using InventorShims in just a few minutes. 22 | 23 | ### Download 24 | 25 | Visit the [releases page](https://github.com/InventorCode/InventorShims/releases) and download the latest InventorShims release. 26 | 27 | ### How to Install 28 | 29 | There are a variety of ways to make use of this API library. The simplest is to download the dll and load it in iLogic by including the following in your iLogic rule's header... 30 | 31 | AddReference "InventorShims.dll" 32 | Imports InventorShims 33 | 34 | Visit the [Quick-Start](articles/quick-start.md) guide for some more in-depth code samples and information on how to get started. -------------------------------------------------------------------------------- /docfx/templates/inventor-shims/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docfx/templates/inventor-shims/favicon.ico -------------------------------------------------------------------------------- /docfx/templates/inventor-shims/logo.svg: -------------------------------------------------------------------------------- 1 | InventorShims -------------------------------------------------------------------------------- /docfx/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Articles 2 | href: articles/ 3 | - name: Api Documentation 4 | href: api/ 5 | - name: Report An Issue 6 | href: https://github.com/InventorCode/InventorShims/issues/ 7 | -------------------------------------------------------------------------------- /docs/api/InventorShims.TranslatorShim.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Namespace InventorShims.TranslatorShim 9 | | InventorShims Documentation 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 | 29 | 52 | 53 | 60 |
61 | 120 | 121 |
122 |
123 | 132 |
133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /docs/api/InventorShims.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Namespace InventorShims 9 | | InventorShims Documentation 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 | 29 | 52 | 53 | 60 |
61 | 130 | 131 |
132 |
133 | 142 |
143 |
144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /docs/api/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | PLACEHOLDER | InventorShims Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 |
26 | 27 | 50 | 51 | 58 |
59 | 93 | 94 |
95 |
96 | 105 |
106 |
107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /docs/api/toc.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 | 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 | 81 |
82 |
83 |
84 |
85 | -------------------------------------------------------------------------------- /docs/articles/quick-start.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Getting Started | InventorShims Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 |
26 | 27 | 50 | 51 | 58 |
59 | 126 | 127 |
128 |
129 | 138 |
139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /docs/articles/toc.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 | 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 | 25 |
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docs/favicon.ico -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docs/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docs/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docs/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docs/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | InventorShims Documentation | InventorShims Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 |
26 | 27 | 50 | 51 | 58 |
59 | 111 | 112 |
113 |
114 | 123 |
124 |
125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/logo.svg: -------------------------------------------------------------------------------- 1 | InventorShims -------------------------------------------------------------------------------- /docs/search-stopwords.json: -------------------------------------------------------------------------------- 1 | [ 2 | "a", 3 | "able", 4 | "about", 5 | "across", 6 | "after", 7 | "all", 8 | "almost", 9 | "also", 10 | "am", 11 | "among", 12 | "an", 13 | "and", 14 | "any", 15 | "are", 16 | "as", 17 | "at", 18 | "be", 19 | "because", 20 | "been", 21 | "but", 22 | "by", 23 | "can", 24 | "cannot", 25 | "could", 26 | "dear", 27 | "did", 28 | "do", 29 | "does", 30 | "either", 31 | "else", 32 | "ever", 33 | "every", 34 | "for", 35 | "from", 36 | "get", 37 | "got", 38 | "had", 39 | "has", 40 | "have", 41 | "he", 42 | "her", 43 | "hers", 44 | "him", 45 | "his", 46 | "how", 47 | "however", 48 | "i", 49 | "if", 50 | "in", 51 | "into", 52 | "is", 53 | "it", 54 | "its", 55 | "just", 56 | "least", 57 | "let", 58 | "like", 59 | "likely", 60 | "may", 61 | "me", 62 | "might", 63 | "most", 64 | "must", 65 | "my", 66 | "neither", 67 | "no", 68 | "nor", 69 | "not", 70 | "of", 71 | "off", 72 | "often", 73 | "on", 74 | "only", 75 | "or", 76 | "other", 77 | "our", 78 | "own", 79 | "rather", 80 | "said", 81 | "say", 82 | "says", 83 | "she", 84 | "should", 85 | "since", 86 | "so", 87 | "some", 88 | "than", 89 | "that", 90 | "the", 91 | "their", 92 | "them", 93 | "then", 94 | "there", 95 | "these", 96 | "they", 97 | "this", 98 | "tis", 99 | "to", 100 | "too", 101 | "twas", 102 | "us", 103 | "wants", 104 | "was", 105 | "we", 106 | "were", 107 | "what", 108 | "when", 109 | "where", 110 | "which", 111 | "while", 112 | "who", 113 | "whom", 114 | "why", 115 | "will", 116 | "with", 117 | "would", 118 | "yet", 119 | "you", 120 | "your" 121 | ] 122 | -------------------------------------------------------------------------------- /docs/styles/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/docs/styles/main.css -------------------------------------------------------------------------------- /docs/styles/main.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information. 2 | -------------------------------------------------------------------------------- /docs/styles/search-worker.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | importScripts('lunr.min.js'); 3 | 4 | var lunrIndex; 5 | 6 | var stopWords = null; 7 | var searchData = {}; 8 | 9 | lunr.tokenizer.separator = /[\s\-\.\(\)]+/; 10 | 11 | var stopWordsRequest = new XMLHttpRequest(); 12 | stopWordsRequest.open('GET', '../search-stopwords.json'); 13 | stopWordsRequest.onload = function () { 14 | if (this.status != 200) { 15 | return; 16 | } 17 | stopWords = JSON.parse(this.responseText); 18 | buildIndex(); 19 | } 20 | stopWordsRequest.send(); 21 | 22 | var searchDataRequest = new XMLHttpRequest(); 23 | 24 | searchDataRequest.open('GET', '../index.json'); 25 | searchDataRequest.onload = function () { 26 | if (this.status != 200) { 27 | return; 28 | } 29 | searchData = JSON.parse(this.responseText); 30 | 31 | buildIndex(); 32 | 33 | postMessage({ e: 'index-ready' }); 34 | } 35 | searchDataRequest.send(); 36 | 37 | onmessage = function (oEvent) { 38 | var q = oEvent.data.q; 39 | var hits = lunrIndex.search(q); 40 | var results = []; 41 | hits.forEach(function (hit) { 42 | var item = searchData[hit.ref]; 43 | results.push({ 'href': item.href, 'title': item.title, 'keywords': item.keywords }); 44 | }); 45 | postMessage({ e: 'query-ready', q: q, d: results }); 46 | } 47 | 48 | function buildIndex() { 49 | if (stopWords !== null && !isEmpty(searchData)) { 50 | lunrIndex = lunr(function () { 51 | this.pipeline.remove(lunr.stopWordFilter); 52 | this.ref('href'); 53 | this.field('title', { boost: 50 }); 54 | this.field('keywords', { boost: 20 }); 55 | 56 | for (var prop in searchData) { 57 | if (searchData.hasOwnProperty(prop)) { 58 | this.add(searchData[prop]); 59 | } 60 | } 61 | 62 | var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords); 63 | lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter'); 64 | this.pipeline.add(docfxStopWordFilter); 65 | this.searchPipeline.add(docfxStopWordFilter); 66 | }); 67 | } 68 | } 69 | 70 | function isEmpty(obj) { 71 | if(!obj) return true; 72 | 73 | for (var prop in obj) { 74 | if (obj.hasOwnProperty(prop)) 75 | return false; 76 | } 77 | 78 | return true; 79 | } 80 | })(); 81 | -------------------------------------------------------------------------------- /docs/toc.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 | 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 | 25 |
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /images/InventorCode-brackets-logo-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/images/InventorCode-brackets-logo-64x64.png -------------------------------------------------------------------------------- /samples/IEnumerable-change-iprops-of-selected.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.DocumentShim 3 | Imports InventorShims.PropertyShim 4 | Imports System.Linq 5 | 6 | ' ################################################################# 7 | ' ### Change Selected Part iProps w/ IEnumerable collection ### 8 | ' ################################################################# 9 | ' 10 | ' Changes the value of selected component "Title" iproperties. Works in a drawing or assembly file. 11 | ' This sample showcases chained IEnumerable methods w/ a fluent syntax. 12 | 13 | Sub Main() 14 | 15 | Dim oApp As Inventor.Application = ThisApplication 16 | Dim oDoc As Document = ThisDoc.Document 17 | 18 | Dim oSSet As SelectSet = oApp.ActiveDocument.SelectSet 'get the current selection set 19 | 20 | 'if nothing is selected... select something! 21 | If oSSet.count = 0 Then 22 | oSSet.Select(oApp.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select thing(s)...")) 23 | End If 24 | 25 | 'if there are selected objects, enumerate through their associated documents and filter... 26 | oSSet.EnumerateDocuments() _ 27 | .Where(Function(d) d.IsAssembly()) _ 28 | .Where(Function(d) Not d.IsContentCenter()) _ 29 | .Where(Function(d) d.IsModifiable()) _ 30 | .Distinct() _ 31 | .ToList() _ 32 | .ForEach(Sub(d) SetPropertyValue(d, "Title", "Some Cool Title!")) 33 | 34 | End Sub -------------------------------------------------------------------------------- /samples/IEnumerable-change-parameter-of-all-referenced-docs.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.DocumentShim 3 | Imports InventorShims.ParameterShim 4 | Imports System.Linq 5 | 6 | ' ##################################################### 7 | ' ### Change All Referenced Document Parameters ### 8 | ' ##################################################### 9 | ' 10 | ' Changes the value of almost all referenced files' parameter "param1". 11 | ' This sample showcases chained IEnumerable methods w/ a fluent syntax. 12 | 13 | Sub Main() 14 | 15 | Dim oApp As Inventor.Application = ThisApplication 16 | Dim oDoc As Document = ThisDoc.Document 17 | 18 | 'enumerate through every referenced document in the current file and filter... 19 | oDoc.EnumerateAllReferencedDocuments() _ 20 | .RemoveNonNativeDocuments() _ 21 | .RemovePresentationDocuments() _ 22 | .Where(Function(d) d.IsModifiable) _ 23 | .ToList() _ 24 | .ForEach(Sub(d) SetParameterValue(d, "testing", "16", "cm", True)) 25 | 26 | End Sub 27 | -------------------------------------------------------------------------------- /samples/ParameterShim-samples.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.ParameterShim 3 | 4 | ' ################################# 5 | ' ### ParameterShim Samples ### 6 | ' ################################# 7 | ' 8 | 9 | Sub Main() 10 | 11 | Dim oDoc As Document = ThisDoc.Document 12 | 13 | 'If the parameter doesn't exist, it will be created... 14 | SetParameterValue(oDoc, "testing", "16", "cm") 15 | 16 | 'If the clobberFlag bool is set to true, an existing parameter will not be overritten... 17 | SetParameterValue(oDoc, "testing", "16", "cm", true) 18 | 19 | 'Create a boolean parameter 20 | SetParameterValue(oDoc, "booleanParam", true) 21 | 22 | 'Create a text parameter 23 | SetParameterValue(oDoc, "booleanParam", "A really cool string!") 24 | 25 | 26 | 'Get a parameters object 27 | Dim oParams As Parameters = GetParameters(oDoc) 28 | 29 | 'Get a parameter object 30 | Dim oParam As Parameter = GetParameter(oDoc, "testing") 31 | 32 | 'If this object does not exist, it will return null 33 | Dim oNullParam As Parameter = GetParameter(oDoc, "nonExistantParameter") 34 | If (oNullParam Is Nothing) Then 35 | 'will return true! 36 | End If 37 | 38 | 'Return the value 39 | Msgbox(GetParameterValue(oDoc, "testing")) 40 | 41 | 'Test if the parameter is writable by the user 42 | 43 | If ParameterIsWritable(oParam) Then 44 | 'will return true! 45 | End If 46 | 47 | 'Remove a parameter 48 | RemoveParameter(oDoc, "testing") 49 | 50 | 51 | End Sub 52 | -------------------------------------------------------------------------------- /samples/PathShim-samples.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.PathShim 3 | 4 | ' ############################ 5 | ' ### PathShim Samples ### 6 | ' ############################ 7 | ' 8 | 9 | Sub Main() 10 | 11 | 12 | 'Test if the string is a Content Center Path... 13 | If IsContentCenterPath("C:/Testing/", ThisApplication) Then 14 | 'do something 15 | End If 16 | 17 | 'Test if the string is a Library Path... 18 | If IsLibraryPath("C:/Testing/", ThisApplication) Then 19 | 'do something 20 | End If 21 | 22 | 'Trim the ending directory / or \ 23 | Dim test As String = TrimEndingDirectorySeperator("C:/Testing/Stuff/") 24 | 'returns "C:/Testing/Stuff" 25 | 26 | 'Trim the ending directory / or \ 27 | Dim test As String = UpOneLevel("C:/Testing/Stuff/") 28 | 'returns "C:/Testing/" 29 | 30 | End Sub -------------------------------------------------------------------------------- /samples/change-iprops-of-selected.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.DocumentShim 3 | Imports InventorShims.PropertyShim 4 | 5 | ' ####################################### 6 | ' ### Change Selected Part iProps ### 7 | ' ####################################### 8 | ' 9 | ' Changes the value of selected component "Title" iproperties. Works in a drawing or assembly file. 10 | ' This sample showcases the GetDocumentsFromSelectSet(), IsAssembly(), IsDrawing(), and SetPropertyValue() methods. 11 | 12 | Sub Main() 13 | 14 | Dim oApp As Inventor.Application = ThisApplication 15 | Dim oDoc As Document = ThisDoc.Document 16 | Dim documentList As List(of Inventor.Document) = new List(of Document) 17 | 18 | Select Case true 19 | 20 | Case oDoc.IsAssembly, oDoc.IsDrawing 21 | 'change the selected documents... 22 | 23 | Dim oSSet As SelectSet = oApp.ActiveDocument.SelectSet 'get the current selection set 24 | 25 | 'if nothing is selected... select something! 26 | If oSSet.count = 0 Then 27 | oSSet.Select(oApp.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select thing(s)...")) 28 | End If 29 | 30 | 'if there are selected objects, get their associated documents... 31 | documentList = GetDocumentsFromSelectSet(oSSet) 32 | 33 | For Each i In documentList 34 | ChangeIProperty(i) 35 | Next 36 | 37 | Case Else 38 | MsgBox ("This tool is not compatible with this type of file. Exiting...") 39 | Exit Sub 40 | 41 | End Select 42 | 43 | End Sub 44 | 45 | 46 | Sub ChangeIProperty(i) 47 | SetPropertyValue(i, "Title", "Some Cool Title!") 48 | 49 | 'Uncomment to show the part titles in messageboxes... 50 | 'MsgBox(GetPropertyValue(i, "Title")) 51 | End Sub 52 | -------------------------------------------------------------------------------- /src/InventorShims/ApplicationShim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Inventor; 4 | 5 | namespace InventorShims 6 | { 7 | /// 8 | /// A simple set of static methods to access the Inventor Application. 9 | /// 10 | public static class ApplicationShim 11 | { 12 | /// 13 | /// Gets an existing Inventor.Application instance, and creates a new instance if one cannot be retrieved. 14 | /// VB.net/iLogic example: Dim oApp As Application = ApplicationShim.Instance() 15 | /// 16 | /// 17 | /// C# example: Application app = ApplicationShim.Instance() 18 | /// 19 | /// Inventor.Application 20 | public static Inventor.Application Instance() 21 | { 22 | Inventor.Application app = null; 23 | 24 | try 25 | { 26 | return (Inventor.Application) Marshal.GetActiveObject("Inventor.Application"); 27 | } 28 | catch 29 | { 30 | // is inventor not visible/in interactive mode? 31 | } 32 | 33 | //perhaps inventor needs to be started... 34 | if (app == null) 35 | { 36 | try //to start inventor 37 | { 38 | Type appType = Type.GetTypeFromProgID("Inventor.Application"); 39 | app = (Inventor.Application)Activator.CreateInstance(appType); 40 | app.Visible = true; 41 | return app; 42 | } 43 | catch (Exception e2) 44 | { 45 | throw new SystemException("Unable to start Inventor. Error message: " + e2.Message, e2); 46 | } 47 | } 48 | 49 | return null; 50 | } 51 | 52 | /// 53 | /// Gets a current Inventor.Application instance. This will not create a new instance if one cannot be found. 54 | /// VB.net/iLogic example: Dim oApp As Application = ApplicationShim.CurrentInstance() 55 | /// 56 | /// 57 | /// C# example: Application app = ApplicationShim.CurrentInstance() 58 | /// 59 | /// Inventor.Application 60 | public static Inventor.Application CurrentInstance() 61 | { 62 | try 63 | { 64 | return (Inventor.Application)Marshal.GetActiveObject("Inventor.Application"); 65 | } 66 | catch (Exception e) 67 | { 68 | throw new SystemException("Unable to get Inventor instance. Error message: " + e.Message, e); 69 | } 70 | } 71 | 72 | /// 73 | /// Creates a new Inventor Application instance. 74 | /// 75 | /// An optional boolean value indicates the visibility of the new Inventor instance: true = visible. 76 | /// VB.net/iLogic example: Dim oApp As Application = ApplicationShim.NewInstance() 77 | /// 78 | /// C# example: Application app = ApplicationShim.NewInstance() 79 | /// 80 | /// Inventor.Application 81 | public static Inventor.Application NewInstance(bool visibility = true) 82 | { 83 | Inventor.Application app; 84 | 85 | try //to start inventor 86 | { 87 | Type appType = Type.GetTypeFromProgID("Inventor.Application"); 88 | app = (Inventor.Application)Activator.CreateInstance(appType); 89 | app.Visible = visibility; 90 | return app; 91 | } 92 | catch (Exception e2) 93 | { 94 | throw new SystemException("Unable to start Inventor. Error message: " + e2.Message, e2); 95 | } 96 | } 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /src/InventorShims/Conversions.cs: -------------------------------------------------------------------------------- 1 | namespace InventorShims 2 | { 3 | /// 4 | /// Conversions class handles easily converting numbers to useful things, like Inches > Centimeters, for example 5 | /// 6 | public static class Conversions 7 | { 8 | #region InchesTo 9 | /// 10 | /// Converts a (double) number from inches to centimeters. 11 | /// 12 | /// 13 | /// double 14 | public static double InchesToCentimeters(this double inputNum) 15 | { 16 | return inputNum * 2.54; 17 | } 18 | 19 | /// 20 | /// Converts an (integer) number from inches to centimeters. 21 | /// 22 | /// 23 | /// double 24 | public static double InchesToCentimeters(this int inputNum) 25 | { 26 | return inputNum * 2.54; 27 | } 28 | 29 | /// 30 | /// Converts a (double) number from inches to millimeters. 31 | /// 32 | /// double 33 | /// double 34 | public static double InchesToMillimeters(this double inputNum) 35 | { 36 | return InchesToCentimeters(inputNum) * 10; 37 | } 38 | 39 | /// 40 | /// Converts an (integer) number from inches to millimeters. 41 | /// 42 | /// integer 43 | /// double 44 | public static double InchesToMillimeters(this int inputNum) 45 | { 46 | return InchesToCentimeters(inputNum) * 10; 47 | } 48 | #endregion 49 | 50 | #region CentimetersTo 51 | /// 52 | /// Converts a (double) number from centimeters to inches. 53 | /// 54 | /// double 55 | /// double 56 | public static double CentimetersToInches(this double inputNum) 57 | { 58 | return inputNum / 2.54; 59 | } 60 | 61 | /// 62 | /// Converts an (integer) number from centimeters to inches. 63 | /// 64 | /// integer 65 | /// double 66 | public static double CentimetersToInches(this int inputNum) 67 | { 68 | return inputNum / 2.54; 69 | } 70 | 71 | /// 72 | /// Converts a (double) number from centimeters to millimeters. 73 | /// 74 | /// double 75 | /// double 76 | public static double CentimetersToMillimeters(this double inputNum) 77 | { 78 | return inputNum * 10; 79 | } 80 | 81 | /// 82 | /// Converts an (integer) number from centimeters to millimeters. 83 | /// 84 | /// integer 85 | /// double 86 | public static double CentimetersToMillimeters(this int inputNum) 87 | { 88 | return inputNum * 10; 89 | } 90 | #endregion 91 | 92 | #region MillimetersTo 93 | 94 | /// 95 | /// Converts a (double) number from millimeters to inches. 96 | /// 97 | /// double 98 | /// double 99 | public static double MillimetersToInches(this double inputNum) 100 | { 101 | return inputNum * 2.54 * 10; 102 | } 103 | 104 | /// 105 | /// Converts an (integer) number from millimeters to inches. 106 | /// 107 | /// integer 108 | /// double 109 | public static double MillimetersToInches(this int inputNum) 110 | { 111 | return inputNum * 2.54 * 10; 112 | } 113 | 114 | /// 115 | /// Converts a (double) number from millimeters to centimeters. 116 | /// 117 | /// double 118 | /// double 119 | public static double MillimetersToCentimeters(this double inputNum) 120 | { 121 | return inputNum / 10; 122 | } 123 | 124 | /// 125 | /// Converts a (double) number from millimeters to centimeters. 126 | /// 127 | /// integer 128 | /// double 129 | public static double MillimetersToCentimeters(this int inputNum) 130 | { 131 | return inputNum / 10; 132 | } 133 | #endregion 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/InventorShims/DrawingViewShim.vb: -------------------------------------------------------------------------------- 1 | Imports Inventor 2 | 3 | Public Class DrawingViewShim 4 | 5 | Public View As Inventor.DrawingView 6 | 7 | Public Sub New(view As Inventor.DrawingView) 8 | view = view 9 | End Sub 10 | 11 | 'TODO: make these set as well as get? 12 | Public Function UpperLeft() As Inventor.Point2d 13 | Dim transientGeometry As Inventor.TransientGeometry = ThisApplication.TransientGeometry 14 | 15 | Dim x As Double = View.Left 16 | Dim y As Double = View.Top 17 | Dim point As Inventor.Point2d = transientGeometry.CreatePoint2d(x, y) 18 | Return point 19 | 20 | End Function 21 | 22 | Public Function UpperRight() As Inventor.Point2d 23 | Dim transientGeometry As Inventor.TransientGeometry = ThisApplication.TransientGeometry 24 | 25 | Dim x As Double = View.Left + View.Width 26 | Dim y As Double = View.Top 27 | Dim point As Inventor.Point2d = transientGeometry.CreatePoint2d(x, y) 28 | Return point 29 | 30 | End Function 31 | 32 | Public Function LowerLeft() As Inventor.Point2d 33 | Dim transientGeometry As Inventor.TransientGeometry = ThisApplication.TransientGeometry 34 | 35 | Dim x As Double = View.Left 36 | Dim y As Double = View.Top + View.Height 37 | Dim point As Inventor.Point2d = transientGeometry.CreatePoint2d(x, y) 38 | Return point 39 | 40 | End Function 41 | Public Function LowerRight() As Inventor.Point2d 42 | Dim transientGeometry As Inventor.TransientGeometry = ThisApplication.TransientGeometry 43 | 44 | Dim x As Double = View.Left + View.Width 45 | Dim y As Double = View.Top + View.Height 46 | Dim point As Inventor.Point2d = transientGeometry.CreatePoint2d(x, y) 47 | Return point 48 | End Function 49 | 50 | 51 | 52 | End Class 53 | -------------------------------------------------------------------------------- /src/InventorShims/ExternalRuleDirectories.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace InventorShims 7 | { 8 | /// 9 | /// A class that allows for simpler manipulation of the iLogic Addin's list of External Rule Directories. 10 | /// 11 | public class ExternalRuleDirectories : IDisposable 12 | { 13 | private bool disposedValue; 14 | private Inventor.Application _app; 15 | private dynamic iLogicAddIn { get; set; } 16 | private dynamic iLogicAuto { get; set; } 17 | 18 | /// 19 | /// Constructor that creates an ExternalRuleDirectories object. 20 | /// 21 | public ExternalRuleDirectories() 22 | { 23 | _app = ApplicationShim.Instance(); 24 | Initialize(_app); 25 | } 26 | 27 | /// 28 | /// Constructor that creates an ExternalRuleDirectories object. 29 | /// 30 | /// Takes an Inventor.Application object. 31 | public ExternalRuleDirectories(Inventor.Application local_app) 32 | { 33 | _app = local_app; 34 | Initialize(_app); 35 | } 36 | 37 | private void Initialize(Inventor.Application _app) 38 | { 39 | ApplicationAddIns appAddIns = _app.ApplicationAddIns; 40 | ApplicationAddIn iLogicAddIn = appAddIns.ItemById["{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}"]; 41 | 42 | if (iLogicAddIn == null) 43 | throw new SystemException("The iLogic add-in could not be found by ID {3bdd8d79-2179-4b11-8a5a-257b1c0263ac}."); 44 | 45 | try 46 | { 47 | iLogicAddIn.Activate(); 48 | iLogicAuto = iLogicAddIn.Automation; 49 | } 50 | catch (Exception e) 51 | { 52 | throw new SystemException("The iLogic add-in could not be accessed.", e); 53 | } 54 | } 55 | 56 | private List _directories = new List { }; 57 | /// 58 | /// Access the iLogic External Rule Directories as a List of strings. 59 | /// 60 | public List Directories 61 | { 62 | get 63 | { 64 | string[] dirs = iLogicAuto.FileOptions.ExternalRuleDirectories(); 65 | List dirList = new List { }; 66 | foreach (string i in dirs) 67 | { 68 | dirList.Add(i); 69 | } 70 | return dirList; 71 | } 72 | set 73 | { 74 | iLogicAuto.FileOptions.ExternalRuleDirectories = value.ToArray(); 75 | } 76 | } 77 | 78 | /// 79 | /// Adds a directory to the iLogic Addin's list of External Rule Directories. Does not 80 | /// add the directory if it already exists in the list. 81 | /// 82 | /// Directory to add 83 | public void Add(string directory) 84 | { 85 | if (!Directories.Contains(directory)) 86 | { 87 | var _directories = Directories; 88 | _directories.Add(directory); 89 | Directories = _directories; 90 | } 91 | 92 | Directories.Add(directory); 93 | } 94 | 95 | /// 96 | /// Removes a directory from the iLogic Addin's list of External Rule Directories. 97 | /// 98 | /// Directory to remove as a string. 99 | public void Remove(string directory) 100 | { 101 | var _directories = Directories; 102 | _directories.Remove(directory); 103 | Directories = _directories; 104 | } 105 | 106 | /// 107 | /// Determines whether a directory is in the iLogic Addin's list of External Rule Directories. 108 | /// 109 | /// 110 | /// Returns true if directory is found in the list. 111 | public bool Contains(string directory) 112 | { 113 | return Directories.Contains(directory); 114 | } 115 | 116 | /// 117 | /// Clears all entries from the iLogic Addin's list of External Rule Directories. 118 | /// 119 | public void Clear() 120 | { 121 | string[] temp = { }; 122 | iLogicAuto.FileOptions.ExternalRuleDirectories = temp; 123 | } 124 | 125 | /// 126 | /// Get the number of directories contained in ExternalRuleDirectories. 127 | /// 128 | public int Count { get => Directories.Count; } 129 | 130 | /// 131 | /// Dispose of the ExternalRuleDirectories object. 132 | /// 133 | /// 134 | protected virtual void Dispose(bool disposing) 135 | { 136 | if (!disposedValue) 137 | { 138 | if (disposing) 139 | { 140 | iLogicAddIn = null; 141 | // TODO: dispose managed state (managed objects) 142 | } 143 | 144 | // TODO: free unmanaged resources (unmanaged objects) and override finalizer 145 | Marshal.ReleaseComObject(iLogicAuto); 146 | Marshal.ReleaseComObject(_app); 147 | iLogicAuto = null; 148 | _app = null; 149 | 150 | // TODO: set large fields to null 151 | disposedValue = true; 152 | } 153 | } 154 | 155 | // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources 156 | /// 157 | /// Finalizer 158 | /// 159 | ~ExternalRuleDirectories() 160 | { 161 | // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method 162 | Dispose(disposing: false); 163 | } 164 | 165 | /// 166 | /// Manually dispose of the ExternalRuleDirectories object. 167 | /// 168 | public void Dispose() 169 | { 170 | // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method 171 | Dispose(disposing: true); 172 | GC.SuppressFinalize(this); 173 | } 174 | } 175 | } -------------------------------------------------------------------------------- /src/InventorShims/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | [assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "", Scope = "member", Target = "~F:InventorShims.TranslatorShim.StlResolutionEnum.Brep")] 9 | [assembly: SuppressMessage("Spellchecker", "CRRSP05:A misspelled word has been found", Justification = "", Scope = "member", Target = "~M:InventorShims.TranslatorShim.StepImporter.DoImport(System.Boolean,System.Boolean,System.Int32)~Inventor.Document")] 10 | -------------------------------------------------------------------------------- /src/InventorShims/InventorShims.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | InventorCode 6 | 1.2.1 7 | https://github.com/InventorCode/InventorShims 8 | MIT 9 | InventorCode-brackets-logo-64x64.png 10 | 11 | https://github.com/InventorCode/InventorShims 12 | Autodesk Inventor API 13 | A collection of extension APIs for Autodesk Inventor. 14 | Copyright 2021 15 | 16 | Changelog at https:=//github.com/InventorCode/InventorShims/blob/feat/fluentdocs/CHANGELOG.md 17 | 18 | 19 | 20 | 21 | TRACE 22 | ..\..\artifacts\Release\net47\InventorShims.xml 23 | ..\..\artifacts\Release 24 | 25 | 26 | 27 | ..\..\artifacts\Debug 28 | ..\..\artifacts\Debug\net47\InventorShims.xml 29 | 30 | 31 | 32 | 33 | True 34 | 35 | 36 | 37 | 38 | 39 | 40 | ..\..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/InventorShims/PathShim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Inventor; 3 | 4 | namespace InventorShims 5 | { 6 | /// 7 | /// A collection of static methods to manipulate and test string paths 8 | /// 9 | public static class PathShim 10 | { 11 | /// 12 | /// Provided a string directory path, returns the path with the last 13 | /// directory removed. E.g. UpOneLevel("C:\Work\Stuff\") returns "C:\Work" 14 | /// 15 | /// The path as a string 16 | /// A string 17 | public static string UpOneLevel(string path) 18 | { 19 | char delimiter; 20 | char DirectorySeparatorChar = System.IO.Path.DirectorySeparatorChar; 21 | char AltDirectorySeparatorChar = System.IO.Path.AltDirectorySeparatorChar; 22 | 23 | if (path.Contains(DirectorySeparatorChar.ToString())) 24 | { 25 | delimiter = DirectorySeparatorChar; 26 | } 27 | else if (path.Contains(AltDirectorySeparatorChar.ToString())) 28 | { 29 | delimiter = AltDirectorySeparatorChar; 30 | } 31 | else //no slashes? not a path... 32 | { 33 | return null; 34 | } 35 | 36 | //Catch paths which end with a delimiter, such as C:\Work\Stuff\ 37 | //Clean up so that they look like C:\Work\Stuff 38 | path = TrimEndingDirectorySeparator(path); 39 | 40 | int delimPosition = path.LastIndexOf(delimiter); 41 | if (delimPosition == 0) 42 | { 43 | return null; 44 | } 45 | else if (delimPosition < 0) 46 | { 47 | return path; 48 | } 49 | 50 | return path.Remove(delimPosition + 1); 51 | } 52 | 53 | /// 54 | /// Provided a string that ends in a "/" or "\", returns the string without those 55 | /// ending characters. 56 | /// 57 | /// string 58 | /// string 59 | public static string TrimEndingDirectorySeparator(string path) 60 | { 61 | char DirectorySeparatorChar = System.IO.Path.DirectorySeparatorChar; 62 | char AltDirectorySeparatorChar = System.IO.Path.AltDirectorySeparatorChar; 63 | 64 | if (path.EndsWith(DirectorySeparatorChar.ToString())) 65 | { 66 | path = path.Remove(path.LastIndexOf(DirectorySeparatorChar)); 67 | } 68 | else if (path.EndsWith(AltDirectorySeparatorChar.ToString())) 69 | { 70 | path = path.Remove(path.LastIndexOf(AltDirectorySeparatorChar)); 71 | } 72 | return path; 73 | } 74 | 75 | /// 76 | /// A function that checks if the provided string contains an Inventor library path. 77 | /// 78 | /// Path as a string. 79 | /// Inventor.Application object. 80 | /// 81 | public static bool IsLibraryPath(this string path, Application inventorApp) 82 | { 83 | if (String.IsNullOrEmpty(path)) return false; 84 | 85 | DesignProject designProject = inventorApp.DesignProjectManager.ActiveDesignProject; 86 | ProjectPaths libraryPaths = designProject.LibraryPaths; 87 | //ProjectPath libraryPath; 88 | 89 | foreach (ProjectPath libraryPath in libraryPaths) 90 | { 91 | if (path.Contains(TrimEndingDirectorySeparator(libraryPath.Path))) 92 | { 93 | return true; 94 | } 95 | } 96 | 97 | return false; 98 | } 99 | 100 | /// 101 | /// A function that checks if the provided string contains a Content Center Library path. 102 | /// 103 | /// Path as a string. 104 | /// Inventor.Application object. 105 | /// 106 | public static bool IsContentCenterPath(this string path, Application inventorApp) 107 | { 108 | if (String.IsNullOrEmpty(path)) return false; 109 | 110 | DesignProject designProject = inventorApp.DesignProjectManager.ActiveDesignProject; 111 | bool projectCCPathInUse = designProject.ContentCenterPathOverridden; 112 | string ccPath; 113 | 114 | if (projectCCPathInUse) 115 | { 116 | ccPath = designProject.ContentCenterPath; 117 | } else 118 | { 119 | ccPath = inventorApp.FileOptions.ContentCenterPath; 120 | } 121 | 122 | ccPath = TrimEndingDirectorySeparator(ccPath); 123 | 124 | if (path.Contains(ccPath)) return true; 125 | 126 | return false; 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /src/InventorShims/Research/ListIprops.vb: -------------------------------------------------------------------------------- 1 | Imports Inventor 2 | 3 | 'This can be run in Inventor's ilogic environment. it will list out the 4 | 'iproperties available in a file. 5 | 6 | Public Sub Main() 7 | Dim test As ListIprops = New ListIprops(ThisApplication) 8 | test.GetPropertySets 9 | ' test.GetInfo 10 | 11 | End Sub 12 | Public Class ListIprops 13 | 14 | Private _doc As Document 15 | Private _file As System.IO.StreamWriter 16 | Private ReadOnly _epoch As String = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().toString 17 | Private _path As String 18 | 19 | Sub New(app As Application) 20 | _doc = app.ActiveDocument 21 | Dim fullPath As String = _doc.FullFileName 22 | Dim directory As String = IO.Path.GetDirectoryName(fullPath) 23 | _path = directory & IO.Path.DirectorySeparatorChar & "IpropertyList " & _epoch & ".txt" 24 | 25 | End Sub 26 | 27 | Private Sub OpenFile 28 | _file = My.Computer.FileSystem.OpenTextFileWriter(_path, True) 29 | End Sub 30 | Private Sub WriteLine(value As String) 31 | _file.WriteLine(value) 32 | End Sub 33 | Private Sub CloseFile 34 | _file.Close() 35 | End Sub 36 | 37 | Sub GetPropertySets() 38 | 39 | OpenFile 40 | Dim propertySet As Inventor.PropertySet 41 | WriteLine("Qty of Property Sets: " & _doc.PropertySets.count) 42 | 43 | For Each propertySet In _doc.PropertySets 44 | WriteLine("") 45 | WriteLine(propertySet.Name + " / " + propertySet.InternalName) 46 | 47 | 48 | Dim prop As Inventor.Property 49 | For Each prop In propertySet 50 | WriteLine(prop.Name + " /" + Str(prop.PropId)) 51 | Next 52 | Next 53 | CloseFile 54 | End Sub 55 | 56 | Sub GetInfo() 57 | Dim propertySet As Inventor.PropertySet 58 | dim ids As Integer() = {} 59 | dim names As String() = {} 60 | Dim values As Object() = {} 61 | propertySet = _doc.PropertySets.Item("F29F85E0-4FF9-1068-AB91-08002B27B3D9") 62 | propertySet.GetPropertyInfo(ids,names,values) 63 | 64 | MsgBox(values(0)) 65 | End Sub 66 | 67 | End Class 68 | -------------------------------------------------------------------------------- /src/InventorShims/Research/Property Info.txt: -------------------------------------------------------------------------------- 1 | 'PropertySet info... 2 | 3 | 'Name: Inventor Summary Information 4 | 'ID: F29F85E0-4FF9-1068-AB91-08002B27B3D9 5 | 'Title / 2 6 | 'Subject / 3 7 | 'Author / 4 8 | 'Keywords / 5 9 | 'Comments / 6 10 | 'Last Saved By / 8 11 | 'Revision Number / 9 12 | 'Thumbnail / 17 13 | 14 | 'Name: Inventor Document Summary Information 15 | 'ID: D5CDD502-2E9C-101B-9397-08002B2CF9AE 16 | 'Category / 2 17 | 'Manager / 14 18 | 'Company / 15 19 | 20 | 'Name: Design Tracking Properties 21 | 'ID: 32853F0F-3444-11D1-9E93-0060B03C1CA6 22 | 'Creation Time / 4 23 | 'Part Number / 5 24 | 'Project / 7 25 | 'Cost Center / 9 26 | 'Checked By / 10 27 | 'Date Checked / 11 28 | 'Engr Approved By / 12 29 | 'Engr Date Approved / 13 30 | 'User Status / 17 31 | 'Material / 20 32 | 'Part Property Revision Id / 21 33 | 'Catalog Web Link / 23 34 | 'Part Icon / 28 35 | 'Description / 29 36 | 'Vendor / 30 37 | 'Document SubType / 31 38 | 'Document SubType Name / 32 39 | 'Proxy Refresh Date / 33 40 | 'Mfg Approved By / 34 41 | 'Mfg Date Approved / 35 42 | 'Cost / 36 43 | 'Standard / 37 44 | 'Design Status / 40 45 | 'Designer / 41 46 | 'Engineer / 42 47 | 'Authority / 43 48 | 'Parameterized Template / 44 49 | 'Template Row / 45 50 | 'External Property Revision Id / 46 51 | 'Standard Revision / 47 52 | 'Manufacturer / 48 53 | 'Standards Organization / 49 54 | 'Language / 50 55 | 'Defer Updates / 51 56 | 'Size Designation / 52 57 | 'Categories / 56 58 | 'Stock Number / 55 59 | 'Weld Material / 57 60 | 'Mass / 58 61 | 'SurfaceArea / 59 62 | 'Volume / 60 63 | 'Density / 61 64 | 'Valid MassProps / 62 65 | 'Flat Pattern Width / 63 66 | 'Flat Pattern Length / 64 67 | 'Flat Pattern Area / 65 68 | 'Sheet Metal Rule / 66 69 | 'Last Updated With / 67 70 | 'Sheet Metal Width / 68 71 | 'Sheet Metal Length / 69 72 | 'Sheet Metal Area / 70 73 | 'Material Identifier / 71 74 | 'Appearance / 72 75 | 'Flat Pattern Defer Update / 73 76 | 77 | 'Name: Inventor User Defined Properties 78 | 'ID: D5CDD505-2E9C-101B-9397-08002B2CF9AE -------------------------------------------------------------------------------- /src/InventorShims/StringShim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace InventorShims 4 | { 5 | /// 6 | /// String formatting methods 7 | /// 8 | public static class StringShim 9 | { 10 | /// 11 | /// Takes a double of inches and returns the string of a fraction equivalent. 12 | /// 13 | /// If you want to round to 1/8" of an inch, pass 8 as roundingAccuracy 14 | /// 15 | /// Supports up to 1/32 rounding accuracy, which would be passed in as 32 16 | /// 17 | /// 18 | /// 19 | /// 20 | public static string ToFractionStringRoundedUp(this double inputNum, int roundingAccuracy = 8) 21 | { 22 | var decimalRepresentationOfInchFraction = 1 / roundingAccuracy; 23 | 24 | // check if it's evenly divisible to the passed fractional 25 | if(inputNum % decimalRepresentationOfInchFraction != 0) 26 | { 27 | // Round up to next 1/8 if it's not already an even 1/8 28 | inputNum = Math.Ceiling(inputNum / decimalRepresentationOfInchFraction) * decimalRepresentationOfInchFraction; 29 | } 30 | 31 | string inputAsString = inputNum.ToString(); 32 | string fractionString = ""; 33 | 34 | // Figure out what the fraction should be 35 | if(inputAsString.Contains(".")) 36 | { 37 | // if we're not an integer 38 | if(inputAsString.EndsWith(".03125")) { fractionString = " 1/32"; } 39 | else if(inputAsString.EndsWith(".0625")) { fractionString = " 1/16"; } 40 | else if(inputAsString.EndsWith(".09375")) { fractionString = " 3/32"; } 41 | else if(inputAsString.EndsWith(".125")) { fractionString = " 1/8"; } 42 | else if(inputAsString.EndsWith(".15625")) { fractionString = " 5/32"; } 43 | else if(inputAsString.EndsWith(".1875")) { fractionString = " 3/16"; } 44 | else if(inputAsString.EndsWith(".21875")) { fractionString = " 7/32"; } 45 | else if(inputAsString.EndsWith(".25")) { fractionString = " 1/4"; } 46 | else if(inputAsString.EndsWith(".28125")) { fractionString = " 9/32"; } 47 | else if(inputAsString.EndsWith(".3125")) { fractionString = " 5/16"; } 48 | else if(inputAsString.EndsWith(".34375")) { fractionString = " 11/32"; } 49 | else if(inputAsString.EndsWith(".375")) { fractionString = " 3/8"; } 50 | else if(inputAsString.EndsWith(".40625")) { fractionString = " 13/32"; } 51 | else if(inputAsString.EndsWith(".4375")) { fractionString = " 7/16"; } 52 | else if(inputAsString.EndsWith(".46875")) { fractionString = " 15/32"; } 53 | else if(inputAsString.EndsWith(".5")) { fractionString = " 1/2"; } 54 | else if(inputAsString.EndsWith(".53125")) { fractionString = " 17/32"; } 55 | else if(inputAsString.EndsWith(".5625")) { fractionString = " 9/16"; } 56 | else if(inputAsString.EndsWith(".59375")) { fractionString = " 19/32"; } 57 | else if(inputAsString.EndsWith(".625")) { fractionString = " 5/8"; } 58 | else if(inputAsString.EndsWith(".65625")) { fractionString = " 21/32"; } 59 | else if(inputAsString.EndsWith(".6875")) { fractionString = " 11/16"; } 60 | else if(inputAsString.EndsWith(".71875")) { fractionString = " 23/32"; } 61 | else if(inputAsString.EndsWith(".75")) { fractionString = " 3/4"; } 62 | else if(inputAsString.EndsWith(".78125")) { fractionString = " 25/32"; } 63 | else if(inputAsString.EndsWith(".8125")) { fractionString = " 13/16"; } 64 | else if(inputAsString.EndsWith(".84375")) { fractionString = " 27/32"; } 65 | else if(inputAsString.EndsWith(".875")) { fractionString = " 7/8"; } 66 | else if(inputAsString.EndsWith(".90625")) { fractionString = " 29/32"; } 67 | else if(inputAsString.EndsWith(".9375")) { fractionString = " 15/16"; } 68 | else if(inputAsString.EndsWith(".96875")) { fractionString = " 31/32"; } 69 | else fractionString = inputAsString; 70 | } 71 | 72 | return ((int)inputNum).ToString() + fractionString; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/InventorShims/TranslatorShim/DwgExporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Inventor; 7 | 8 | namespace InventorShims.TranslatorShim 9 | { 10 | /// Exports a document to a DWG file 11 | public class DwgExporter 12 | { 13 | ///The document to be exported 14 | public Inventor.Document Document { get; set; } = null; 15 | 16 | /// ini file specifying the export configuration 17 | public string ConfigurationFile { get; set; } = ""; 18 | 19 | ///Initializes a new instance of with a custom export configuration file. 20 | public DwgExporter(Inventor.Document Document, string ConfigurationFile) 21 | { 22 | this.Document = Document; 23 | 24 | this.ConfigurationFile = ConfigurationFile; 25 | } 26 | 27 | ///Initializes a new instance of with the default export configuration. 28 | public DwgExporter(Inventor.Document Document) 29 | { 30 | this.Document = Document; 31 | } 32 | 33 | ///Export to DWG file with the same folder and filename as the document. 34 | public void Export() 35 | { 36 | Export(System.IO.Path.ChangeExtension(this.Document.FullFileName, "dwg")); 37 | } 38 | 39 | ///Export to DWG file with the specified full file path. 40 | public void Export(string OutputFile) 41 | { 42 | TranslatorData oTranslatorData = new TranslatorData(addinGUID: "{C24E3AC2-122E-11D5-8E91-0010B541CD80}", fullFileName: OutputFile, doc: this.Document); 43 | 44 | oTranslatorData.oOptions.Value["Export_Acad_IniFile"] = ConfigurationFile; 45 | 46 | //Create output directory if it does not exist 47 | System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(OutputFile)); 48 | 49 | TranslatorAddIn oTranslatorAddIn = (TranslatorAddIn)oTranslatorData.oAppAddIn; 50 | 51 | oTranslatorAddIn.SaveCopyAs(this.Document, oTranslatorData.oContext, oTranslatorData.oOptions, oTranslatorData.oDataMedium); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/InventorShims/TranslatorShim/StepExporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Inventor; 7 | 8 | namespace InventorShims.TranslatorShim 9 | { 10 | /// Exports a document to a STP file 11 | public class StepExporter 12 | { 13 | private Inventor.Document _document; 14 | 15 | ///The document to be exported 16 | public Inventor.Document Document 17 | { 18 | get {return _document;} 19 | 20 | set { 21 | _document = value; 22 | 23 | Description = (string)_document.GetPropertyValue("Description"); 24 | 25 | Organization = (string)_document.GetPropertyValue("Company"); 26 | } 27 | } 28 | 29 | /// Include 2d and 3d sketch lines and curves in the export. Does not include 2d or 3d sketch points. 30 | public bool IncludeSketches { get; set; } = false; 31 | 32 | /// 33 | ///The type of STEP file to be created: AP203 / AP214 / AP242. 34 | ///Defaults to AP214 for compatibility with other software. 35 | /// 36 | public StepProtocolEnum ApplicationProtocol { get; set; } = StepProtocolEnum.AP214; 37 | 38 | /// Defaults to the current username that is defined in Inventor's Application Options 39 | public string Author { get; set; } = ""; 40 | 41 | /// Defaults to the document's Company iProperty 42 | public string Organization { get; set; } = ""; 43 | 44 | /// Not set by default. From ISO 10303-21: The name/mailing address of the person who authorized this file. 45 | public string Authorization { get; set; } = ""; 46 | 47 | /// Defaults to the document's Description iProperty 48 | public string Description { get; set; } = ""; 49 | 50 | ///How far curves can deviate from their true value (also known as ExportFitTolerance). 51 | ///Accepted range of 0.00001 to 0.001 (centimeters) 52 | /// 53 | public float SplineFitAccuracy { get; set; } = .001f; 54 | 55 | ///Initializes a new instance of 56 | public StepExporter(Inventor.Document Document) 57 | { 58 | this.Document = Document; 59 | 60 | Application app = (Application)Document.Parent; 61 | 62 | Author = app.UserName; 63 | } 64 | 65 | ///Export to STP file with the same folder and filename as the document. 66 | public void Export() 67 | { 68 | Export(System.IO.Path.ChangeExtension(_document.FullFileName, "stp")); 69 | } 70 | 71 | ///Export to STP file with the specified full file path. 72 | public void Export(string OutputFile) 73 | { 74 | TranslatorData oTranslatorData = new TranslatorData(addinGUID: "{90AF7F40-0C01-11D5-8E83-0010B541CD80}", fullFileName: OutputFile, doc: _document); 75 | 76 | NameValueMap op = oTranslatorData.oOptions; 77 | 78 | op.Value["IncludeSketches"] = IncludeSketches; 79 | op.Value["ApplicationProtocolType"] = ApplicationProtocol; 80 | op.Value["Author"] = Author; 81 | op.Value["Organization"] = Organization; 82 | op.Value["Authorization"] = Authorization; 83 | op.Value["Description"] = Description; 84 | op.Value["export_fit_tolerance"] = SplineFitAccuracy; 85 | 86 | TranslatorAddIn oTranslatorAddIn = (TranslatorAddIn)oTranslatorData.oAppAddIn; 87 | 88 | oTranslatorAddIn.SaveCopyAs(this.Document, oTranslatorData.oContext, oTranslatorData.oOptions, oTranslatorData.oDataMedium); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/InventorShims/TranslatorShim/StepProtocolEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InventorShims.TranslatorShim 8 | { 9 | /// Wrapper for the ApplicationProtocolType that is used by the STEP export method. 10 | public enum StepProtocolEnum 11 | { 12 | /// Configuration Controlled Design 13 | AP203 = 2, 14 | 15 | /// Automotive Design 16 | AP214 = 3, 17 | 18 | /// 19 | /// Managed Model Based 3D Engineering
20 | /// (Includes PMI and meshes) 21 | ///
22 | AP242 = 5 23 | } 24 | } -------------------------------------------------------------------------------- /src/InventorShims/TranslatorShim/StlExporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Inventor; 7 | 8 | namespace InventorShims.TranslatorShim 9 | { 10 | /// Exports a document to a STL file 11 | public class StlExporter 12 | { 13 | ///The document to be exported 14 | public Inventor.Document Document { get; set; } = null; 15 | 16 | ///Defaults to mm. 17 | public ImportUnitsTypeEnum Units { get; set; } = ImportUnitsTypeEnum.kMillimeterUnitsType; 18 | 19 | /// 20 | /// Setting this to anything other than Custom will cause the exporter to ignore the following variables: 21 | /// , 22 | /// , 23 | /// , 24 | /// 25 | /// 26 | public StlResolutionEnum Resolution { get; set; } = StlResolutionEnum.Custom; 27 | 28 | /// 29 | /// 30 | /// 31 | public bool AllowMoveMeshNodes { get; set; } = false; 32 | 33 | 34 | ///backing variable for 35 | private double _surfaceDeviation = 0.005; 36 | 37 | /// Max distance between facet edges and surface edges (as a percentage of each body's RangeBox size). 38 | /// Modifying this value automatically changes to 39 | /// Valid values: 0 to 100 40 | /// 41 | public double SurfaceDeviation 42 | { 43 | get { return _surfaceDeviation; } 44 | 45 | set 46 | { 47 | _surfaceDeviation = value; 48 | 49 | Resolution = StlResolutionEnum.Custom; 50 | } 51 | } 52 | 53 | ///backing variable for 54 | private double _normalDeviation = 10.0; 55 | 56 | /// The max angle between adjacent face normals of approximated curves. 57 | /// Modifying this value automatically changes to 58 | /// Valid values: 0 to 41 59 | /// 60 | public double NormalDeviation 61 | { 62 | get { return _normalDeviation; } 63 | 64 | set 65 | { 66 | _normalDeviation = value; 67 | 68 | Resolution = StlResolutionEnum.Custom; 69 | } 70 | } 71 | 72 | ///backing variable for 73 | private double _maxEdgeLength = 0.0; 74 | 75 | /// Max distance between the grid lines that are placed on a face during the tessellation process (as a percentage of each body's RangeBox size). 76 | /// Modifying this value automatically changes to 77 | /// Valid Values: 0 to 100 (0 to disable) 78 | /// 79 | public double MaxEdgeLength 80 | { 81 | get { return _maxEdgeLength; } 82 | 83 | set 84 | { 85 | _maxEdgeLength = value; 86 | 87 | Resolution = StlResolutionEnum.Custom; 88 | } 89 | } 90 | 91 | ///backing variable for 92 | private double _maxAspectRatio = 0.0; 93 | 94 | /// Ratio between height and width of facets. 95 | /// Modifying this value automatically changes to 96 | /// Valid Values: 0 to 21.5 (0 to disable) 97 | /// 98 | public double MaxAspectRatio 99 | { 100 | get { return _maxAspectRatio; } 101 | 102 | set 103 | { 104 | _maxAspectRatio = value; 105 | 106 | Resolution = StlResolutionEnum.Custom; 107 | } 108 | } 109 | 110 | /// Determines whether an assembly is exported as one or multiple files. 111 | public bool OneFilePerPartInstance { get; set; } = false; 112 | 113 | /// Requires = true 114 | public bool ExportColors { get; set; } = true; 115 | 116 | /// 117 | /// Exported STL file will be binary instead of plaintext ASCII. 118 | /// Binary files have a smaller filesize, and support colors. 119 | /// 120 | public bool Binary { get; set; } = true; 121 | 122 | ///Initializes a new instance of 123 | public StlExporter(Inventor.Document Document) 124 | { 125 | this.Document = Document; 126 | } 127 | 128 | ///Export to STL file with the same folder and filename as the document. 129 | public void Export() 130 | { 131 | Export(System.IO.Path.ChangeExtension(this.Document.FullFileName, "stl")); 132 | } 133 | 134 | ///Export to STL file with the specified full file path. 135 | public void Export(string OutputFile) 136 | { 137 | TranslatorData oTranslatorData = new TranslatorData(addinGUID: "{533E9A98-FC3B-11D4-8E7E-0010B541CD80}", fullFileName: OutputFile, doc: this.Document); 138 | 139 | NameValueMap op = oTranslatorData.oOptions; 140 | 141 | op.Value["ExportUnits"] = (int)Units - 110080; //Convert ImportUnitsTypeEnum to the integer values expected by the STL exporter 142 | op.Value["Resolution"] = Resolution; 143 | op.Value["AllowMoveMeshNode"] = AllowMoveMeshNodes; 144 | op.Value["SurfaceDeviation"] = SurfaceDeviation; 145 | op.Value["NormalDeviation"] = NormalDeviation; 146 | op.Value["MaxEdgeLength"] = MaxEdgeLength; 147 | op.Value["AspectRatio"] = MaxAspectRatio; 148 | op.Value["ExportFileStructure"] = Convert.ToInt32(OneFilePerPartInstance); 149 | op.Value["OutputFileType"] = Convert.ToInt32(!Binary); 150 | op.Value["ExportColor"] = ExportColors; 151 | 152 | TranslatorAddIn oTranslatorAddIn = (TranslatorAddIn)oTranslatorData.oAppAddIn; 153 | 154 | oTranslatorAddIn.SaveCopyAs(this.Document, oTranslatorData.oContext, oTranslatorData.oOptions, oTranslatorData.oDataMedium); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/InventorShims/TranslatorShim/StlResolutionEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InventorShims.TranslatorShim 8 | { 9 | /// Wrapper for the Resolution that is used by the STL export method. 10 | public enum StlResolutionEnum 11 | { 12 | /// 13 | /// High resolution for stl export. 14 | /// 15 | High = 0, 16 | 17 | /// 18 | /// Medium resolution for stl export. 19 | /// 20 | Medium = 1, 21 | 22 | /// 23 | /// Low resolution for stl export. 24 | /// 25 | Low = 2, 26 | 27 | /// 28 | /// Custom resolution for stl export. 29 | /// 30 | Custom = 3, 31 | 32 | /// 33 | /// Brep resolution for stl export. 34 | /// 35 | Brep = 4 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/InventorShims/TranslatorShim/TranslatorData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Inventor; 7 | 8 | namespace InventorShims.TranslatorShim 9 | { 10 | /// Stores temporary data for import and export methods. 11 | internal class TranslatorData 12 | { 13 | internal readonly ApplicationAddIn oAppAddIn; 14 | internal readonly TranslationContext oContext; 15 | internal readonly NameValueMap oOptions; 16 | internal readonly DataMedium oDataMedium; 17 | 18 | ///Initializes a new instance of 19 | internal TranslatorData(string addinGUID, string fullFileName, Document doc = null, Inventor.Application app = null) 20 | { 21 | if (app == null) { app = (Application)doc.Parent; } 22 | 23 | oAppAddIn = app.ApplicationAddIns.ItemById[addinGUID]; 24 | 25 | TransientObjects oTo = app.TransientObjects; 26 | 27 | if (oAppAddIn is TranslatorAddIn) 28 | { 29 | oContext = oTo.CreateTranslationContext(); 30 | oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism; 31 | 32 | oDataMedium = oTo.CreateDataMedium(); 33 | 34 | oDataMedium.FileName = fullFileName; 35 | } 36 | oOptions = oTo.CreateNameValueMap(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/InventorShims/UiShim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Inventor; 7 | 8 | namespace InventorShims 9 | { 10 | /// 11 | /// Extension methods that work on an inventor application com object reference 12 | /// 13 | public static class UiShim 14 | { 15 | /// 16 | /// Gets the active color scheme name as a string 17 | /// 18 | /// 19 | /// 20 | public static string GetActiveColorSchemeName(this Application inventorAppToWork) 21 | { 22 | return inventorAppToWork.ActiveColorScheme.Name; 23 | } 24 | /// 25 | /// Sets the active color scheme name, passed in as a string 26 | /// 27 | /// 28 | /// 29 | /// 30 | public static void SetActiveColorScheme(this Application inventorAppToWork, string colorSchemeNameToActivate) 31 | { 32 | inventorAppToWork.ColorSchemes[colorSchemeNameToActivate].Activate(); 33 | } 34 | /// 35 | /// Gets the background type enum in a more memorable way 36 | /// 37 | /// 38 | /// 39 | public static BackgroundTypeEnum GetActiveColorSchemeBackground(this Application inventorAppToWork) 40 | { 41 | return inventorAppToWork.ColorSchemes.BackgroundType; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/InventorShims/WinMacros.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | 5 | namespace InventorShims 6 | { 7 | /// 8 | /// Windows helper methods, such as a sleep that accounts for doEvents so you can use it in a GUI and not have the user experience blocked. 9 | /// 10 | internal static class WinMacros 11 | { 12 | /// 13 | /// Pass int seconds to sleep a number of seconds. 14 | /// 15 | /// Do not use this method where accurate time is important. Accuracy will get worse with values of many seconds. 16 | /// 17 | /// 18 | public static void WinSleep(int seconds) 19 | { 20 | WinMacros.WinSleepLong(seconds); 21 | } 22 | /// 23 | /// Returns a string of random A - Z 0 - 9 characters. 24 | /// 25 | /// 26 | /// 27 | public static string GetRandomString(int lengthOfString = 10) 28 | { 29 | Random random = new Random(); 30 | 31 | const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 32 | string randChars = new string(System.Linq.Enumerable.Repeat(chars, lengthOfString).Select(s => s[random.Next(s.Length)]).ToArray()); 33 | 34 | return randChars; 35 | } 36 | /// 37 | /// Pass a double to sleep for fractions of a second. (0.1 sleeps for around 1/10 second) 38 | /// 39 | /// Do not use this method where accurate time is important. Accuracy will get worse with values of many seconds. 40 | /// 41 | /// 42 | public static void WinSleep(double seconds) 43 | { 44 | // Handle very very short 45 | if(seconds < 0.002) 46 | { 47 | WinMacros.WinSleepShort(2); 48 | } 49 | else if(seconds <= 1) 50 | { 51 | WinMacros.WinSleepShort((int)(seconds * 1000)); 52 | } 53 | else 54 | { 55 | WinMacros.WinSleepLong((int)(seconds * 100)); 56 | } 57 | } 58 | private static void WinSleepLong(int tenthsOfSeconds) 59 | { 60 | for(int i = 0; i < tenthsOfSeconds * 10; i++) 61 | { 62 | System.Windows.Forms.Application.DoEvents(); 63 | System.Threading.Thread.Sleep(100); 64 | } 65 | } 66 | private static void WinSleepShort(int milliSeconds) 67 | { 68 | for(int i = 0; i < milliSeconds; i++) 69 | { 70 | System.Windows.Forms.Application.DoEvents(); 71 | Thread.Sleep(1); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tests/GetDocumentFromObject.tests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/GetDocumentFromObject.tests/GetDocumentFromObject.tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E3FBC284-4903-491E-9665-DD34D1A0D5B0} 8 | Exe 9 | GetDocumentFromObjectTest 10 | GetDocumentFromObjectTest 11 | v4.8 12 | 512 13 | true 14 | true 15 | false 16 | publish\ 17 | true 18 | Disk 19 | false 20 | Foreground 21 | 7 22 | Days 23 | false 24 | false 25 | true 26 | 0 27 | 1.0.0.%2a 28 | false 29 | true 30 | 31 | 32 | AnyCPU 33 | true 34 | full 35 | false 36 | ..\..\artifacts\debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | 41 | 42 | AnyCPU 43 | pdbonly 44 | true 45 | ..\..\artifacts\Release\ 46 | TRACE 47 | prompt 48 | 4 49 | 50 | 51 | GetDocumentFromObjectTest.Program 52 | 53 | 54 | true 55 | bin\GetDocumentFromObject-tests\ 56 | DEBUG;TRACE 57 | full 58 | AnyCPU 59 | 7.3 60 | prompt 61 | true 62 | 63 | 64 | bin\Pack\ 65 | TRACE 66 | true 67 | pdbonly 68 | AnyCPU 69 | 7.3 70 | prompt 71 | true 72 | 73 | 74 | 75 | False 76 | False 77 | C:\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | False 98 | Microsoft .NET Framework 4.7 %28x86 and x64%29 99 | true 100 | 101 | 102 | False 103 | .NET Framework 3.5 SP1 104 | false 105 | 106 | 107 | 108 | 109 | {de9044a0-4809-4828-adee-fa787925cbcf} 110 | InventorShims 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /tests/GetDocumentFromObject.tests/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Inventor; 7 | using InventorShims; 8 | 9 | namespace GetDocumentFromObjectTest 10 | { 11 | static class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | test_GetDocumentsFromSelectSet(); 16 | //wip_kDrawingCurveSegmentObject(); 17 | } 18 | 19 | private static void test_GetDocumentsFromSelectSet() 20 | { 21 | Inventor.Application oApp = ApplicationShim.CurrentInstance(); 22 | SelectSet oSSet = oApp.ActiveDocument.SelectSet; 23 | if (oSSet.Count == 0) 24 | { 25 | oSSet.Select(oApp.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select thing(s)...")); 26 | } 27 | 28 | 29 | if (oSSet.Count == 0) 30 | { 31 | return; 32 | } 33 | 34 | List documentList = new List(); 35 | documentList = DocumentShim.GetDocumentsFromSelectSet(oSSet); 36 | 37 | Console.WriteLine("Number of documents in List: " + documentList.Count().ToString()); 38 | foreach (Document i in documentList) 39 | { 40 | // Console.WriteLine(i.FullFileName); 41 | } 42 | 43 | Console.WriteLine("Press Enter to Exit!"); 44 | Console.ReadLine(); 45 | } 46 | 47 | private static void wip_kDrawingCurveSegmentObject() 48 | { 49 | 50 | Inventor.Application oApp = ApplicationShim.CurrentInstance(); 51 | SelectSet oSSet = oApp.ActiveDocument.SelectSet; 52 | if (oSSet.Count == 0) 53 | { 54 | return; 55 | } 56 | 57 | Inventor.Document returnDocument = null; 58 | 59 | dynamic obj = oSSet[2]; 60 | switch (obj.type) 61 | { 62 | case 117478144: //kDrawingCurveSegmentObject 63 | //try to set the drawing curve object to point at the containingOccurrence object. 64 | //Edge Objects and Edge Proxy Objects 65 | 66 | DrawingCurveSegment drawingCurveSegment = (DrawingCurveSegment)obj; 67 | DrawingCurve drawingCurve = drawingCurveSegment.Parent; 68 | 69 | 70 | dynamic modelGeometry; 71 | try 72 | { 73 | modelGeometry = drawingCurve.ModelGeometry; 74 | } 75 | catch 76 | { 77 | Console.WriteLine("Are you sure the object can be found? The ModelGeometry cannot be located. exiting..."); 78 | Console.ReadLine(); 79 | return; 80 | } 81 | 82 | ComponentOccurrence componentOccurrence; 83 | 84 | try //for a selected DrawingCurveSegment belonging to an assembly component 85 | { 86 | componentOccurrence = modelGeometry.ContainingOccurrence; 87 | returnDocument = (Document)componentOccurrence.Definition.Document; 88 | break; 89 | } 90 | catch { } 91 | 92 | try //for a selected DrawingCurveSegment belonging to a part 93 | { 94 | returnDocument = (Document)modelGeometry.Parent.ComponentDefinition.Document; 95 | break; 96 | } 97 | catch { } 98 | break; 99 | 100 | } 101 | 102 | if (returnDocument == null) 103 | { 104 | Console.WriteLine("The document could not be found!"); 105 | } 106 | else 107 | { 108 | Console.WriteLine("Document Type: " + returnDocument.DocumentSubType); 109 | Console.WriteLine(returnDocument.FullFileName); 110 | } 111 | 112 | Console.ReadLine(); 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /tests/GetDocumentFromObject.tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GetDocumentFromObjectTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GetDocumentFromObjectTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e3fbc284-4903-491e-9665-dd34d1a0d5b0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.3.1.0")] 35 | [assembly: AssemblyVersion("1.3.1.0")] 36 | [assembly: AssemblyFileVersion("1.3.1.0")] 37 | [assembly: AssemblyInformationalVersion("1.3.1+Branch.docs-cleanup.Sha.652061d7943d2a9870071ec4128942ced2495209")] 38 | -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Sheet Metal.ipt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Sheet Metal.ipt -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Standard.iam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Standard.iam -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Standard.idw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Standard.idw -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Standard.inest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Standard.inest -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Standard.ipn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Standard.ipn -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Standard.ipt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Standard.ipt -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/Weldment.iam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/Weldment.iam -------------------------------------------------------------------------------- /tests/Inventor.test.config/Templates/standard.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Templates/standard.dwg -------------------------------------------------------------------------------- /tests/Inventor.test.config/Test.ipj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InventorCode/InventorShims/8705113ce6c57d88af07c26e0a050abb4c5e4448/tests/Inventor.test.config/Test.ipj -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/DocumentType.Test.vb: -------------------------------------------------------------------------------- 1 | 'Imports InventorShims 2 | Imports Inventor 3 | AddVbFile "src-vb/DocumentType.vb" 4 | 5 | 'Run the PropertyShim functions from inventor's ilogic environment. 6 | 'Public Module Test 7 | Sub Main() 8 | 9 | MsgBox("IsAssembly: " & DocumentType.IsAssembly(ThisApplication.ActiveDocument) & vbLf & 10 | "IsDrawing: " & DocumentType.IsDrawing(ThisApplication.ActiveDocument) & vbLf & 11 | "IsForeignModel: " & DocumentType.IsForeignModel(ThisApplication.ActiveDocument) & vbLf & 12 | "IsNest: " & DocumentType.IsNest(ThisApplication.ActiveDocument) & vbLf & 13 | "IsPart: " & DocumentType.IsPart(ThisApplication.ActiveDocument) & vbLf & 14 | "IsPresentation: " & DocumentType.IsPresentation(ThisApplication.ActiveDocument) & vbLf & 15 | "IsSAT: " & DocumentType.IsSAT(ThisApplication.ActiveDocument) & vbLf & 16 | "IsUnknown: " & DocumentType.IsUnknown(ThisApplication.ActiveDocument)) 17 | 18 | End Sub 19 | 'End Module 20 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/DrawingDocumentExtensionsTests.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.DrawingDocumentExtensions 3 | 4 | Dim oDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument 5 | oDoc.SaveWithFileDialog 6 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/Iproperty SpeedTest.vb: -------------------------------------------------------------------------------- 1 | 'This is a speed test between several methods to access propertysets and properties. 2 | ' Results: accessing properties By ID is slightly faster than accessing by name. 3 | ' Results: accessing propertysets by name is almost 4x faster than accessing by the unique id. 4 | 5 | 'Module SpeedTestMain '' 6 | Public Sub Main () 7 | 8 | Dim test As SpeedTest = New SpeedTest() 9 | 10 | test.AddTest("PropByName", AddressOf AccessPropByName) 11 | test.AddTest("PropByID", AddressOf AccessPropByID) 12 | test.AddTest("SetByName", AddressOf AccessPropertySetByName) 13 | test.AddTest("SetByUnique", AddressOf AccessPropertySetByUniqueID) 14 | 15 | test.Iterations = 100 16 | test.RunTests() 17 | test.ShowResultsInDialog() 18 | 19 | End Sub 20 | 21 | Public Sub AccessPropByName() 22 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 23 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("Design Tracking Properties") 24 | Dim propValue As Inventor.Property = propertySet.Item("Part Number") 25 | End Sub 26 | 27 | Public Sub AccessPropByID() 28 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 29 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("Design Tracking Properties") 30 | Dim propValue As Inventor.Property = propertySet.ItemByPropId(5) 31 | End Sub 32 | 33 | Public Sub AccessPropertySetByName() 34 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 35 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("Design Tracking Properties") 36 | End Sub 37 | 38 | Public Sub AccessPropertySetByUniqueID() 39 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 40 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("32853F0F-3444-11D1-9E93-0060B03C1CA6") 41 | End Sub 42 | 43 | 'End Module '' 44 | 45 | Public Class SpeedTest 46 | 47 | Public Delegate Sub CodeToExecute() 48 | Public Property Iterations As Integer = 1 49 | Private _results As String = "" 50 | Private _timers As Dictionary(Of Timer, CodeToExecute) = New Dictionary(Of Timer,CodeToExecute) 51 | 52 | Public Sub New() 53 | End Sub 54 | 55 | Public Sub AddTest(message As String, ByVal code As CodeToExecute) 56 | 57 | _timers.Add(New Timer(message), code) 58 | 59 | End Sub 60 | 61 | Public Sub RunTests() 62 | 63 | For Each timer As KeyValuePair(Of Timer, CodeToExecute) in _timers 64 | 65 | GC.WaitForPendingFinalizers 66 | GC.Collect 67 | 68 | timer.Key.StartTimer() 69 | For i = 0 To Iterations 70 | timer.Value.Invoke() 71 | Next i 72 | timer.Key.StopTimer() 73 | 74 | AppendResults(timer.Key.GetResults) 75 | Next timer 76 | End Sub 77 | 78 | Public Sub ShowResultsInDialog() 79 | System.Windows.Forms.Messagebox.Show(_results) 80 | End Sub 81 | 82 | Public Function GetResults() As String 83 | Return _results 84 | End Function 85 | 86 | Private Sub AppendResults(value As String) 87 | _results = _results & vbLf & value 88 | End Sub 89 | 90 | End Class 91 | 92 | Public Class Timer 93 | 94 | Private _stopwatch As Stopwatch = New Stopwatch() 95 | Private _timespan As TimeSpan 96 | Private _totalTime As String 97 | Private _message As String = "" 98 | Private _result As String = "Speed test has not been run." 99 | 100 | Public Sub New() 101 | End Sub 102 | 103 | Public Sub New(value As String) 104 | me._message = value 105 | End Sub 106 | 107 | Public Sub StartTimer() 108 | _stopwatch.Start() 109 | End Sub 110 | 111 | Public Sub StopTimer() 112 | _stopwatch.Stop() 113 | _timespan = _stopwatch.Elapsed 114 | _result = String.Format("{0:00}.{1:000} seconds", (_timespan.Hours * 3600) + (_timespan.Minutes*60) + _timespan.Seconds, _timespan.Milliseconds) 115 | End Sub 116 | 117 | Public Function GetResults() As String 118 | Return me._message & " Total Time: " & _result 119 | End Function 120 | 121 | Public Function GetMessage() As String 122 | Return me._message 123 | End Function 124 | End Class 125 | 126 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/ListIprops.vb: -------------------------------------------------------------------------------- 1 | Imports Inventor 2 | 3 | 'This can be run in Inventor's ilogic environment. it will list out the 4 | 'iproperties available in a file. 5 | 6 | Public Sub Main() 7 | Dim test As ListIprops = New ListIprops(ThisApplication) 8 | test.GetPropertySets 9 | ' test.GetInfo 10 | 11 | End Sub 12 | Public Class ListIprops 13 | 14 | Private _doc As Document 15 | Private _file As System.IO.StreamWriter 16 | Private ReadOnly _epoch As String = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().toString 17 | Private _path As String 18 | 19 | Sub New(app As Application) 20 | _doc = app.ActiveDocument 21 | Dim fullPath As String = _doc.FullFileName 22 | Dim directory As String = IO.Path.GetDirectoryName(fullPath) 23 | _path = directory & IO.Path.DirectorySeparatorChar & "IpropertyList " & _epoch & ".txt" 24 | 25 | End Sub 26 | 27 | Private Sub OpenFile 28 | _file = My.Computer.FileSystem.OpenTextFileWriter(_path, True) 29 | End Sub 30 | Private Sub WriteLine(value As String) 31 | _file.WriteLine(value) 32 | End Sub 33 | Private Sub CloseFile 34 | _file.Close() 35 | End Sub 36 | 37 | Sub GetPropertySets() 38 | 39 | OpenFile 40 | Dim propertySet As Inventor.PropertySet 41 | WriteLine("Qty of Property Sets: " & _doc.PropertySets.count) 42 | 43 | For Each propertySet In _doc.PropertySets 44 | WriteLine("") 45 | WriteLine(propertySet.Name + " / " + propertySet.InternalName) 46 | 47 | 48 | Dim prop As Inventor.Property 49 | For Each prop In propertySet 50 | WriteLine(prop.Name + " /" + Str(prop.PropId)) 51 | Next 52 | Next 53 | CloseFile 54 | End Sub 55 | 56 | Sub GetInfo() 57 | Dim propertySet As Inventor.PropertySet 58 | dim ids As Integer() = {} 59 | dim names As String() = {} 60 | Dim values As Object() = {} 61 | propertySet = _doc.PropertySets.Item("F29F85E0-4FF9-1068-AB91-08002B27B3D9") 62 | propertySet.GetPropertyInfo(ids,names,values) 63 | 64 | MsgBox(values(0)) 65 | End Sub 66 | 67 | End Class 68 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/PropertyShim.GetProperty.SpeedTest Results.md: -------------------------------------------------------------------------------- 1 | SpeedTest Results - Try vs GetPropsInfo 2 | === 3 | 4 | Test of typical iproperty GetProperty: 5 | 6 | | GetProperty | API | Iterations | 7 | |-------------|-----|------------| 8 | | 189.0 | 184.1 | 500,000 | 9 | | 187.4 | 183.8 | 500,000 | 10 | | 185.3 | 187.9 | 500,000 | 11 | | .061 | .054 | 100 | 12 | | .050 | .068 | 100 | 13 | | .083 | .055 | 100 | 14 | | .093 | .101 | 100 | 15 | 16 | 17 | Test of GetProperty with a custom iproperty: 18 | 19 | | GetProperty | API | Iterations | 20 | |-------------|-----|------------| 21 | | 72.2 | 73.0 | 500,000 | 22 | | 110.0 | 115.1 | 500,000 | 23 | | | | 500,000 | 24 | | .043 | .040 | 100 | 25 | | .037 | .026 | 100 | 26 | | .022 | .034 | 100 | 27 | 28 | 29 | Test of GetProperty where the iproperty does not exist: 30 | 31 | | GetProperty | API | Iterations | 32 | |-------------|-----|------------| 33 | | 341.5 | | 500,000 | 34 | | 342.6 | | 500,000 | 35 | | 348.8 | | 500,000 | 36 | | .086 | | 100 | 37 | | .088 | | 100 | 38 | | .084 | | 100 | 39 | 40 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/SpeedTest Results - try vs GetPropsInfo.md: -------------------------------------------------------------------------------- 1 | SpeedTest Results - Try vs GetPropsInfo 2 | === 3 | 4 | Test where custom iproperty value does not exist, (12x custom iprops): 5 | 6 | | GetPropsInfo | Try | Iterations | 7 | |--------------|-----|------------| 8 | | 24.313 | 23.956 | 100,000 | 9 | | 24.338 | 23.558 | 100,000 | 10 | | 21.572 | 22.808 | 100,000 | 11 | | 24.743 | 22.687 | 100,000 | 12 | | 24.216 | 23.664 | 100,000 | 13 | | 237.89 | 230.59 | 1,000,000 | 14 | | 233.53 | 226.39 | 1,000,000 | 15 | | 241.90 | 228.48 | 1,000,000 | 16 | 17 | 18 | Test where custom iproperty does exist, (12x custom iprops): 19 | 20 | | GetPropsInfo | Try | Iterations | 21 | |--------------|-----|------------| 22 | | 26.648 | 9.256 | 100,000 | 23 | | 26.532 | 9.209 | 100,000 | 24 | | 26.901 | 9.474 | 100,000 | 25 | | 25.720 | 9.376 | 100,000 | 26 | | 262.18 | 89.52 | 1,000,000 | 27 | | 264.17 | 86.54 | 1,000,000 | 28 | | 263.21 | 88.36 | 1,000,000 | 29 | 30 | 31 | Test where custom iproperty value does not exist, (30x custom iprops): 32 | 33 | | GetPropsInfo | Try | Iterations | 34 | |--------------|-----|------------| 35 | | 33.541 | 24.078 | 100,000 | 36 | | 33.337 | 23.062 | 100,000 | 37 | | 32.508 | 23.797 | 100,000 | 38 | | 320.48 | 237.69 | 1,000,000 | 39 | | 327.61 | 234.47 | 1,000,000 | 40 | | 333.30 | 239.64 | 1,000,000 | 41 | 42 | 43 | Test where custom iproperty value does exist, (30x custom iprops): 44 | 45 | | GetPropsInfo | Try | Iterations | 46 | |--------------|-----|------------| 47 | | 35.708 | 8.551 | 100,000 | 48 | | 35.745 | 8.671 | 100,000 | 49 | | 36.157 | 9.037 | 100,000 | 50 | | 361.24 | 88.03 | 1,000,000 | 51 | | 345.04 | 88.08 | 1,000,000 | 52 | | 346.52 | 82.71 | 1,000,000 | 53 | 54 | 55 | Test where custom iproperty value does not exist, (1x custom iprops): 56 | 57 | | GetPropsInfo | Try | Iterations | 58 | |--------------|-----|------------| 59 | | 12.954 | 23.389 | 100,000 | 60 | | 13.187 | 24.196 | 100,000 | 61 | | 12.928 | 23.516 | 100,000 | 62 | | 123.55 | 230.08 | 1,000,000 | 63 | | 129.85 | 237.60 | 1,000,000 | 64 | | 133.15 | 240.79 | 1,000,000 | 65 | 66 | 67 | 68 | Test where custom iproperty value does exist, (1x custom iprops): 69 | 70 | | GetPropsInfo | Try | Iterations | 71 | |--------------|-----|------------| 72 | | 14.032 | 8.481 | 100,000 | 73 | | 16.024 | 9.707 | 100,000 | 74 | | 16.095 | 8.579 | 100,000 | 75 | | 155.02 | 85.37 | 1,000,000 | 76 | | 144.51 | 92.31 | 1,000,000 | 77 | | 150.00 | 88.56 | 1,000,000 | 78 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/SpeedTest.vb: -------------------------------------------------------------------------------- 1 | 'https://github.com/jordanrobot/SpeedTest [master@2b1aee2] 2 | ' 3 | Public Class SpeedTest 4 | 5 | Public Delegate Sub CodeToExecute() 6 | Public Property Iterations As Integer = 1 7 | Private _results As String = "" 8 | Private _timers As Dictionary(Of Timer, CodeToExecute) = New Dictionary(Of Timer,CodeToExecute) 9 | 10 | Public Sub New() 11 | End Sub 12 | 13 | Public Sub AddTest(message As String, ByVal code As CodeToExecute) 14 | 15 | _timers.Add(New Timer(message), code) 16 | 17 | End Sub 18 | 19 | Public Sub RunTests() 20 | 21 | For Each timer As KeyValuePair(Of Timer, CodeToExecute) in _timers 22 | 23 | GC.WaitForPendingFinalizers 24 | GC.Collect 25 | 26 | timer.Key.StartTimer() 27 | For i = 0 To Iterations 28 | timer.Value.Invoke() 29 | Next i 30 | timer.Key.StopTimer() 31 | 32 | AppendResults(timer.Key.GetResults) 33 | Next timer 34 | End Sub 35 | 36 | Public Sub ShowResultsInDialog() 37 | System.Windows.Forms.Messagebox.Show(_results) 38 | End Sub 39 | 40 | Public Function GetResults() As String 41 | Return _results 42 | End Function 43 | 44 | Private Sub AppendResults(value As String) 45 | _results = _results & vbLf & value 46 | End Sub 47 | 48 | End Class 49 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/Timer.vb: -------------------------------------------------------------------------------- 1 | ' 2 | Public Class Timer 3 | 4 | Private _stopwatch As Stopwatch = New Stopwatch() 5 | Private _timespan As TimeSpan 6 | Private _totalTime As String 7 | Private _message As String = "" 8 | Private _result As String = "Speed test has not been run." 9 | 10 | Public Sub New() 11 | End Sub 12 | 13 | Public Sub New(value As String) 14 | me._message = value 15 | End Sub 16 | 17 | Public Sub StartTimer() 18 | _stopwatch.Start() 19 | End Sub 20 | 21 | Public Sub StopTimer() 22 | _stopwatch.Stop() 23 | _timespan = _stopwatch.Elapsed 24 | _result = String.Format("{0:00}.{1:000} seconds", (_timespan.Hours * 3600) + (_timespan.Minutes*60) + _timespan.Seconds, _timespan.Milliseconds) 25 | End Sub 26 | 27 | Public Function GetResults() As String 28 | Return me._message & " Total Time: " & _result 29 | End Function 30 | 31 | Public Function GetMessage() As String 32 | Return me._message 33 | End Function 34 | End Class -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/iProperty.GetProperty SpeedTest.vb: -------------------------------------------------------------------------------- 1 | Imports InventorShims 2 | AddVbFile "src-vb/iProperty.vb" 3 | AddVbFile "tests/SpeedTest.vb" 4 | AddVbFile "tests/Timer.vb" 5 | 6 | 'This is a speed test between several methods to access all iproperties within a propertyset. 7 | ' Results: accessing all properties in a propertyset with GetPropertyInfo is faster than 8 | ' iterating through all properties within that propertyset. 9 | 10 | 'Module SpeedTestMain '' 11 | Public Sub Main () 12 | 13 | Dim test As SpeedTest = New SpeedTest() 14 | 15 | test.AddTest("PropertyShim.GetProperty", AddressOf Test1) 16 | test.AddTest("Inventor API", AddressOf Test2) 17 | 18 | test.Iterations = 100 19 | test.RunTests() 20 | test.ShowResultsInDialog() 21 | 22 | End Sub 23 | 24 | 25 | Public Sub Test1() 26 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 27 | Dim value As String 28 | value = iProperty.GetProperty(_doc, "Part Number") 29 | 30 | End Sub 31 | 32 | Public Sub Test2() 33 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 34 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("Design Tracking Properties") 35 | Dim value As String 36 | value = propertySet.Item("Part Number").Value 37 | 38 | End Sub 39 | 40 | ' End Module '' 41 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/iProperty.GetProperty.SpeedTest custom property.vb: -------------------------------------------------------------------------------- 1 | AddVbFile "src-vb/iProperty.vb" 2 | AddVbFile "tests/SpeedTest.vb" 3 | AddVbFile "tests/Timer.vb" 4 | 5 | 'This is a speed test between several methods to access all iproperties within a propertyset. 6 | ' Results: accessing all properties in a propertyset with GetPropertyInfo is faster than 7 | ' iterating through all properties within that propertyset. 8 | 9 | 'Module SpeedTestMain '' 10 | Public Sub Main () 11 | 12 | Dim test As SpeedTest = New SpeedTest() 13 | 14 | test.AddTest("iProperty.GetProperty", AddressOf Test1) 15 | test.AddTest("Inventor API", AddressOf Test2) 16 | 17 | test.Iterations = 100 18 | test.RunTests() 19 | test.ShowResultsInDialog() 20 | 21 | End Sub 22 | 23 | 24 | Public Sub Test1() 25 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 26 | Dim value As String 27 | value = iProperty.GetProperty(_doc, "Sheet") 28 | 29 | End Sub 30 | 31 | Public Sub Test2() 32 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 33 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("Inventor User Defined Properties") 34 | Dim value As String 35 | value = propertySet.Item("Sheet").Value 36 | 37 | End Sub 38 | 39 | ' End Module '' 40 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/iProperty.GetProperty.SpeedTest no parameter.vb: -------------------------------------------------------------------------------- 1 | AddVbFile "src-vb/iProperty.vb" 2 | AddVbFile "tests/SpeedTest.vb" 3 | AddVbFile "tests/Timer.vb" 4 | 5 | 'This is a speed test between several methods to access all iproperties within a propertyset. 6 | ' Results: accessing all properties in a propertyset with GetPropertyInfo is faster than 7 | ' iterating through all properties within that propertyset. 8 | 9 | 'Module SpeedTestMain '' 10 | Public Sub Main () 11 | 12 | Dim test As SpeedTest = New SpeedTest() 13 | 14 | test.AddTest("iProperty.GetProperty", AddressOf Test1) 15 | 'test.AddTest("Inventor API", AddressOf Test2) 16 | 17 | test.Iterations = 100 18 | test.RunTests() 19 | test.ShowResultsInDialog() 20 | 21 | End Sub 22 | 23 | 24 | Public Sub Test1() 25 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 26 | Dim value As String 27 | value = iProperty.GetProperty(_doc, "Part Numberz") 28 | 29 | End Sub 30 | 31 | Public Sub Test2() 32 | Dim _doc As Inventor.Document = ThisApplication.ActiveDocument 33 | Dim propertySet As Inventor.PropertySet = _doc.PropertySets.Item("Design Tracking Properties") 34 | Dim value As String 35 | value = propertySet.Item("Part Number").Value 36 | 37 | End Sub 38 | 39 | ' End Module '' 40 | -------------------------------------------------------------------------------- /tests/InventorShims.iLogic.tests/iProperty.Unit Tests.vb: -------------------------------------------------------------------------------- 1 | AddReference "InventorShims.dll" 2 | Imports InventorShims.PropertyShims 3 | 'Imports InventorShims.PropertyShims 4 | 'Run this test from inventor's ilogic environment. 5 | 6 | Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument 7 | oDoc.SetProperty("Title", "Stuffffff") 8 | oDoc.SetProperty("Things", "Stuffffff2") 9 | oDoc.SetProperty("Custom Prop Set", "Things", "Stufzzzzzz") 10 | 11 | MessageBox.Show(oDoc.GetProperty("Title"),"Stuffffff") 12 | MessageBox.Show(oDoc.GetProperty("Things"),"Stuffffff2") 13 | MessageBox.Show(oDoc.GetProperty("Custom Prop Set", "Things"), "Stufzzzzzz") 14 | 15 | MsgBox("Does title exist? (yes): " & oDoc.PropertyExists("Title")) 16 | MsgBox("Does things exist? (yes): " & oDoc.PropertyExists("Things")) 17 | MsgBox("Does custom things exist? (yes): " & oDoc.PropertyExists("Custom Prop Set", "Things")) 18 | 19 | 20 | oDoc.SetProperty("Title", "Title") 21 | oDoc.RemoveProperty("Things") 22 | oDoc.RemoveProperty("Custom Prop Set", "Things") 23 | 24 | MsgBox("Does title exist? (yes): " & oDoc.PropertyExists("Title")) 25 | MsgBox("Does things exist? (no): " & oDoc.PropertyExists("Things")) 26 | MsgBox("Does custom things exist? (no): " & oDoc.PropertyExists("Custom Prop Set", "Things")) 27 | -------------------------------------------------------------------------------- /tests/InventorShims.tests/ApplicationShimTests.cs: -------------------------------------------------------------------------------- 1 | using InventorShims; 2 | using NUnit.Framework; 3 | using System.Diagnostics; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace ApplicationShimTests 7 | { 8 | [TestFixture] 9 | public class Instance 10 | { 11 | [Test] 12 | public void GetsOrStartsInstance() 13 | { 14 | Inventor.Application app = ApplicationShim.Instance(); 15 | app.Visible = true; 16 | 17 | var testVariable = app.AssemblyOptions.DeferUpdate; 18 | 19 | Assert.IsNotNull(testVariable); 20 | 21 | Process[] procs = Process.GetProcessesByName("Inventor"); 22 | app.Quit(); 23 | if (procs.Length == 1) { procs[0].WaitForExit(); } 24 | 25 | Marshal.ReleaseComObject(app); 26 | app = null; 27 | //GC.Collect(); 28 | //GC.WaitForPendingFinalizers(); 29 | } 30 | } 31 | 32 | [TestFixture] 33 | public class NewInstance 34 | { 35 | [Test] 36 | public void Works_isVisible() 37 | { 38 | Inventor.Application app = null; 39 | app = ApplicationShim.NewInstance(); 40 | 41 | try 42 | { 43 | Assert.IsNotNull(app); 44 | } 45 | finally 46 | { 47 | if (app != null) 48 | { 49 | Process[] procs = Process.GetProcessesByName("Inventor"); 50 | app.Quit(); 51 | if (procs.Length == 1) { procs[0].WaitForExit(); } 52 | 53 | Marshal.ReleaseComObject(app); 54 | app = null; 55 | //GC.Collect(); 56 | //GC.WaitForPendingFinalizers(); 57 | } 58 | } 59 | } 60 | 61 | [Test] 62 | public void Works_isInvisible() 63 | { 64 | Inventor.Application app = null; 65 | app = ApplicationShim.NewInstance(false); 66 | 67 | try 68 | { 69 | Assert.IsNotNull(app); 70 | } 71 | finally 72 | { 73 | if (app != null) 74 | { 75 | Process[] procs = Process.GetProcessesByName("Inventor"); 76 | app.Quit(); 77 | if (procs.Length == 1) { procs[0].WaitForExit(); } 78 | 79 | Marshal.ReleaseComObject(app); 80 | app = null; 81 | //GC.Collect(); 82 | //GC.WaitForPendingFinalizers(); 83 | } 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /tests/InventorShims.tests/ExternalRuleDirectoriesTests.cs: -------------------------------------------------------------------------------- 1 | using InventorShims; 2 | using NUnit.Framework; 3 | using System.Collections.Generic; 4 | 5 | namespace ExternalRuleDirectories_Tests 6 | { 7 | [TestFixture] 8 | public class ExternalRuleDirectoriesTests 9 | { 10 | [Test] 11 | public void Dispose_DoesNotThrowError() 12 | { 13 | ExternalRuleDirectories shim = new ExternalRuleDirectories(); 14 | shim.Dispose(); 15 | } 16 | 17 | [Test] 18 | public void Using_DoesNotThrowError() 19 | { 20 | using (ExternalRuleDirectories shim = new ExternalRuleDirectories()) 21 | { 22 | } 23 | } 24 | 25 | [Test] 26 | public void Constructor_doesNotThrowError() 27 | { 28 | ExternalRuleDirectories shim = new ExternalRuleDirectories(); 29 | } 30 | 31 | [Test] 32 | public void ConstructorLong_doesNotThrowError() 33 | { 34 | Inventor.Application app = ApplicationShim.Instance(); 35 | ExternalRuleDirectories shim = new ExternalRuleDirectories(app); 36 | } 37 | 38 | [Test] 39 | public void ExternalRuleDirectories_doesNotThrowError() 40 | { 41 | ExternalRuleDirectories shim = new ExternalRuleDirectories(); 42 | List _ = shim.Directories; 43 | } 44 | 45 | [Test] 46 | public void Add_Works() 47 | { 48 | using (ExternalRuleDirectories shim = new ExternalRuleDirectories()) 49 | { 50 | var test = @"C:\Users\Default\AppData\Local\Temp\"; 51 | shim.Add(test); 52 | 53 | List answer = shim.Directories; 54 | 55 | try 56 | { 57 | Assert.IsTrue(answer.Contains(test)); 58 | } 59 | finally 60 | { 61 | shim.Remove(test); 62 | } 63 | } 64 | } 65 | 66 | [Test] 67 | public void Contains_Works() 68 | { 69 | ExternalRuleDirectories shim = new ExternalRuleDirectories(); 70 | var test = @"C:\Users\Default\AppData\Local\Temp\"; 71 | shim.Add(test); 72 | 73 | try 74 | { 75 | Assert.IsTrue(shim.Contains(test)); 76 | } 77 | finally 78 | { 79 | shim.Remove(test); 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /tests/InventorShims.tests/GetDocumentFromObjectTests.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorShims; 3 | using NUnit.Framework; 4 | 5 | namespace DocumentShim_Tests 6 | { 7 | [TestFixture] 8 | public class ReturnDocumentFromObject_Tests 9 | { 10 | [Test] 11 | public void PartDocumentIn_ReturnsDocument() 12 | { 13 | var doc = tests.TestUtilities.CreatePartDocument(); 14 | 15 | var doc2 = doc.GetDocumentFromObject(); 16 | 17 | var tt = PropertyShim.GetPropertyValue(doc2, "Author"); 18 | //only exists in ParDocuments 19 | PropertySets test = null; 20 | try 21 | { 22 | test = doc2.PropertySets; 23 | } 24 | catch { } 25 | 26 | try 27 | { 28 | Assert.IsNotNull(test); 29 | } 30 | finally { doc.Close(true); } 31 | } 32 | 33 | [Test] 34 | public void AssemblyDocumentIn_ReturnsDocument() 35 | { 36 | var doc = tests.TestUtilities.CreateAssemblyDocument(); 37 | 38 | var doc2 = doc.GetDocumentFromObject(); 39 | 40 | var tt = PropertyShim.GetPropertyValue(doc2, "Author"); 41 | //only exists in ParDocuments 42 | PropertySets test = null; 43 | try 44 | { 45 | test = doc2.PropertySets; 46 | } 47 | catch { } 48 | 49 | try 50 | { 51 | Assert.IsNotNull(test); 52 | } 53 | finally { doc.Close(true); } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /tests/InventorShims.tests/InventorShims.tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | AnyCPU 9 | {9A4C4253-55EA-4218-9FE0-9E473562A096} 10 | Library 11 | Properties 12 | tests 13 | tests 14 | v4.8 15 | 512 16 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 15.0 18 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 19 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 20 | False 21 | UnitTest 22 | 23 | 24 | 25 | 26 | 27 | true 28 | full 29 | false 30 | ..\..\artifacts\Debug\ 31 | DEBUG;TRACE 32 | prompt 33 | 4 34 | 35 | 36 | pdbonly 37 | true 38 | ..\..\artifacts\Release\ 39 | TRACE 40 | prompt 41 | 4 42 | x64 43 | 44 | 45 | 46 | False 47 | True 48 | ..\..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll 49 | 50 | 51 | ..\..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll 52 | 53 | 54 | 55 | ..\..\packages\NSubstitute.4.2.2\lib\net46\NSubstitute.dll 56 | 57 | 58 | ..\..\packages\NUnit.3.13.2\lib\net45\nunit.framework.dll 59 | 60 | 61 | 62 | 63 | 64 | ..\..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | {de9044a0-4809-4828-adee-fa787925cbcf} 87 | InventorShims 88 | 89 | 90 | 91 | 92 | {00020430-0000-0000-C000-000000000046} 93 | 2 94 | 0 95 | 0 96 | primary 97 | False 98 | True 99 | 100 | 101 | 102 | 103 | 104 | 105 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /tests/InventorShims.tests/PathShimTests.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorShims; 3 | using NUnit.Framework; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace PathShims_Tests 7 | { 8 | [TestFixture] 9 | public class UpOneLevel 10 | { 11 | [TestCase(@"C:\A\Test\String\", @"C:\A\Test\")] 12 | [TestCase(@"C:\A\Test\String", @"C:\A\Test\")] 13 | [TestCase(@"C:\", @"C:")] 14 | [TestCase(@"C:/Users/", @"C:/")] 15 | [TestCase(@"C:\A\", @"C:\")] 16 | [TestCase("C:", null)] 17 | [Test] 18 | public void UpOneLevel_MultipleInputs(string stringA, string stringB) 19 | { 20 | Assert.AreEqual(PathShim.UpOneLevel(stringA), stringB); 21 | } 22 | } 23 | 24 | [TestFixture] 25 | public class IsLibraryPath 26 | { 27 | [Test] 28 | public void GoodInput() 29 | { 30 | Inventor.Application app = ApplicationShim.Instance(); 31 | 32 | var designProject = app.DesignProjectManager.ActiveDesignProject; 33 | var libraryPaths = designProject.LibraryPaths; 34 | 35 | var i = libraryPaths.Count + 1; 36 | 37 | libraryPaths.Add("temporary path", @"C:\"); 38 | 39 | string test = libraryPaths[1].Path; 40 | test = PathShim.TrimEndingDirectorySeparator(test); 41 | 42 | try 43 | { 44 | Assert.IsTrue(test.IsLibraryPath(app)); 45 | } 46 | finally 47 | { 48 | libraryPaths[i].Delete(); 49 | Marshal.ReleaseComObject(app); 50 | app = null; 51 | } 52 | } 53 | 54 | [TestCase(@"C:\Zarthastoriatarigula\the\fiverth")] 55 | [TestCase("")] 56 | [TestCase(null)] 57 | [Test] 58 | public void BadInput_WrongPath(string testString) 59 | { 60 | Inventor.Application app = ApplicationShim.Instance(); 61 | 62 | try 63 | { 64 | Assert.IsFalse(testString.IsLibraryPath(app)); 65 | } 66 | finally 67 | { 68 | Marshal.ReleaseComObject(app); 69 | app = null; 70 | } 71 | } 72 | } 73 | 74 | [TestFixture] 75 | public class IsContentCenterPath 76 | { 77 | [Test] 78 | public void GoodInput() 79 | { 80 | Inventor.Application app = ApplicationShim.Instance(); 81 | 82 | string test = app.DesignProjectManager.ActiveDesignProject.ContentCenterPath; 83 | 84 | try 85 | { 86 | Assert.IsTrue(test.IsContentCenterPath(app)); 87 | } 88 | finally 89 | { 90 | Marshal.ReleaseComObject(app); 91 | app = null; 92 | } 93 | } 94 | 95 | [Test] 96 | public void GoodInput_NoTrailingSlash() 97 | { 98 | Inventor.Application app = ApplicationShim.Instance(); 99 | 100 | string test = app.DesignProjectManager.ActiveDesignProject.ContentCenterPath; 101 | test = PathShim.TrimEndingDirectorySeparator(test); 102 | 103 | try 104 | { 105 | Assert.IsTrue(test.IsContentCenterPath(app)); 106 | } 107 | finally 108 | { 109 | Marshal.ReleaseComObject(app); 110 | app = null; 111 | } 112 | } 113 | 114 | [TestCase(@"C:\Windows\")] 115 | [TestCase("")] 116 | [TestCase(null)] 117 | [Test] 118 | public void BadInput_Wrong(string testString) 119 | { 120 | Inventor.Application app = ApplicationShim.Instance(); 121 | 122 | try 123 | { 124 | Assert.IsFalse(testString.IsContentCenterPath(app)); 125 | } 126 | finally 127 | { 128 | Marshal.ReleaseComObject(app); 129 | app = null; 130 | } 131 | } 132 | } 133 | 134 | [TestFixture] 135 | public class TrimTrailingSlash 136 | { 137 | [TestCase(@"C:\Windows\SysWow\", @"C:\Windows\SysWow")] 138 | [TestCase(@"C:\Windows\SysWow", @"C:\Windows\SysWow")] 139 | [Test] 140 | public void GoodInput_TrailingSlash(string testA, string testB) 141 | { 142 | Assert.AreEqual(PathShim.TrimEndingDirectorySeparator(testA), testB); 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /tests/InventorShims.tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("tests")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("tests")] 10 | [assembly: AssemblyCopyright("Copyright © 2020")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: Guid("9a4c4253-55ea-4218-9fe0-9e473562a096")] 17 | 18 | // [assembly: AssemblyVersion("1.3.1.0")] 19 | [assembly: AssemblyVersion("1.3.1.0")] 20 | [assembly: AssemblyFileVersion("1.3.1.0")] 21 | [assembly: AssemblyInformationalVersion("1.3.1+Branch.docs-cleanup.Sha.652061d7943d2a9870071ec4128942ced2495209")] 22 | -------------------------------------------------------------------------------- /tests/InventorShims.tests/TestUtilities.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorShims; 3 | using System; 4 | 5 | namespace tests 6 | { 7 | public static class TestUtilities 8 | { 9 | internal static Inventor.Document CreatePartDocument() 10 | { 11 | Inventor.Application app = ApplicationShim.Instance(); 12 | var path = app.DesignProjectManager.ActiveDesignProject.TemplatesPath; 13 | return app.Documents.Add(DocumentTypeEnum.kPartDocumentObject, path + "Standard.ipt", true); 14 | } 15 | 16 | public static Document CreateAssemblyDocument() 17 | { 18 | Inventor.Application app = ApplicationShim.Instance(); 19 | var path = app.DesignProjectManager.ActiveDesignProject.TemplatesPath; 20 | Document doc = app.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject, path + "Standard.iam", true); 21 | return doc; 22 | } 23 | 24 | internal static Document CreateDrawingDocument() 25 | { 26 | Inventor.Application app = ApplicationShim.Instance(); 27 | var path = app.DesignProjectManager.ActiveDesignProject.TemplatesPath; 28 | Document doc = app.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, path + "Standard.idw", true); 29 | return doc; 30 | } 31 | 32 | internal static Document CreatePresentationDocument() 33 | { 34 | Inventor.Application app = ApplicationShim.Instance(); 35 | var path = app.DesignProjectManager.ActiveDesignProject.TemplatesPath; 36 | Document doc = app.Documents.Add(DocumentTypeEnum.kPresentationDocumentObject, path + "Standard.ipn", true); 37 | return doc; 38 | } 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /tests/InventorShims.tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | --------------------------------------------------------------------------------