├── .gitattributes ├── .gitignore ├── Application.cs ├── BOM ├── InventorBom.cs ├── InventorBomHelpers.cs └── InventorBomItem.cs ├── CaptureDto ├── DrawingCapture │ ├── DimensionCaptureDto.cs │ ├── DrawingCaptureDto.cs │ ├── Enums │ │ ├── DimensionDirectionEnum.cs │ │ ├── DimensionTypeEnum.cs │ │ ├── PointCaptureType.cs │ │ └── PointLocationEnum.cs │ ├── PointCaptureDto.cs │ ├── SheetCaptureDto.cs │ └── ViewCaptureDto.cs ├── Enums │ └── FeatureCaptureType.cs ├── FeatureCaptureDto.cs └── ParameterCaptureDto.cs ├── Components ├── InventorComponent.cs ├── InventorComponents.cs └── Options │ └── InventorNameValueMapOptions.cs ├── Constants └── InventorApplicationAddInIds.cs ├── Constraints ├── InventorConstraintType.cs └── InventorConstraints.cs ├── CopyTools ├── CopyHelpers.cs └── ReferenceDto.cs ├── Data └── HoleSizes.cs ├── Documents ├── DocumentHelper.cs ├── InventorAssemblyDocument.cs ├── InventorDocument.cs ├── InventorDocumentType.cs ├── InventorDrawingDocument.cs └── InventorPartDocument.cs ├── Drawings ├── Annotations │ ├── InventorCenterLine.cs │ ├── InventorDrawingNote.cs │ ├── InventorGeneralNote.cs │ ├── InventorLeader.cs │ └── InventorLeaderNote.cs ├── Curves │ ├── GeometryPoint.cs │ ├── InventorDrawingCurve.cs │ └── Point.cs ├── Dimensions │ ├── IDimension.cs │ ├── InventorGeneralDimension.cs │ ├── InventorLinearGeneralDim.cs │ └── OrdinateDims │ │ ├── InventorDiameterDimension.cs │ │ ├── InventorOrdinateDimension.cs │ │ └── InventorOrdinateDimensionSet.cs ├── DrawingSheet │ ├── InventorBorder.cs │ ├── InventorPartsList.cs │ ├── InventorSheet.cs │ ├── InventorSketchSymbol.cs │ ├── InventorTable.cs │ ├── InventorTitleBlock.cs │ └── Style │ │ ├── InventorColor.cs │ │ ├── InventorTableStyle.cs │ │ └── InventorTextStyle.cs ├── Enums │ ├── CurveTypes.cs │ ├── InventorCenterLineType.cs │ ├── InventorColorSourceTypeEnum.cs │ ├── InventorDimensionType.cs │ ├── InventorDrawingSheetSizeEnum.cs │ ├── InventorDrawingViewStyle.cs │ ├── InventorDrawingViewType.cs │ ├── InventorHeaderPlacementEnum.cs │ ├── InventorHorizontalTextAlignment.cs │ ├── InventorLineSpacingEnum.cs │ ├── InventorPartsListLevelEnum.cs │ ├── InventorStyleTypeEnum.cs │ ├── InventorTableDirectionEnum.cs │ ├── InventorTextLineSpacingTypeEnum.cs │ ├── InventorTitleBlockLocationEnum.cs │ ├── InventorVerticalTextAlignmentEnum.cs │ ├── InventorViewOrientaionType.cs │ ├── PointType.cs │ ├── ProjectedViewDirection.cs │ ├── RotationEnum.cs │ ├── ShiftDirection.cs │ └── ViewSide.cs ├── Helpers │ ├── DTO │ │ └── InventorTableDto.cs │ └── DrawingViewPlacement.cs ├── Interfaces │ ├── IMajorPoints.cs │ └── IlocationEntity.cs └── View │ ├── InventorDetailDrawingView.cs │ ├── InventorDrawingViewLabel.cs │ ├── InventorSectionDrawingView.cs │ └── InventorView.cs ├── Enums └── InventorObjectTypes.cs ├── Extensions ├── ComponentOccurenceExtensions.cs └── Curves │ ├── CurveExtension.cs │ └── GeometryPointExtensions.cs ├── Features ├── FeatureTypes.cs ├── InventorFace.cs ├── InventorFeature.cs └── InventorHoleFeature.cs ├── General ├── AngularUnits.cs ├── DefaultOptions.cs ├── LengthUnits.cs ├── UnitManager.cs └── UnitTypes.cs ├── Geometry ├── InventorProxy.cs ├── InventorWorkAxes.cs └── InventorWorkPlanes.cs ├── Helpers └── EnumHelpers.cs ├── IProps ├── InventorProperties.cs ├── InventorPropertyTypeEnum.cs └── IpropertyEnum.cs ├── InventorWrapper.csproj ├── InventorWrapper.nuspec ├── InventorWrapper.sln ├── Parameters ├── InventorParameter.cs └── InventorParameters.cs ├── Patterns ├── InventorPattern.cs └── InventorPatterns.cs ├── Project ├── InventorDesignProject.cs ├── InventorDesignProjectManager.cs └── InventorProjectPath.cs ├── Properties └── AssemblyInfo.cs ├── Representation └── InventorRepresentationManager.cs └── lib ├── Autodesk.Inventor.Interop.dll └── References └── Autodesk.Inventor.Interop.dll /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /BOM/InventorBom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Web; 6 | using Inventor; 7 | 8 | namespace InventorWrapper.BOM 9 | { 10 | /// 11 | /// Inventor document 12 | /// 13 | public class InventorBom : IDisposable 14 | { 15 | private Inventor.BOM _bom; 16 | 17 | private Inventor.BOMView _view; 18 | 19 | private IEnumerable _viewNames; 20 | 21 | public InventorBom(Inventor.BOM bom) 22 | { 23 | _bom = bom; 24 | } 25 | 26 | /// 27 | /// Collection of the views for the bill 28 | /// 29 | public IEnumerable Views 30 | { 31 | get 32 | { 33 | if (_viewNames == null) 34 | { 35 | _viewNames = (from BOMView b in _bom.BOMViews select (b.Name)); 36 | } 37 | 38 | return _viewNames; 39 | } 40 | } 41 | 42 | /// 43 | /// Delimter for bill. 44 | /// 45 | public string StructuredViewDelimiter 46 | { 47 | get => _bom.StructuredViewDelimiter; 48 | set => _bom.StructuredViewDelimiter = value; 49 | } 50 | 51 | /// 52 | /// If the structured view of bill should only be the top level components 53 | /// 54 | public bool StructureViewFirstLevelOnly 55 | { 56 | get => _bom.StructuredViewFirstLevelOnly; 57 | set => _bom.StructuredViewFirstLevelOnly = value; 58 | } 59 | 60 | /// 61 | /// Gets and sets the if structure view is enabled 62 | /// 63 | public bool StructuredViewEnabled 64 | { 65 | get => _bom.StructuredViewEnabled; 66 | set => _bom.StructuredViewEnabled = value; 67 | } 68 | 69 | /// 70 | /// Gets and sets the if part view is enabled 71 | /// 72 | public bool PartsOnlyViewEnabled 73 | { 74 | get => _bom.PartsOnlyViewEnabled; 75 | set => _bom.PartsOnlyViewEnabled = value; 76 | } 77 | 78 | /// 79 | /// Sets the active view 80 | /// 81 | public string View 82 | { 83 | get => _view.Name; 84 | set => _view = _bom.BOMViews[value]; 85 | } 86 | 87 | /// 88 | /// Gets all the bill items in the active assembly 89 | /// 90 | /// 91 | public List GetBill() 92 | { 93 | var tempList = new List(); 94 | 95 | foreach (BOMRow row in _view.BOMRows) 96 | { 97 | var bomItem = new InventorBomItem(row); 98 | 99 | if (row.ChildRows != null && row.ChildRows.Count > 0) 100 | { 101 | GetChildren(row.ChildRows, bomItem); 102 | } 103 | 104 | tempList.Add(bomItem); 105 | } 106 | 107 | return tempList; 108 | } 109 | 110 | private void GetChildren(BOMRowsEnumerator rows, InventorBomItem parent) 111 | { 112 | foreach (BOMRow row in rows) 113 | { 114 | var bomItem = new InventorBomItem(row); 115 | 116 | parent.Children.Add(bomItem); 117 | 118 | if (row.ChildRows != null && row.ChildRows.Count > 0) 119 | { 120 | GetChildren(row.ChildRows, bomItem); 121 | } 122 | } 123 | } 124 | 125 | public void Dispose() 126 | { 127 | if (_bom == null) return; 128 | Marshal.ReleaseComObject(_bom); 129 | _bom = null; 130 | } 131 | } 132 | } -------------------------------------------------------------------------------- /BOM/InventorBomHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using InventorWrapper.Documents; 7 | 8 | namespace InventorWrapper.BOM 9 | { 10 | public static class InventorBomHelpers 11 | { 12 | public static List GetStructuredBill(InventorAssemblyDocument adoc) 13 | { 14 | // store the previous state of the level details 15 | var previousLevelOfDetail = adoc.RepresentationManager.ActiveLevelOfDetail; 16 | 17 | // Extract bill of materials from the master level detail custom details will cause issues 18 | adoc.RepresentationManager.ActivateLevelOfDetail("Master"); 19 | 20 | adoc.Bom.StructuredViewEnabled = true; 21 | adoc.Bom.StructureViewFirstLevelOnly = false; 22 | adoc.Bom.View = "Structured"; 23 | 24 | var bomItems = adoc.Bom.GetBill(); 25 | 26 | // Set the previous detail back after finishing 27 | adoc.RepresentationManager.ActivateLevelOfDetail(previousLevelOfDetail); 28 | 29 | return bomItems; 30 | } 31 | 32 | public static List GetFlatBill(InventorAssemblyDocument adoc) 33 | { 34 | // store the previous state of the level details 35 | var previousLevelOfDetail = adoc.RepresentationManager.ActiveLevelOfDetail; 36 | 37 | // Extract bill of materials from the master level detail custom details will cause issues 38 | adoc.RepresentationManager.ActivateLevelOfDetail("Master"); 39 | 40 | adoc.Bom.PartsOnlyViewEnabled = true; 41 | adoc.Bom.View = "Parts Only"; 42 | 43 | var bomItems = adoc.Bom.GetBill(); 44 | 45 | // Set the previous detail back after finishing 46 | adoc.RepresentationManager.ActivateLevelOfDetail(previousLevelOfDetail); 47 | 48 | return bomItems; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /BOM/InventorBomItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using Inventor; 5 | using InventorWrapper.Documents; 6 | 7 | namespace InventorWrapper.BOM 8 | { 9 | /// 10 | /// Single row of the bill material 11 | /// 12 | public class InventorBomItem : IDisposable 13 | { 14 | private BOMRow _row; 15 | 16 | private InventorDocument _document; 17 | 18 | public InventorBomItem(BOMRow row) 19 | { 20 | _row = row; 21 | Children = new List(); 22 | } 23 | 24 | /// 25 | /// Document reference for the bom item 26 | /// 27 | public InventorDocument Document 28 | { 29 | get 30 | { 31 | if (_document == null) 32 | { 33 | _document = new InventorDocument(_row.ComponentDefinitions[1].Document as Document); 34 | } 35 | 36 | return _document; 37 | } 38 | } 39 | 40 | /// 41 | /// Children of the bom item 42 | /// 43 | public List Children { get; set; } 44 | 45 | /// 46 | /// Qty of items for the bill 47 | /// 48 | public int Qty => _row.ItemQuantity; 49 | 50 | public void Dispose() 51 | { 52 | if (_row != null) 53 | { 54 | Marshal.ReleaseComObject(_row); 55 | _row = null; 56 | } 57 | 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/DimensionCaptureDto.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.CaptureDto.DrawingCapture.Enums; 2 | using InventorWrapper.Drawings; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections.ObjectModel; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace InventorWrapper.CaptureDto.DrawingCapture 11 | { 12 | public class DimensionCaptureDto 13 | { 14 | public Guid Id { get; set; } 15 | 16 | public Guid ViewId { get; set; } 17 | 18 | public string Name { get; set; } 19 | 20 | public ObservableCollection Points { get; set; } 21 | 22 | public DimensionTypeEnum Type { get; set; } 23 | 24 | public DimensionDirectionEnum Direction { get; set; } 25 | 26 | public PointCaptureDto AddPoint() 27 | { 28 | var p = new PointCaptureDto(); 29 | 30 | p.DimensionId = Id; 31 | 32 | Points.Add(p); 33 | 34 | return p; 35 | } 36 | 37 | public DimensionCaptureDto() 38 | { 39 | Name = "Enter Name"; 40 | 41 | Id = Guid.NewGuid(); 42 | 43 | Points = new ObservableCollection(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/DrawingCaptureDto.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Documents; 3 | using InventorWrapper.Drawings; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.ObjectModel; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.CaptureDto.DrawingCapture 12 | { 13 | public class DrawingCaptureDto 14 | { 15 | public Guid Id { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public string FileName { get; set; } 20 | 21 | public void AddSheet(InventorSheet inventorSheet) 22 | { 23 | var newSheet = new SheetCaptureDto(inventorSheet); 24 | 25 | newSheet.DrawingId = Id; 26 | 27 | Sheets.Add(newSheet); 28 | } 29 | 30 | public ObservableCollection Sheets { get; set; } 31 | 32 | public DrawingCaptureDto() 33 | { 34 | Sheets = new ObservableCollection(); 35 | } 36 | 37 | public DrawingCaptureDto(InventorDrawingDocument inventorDrawing) 38 | { 39 | Sheets = new ObservableCollection(); 40 | 41 | Id = Guid.NewGuid(); 42 | 43 | Name = inventorDrawing.Name; 44 | FileName = inventorDrawing.FileName; 45 | 46 | foreach (var s in inventorDrawing.Sheets) 47 | { 48 | Sheets.Add(new SheetCaptureDto(s)); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/Enums/DimensionDirectionEnum.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 InventorWrapper.CaptureDto.DrawingCapture.Enums 8 | { 9 | public enum DimensionDirectionEnum 10 | { 11 | Vertical, 12 | Horizontal 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/Enums/DimensionTypeEnum.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 InventorWrapper.CaptureDto.DrawingCapture.Enums 8 | { 9 | public enum DimensionTypeEnum 10 | { 11 | General, 12 | Ord 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/Enums/PointCaptureType.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 InventorWrapper.CaptureDto.DrawingCapture.Enums 8 | { 9 | public enum PointCaptureType 10 | { 11 | Single, 12 | Collection, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/Enums/PointLocationEnum.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 InventorWrapper.CaptureDto.DrawingCapture.Enums 8 | { 9 | public enum PointLocationEnum 10 | { 11 | MaxX, 12 | MaxY, 13 | MinX, 14 | MinY, 15 | Center, 16 | MiddleBottom, 17 | MiddleLeft, 18 | MiddleRight, 19 | MiddleTop, 20 | MaxXMinY, 21 | MinXMaxY, 22 | MaxXMaxY, 23 | MinXMinY, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/PointCaptureDto.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.CaptureDto.DrawingCapture.Enums; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.CaptureDto.DrawingCapture 9 | { 10 | public class PointCaptureDto 11 | { 12 | public Guid Id { get; set; } 13 | 14 | public Guid DimensionId { get; set; } 15 | 16 | public string Name { get; set; } 17 | 18 | public string OccurencePath { get; set; } 19 | 20 | /// 21 | /// If the we should capture a single point or all the matching points 22 | /// 23 | public PointCaptureType CaptureType { get; set; } 24 | 25 | public PointLocationEnum PointLocation { get; set; } 26 | 27 | public PointCaptureDto() 28 | { 29 | Name = "Enter Name"; 30 | Id = Guid.NewGuid(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/SheetCaptureDto.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.Drawings; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.CaptureDto.DrawingCapture 10 | { 11 | public class SheetCaptureDto 12 | { 13 | public Guid Id { get; set; } 14 | 15 | public Guid DrawingId { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public ObservableCollection Views { get; set; } 20 | 21 | public void AddDim(InventorView view) 22 | { 23 | var viewCap = new ViewCaptureDto(view); 24 | 25 | viewCap.SheetId = Id; 26 | 27 | Views.Add(viewCap); 28 | } 29 | 30 | public SheetCaptureDto() 31 | { 32 | Views = new ObservableCollection(); 33 | } 34 | 35 | public SheetCaptureDto(InventorSheet inventorSheet) 36 | { 37 | Views = new ObservableCollection(); 38 | Name = inventorSheet.Name; 39 | 40 | Guid.NewGuid(); 41 | 42 | foreach (var v in inventorSheet.Views) 43 | { 44 | Views.Add(new ViewCaptureDto(v)); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /CaptureDto/DrawingCapture/ViewCaptureDto.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.Drawings; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace InventorWrapper.CaptureDto.DrawingCapture 11 | { 12 | public class ViewCaptureDto 13 | { 14 | public Guid Id { get; set; } 15 | 16 | public Guid SheetId { get; set; } 17 | 18 | public string ReferencedFileName { get; set; } 19 | 20 | public bool Projected { get; set; } 21 | 22 | public string Name { get; set; } 23 | 24 | public double Scale { get; set; } 25 | 26 | public double X { get; set; } 27 | 28 | public double Y { get; set; } 29 | 30 | public ObservableCollection Dimensions { get; set; } 31 | 32 | public DimensionCaptureDto AddDim() 33 | { 34 | var dim = new DimensionCaptureDto(); 35 | 36 | dim.ViewId = Id; 37 | 38 | Dimensions.Add(dim); 39 | 40 | return dim; 41 | } 42 | 43 | public ViewCaptureDto() 44 | { 45 | Dimensions = new ObservableCollection(); 46 | } 47 | 48 | public ViewCaptureDto(InventorView view) 49 | { 50 | Dimensions = new ObservableCollection(); 51 | 52 | ReferencedFileName = view.Document.FileName; 53 | 54 | Name = view.Name; 55 | 56 | Projected = view._view.ParentView == null; 57 | 58 | Scale = view.Scale; 59 | 60 | X = view.Point.X; 61 | 62 | Y = view.Point.Y; 63 | 64 | Id = Guid.NewGuid(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /CaptureDto/Enums/FeatureCaptureType.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 InventorWrapper.CaptureDto.Enums 8 | { 9 | public enum FeatureCaptureType 10 | { 11 | Component, 12 | Constraint, 13 | Pattern, 14 | Feature 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CaptureDto/FeatureCaptureDto.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.CaptureDto.Enums; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.CaptureDto 9 | { 10 | public class FeatureCaptureDto 11 | { 12 | public object FeatureSource { get; set; } 13 | 14 | public string Name { get; set; } 15 | 16 | public FeatureCaptureType Type { get; set; } 17 | 18 | public bool Suppressed { get; set; } 19 | 20 | public FeatureCaptureDto(object feature, string name, FeatureCaptureType type, bool suppressed) 21 | { 22 | FeatureSource = feature; 23 | Name = name; 24 | Type = type; 25 | Suppressed = suppressed; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CaptureDto/ParameterCaptureDto.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 InventorWrapper.CaptureDto 8 | { 9 | public class ParameterCaptureDto 10 | { 11 | public string Name { get; set; } 12 | 13 | public bool User { get; set; } 14 | 15 | public dynamic Value { get; set; } 16 | 17 | public ParameterCaptureDto(string name, bool user, dynamic value) 18 | { 19 | Name = name; 20 | User = user; 21 | Value = value; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Components/InventorComponents.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Components.Options; 3 | using InventorWrapper.Documents; 4 | using InventorWrapper.General; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace InventorWrapper.Components 13 | { 14 | /// 15 | /// Collection of inventor component 16 | /// 17 | public class InventorComponents : List, IDisposable 18 | { 19 | private InventorAssemblyDocument _adoc; 20 | 21 | /// 22 | /// Sets the reference to the assembly document and if recursion is true will grab all the child occurrences of sub assemblies 23 | /// 24 | /// 25 | /// 26 | public InventorComponents(InventorAssemblyDocument adoc, bool recurse = false) 27 | { 28 | _adoc = adoc; 29 | 30 | GetComponents(_adoc._adef.Occurrences, recurse); 31 | } 32 | 33 | /// 34 | /// Tries to set the level of detail of every component in the assembly 35 | /// 36 | /// 37 | public void SetLevelOfDetailToAllComponents(string levelOfDetail) 38 | { 39 | foreach (var component in this) 40 | { 41 | if (component.Suppressed) continue; 42 | 43 | if (component.Document.RepresentationManager.GetLevelDetails().Any(x => x.Equals(levelOfDetail))) 44 | { 45 | component.LevelOfDetail = levelOfDetail; 46 | } 47 | } 48 | } 49 | 50 | /// 51 | /// Sets the status of component in the assembly by reference 52 | /// 53 | /// 54 | /// 55 | /// 56 | public void SetComponentStatus(string name, bool value) 57 | { 58 | try 59 | { 60 | ComponentOccurrence occ = _adoc._adef.Occurrences.ItemByName[name]; 61 | 62 | if (value) 63 | { 64 | occ.BOMStructure = BOMStructureEnum.kReferenceBOMStructure; 65 | occ.Suppress(); 66 | } 67 | else 68 | { 69 | occ.Unsuppress(); 70 | occ.BOMStructure = BOMStructureEnum.kDefaultBOMStructure; 71 | } 72 | } 73 | catch 74 | { 75 | throw new Exception("Could not find component " + name); 76 | } 77 | } 78 | 79 | /// 80 | /// Deletes the component by name 81 | /// 82 | /// 83 | /// 84 | public void DeleteComponent(string name) 85 | { 86 | var componentToRemove = this.FirstOrDefault(x => x.Name == name); 87 | 88 | if (componentToRemove == null) throw new Exception($"Could not find component {name} in document {_adoc.Name}"); 89 | 90 | componentToRemove.Delete(); 91 | 92 | componentToRemove.Dispose(); 93 | 94 | Remove(componentToRemove); 95 | 96 | } 97 | 98 | /// 99 | /// Deletes all components in the by document reference 100 | /// 101 | /// 102 | public void DeleteComponents(string name) 103 | { 104 | foreach (ComponentOccurrence c in _adoc._adef.Occurrences) 105 | { 106 | var suppressed = false; 107 | 108 | if (c.Suppressed) 109 | { 110 | suppressed = true; 111 | c.Unsuppress(); 112 | } 113 | 114 | if (System.IO.Path.GetFileNameWithoutExtension(((Document)c.Definition.Document).FullFileName) == name) 115 | { 116 | if (c.IsPatternElement) 117 | { 118 | // TODO Look into supporting pattern elements 119 | continue; 120 | } 121 | else 122 | { 123 | c.Delete(); 124 | } 125 | } 126 | else 127 | { 128 | if (suppressed) 129 | { 130 | c.Suppress(); 131 | } 132 | } 133 | } 134 | } 135 | 136 | /// 137 | /// Gets the status of component in the assembly 138 | /// 139 | /// 140 | /// 141 | /// 142 | public bool GetComponentStatus(string name) 143 | { 144 | try 145 | { 146 | ComponentOccurrence occ = _adoc._adef.Occurrences.ItemByName[name]; 147 | 148 | return occ.Suppressed; 149 | } 150 | catch 151 | { 152 | throw new Exception("Could not find component " + name); 153 | } 154 | } 155 | 156 | /// 157 | /// Gets all the components in the active assembly 158 | /// 159 | /// 160 | /// 161 | public void GetComponents(ComponentOccurrences occurrences, bool recurse) 162 | { 163 | foreach (ComponentOccurrence c in occurrences) 164 | { 165 | var component = new InventorComponent(c); 166 | 167 | Add(new InventorComponent(c)); 168 | 169 | if (component.Suppressed) continue; 170 | 171 | if (recurse) 172 | { 173 | if (c.Definition.Type == ObjectTypeEnum.kAssemblyComponentDefinitionObject || c.Definition.Type == ObjectTypeEnum.kWeldmentComponentDefinitionObject) 174 | { 175 | var subOccurences = c.SubOccurrences as ComponentOccurrences; 176 | 177 | GetComponents(subOccurences, recurse); 178 | } 179 | } 180 | } 181 | } 182 | 183 | /// 184 | /// Place component in assembly 185 | /// 186 | /// Path to source file to place 187 | /// Option include representaion and level of detail. Default options are provided in Default options class 188 | /// 189 | /// 190 | /// 191 | /// 192 | public InventorComponent PlaceComponentWithOptions(string fileName, 193 | List options, 194 | double x = 0, 195 | double y = 0, 196 | double z = 0 197 | ) 198 | { 199 | TransientGeometry transientGeometry = InventorApplication.GetTransientGeometry(); 200 | Matrix matrix = transientGeometry.CreateMatrix(); 201 | NameValueMap objectNameMapOptions = InventorApplication.GetTransientObjects().CreateNameValueMap(); 202 | foreach (var option in options) 203 | { 204 | objectNameMapOptions.Add(option.Name, option.Value); 205 | } 206 | 207 | matrix.SetTranslation(transientGeometry.CreateVector(x, y, z)); 208 | var occurence = _adoc._adef.Occurrences.AddWithOptions(fileName, matrix, objectNameMapOptions); 209 | 210 | var component = new InventorComponent(occurence); 211 | 212 | Add(component); 213 | 214 | Marshal.ReleaseComObject(transientGeometry); 215 | Marshal.ReleaseComObject(matrix); 216 | Marshal.ReleaseComObject(objectNameMapOptions); 217 | 218 | return component; 219 | } 220 | 221 | /// 222 | /// Places a component in the active assembly 223 | /// 224 | /// Path to source file to place 225 | /// 226 | /// 227 | /// 228 | /// 229 | public InventorComponent PlaceComponent(string fileName, 230 | double x = 0, 231 | double y = 0, 232 | double z = 0 233 | ) 234 | { 235 | TransientGeometry transientGeometry = InventorApplication.GetTransientGeometry(); 236 | Matrix matrix = transientGeometry.CreateMatrix(); 237 | 238 | matrix.SetTranslation(transientGeometry.CreateVector(x, y, z)); 239 | var occurence = _adoc._adef.Occurrences.Add(fileName, matrix); 240 | 241 | var component = new InventorComponent(occurence); 242 | 243 | Add(component); 244 | 245 | Marshal.ReleaseComObject(transientGeometry); 246 | Marshal.ReleaseComObject(matrix); 247 | 248 | return component; 249 | } 250 | 251 | 252 | public void Dispose() 253 | { 254 | if (Count > 0) 255 | { 256 | foreach (var c in this) 257 | { 258 | if (c != null) 259 | { 260 | c.Dispose(); 261 | } 262 | } 263 | } 264 | } 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /Components/Options/InventorNameValueMapOptions.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 InventorWrapper.Components.Options 8 | { 9 | public class InventorNameValueMapOptions 10 | { 11 | public InventorNameValueMapOptions(string name, object value) 12 | { 13 | Name = name; 14 | Value = value; 15 | } 16 | 17 | public string Name { get; set; } 18 | 19 | public object Value { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Constants/InventorApplicationAddInIds.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Constants 2 | { 3 | public class InventorApplicationAddInIds 4 | { 5 | public const string PDF = "{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}"; 6 | 7 | public const string STEP = "{90AF7F40-0C01-11D5-8E83-0010B541CD80}"; 8 | 9 | public const string DXF = "{C24E3AC4-122E-11D5-8E91-0010B541CD80}"; 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Constraints/InventorConstraintType.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 InventorWrapper.Constraints 8 | { 9 | public enum InventorConstraintType 10 | { 11 | Mate, 12 | Flush 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Constraints/InventorConstraints.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Documents; 3 | using InventorWrapper.Geometry; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Data; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.Constraints 12 | { 13 | /// 14 | /// Manages assembly constraints and statuses 15 | /// 16 | public class InventorConstraints 17 | { 18 | private InventorAssemblyDocument _adoc; 19 | 20 | private List _constraintNames; 21 | 22 | public InventorConstraints(InventorAssemblyDocument adoc) 23 | { 24 | _adoc = adoc; 25 | } 26 | 27 | public void AddMateConstraint(InventorProxy proxyOne, InventorProxy proxyTwo, double offset) 28 | { 29 | _adoc._adef.Constraints.AddMateConstraint(proxyOne._reference, proxyTwo._reference, offset); 30 | } 31 | 32 | public void AddMateConstraint(InventorWorkPlane plane, InventorProxy proxyTwo, double offset) 33 | { 34 | _adoc._adef.Constraints.AddMateConstraint(plane._workPlane, proxyTwo._reference, offset); 35 | } 36 | 37 | public void AddFlushConstraint(InventorWorkPlane plane, InventorProxy proxyTwo, double offset) 38 | { 39 | _adoc._adef.Constraints.AddFlushConstraint(plane._workPlane, proxyTwo._reference, offset); 40 | } 41 | 42 | public void AddFlushConstraint(InventorProxy proxyOne, InventorProxy proxyTwo, double offset) 43 | { 44 | _adoc._adef.Constraints.AddFlushConstraint(proxyOne._reference, proxyTwo._reference, offset); 45 | } 46 | 47 | public void Delete(string name) 48 | { 49 | try 50 | { 51 | _adoc._adef.Constraints[name].Delete(); 52 | } 53 | catch (Exception ex) 54 | { 55 | throw new Exception($"Could not delete constraint {name}", ex); 56 | } 57 | } 58 | 59 | public void DeleteAll() 60 | { 61 | foreach (AssemblyConstraint constraint in _adoc._adef.Constraints) 62 | { 63 | constraint.Delete(); 64 | } 65 | } 66 | 67 | /// 68 | /// Sets the status of named constraint 69 | /// 70 | /// 71 | /// 72 | /// 73 | public bool SetConstraintStatus(string name, bool status) 74 | { 75 | var value = false; 76 | 77 | foreach (AssemblyConstraint c in _adoc._adef.Constraints) 78 | { 79 | if (c.Name == name) 80 | { 81 | c.Suppressed = status; 82 | value = true; 83 | break; 84 | } 85 | } 86 | 87 | return value; 88 | } 89 | 90 | /// 91 | /// Gets a list of all the constraints 92 | /// 93 | public List ConstraintNames 94 | { 95 | get 96 | { 97 | if (_constraintNames == null) 98 | { 99 | _constraintNames = new List(); 100 | 101 | foreach (AssemblyConstraint c in _adoc._adef.Constraints) 102 | { 103 | _constraintNames.Add(c.Name); 104 | } 105 | } 106 | 107 | return _constraintNames; 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /CopyTools/CopyHelpers.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Documents; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.CopyTools 10 | { 11 | /// 12 | /// Methods for simplifying copy inventor assembly models 13 | /// 14 | public class CopyHelpers 15 | { 16 | /// 17 | /// Replace the references in the document 18 | /// 19 | /// 20 | /// 21 | /// 22 | public static void ReplaceReferences(InventorDocument document, List referenceData, List skip = null) 23 | { 24 | Recurse(document._document.File.ReferencedFileDescriptors, referenceData); 25 | } 26 | 27 | /// 28 | /// Recursive method that will replace all the references 29 | /// In the assembly document and all the child assembly documents 30 | /// 31 | /// 32 | /// 33 | /// 34 | private static void Recurse(FileDescriptorsEnumerator refs, List referenceData, List skip = null) 35 | { 36 | // Loop through the references in the document 37 | foreach (FileDescriptor r in refs) 38 | { 39 | // get the full path of the file 40 | var path = r.FullFileName; 41 | 42 | // If any of the files are in skip then continue 43 | if (skip != null && skip.Count > 0) 44 | { 45 | if (skip.Any(x => r.FullFileName.ToUpper().Contains(x.ToUpper()))) 46 | { 47 | continue; 48 | } 49 | } 50 | 51 | // Get the file name that matches the file ref 52 | var refPath = referenceData.FirstOrDefault(x => x.OriginalReference.ToUpper() == path.ToUpper()); 53 | 54 | // if not found then continue 55 | if (refPath == null) continue; 56 | 57 | // Replace the reference with item 2 58 | r.ReplaceReference(refPath.NewReference); 59 | 60 | // If the document is an assembly document 61 | if (r.ReferencedFileType == FileTypeEnum.kAssemblyFileType) 62 | { 63 | // Get the reference file 64 | Inventor.File file = r.ReferencedFile; 65 | 66 | // Recurse through the sub assembly files 67 | Recurse(file.ReferencedFileDescriptors, referenceData, skip); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /CopyTools/ReferenceDto.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.CopyTools 2 | { 3 | /// 4 | /// Data for tracking references 5 | /// 6 | public class ReferenceDto 7 | { 8 | /// 9 | /// Original file path 10 | /// 11 | public string OriginalReference { get; set; } 12 | 13 | /// 14 | /// New file path 15 | /// 16 | public string NewReference { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Documents/DocumentHelper.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 InventorWrapper.Documents 8 | { 9 | /// 10 | /// Helps retrieve documents from the active document 11 | /// 12 | public class DocumentHelper 13 | { 14 | /// 15 | /// Finds a document in the active assembly 16 | /// 17 | /// 18 | /// 19 | public static InventorDocument GetDocument(string name) 20 | { 21 | // Set an initial value to return 22 | InventorDocument documentToReturn = null; 23 | 24 | if (InventorApplication.ActiveDocument == null) 25 | { 26 | throw new Exception("Must have an open document"); 27 | } 28 | 29 | // if an assembly document then parse the document 30 | if (InventorApplication.ActiveDocument.IsAssemblyDoc) 31 | { 32 | var adoc = InventorApplication.ActiveDocument.GetAssemblyDocument(); 33 | 34 | // if the active document matches the name then return the active 35 | if (name == System.IO.Path.GetFileNameWithoutExtension(adoc.Name)) 36 | { 37 | documentToReturn = InventorApplication.ActiveDocument; 38 | } 39 | else 40 | { 41 | // Search the document in the referenced documents within the assembly 42 | documentToReturn = adoc.GetReferencedDocument(name); 43 | } 44 | } 45 | // if it is a part doc then return the active document 46 | else if (InventorApplication.ActiveDocument.IsPartDoc) 47 | { 48 | documentToReturn = InventorApplication.ActiveDocument; 49 | } 50 | 51 | return documentToReturn; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Documents/InventorAssemblyDocument.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Components; 3 | using InventorWrapper.Constraints; 4 | using InventorWrapper.Parameters; 5 | using InventorWrapper.Patterns; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using InventorWrapper.BOM; 12 | using InventorWrapper.Geometry; 13 | 14 | namespace InventorWrapper.Documents 15 | { 16 | /// 17 | /// Inventor Assembly document 18 | /// 19 | public class InventorAssemblyDocument : InventorDocument 20 | { 21 | 22 | private List _referencedDocuments; 23 | 24 | private List _children; 25 | 26 | private InventorPatterns _inventorPatterns; 27 | 28 | private InventorWorkPlanes _inventorWorkPlanes; 29 | 30 | private InventorWorkAxes _inventorWorkAxes; 31 | 32 | private InventorComponents _components; 33 | 34 | private InventorConstraints _constraints; 35 | 36 | private InventorBom _bom; 37 | 38 | /// 39 | /// Backing interop object for the assembly object 40 | /// 41 | public AssemblyDocument _adoc; 42 | 43 | /// 44 | /// Component definition for the assembly document 45 | /// 46 | public AssemblyComponentDefinition _adef; 47 | 48 | /// 49 | /// When components are retreived should all be retreived 50 | /// 51 | public bool AllChildComponents { get; set; } 52 | 53 | /// 54 | /// Casts the source document as an assembly document, assembly component definition, and setup the features 55 | /// 56 | /// 57 | public InventorAssemblyDocument(Document document, bool allChildren = false) : base(document) 58 | { 59 | AllChildComponents = allChildren; 60 | 61 | _adoc = document as AssemblyDocument; 62 | 63 | _adef = _adoc.ComponentDefinition; 64 | 65 | var f = _adef.Features; 66 | } 67 | 68 | /// 69 | /// Gets all the documents that the assembly document references 70 | /// 71 | public List ReferencedDocuments 72 | { 73 | get 74 | { 75 | if (_referencedDocuments == null) 76 | { 77 | _referencedDocuments = new List(); 78 | 79 | foreach (Document doc in _adoc.AllReferencedDocuments) 80 | { 81 | _referencedDocuments.Add(new InventorDocument(doc)); 82 | } 83 | } 84 | 85 | return _referencedDocuments; 86 | } 87 | } 88 | 89 | /// 90 | /// Gets the documents immediate children 91 | /// 92 | public List ChildDocuments 93 | { 94 | get 95 | { 96 | if (_children == null) 97 | { 98 | _children = new List(); 99 | 100 | foreach (Document doc in _adoc.ReferencedDocuments) 101 | { 102 | _children.Add(new InventorDocument(doc)); 103 | } 104 | } 105 | 106 | return _children; 107 | } 108 | } 109 | 110 | public InventorWorkPlanes WorkPlanes 111 | { 112 | get 113 | { 114 | if (_inventorWorkPlanes == null) 115 | { 116 | _inventorWorkPlanes = new InventorWorkPlanes(_adef); 117 | } 118 | 119 | return _inventorWorkPlanes; 120 | } 121 | } 122 | 123 | public InventorWorkAxes WorkAxes 124 | { 125 | get 126 | { 127 | if (_inventorWorkAxes == null) 128 | { 129 | _inventorWorkAxes = new InventorWorkAxes(_adef); 130 | } 131 | 132 | return _inventorWorkAxes; 133 | } 134 | } 135 | 136 | 137 | /// 138 | /// Gets all the component patterns in the assembly 139 | /// 140 | public InventorPatterns Patterns 141 | { 142 | get 143 | { 144 | if (_inventorPatterns == null) 145 | { 146 | _inventorPatterns = new InventorPatterns(this); 147 | } 148 | 149 | return _inventorPatterns; 150 | } 151 | } 152 | 153 | /// 154 | /// Gets all the component occurrences in the assembly 155 | /// 156 | public InventorComponents Components 157 | { 158 | get 159 | { 160 | if (_components == null) 161 | { 162 | _components = new InventorComponents(this, AllChildComponents); 163 | } 164 | 165 | return _components; 166 | } 167 | } 168 | 169 | /// 170 | /// Gets all the constraints active assembly 171 | /// 172 | public InventorConstraints Constraints 173 | { 174 | get 175 | { 176 | if (_constraints == null) 177 | { 178 | _constraints = new InventorConstraints(this); 179 | } 180 | 181 | return _constraints; 182 | } 183 | } 184 | 185 | /// 186 | /// Searches the assembly for the referenced document 187 | /// 188 | /// 189 | /// 190 | public InventorDocument GetReferencedDocument(string name) 191 | { 192 | InventorDocument tempdoc = null; 193 | 194 | foreach (Document doc in _adoc.AllReferencedDocuments) 195 | { 196 | if (System.IO.Path.GetFileNameWithoutExtension(doc.FullFileName) == name) 197 | { 198 | tempdoc = new InventorDocument(doc); 199 | 200 | break; 201 | } 202 | } 203 | 204 | return tempdoc; 205 | } 206 | 207 | /// 208 | /// Gets the bill of material from the assembly 209 | /// 210 | public InventorBom Bom 211 | { 212 | get 213 | { 214 | if (_bom == null) 215 | { 216 | _bom = new InventorBom(this._adef.BOM); 217 | } 218 | 219 | return _bom; 220 | } 221 | } 222 | 223 | public override void Dispose() 224 | { 225 | if (_referencedDocuments != null) 226 | { 227 | foreach (var d in _referencedDocuments) 228 | { 229 | d.Dispose(); 230 | } 231 | } 232 | 233 | if (Components != null) 234 | { 235 | Components.Dispose(); 236 | } 237 | 238 | if (Bom != null) 239 | { 240 | Components.Dispose(); 241 | } 242 | 243 | 244 | 245 | base.Dispose(); 246 | } 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /Documents/InventorDocumentType.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 InventorWrapper.Documents 8 | { 9 | public enum InventorDocumentType 10 | { 11 | Unknown = 12289, 12 | Part = 12290, 13 | Assembly = 12291, 14 | Drawing = 12292, 15 | Presentation = 12293, 16 | DesignElement = 12294, 17 | ForeignModel = 12295, 18 | SATFile = 12296, 19 | No = 12297, 20 | NestingDocument = 12298 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Documents/InventorDrawingDocument.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings; 3 | using InventorWrapper.Drawings.Curves; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using InventorWrapper.Components.Options; 10 | using InventorWrapper.Constants; 11 | using InventorWrapper.Drawings.Enums; 12 | 13 | namespace InventorWrapper.Documents 14 | { 15 | /// 16 | /// Inventor Drawing document 17 | /// 18 | public class InventorDrawingDocument : InventorDocument 19 | { 20 | /// 21 | /// Reference to the interop drawing document 22 | /// 23 | private DrawingDocument _drawing; 24 | 25 | /// 26 | /// Sheets for the active document 27 | /// 28 | public List Sheets { get; set; } 29 | 30 | /// 31 | /// Sets up the drawing document and gets the sheets 32 | /// 33 | /// 34 | public InventorDrawingDocument(Document doc) : base(doc) 35 | { 36 | _drawing = (DrawingDocument)doc; 37 | Sheets = new List(); 38 | 39 | GetSheets(); 40 | } 41 | 42 | /// 43 | /// Gets the sheets from the active document 44 | /// 45 | private void GetSheets() 46 | { 47 | foreach (Sheet s in _drawing.Sheets) 48 | { 49 | Sheets.Add(new InventorSheet(s)); 50 | } 51 | } 52 | 53 | /// 54 | /// Adds new sheet to the drawing with option to add title block 55 | /// 56 | /// Choose a standard sheet size or a custom one 57 | /// Optional parameter to add the default border 58 | /// Optional parameter to add the title block if true title block name must be set 59 | /// Optional parameter name of the title block to add 60 | /// 61 | public InventorSheet AddSheet(InventorDrawingSheetSizeEnum drawingSheetSize = InventorDrawingSheetSizeEnum.kDefaultDrawingSheetSize, bool addDefaultBorder = true, bool addTitleBlock = false, string titleBlockName = "") 62 | { 63 | var sheet = new InventorSheet(_drawing.Sheets.Add((DrawingSheetSizeEnum)drawingSheetSize)); 64 | 65 | if (addDefaultBorder) sheet.AddBorder(); 66 | 67 | if (addTitleBlock) 68 | { 69 | sheet.AddTitleBlock(titleBlockName); 70 | } 71 | 72 | return sheet; 73 | } 74 | 75 | public InventorSheet ActiveSheet => new InventorSheet(_drawing.ActiveSheet); 76 | 77 | public void ExportPdfWithOptions(string location, IEnumerable options) 78 | { 79 | TranslatorAddIn pdfAddin = (TranslatorAddIn)InventorApplication._inventor.ApplicationAddIns.ItemById[InventorApplicationAddInIds.PDF]; 80 | 81 | var context = InventorApplication._inventor.TransientObjects.CreateTranslationContext(); 82 | 83 | context.Type = IOMechanismEnum.kFileBrowseIOMechanism; 84 | 85 | var nameValueMap = InventorApplication._inventor.TransientObjects.CreateNameValueMap(); 86 | 87 | var dataMedium = InventorApplication._inventor.TransientObjects.CreateDataMedium(); 88 | 89 | if (pdfAddin.HasSaveCopyAsOptions[_document, context, nameValueMap]) 90 | { 91 | foreach (var option in options) 92 | { 93 | nameValueMap.Value[option.Name] = option.Value; 94 | } 95 | } 96 | 97 | dataMedium.FileName = System.IO.Path.ChangeExtension(location, ".pdf"); 98 | 99 | pdfAddin.SaveCopyAs(_document, context, nameValueMap, dataMedium); 100 | 101 | } 102 | 103 | /// 104 | /// Export pdf with some default settings 105 | /// 106 | /// Default setttings applied with this config 107 | /// nameValueMap.Value["All_Color_AS_BLACK"] = 0; 108 | /// nameValueMap.Value["Remove_Line_Weights"] = 0; 109 | /// nameValueMap.Value["Vector_Resolution"] = 4800; 110 | /// nameValueMap.Value["Sheet_Range"] = PrintRangeEnum.kPrintAllSheets; 111 | /// 112 | public void ExportPdfDefaultSettings(string location) 113 | { 114 | TranslatorAddIn pdfAddin = (TranslatorAddIn)InventorApplication._inventor.ApplicationAddIns.ItemById[InventorApplicationAddInIds.PDF]; 115 | 116 | var context = InventorApplication._inventor.TransientObjects.CreateTranslationContext(); 117 | 118 | context.Type = IOMechanismEnum.kFileBrowseIOMechanism; 119 | 120 | var nameValueMap = InventorApplication._inventor.TransientObjects.CreateNameValueMap(); 121 | 122 | var dataMedium = InventorApplication._inventor.TransientObjects.CreateDataMedium(); 123 | 124 | if (pdfAddin.HasSaveCopyAsOptions[_document, context, nameValueMap]) 125 | { 126 | nameValueMap.Value["All_Color_AS_BLACK"] = 0; 127 | nameValueMap.Value["Remove_Line_Weights"] = 0; 128 | nameValueMap.Value["Vector_Resolution"] = 4800; 129 | nameValueMap.Value["Sheet_Range"] = PrintRangeEnum.kPrintAllSheets; 130 | } 131 | 132 | dataMedium.FileName = System.IO.Path.ChangeExtension(location, ".pdf"); 133 | 134 | pdfAddin.SaveCopyAs(_document, context, nameValueMap, dataMedium); 135 | } 136 | 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Documents/InventorPartDocument.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Geometry; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices.ComTypes; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace InventorWrapper.Documents 11 | { 12 | /// 13 | /// Part document for inventor 14 | /// 15 | public class InventorPartDocument : InventorDocument 16 | { 17 | private InventorWorkPlanes _inventorWorkPlanes; 18 | 19 | private InventorWorkAxes _inventorWorkAxes; 20 | 21 | /// 22 | /// Reference to the interop part document 23 | /// 24 | public PartDocument _partDoc; 25 | 26 | /// 27 | /// Component definition for the part document 28 | /// 29 | public PartComponentDefinition _partDef; 30 | 31 | public InventorWorkPlanes WorkPlanes 32 | { 33 | get 34 | { 35 | if (_inventorWorkPlanes == null) 36 | { 37 | _inventorWorkPlanes = new InventorWorkPlanes(_partDef); 38 | } 39 | 40 | return _inventorWorkPlanes; 41 | } 42 | } 43 | 44 | public InventorWorkAxes WorkAxes 45 | { 46 | get 47 | { 48 | if (_inventorWorkAxes == null) 49 | { 50 | _inventorWorkAxes = new InventorWorkAxes(_partDef); 51 | } 52 | 53 | return _inventorWorkAxes; 54 | } 55 | } 56 | 57 | public InventorPartDocument(Document doc) : base(doc) 58 | { 59 | _partDoc = doc as PartDocument; 60 | _partDef = _partDoc.ComponentDefinition; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Drawings/Annotations/InventorCenterLine.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings.Curves; 3 | using InventorWrapper.Drawings.Enums; 4 | using InventorWrapper.Enums; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace InventorWrapper.Drawings.Annotations 13 | { 14 | public class InventorCenterLine : IDisposable 15 | { 16 | public Centerline _centerLine; 17 | 18 | public Sheet _sheet; 19 | 20 | public InventorCenterLine(Centerline centerLine, Sheet sheet) 21 | { 22 | _centerLine = centerLine; 23 | _sheet = sheet; 24 | } 25 | 26 | public bool Attached => _centerLine.Attached; 27 | 28 | public List Points => new List { StartPoint, EndPoint }; 29 | 30 | public InventorCenterLineType CenterLineType => (InventorCenterLineType)_centerLine.CenterlineType; 31 | 32 | public GeometryPoint EndPoint 33 | { 34 | get => new GeometryPoint(_centerLine.EndPoint, this, PointType.EndPoint); 35 | set => _centerLine.EndPoint = value.CreatePoint(); 36 | } 37 | 38 | public void SetEndPoint(double x, double y) 39 | { 40 | _centerLine.EndPoint = new Curves.Point(x, y).CreatePoint(); 41 | } 42 | 43 | public CurveTypes GeometryType => (CurveTypes)_centerLine.GeometryType; 44 | 45 | public GeometryPoint StartPoint 46 | { 47 | get => new GeometryPoint(_centerLine.StartPoint, this, PointType.EndPoint); 48 | set => _centerLine.StartPoint = value.CreatePoint(); 49 | } 50 | 51 | public void SetStartPoint(double x, double y) 52 | { 53 | _centerLine.StartPoint = new Curves.Point(x, y).CreatePoint(); 54 | } 55 | 56 | public InventorObjectTypes Type => (InventorObjectTypes)_centerLine.Type; 57 | 58 | public bool Visible 59 | { 60 | get => _centerLine.Visible; 61 | set => _centerLine.Visible = value; 62 | } 63 | 64 | public void Delete() => _centerLine.Delete(); 65 | 66 | 67 | public void Dispose() 68 | { 69 | if (_centerLine != null) 70 | { 71 | Marshal.ReleaseComObject(_centerLine); 72 | _centerLine = null; 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Drawings/Annotations/InventorDrawingNote.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Inventor; 4 | using InventorWrapper.Drawings.DrawingSheet.Style; 5 | using InventorWrapper.Drawings.Enums; 6 | using InventorWrapper.Enums; 7 | 8 | namespace InventorWrapper.Drawings.Annotations 9 | { 10 | public class InventorDrawingNote : IDisposable 11 | { 12 | public DrawingNote _note; 13 | 14 | public InventorDrawingNote(DrawingNote note) 15 | { 16 | _note = note; 17 | } 18 | 19 | private InventorColor _color; 20 | 21 | public void Delete() => _note.Delete(); 22 | 23 | public InventorColor Color 24 | { 25 | get 26 | { 27 | if (_color == null ) 28 | { 29 | _color = new InventorColor(_note.Color); 30 | } 31 | 32 | return _color; 33 | } 34 | } 35 | 36 | public string FormattedText 37 | { 38 | get => _note.FormattedText; 39 | set => _note.FormattedText = value; 40 | } 41 | 42 | public InventorHorizontalTextAlignment HorizontalJustification 43 | { 44 | get => (InventorHorizontalTextAlignment)_note.HorizontalJustification; 45 | set => _note.HorizontalJustification = (HorizontalTextAlignmentEnum)value; 46 | } 47 | 48 | public double LineSpacing 49 | { 50 | get => _note.LineSpacing; 51 | set => _note.LineSpacing = value; 52 | } 53 | 54 | public Curves.Point Position 55 | { 56 | get => new Curves.Point(_note.Position); 57 | set => _note.Position = value.CreatePoint(); 58 | } 59 | 60 | public Curves.Point TopRightPoint => new Curves.Point(_note.RangeBox.MaxPoint); 61 | 62 | public Curves.Point TopLeftPoint => new Curves.Point(_note.RangeBox.MinPoint.X, _note.RangeBox.MaxPoint.Y); 63 | 64 | public Curves.Point BottomLeftPoint => new Curves.Point(_note.RangeBox.MinPoint); 65 | 66 | public Curves.Point BottomRightPoint => 67 | new Curves.Point(_note.RangeBox.MaxPoint.X, _note.RangeBox.MinPoint.Y); 68 | 69 | public Curves.Point CenterPoint => Curves.Point.MidPoint(TopRightPoint, BottomLeftPoint); 70 | 71 | public double Width => Math.Abs(TopRightPoint.X - TopLeftPoint.X); 72 | 73 | public double Height => Math.Abs(TopRightPoint.Y - BottomRightPoint.Y); 74 | 75 | 76 | public InventorVerticalTextAlignmentEnum StackedTextPosition 77 | { 78 | get => (InventorVerticalTextAlignmentEnum)_note.StackedTextPosition; 79 | set => _note.StackedTextPosition = (VerticalTextAlignmentEnum)value; 80 | } 81 | 82 | public string Text 83 | { 84 | get => _note.Text; 85 | set => _note.Text = value; 86 | } 87 | 88 | public InventorObjectTypes Type => (InventorObjectTypes)_note.Type; 89 | 90 | public InventorVerticalTextAlignmentEnum VerticalJustification 91 | { 92 | get => (InventorVerticalTextAlignmentEnum)_note.VerticalJustification; 93 | set => _note.VerticalJustification = (VerticalTextAlignmentEnum)value; 94 | } 95 | 96 | public double WidthScale 97 | { 98 | get => _note.WidthScale; 99 | set => _note.WidthScale = value; 100 | } 101 | 102 | public virtual void Dispose() 103 | { 104 | if (_note != null) 105 | { 106 | Marshal.ReleaseComObject(_note); 107 | _note = null; 108 | } 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /Drawings/Annotations/InventorGeneralNote.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Inventor; 3 | using InventorWrapper.Drawings.DrawingSheet.Style; 4 | 5 | namespace InventorWrapper.Drawings.Annotations 6 | { 7 | public class InventorGeneralNote : InventorDrawingNote 8 | { 9 | public GeneralNote _generalNote; 10 | 11 | private InventorTextStyle _textStyle; 12 | 13 | public InventorGeneralNote(GeneralNote note) : base((DrawingNote)note) 14 | { 15 | _generalNote = note; 16 | } 17 | 18 | public double FittedTextHeight => _generalNote.FittedTextHeight; 19 | 20 | public double FittedTextWidth => _generalNote.FittedTextWidth; 21 | 22 | public new double Height 23 | { 24 | get => _generalNote.Height; 25 | set => _generalNote.Height = value; 26 | } 27 | 28 | public InventorTextStyle TextStyle 29 | { 30 | get 31 | { 32 | if (_textStyle == null) 33 | { 34 | _textStyle = new InventorTextStyle(_generalNote.TextStyle); 35 | } 36 | 37 | return _textStyle; 38 | } 39 | } 40 | 41 | public override void Dispose() 42 | { 43 | if (_generalNote != null) 44 | { 45 | _textStyle?.Dispose(); 46 | 47 | Marshal.ReleaseComObject(_generalNote); 48 | _generalNote = null; 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Drawings/Annotations/InventorLeader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using Inventor; 5 | using InventorWrapper.Drawings.Curves; 6 | using InventorWrapper.Enums; 7 | 8 | namespace InventorWrapper.Drawings.Annotations 9 | { 10 | public class InventorLeader : IDisposable 11 | { 12 | public Leader _leader; 13 | 14 | public InventorLeader(Leader leader) 15 | { 16 | _leader = leader; 17 | } 18 | 19 | public void AddLeader(List points) 20 | { 21 | var objCollection = InventorApplication.CreateObjectCollection(); 22 | 23 | foreach (var point in points) 24 | { 25 | objCollection.Add(point); 26 | } 27 | 28 | _leader.AddLeader(objCollection); 29 | 30 | Marshal.ReleaseComObject(objCollection); 31 | } 32 | 33 | public InventorObjectTypes Type => (InventorObjectTypes)_leader.Type; 34 | 35 | public void Dispose() 36 | { 37 | throw new NotImplementedException(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Drawings/Annotations/InventorLeaderNote.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Inventor; 4 | using InventorWrapper.Drawings.Curves; 5 | using InventorWrapper.Drawings.DrawingSheet.Style; 6 | using InventorWrapper.Drawings.Enums; 7 | using InventorWrapper.Enums; 8 | using Microsoft.SqlServer.Server; 9 | using Point = InventorWrapper.Drawings.Curves.Point; 10 | 11 | namespace InventorWrapper.Drawings.Annotations 12 | { 13 | public class InventorLeaderNote : InventorDrawingNote 14 | { 15 | public LeaderNote _leaderNote; 16 | 17 | private InventorLeader _leader; 18 | 19 | public InventorLeaderNote(LeaderNote leaderNote) : base((DrawingNote)leaderNote) 20 | { 21 | _leaderNote = leaderNote; 22 | } 23 | 24 | public InventorLeader Leader 25 | { 26 | get 27 | { 28 | if (_leader == null) 29 | { 30 | _leader = new InventorLeader(_leaderNote.Leader); 31 | } 32 | 33 | return _leader; 34 | } 35 | } 36 | 37 | public bool UseBackGroundColor 38 | { 39 | get => _leaderNote.UseBackgroundColor; 40 | set => _leaderNote.UseBackgroundColor = value; 41 | } 42 | 43 | public override void Dispose() 44 | { 45 | if (_leaderNote != null) 46 | { 47 | _leader?.Dispose(); 48 | 49 | Marshal.ReleaseComObject(_leaderNote); 50 | _leaderNote = null; 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Drawings/Curves/GeometryPoint.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings.Annotations; 3 | using InventorWrapper.Drawings.Enums; 4 | 5 | namespace InventorWrapper.Drawings.Curves 6 | { 7 | public class GeometryPoint : Point 8 | { 9 | public InventorDrawingCurve Curve { get; private set; } 10 | 11 | public InventorCenterLine CenterLine { get; private set; } 12 | 13 | public PointType PointType { get; private set; } 14 | 15 | public PointSource PointSource { get; private set; } 16 | 17 | /// 18 | /// Create geometry intent to apply dimensions 19 | /// 20 | public GeometryIntent CreateIntent() 21 | { 22 | switch (PointSource) 23 | { 24 | case PointSource.Centerline: 25 | return CenterLine._sheet.CreateGeometryIntent(CenterLine._centerLine, CreatePoint()); 26 | case PointSource.Curve: 27 | default: 28 | return Curve._sheet.CreateGeometryIntent(Curve._curve, CreatePoint()); 29 | } 30 | } 31 | 32 | /// 33 | /// Create the geometry intent based on x and y values 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | public GeometryPoint(double x, double y, InventorDrawingCurve curve, PointType pointType) : base(x, y) 40 | { 41 | Curve = curve; 42 | PointType = pointType; 43 | PointSource = PointSource.Curve; 44 | } 45 | 46 | /// 47 | /// Creates the geometry intent based on a source inventor point 48 | /// 49 | /// 50 | /// 51 | /// 52 | public GeometryPoint(Point2d point, InventorDrawingCurve curve, PointType pointType) : base(point) 53 | { 54 | Curve = curve; 55 | PointType = pointType; 56 | PointSource = PointSource.Curve; 57 | } 58 | 59 | public GeometryPoint(Point2d point, InventorCenterLine centerLine, PointType pointType) : base(point) 60 | { 61 | CenterLine = centerLine; 62 | PointType = pointType; 63 | PointSource = PointSource.Centerline; 64 | } 65 | 66 | } 67 | 68 | public enum PointSource 69 | { 70 | Curve = 1, 71 | Centerline = 2 72 | } 73 | } -------------------------------------------------------------------------------- /Drawings/Curves/InventorDrawingCurve.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Components; 3 | using InventorWrapper.Drawings.Enums; 4 | using InventorWrapper.Drawings.Interfaces; 5 | using InventorWrapper.Extensions; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Runtime.InteropServices; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | 13 | namespace InventorWrapper.Drawings.Curves 14 | { 15 | /// 16 | /// Inventor drawing curve 17 | /// 18 | public class InventorDrawingCurve : IDisposable 19 | { 20 | /// 21 | /// Source inventor drawing curve 22 | /// 23 | public DrawingCurve _curve; 24 | 25 | /// 26 | /// Refrence to the sheet for creating geometry intent 27 | /// 28 | public Sheet _sheet; 29 | 30 | /// 31 | /// If the curve was found 32 | /// 33 | private bool found; 34 | 35 | /// 36 | /// Range box for the curve 37 | /// 38 | private Box2d _rangeBox; 39 | 40 | /// 41 | /// Type of curve 42 | /// 43 | public CurveTypes CurveType { get; } 44 | 45 | public GeometryIntent CreateIntent() 46 | { 47 | return _sheet.CreateGeometryIntent(_curve); 48 | } 49 | 50 | /// 51 | /// Component the curve is pulled from. 52 | /// Not all curves will have a component. 53 | /// Important to null check 54 | /// 55 | public InventorComponent Component { get; set; } 56 | 57 | /// 58 | /// Start point of the curve returns null on circular curves 59 | /// 60 | public GeometryPoint StartPoint => _curve.StartPoint == null ? null : new GeometryPoint(_curve.StartPoint, this, PointType.EndPoint); 61 | 62 | /// 63 | /// End point of the curve returns null on circular curves 64 | /// 65 | public GeometryPoint EndPoint => _curve.EndPoint == null ? null : new GeometryPoint(_curve.EndPoint, this, PointType.EndPoint); 66 | 67 | /// 68 | /// Top left point of the curve 69 | /// 70 | public GeometryPoint TopLeftPoint => new GeometryPoint(_rangeBox.MinPoint.X, _rangeBox.MaxPoint.Y, this, PointType.TopLeftPoint); 71 | 72 | /// 73 | /// Top Right point of the curve 74 | /// 75 | public GeometryPoint TopRightPoint => new GeometryPoint(_rangeBox.MaxPoint, this, PointType.TopRightPoint); 76 | 77 | /// 78 | /// Bottom Left Point of the curve 79 | /// 80 | public GeometryPoint BottomLeftPoint => new GeometryPoint(_rangeBox.MinPoint, this, PointType.BottomLeftPoint); 81 | 82 | /// 83 | /// Bottom Right point of the curve 84 | /// 85 | public GeometryPoint BottomRightPoint => new GeometryPoint(_rangeBox.MaxPoint.X, _rangeBox.MinPoint.Y, this, PointType.BottomRightPoint); 86 | 87 | /// 88 | /// Max x vertex point of a circular curve 89 | /// 90 | public GeometryPoint RightMidPoint => new GeometryPoint(_rangeBox.MaxPoint.X, MidY, this, PointType.VertexPoint); 91 | 92 | /// 93 | /// Max x vertex point of a circular curve 94 | /// 95 | public GeometryPoint TopMidPoint => new GeometryPoint(MidX, _rangeBox.MaxPoint.Y, this, PointType.VertexPoint); 96 | 97 | /// 98 | /// Max x vertex point of a circular curve 99 | /// 100 | public GeometryPoint LeftMidPoint => new GeometryPoint(_rangeBox.MinPoint.X, MidY, this, PointType.VertexPoint); 101 | 102 | /// 103 | /// Max x vertex point of a circular curve 104 | /// 105 | public GeometryPoint BottomMidPoint => new GeometryPoint(MidX, _rangeBox.MinPoint.Y, this, PointType.VertexPoint); 106 | 107 | /// 108 | /// Center point or midpoint of the curve 109 | /// 110 | public GeometryPoint CenterPoint => 111 | _curve.CenterPoint == null ? null : new GeometryPoint(_curve.CenterPoint, this, PointType.CenterPoint); 112 | 113 | public GeometryPoint MidPoint => _curve.MidPoint == null ? null : new GeometryPoint(_curve.MidPoint, this, PointType.MidPoint); 114 | 115 | /// 116 | /// Returns all the points on the curve that are not null 117 | /// 118 | /// 119 | public List Points() 120 | { 121 | // Put all the points in a list 122 | var tempList = new List 123 | { 124 | StartPoint, 125 | EndPoint, 126 | TopLeftPoint, 127 | TopRightPoint, 128 | BottomLeftPoint, 129 | BottomRightPoint, 130 | CenterPoint, 131 | MidPoint 132 | }; 133 | 134 | // remove all the null points 135 | tempList.RemoveAll(point => point == null); 136 | 137 | // return the temp list 138 | return tempList; 139 | } 140 | 141 | /// 142 | /// Constructs the inventor curve and adds reference to the source sheet. 143 | /// 144 | /// 145 | /// 146 | public InventorDrawingCurve(DrawingCurve curve, Sheet sheet, InventorComponent component = null) 147 | { 148 | _curve = curve; 149 | _sheet = sheet; 150 | _rangeBox = _curve.Evaluator2D.RangeBox; 151 | CurveType = (CurveTypes)_curve.CurveType; 152 | Component = component; 153 | } 154 | 155 | /// 156 | /// Gets the mid x value of the curves range box 157 | /// 158 | private double MidX => _rangeBox.MaxPoint.X - (_rangeBox.MaxPoint.X - _rangeBox.MinPoint.X) / 2; 159 | 160 | /// 161 | /// Gets the mid y value of the curves range box 162 | /// 163 | private double MidY => _rangeBox.MaxPoint.Y - (_rangeBox.MaxPoint.Y - _rangeBox.MinPoint.Y) / 2; 164 | 165 | public void Dispose() 166 | { 167 | if (_curve != null) 168 | { 169 | if (_rangeBox != null) 170 | { 171 | Marshal.ReleaseComObject(_rangeBox); 172 | _rangeBox = null; 173 | } 174 | 175 | Marshal.ReleaseComObject(_curve); 176 | _curve = null; 177 | } 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /Drawings/Curves/Point.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | 3 | namespace InventorWrapper.Drawings.Curves 4 | { 5 | public class Point 6 | { 7 | public double X { get; set; } 8 | 9 | public double Y { get; set; } 10 | 11 | public Point(double x, double y) 12 | { 13 | X = x; 14 | Y = y; 15 | } 16 | 17 | public Point(Point2d point) 18 | { 19 | X = point.X; 20 | Y = point.Y; 21 | } 22 | 23 | public Point2d CreatePoint() 24 | { 25 | return InventorApplication._inventor.TransientGeometry.CreatePoint2d(X, Y); 26 | } 27 | 28 | public static Point MidPoint(Point pointOne, Point pointTwo) 29 | { 30 | return new Point((pointOne.X + pointTwo.X) / 2, (pointOne.Y + pointTwo.Y) / 2); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Drawings/Dimensions/IDimension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Inventor; 4 | 5 | namespace InventorWrapper.Drawings.Dimensions 6 | { 7 | public interface IDimension : IDisposable 8 | { 9 | InventorSheet Sheet { get; } 10 | 11 | string Text { get; set; } 12 | 13 | double ModelValue { get; } 14 | 15 | bool Attached { get; } 16 | 17 | bool HideValue { get; set; } 18 | 19 | void Delete(); 20 | } 21 | } -------------------------------------------------------------------------------- /Drawings/Dimensions/InventorGeneralDimension.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Inventor; 3 | 4 | namespace InventorWrapper.Drawings.Dimensions 5 | { 6 | /// 7 | /// Base for all General Dimensions 8 | /// 9 | public class InventorGeneralDimension : IDimension 10 | { 11 | private GeneralDimension _dimension; 12 | 13 | /// 14 | /// Reference to the parent sheet 15 | /// 16 | public InventorSheet Sheet { get; private set; } 17 | 18 | /// 19 | /// Gets and sets the dimension text 20 | /// 21 | public string Text 22 | { 23 | get => _dimension.Text.Text; 24 | set => _dimension.Text.FormattedText = value; 25 | } 26 | 27 | /// 28 | /// Gets the model value 29 | /// 30 | public double ModelValue => _dimension.ModelValue; 31 | 32 | /// 33 | /// If the dimension is attached 34 | /// 35 | public bool Attached => _dimension.Attached; 36 | 37 | /// 38 | /// Show and hide the model value 39 | /// 40 | public bool HideValue 41 | { 42 | get => _dimension.HideValue; 43 | set => _dimension.HideValue = value; 44 | } 45 | 46 | public InventorGeneralDimension(GeneralDimension dimension) 47 | { 48 | _dimension = dimension; 49 | Sheet = new InventorSheet(dimension.Parent); 50 | } 51 | 52 | public void Delete() => _dimension.Delete(); 53 | 54 | public void Dispose() 55 | { 56 | if (_dimension != null) 57 | { 58 | Marshal.ReleaseComObject(_dimension); 59 | _dimension = null; 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Drawings/Dimensions/InventorLinearGeneralDim.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Inventor; 3 | using InventorWrapper.Drawings.Curves; 4 | using Point = InventorWrapper.Drawings.Curves.Point; 5 | 6 | namespace InventorWrapper.Drawings.Dimensions 7 | { 8 | public class InventorLinearGeneralDim : IDimension 9 | { 10 | private LinearGeneralDimension _dimension; 11 | 12 | // 13 | /// Reference to the parent sheet 14 | /// 15 | public InventorSheet Sheet { get; private set; } 16 | 17 | public InventorLinearGeneralDim(LinearGeneralDimension dimension) 18 | { 19 | _dimension = dimension; 20 | Sheet = new InventorSheet(_dimension.Parent); 21 | } 22 | 23 | public void CenterText() => _dimension.CenterText(); 24 | 25 | public Point PointOne => new Point(_dimension.IntentOne.PointOnSheet); 26 | 27 | public Point PointTwo => new Point(_dimension.IntentTwo.PointOnSheet); 28 | 29 | /// 30 | /// Gets and sets the dimension text 31 | /// 32 | public string Text 33 | { 34 | get => _dimension.Text.Text; 35 | set => _dimension.Text.FormattedText = value; 36 | } 37 | 38 | /// 39 | /// Gets the model value 40 | /// 41 | public double ModelValue => _dimension.ModelValue; 42 | 43 | /// 44 | /// If the dimension is attached 45 | /// 46 | public bool Attached => _dimension.Attached; 47 | 48 | /// 49 | /// Show and hide the model value 50 | /// 51 | public bool HideValue 52 | { 53 | get => _dimension.HideValue; 54 | set => _dimension.HideValue = value; 55 | } 56 | 57 | public void Delete() => _dimension.Delete(); 58 | 59 | public void Dispose() 60 | { 61 | if (_dimension != null) 62 | { 63 | Marshal.ReleaseComObject(_dimension); 64 | _dimension = null; 65 | } 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Drawings/Dimensions/OrdinateDims/InventorDiameterDimension.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Inventor; 3 | using Point = InventorWrapper.Drawings.Curves.Point; 4 | 5 | namespace InventorWrapper.Drawings.Dimensions.OrdinateDims 6 | { 7 | public class InventorDiameterDimension : IDimension 8 | { 9 | private DiameterGeneralDimension _dimension; 10 | 11 | /// 12 | /// Reference to the parent sheet 13 | /// 14 | public InventorSheet Sheet { get; private set; } 15 | 16 | /// 17 | /// Gets and sets the dimension text 18 | /// 19 | public string Text 20 | { 21 | get => _dimension.Text.Text; 22 | set => _dimension.Text.FormattedText = value; 23 | } 24 | 25 | /// 26 | /// Gets the model value 27 | /// 28 | public double ModelValue => _dimension.ModelValue; 29 | 30 | /// 31 | /// If the dimension is attached 32 | /// 33 | public bool Attached => _dimension.Attached; 34 | 35 | /// 36 | /// Show and hide the model value 37 | /// 38 | public bool HideValue 39 | { 40 | get => _dimension.HideValue; 41 | set => _dimension.HideValue = value; 42 | } 43 | 44 | public InventorDiameterDimension(DiameterGeneralDimension dimension) 45 | { 46 | _dimension = dimension; 47 | Sheet = new InventorSheet(_dimension.Parent); 48 | } 49 | 50 | public Point Intent => new Point(_dimension.Intent.PointOnSheet); 51 | 52 | public void Delete() => _dimension.Delete(); 53 | 54 | public void Dispose() 55 | { 56 | if (_dimension != null) 57 | { 58 | Marshal.ReleaseComObject(_dimension); 59 | _dimension = null; 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Drawings/Dimensions/OrdinateDims/InventorOrdinateDimension.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Inventor; 3 | 4 | namespace InventorWrapper.Drawings.Dimensions.OrdinateDims 5 | { 6 | public class InventorOrdinateDimension : IDimension 7 | { 8 | private OrdinateDimension _dimension; 9 | 10 | /// 11 | /// Reference to the parent sheet 12 | /// 13 | public InventorSheet Sheet { get; private set; } 14 | 15 | /// 16 | /// Gets and sets the dimension text 17 | /// 18 | public string Text 19 | { 20 | get => _dimension.Text.Text; 21 | set => _dimension.Text.FormattedText = value; 22 | } 23 | 24 | /// 25 | /// Gets the model value 26 | /// 27 | public double ModelValue => _dimension.ModelValue; 28 | 29 | /// 30 | /// If the dimension is attached 31 | /// 32 | public bool Attached => _dimension.Attached; 33 | 34 | /// 35 | /// Show and hide the model value 36 | /// 37 | public bool HideValue 38 | { 39 | get => _dimension.HideValue; 40 | set => _dimension.HideValue = value; 41 | } 42 | 43 | public InventorOrdinateDimension(OrdinateDimension dimension) 44 | { 45 | _dimension = dimension; 46 | Sheet = new InventorSheet(_dimension.Parent); 47 | } 48 | 49 | public bool IsOrdinateSetMember => _dimension.IsOrdinateSetMember; 50 | 51 | public void Delete() => _dimension.Delete(); 52 | 53 | public void Dispose() 54 | { 55 | if (_dimension != null) 56 | { 57 | Marshal.ReleaseComObject(_dimension); 58 | _dimension = null; 59 | } 60 | } 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /Drawings/Dimensions/OrdinateDims/InventorOrdinateDimensionSet.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Inventor; 3 | using InventorWrapper.Drawings.Curves; 4 | 5 | namespace InventorWrapper.Drawings.Dimensions.OrdinateDims 6 | { 7 | public class InventorOrdinateDimensionSet : List 8 | { 9 | private OrdinateDimensionSet _ordinateDimensionSet; 10 | 11 | public InventorOrdinateDimensionSet(OrdinateDimensionSet ordinateDimensionSet) 12 | { 13 | _ordinateDimensionSet = ordinateDimensionSet; 14 | 15 | foreach (OrdinateDimension member in _ordinateDimensionSet.Members) 16 | { 17 | Add(new InventorOrdinateDimension(member)); 18 | } 19 | } 20 | 21 | public InventorOrdinateDimension AddMember(GeometryPoint point) 22 | { 23 | var newMember = new InventorOrdinateDimension(_ordinateDimensionSet.AddMember(point.CreateIntent())); 24 | 25 | Add(newMember); 26 | 27 | return newMember; 28 | } 29 | 30 | public void Delete() => _ordinateDimensionSet.Delete(); 31 | } 32 | } -------------------------------------------------------------------------------- /Drawings/DrawingSheet/InventorBorder.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Security.Policy; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace InventorWrapper.Drawings.DrawingSheet 11 | { 12 | public class InventorBorder : IDisposable 13 | { 14 | public Border _border; 15 | 16 | public Curves.Point BottomLeft => new Curves.Point(_border.RangeBox.MinPoint); 17 | 18 | public Curves.Point BottomRight => new Curves.Point(_border.RangeBox.MaxPoint.X, _border.RangeBox.MinPoint.Y); 19 | 20 | public Curves.Point TopRight => new Curves.Point(_border.RangeBox.MaxPoint); 21 | 22 | public Curves.Point TopLeft => new Curves.Point(_border.RangeBox.MinPoint.X, _border.RangeBox.MaxPoint.Y); 23 | 24 | public double Height => Math.Abs(TopLeft.Y - BottomLeft.Y); 25 | 26 | public double Width => Math.Abs(BottomRight.X - BottomLeft.X); 27 | 28 | public string Name 29 | { 30 | get => _border.Name; 31 | set => _border.Name = value; 32 | } 33 | 34 | public InventorBorder(Border border) 35 | { 36 | _border = border; 37 | } 38 | 39 | public void Dispose() 40 | { 41 | if (_border != null) 42 | { 43 | Marshal.ReleaseComObject(_border); 44 | _border = null; 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Drawings/DrawingSheet/InventorSketchSymbol.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 InventorWrapper.Drawings.DrawingSheet 8 | { 9 | internal class InventorSketchSymbol 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Drawings/DrawingSheet/InventorTitleBlock.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings.Interfaces; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using Point = InventorWrapper.Drawings.Curves.Point; 10 | 11 | namespace InventorWrapper.Drawings.DrawingSheet 12 | { 13 | public class InventorTitleBlock : ILocationEntity, IDisposable 14 | { 15 | private TitleBlock _title; 16 | 17 | public InventorTitleBlock(TitleBlock title) 18 | { 19 | _title = title; 20 | 21 | } 22 | 23 | public string Name 24 | { 25 | get => _title.Name; 26 | set => _title.Name = value; 27 | } 28 | 29 | public double Height => Math.Abs(_title.RangeBox.MaxPoint.Y - _title.RangeBox.MinPoint.Y); 30 | 31 | public double Width => Math.Abs(_title.RangeBox.MaxPoint.X - _title.RangeBox.MinPoint.X); 32 | 33 | public Point TopLeftPoint => new Point(_title.RangeBox.MinPoint.X, _title.RangeBox.MaxPoint.Y); 34 | 35 | public Point TopRightPoint => new Point(_title.RangeBox.MaxPoint); 36 | 37 | public Point BottomLeftPoint => new Point(_title.RangeBox.MinPoint); 38 | 39 | public Point BottomRightPoint => new Point(_title.RangeBox.MaxPoint.X, _title.RangeBox.MinPoint.Y); 40 | 41 | public Point CenterPoint => new Point((TopRightPoint.X + BottomLeftPoint.X) / 2, (TopRightPoint.Y + BottomLeftPoint.Y) / 2); 42 | 43 | public Point Position 44 | { 45 | get => new Point(_title.Position); 46 | set => new Point(value.X, value.Y); 47 | } 48 | 49 | /// 50 | /// Deletes the title block from the sheet 51 | /// 52 | public void Delete() 53 | { 54 | _title.Delete(); 55 | 56 | // TODO Verify if dispose should be ran 57 | // Dispose(); 58 | } 59 | 60 | public void Dispose() 61 | { 62 | if (_title != null) 63 | { 64 | Marshal.ReleaseComObject(_title); 65 | 66 | _title = null; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Drawings/DrawingSheet/Style/InventorColor.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings.Enums; 3 | using InventorWrapper.Enums; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.Drawings.DrawingSheet.Style 12 | { 13 | public class InventorColor : IDisposable 14 | { 15 | public Color _color; 16 | 17 | public InventorColor(Color color) 18 | { 19 | _color = color; 20 | } 21 | 22 | public byte Blue 23 | { 24 | get => _color.Blue; 25 | set => _color.Blue = value; 26 | } 27 | 28 | public byte Green 29 | { 30 | get => _color.Green; 31 | set => _color.Green = value; 32 | } 33 | 34 | public byte Red 35 | { 36 | get => _color.Red; 37 | set => _color.Red = value; 38 | } 39 | 40 | public double Opacity 41 | { 42 | get => _color.Opacity; 43 | set => _color.Opacity = value; 44 | } 45 | 46 | public InventorColorSourceTypeEnun ColorSourceType 47 | { 48 | get => (InventorColorSourceTypeEnun)_color.ColorSourceType; 49 | set => _color.ColorSourceType = (ColorSourceTypeEnum)value; 50 | } 51 | 52 | public InventorObjectTypes Type => (InventorObjectTypes)_color.Type; 53 | 54 | public ColorStruct GetColor() 55 | { 56 | _color.GetColor(out byte red, out byte green, out byte blue); 57 | 58 | return new ColorStruct(red, green, blue); 59 | } 60 | 61 | public void SetColor(byte red, byte green, byte blue) 62 | { 63 | _color.SetColor(red, green, blue); 64 | } 65 | 66 | public void Dispose() 67 | { 68 | if ( _color != null ) 69 | { 70 | Marshal.ReleaseComObject(_color); 71 | _color = null; 72 | } 73 | } 74 | } 75 | 76 | public struct ColorStruct 77 | { 78 | public ColorStruct(byte red, byte green, byte blue) 79 | { 80 | Red = red; 81 | Green = green; 82 | Blue = blue; 83 | } 84 | 85 | public byte Red { get; set; } 86 | 87 | public byte Green { get; set; } 88 | 89 | public byte Blue { get; set; } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Drawings/DrawingSheet/Style/InventorTableStyle.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings.Enums; 3 | using InventorWrapper.Enums; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.Drawings.DrawingSheet.Style 12 | { 13 | public class InventorTableStyle : IDisposable 14 | { 15 | private InventorTextStyle _columnHeaderTextStyle; 16 | 17 | private InventorTextStyle _dataTextStyle; 18 | 19 | private InventorTextStyle _titleTextStyle; 20 | 21 | public TableStyle _tableStyle; 22 | 23 | public InventorTableStyle(TableStyle tableStyle) 24 | { 25 | _tableStyle = tableStyle; 26 | } 27 | 28 | public InventorTextStyle ColumnHeaderTextStyle 29 | { 30 | get 31 | { 32 | if (_columnHeaderTextStyle == null) 33 | { 34 | _columnHeaderTextStyle = new InventorTextStyle(_tableStyle.ColumnHeaderTextStyle); 35 | } 36 | 37 | return _columnHeaderTextStyle; 38 | } 39 | } 40 | 41 | public InventorHorizontalTextAlignment ColumnTitleHorizontalJustification 42 | { 43 | get => (InventorHorizontalTextAlignment)_tableStyle.ColumnTitleHorizontalJustification; 44 | set => _tableStyle.ColumnTitleHorizontalJustification = (HorizontalTextAlignmentEnum)value; 45 | } 46 | 47 | public InventorHorizontalTextAlignment ColumnValueHorizontalJustification 48 | { 49 | get => (InventorHorizontalTextAlignment)_tableStyle.ColumnValueHorizontalJustification; 50 | set => _tableStyle.ColumnValueHorizontalJustification = (HorizontalTextAlignmentEnum)value; 51 | } 52 | 53 | public double ColumnWidth 54 | { 55 | get => _tableStyle.ColumnWidth; 56 | set => _tableStyle.ColumnWidth = value; 57 | } 58 | 59 | public string Comments 60 | { 61 | get => _tableStyle.Comments; 62 | set => _tableStyle.Comments = value; 63 | } 64 | 65 | public InventorTextStyle DataTextStyle 66 | { 67 | get 68 | { 69 | if (_dataTextStyle == null) 70 | { 71 | _dataTextStyle = new InventorTextStyle(_tableStyle.DataTextStyle); 72 | } 73 | 74 | return _dataTextStyle; 75 | } 76 | } 77 | 78 | public double HeadingGap 79 | { 80 | get => _tableStyle.HeadingGap; 81 | set => _tableStyle.HeadingGap = value; 82 | } 83 | 84 | public InventorHeaderPlacementEnum HeadingPlacement 85 | { 86 | get => (InventorHeaderPlacementEnum)_tableStyle.HeadingPlacement; 87 | set => _tableStyle.HeadingPlacement = (HeadingPlacementEnum)value; 88 | } 89 | 90 | public double InsideLineWeight 91 | { 92 | get => _tableStyle.InsideLineWeight; 93 | set => _tableStyle.InsideLineWeight = value; 94 | } 95 | 96 | public bool InUse => _tableStyle.InUse; 97 | 98 | public string Name 99 | { 100 | get => _tableStyle.Name; 101 | set => _tableStyle.Name = value; 102 | } 103 | 104 | public double OutsideLineWeight 105 | { 106 | get => _tableStyle.OutsideLineWeight; 107 | set => _tableStyle.OutsideLineWeight = value; 108 | } 109 | 110 | public double RowGap 111 | { 112 | get => _tableStyle.RowGap; 113 | set => _tableStyle.RowGap = value; 114 | } 115 | 116 | public InventorLineSpacingEnum RowLineSpacing 117 | { 118 | get => (InventorLineSpacingEnum)_tableStyle.RowLineSpacing; 119 | set => _tableStyle.RowLineSpacing = (LineSpacingEnum)value; 120 | } 121 | 122 | public bool ShowTitle 123 | { 124 | get => _tableStyle.ShowTitle; 125 | set => _tableStyle.ShowTitle = value; 126 | } 127 | 128 | public InventorStyleTypeEnum StyleType => (InventorStyleTypeEnum)_tableStyle.StyleType; 129 | 130 | public InventorTableDirectionEnum TableDirection 131 | { 132 | get => (InventorTableDirectionEnum)_tableStyle.TableDirection; 133 | set => _tableStyle.TableDirection = (TableDirectionEnum)value; 134 | } 135 | 136 | public string Title 137 | { 138 | get => _tableStyle.Title; 139 | set => _tableStyle.Title = value; 140 | } 141 | 142 | public InventorTextStyle TitleTextStyle 143 | { 144 | get 145 | { 146 | if (_titleTextStyle == null) 147 | { 148 | _titleTextStyle = new InventorTextStyle(_tableStyle.TitleTextStyle); 149 | } 150 | 151 | return _titleTextStyle; 152 | } 153 | } 154 | 155 | public InventorObjectTypes Type => (InventorObjectTypes)_tableStyle.Type; 156 | 157 | public bool UpToDate => _tableStyle.UpToDate; 158 | 159 | public void Dispose() 160 | { 161 | _columnHeaderTextStyle?.Dispose(); 162 | 163 | _titleTextStyle?.Dispose(); 164 | 165 | _dataTextStyle?.Dispose(); 166 | 167 | if (_tableStyle != null) 168 | { 169 | Marshal.ReleaseComObject(_tableStyle); 170 | _tableStyle = null; 171 | } 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /Drawings/DrawingSheet/Style/InventorTextStyle.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Drawings.Enums; 3 | using InventorWrapper.Enums; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.Drawings.DrawingSheet.Style 12 | { 13 | public class InventorTextStyle : IDisposable 14 | { 15 | public TextStyle _textStyle; 16 | 17 | private InventorColor _color; 18 | 19 | public InventorTextStyle(TextStyle textStyle) 20 | { 21 | _textStyle = textStyle; 22 | } 23 | 24 | public bool Bold 25 | { 26 | get => _textStyle.Bold; 27 | set => _textStyle.Bold = value; 28 | } 29 | 30 | public string Comments 31 | { 32 | get => _textStyle.Comments; 33 | set => _textStyle.Comments = value; 34 | } 35 | 36 | public string Font 37 | { 38 | get => _textStyle.Font; 39 | set => _textStyle.Font = value; 40 | } 41 | 42 | public double FontSize 43 | { 44 | get => _textStyle.FontSize; 45 | set => _textStyle.FontSize = value; 46 | } 47 | 48 | public InventorHorizontalTextAlignment HorizontalJustification 49 | { 50 | get => (InventorHorizontalTextAlignment)_textStyle.HorizontalJustification; 51 | set => _textStyle.HorizontalJustification = (HorizontalTextAlignmentEnum)value; 52 | } 53 | 54 | public bool InUse => _textStyle.InUse; 55 | 56 | public bool Italic 57 | { 58 | get => _textStyle.Italic; 59 | set => _textStyle.Italic = value; 60 | } 61 | 62 | public double LineSpacingEnum 63 | { 64 | get => _textStyle.LineSpacing; 65 | set => _textStyle.LineSpacing = value; 66 | } 67 | 68 | public InventorTextLineSpacingTypeEnum LineSpacingType 69 | { 70 | get => (InventorTextLineSpacingTypeEnum)_textStyle.LineSpacingType; 71 | set => _textStyle.LineSpacingType = (TextLineSpacingTypeEnum)value; 72 | } 73 | 74 | public string Name 75 | { 76 | get => _textStyle.Name; 77 | set => _textStyle.Name = value; 78 | } 79 | 80 | /// 81 | /// Returned in radians 82 | /// Can only be set in 90 degree increments 83 | /// 0, pi/2, pi, 1.5pi 84 | /// 85 | public double Rotation 86 | { 87 | get => _textStyle.Rotation; 88 | set => _textStyle.Rotation = value; 89 | } 90 | 91 | public InventorStyleTypeEnum StyleType => (InventorStyleTypeEnum)_textStyle.StyleType; 92 | 93 | public InventorObjectTypes Type => (InventorObjectTypes)_textStyle.Type; 94 | 95 | public bool UpToDate => _textStyle.UpToDate; 96 | 97 | public InventorVerticalTextAlignmentEnum VerticalJustification 98 | { 99 | get => (InventorVerticalTextAlignmentEnum)_textStyle.VerticalJustification; 100 | set => _textStyle.VerticalJustification = (VerticalTextAlignmentEnum)value; 101 | } 102 | 103 | public double WidthScale 104 | { 105 | get => _textStyle.WidthScale; 106 | set => _textStyle.WidthScale = value; 107 | } 108 | 109 | public InventorColor Color 110 | { 111 | get 112 | { 113 | if (_color == null ) 114 | { 115 | _color = new InventorColor(_textStyle.Color); 116 | } 117 | 118 | return _color; 119 | } 120 | } 121 | 122 | public void Dispose() 123 | { 124 | _color?.Dispose(); 125 | 126 | if (_textStyle != null ) 127 | { 128 | Marshal.ReleaseComObject(_textStyle); 129 | _textStyle = null; 130 | } 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Drawings/Enums/CurveTypes.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum CurveTypes 10 | { 11 | UnknownCurve = 5121, 12 | LineCurve = 5122, 13 | LineSegmentCurve = 5123, 14 | CircleCurve = 5124, 15 | CircularArcCurve = 5125, 16 | EllipseFullCurve = 5126, 17 | EllipticalArcCurve = 5127, 18 | BSplineCurve = 5128, 19 | PolylineCurve = 5129 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorCenterLineType.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorCenterLineType 10 | { 11 | BisectorCenterline = 62978, 12 | CenteredPatternCenterline = 62980, 13 | RegularCenterline = 62977, 14 | WorkFeatureCenterline = 62979 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorColorSourceTypeEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorColorSourceTypeEnun 10 | { 11 | Automatic = 79106, 12 | Layer = 79107, 13 | Override = 79105, 14 | Sheet = 79108 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorDimensionType.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum InventorDimensionType 4 | { 5 | AlignedDimensionType = 60161, // 0x0000EB01 6 | HorizontalDimensionType = 60162, // 0x0000EB02 7 | VerticalDimensionType = 60163, // 0x0000EB03 8 | ArcLengthDimensionType = 60164, // 0x0000EB04 9 | SymmetricDimensionType = 60165, // 0x0000EB05 10 | DiametricDimensionType = 60166, // 0x0000EB06 11 | LinearForeshortenedDimensionType = 60167, // 0x0000EB07 12 | ArcLengthForeshortenedDimensionType = 60168, // 0x0000EB08 13 | AngularDimensionType = 60169, // 0x0000EB09 14 | AngularForeshortenedDimensionType = 60170, // 0x0000EB0A 15 | ParallelDiametricDimensionType = 60171, // 0x0000EB0B 16 | AlignedToCurveDimensionType = 60172, // 0x0000EB0C 17 | NormalToCurveDimensionType = 60173, // 0x0000EB0D 18 | } 19 | } -------------------------------------------------------------------------------- /Drawings/Enums/InventorDrawingSheetSizeEnum.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum InventorDrawingSheetSizeEnum 4 | { 5 | kDefaultDrawingSheetSize = 9985, // 0x00002701 6 | kCustomDrawingSheetSize = 9986, // 0x00002702 7 | kADrawingSheetSize = 9987, // 0x00002703 8 | kBDrawingSheetSize = 9988, // 0x00002704 9 | kCDrawingSheetSize = 9989, // 0x00002705 10 | kDDrawingSheetSize = 9990, // 0x00002706 11 | kEDrawingSheetSize = 9991, // 0x00002707 12 | kFDrawingSheetSize = 9992, // 0x00002708 13 | kA0DrawingSheetSize = 9993, // 0x00002709 14 | kA1DrawingSheetSize = 9994, // 0x0000270A 15 | kA2DrawingSheetSize = 9995, // 0x0000270B 16 | kA3DrawingSheetSize = 9996, // 0x0000270C 17 | kA4DrawingSheetSize = 9997, // 0x0000270D 18 | k9x12InDrawingSheetSize = 9998, // 0x0000270E 19 | k12x18InDrawingSheetSize = 9999, // 0x0000270F 20 | k18x24InDrawingSheetSize = 10000, // 0x00002710 21 | k24x36InDrawingSheetSize = 10001, // 0x00002711 22 | k36x48InDrawingSheetSize = 10002, // 0x00002712 23 | k30x42InDrawingSheetSize = 10003, // 0x00002713 24 | } 25 | } -------------------------------------------------------------------------------- /Drawings/Enums/InventorDrawingViewStyle.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum InventorDrawingViewStyle 4 | { 5 | // 6 | // Summary: 7 | // Hidden line style. 8 | HiddenLineDrawing = 32257, 9 | // 10 | // Summary: 11 | // Hidden lines removed style. 12 | HiddenLineRemovedDrawing = 32258, 13 | // 14 | // Summary: 15 | // Shaded style (with hidden lines removed). 16 | ShadedDrawing = 32259, 17 | // 18 | // Summary: 19 | // Shaded style with hidden lines. 20 | ShadedHiddenLineDrawing = 32261, 21 | // 22 | // Summary: 23 | // Derive the style from the base drawing view. 24 | FromBaseDrawing = 32260 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorDrawingViewType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.Drawings.Enums 9 | { 10 | public enum InventorDrawingViewType 11 | { 12 | DefaultDrawing = 10497, 13 | CustomDrawing = 10498, 14 | StandardDrawing = 10501, 15 | DetailDrawing = 10502, 16 | SectionDrawing = 10503, 17 | AuxiliaryDrawing = 10499, 18 | OLEAttachmentDrawing = 10500, 19 | ProjectedDrawing = 10504, 20 | DraftDrawing = 10505, 21 | AssociativeDraftDrawing = 10506, 22 | OverlayDrawing = 10507 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorHeaderPlacementEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorHeaderPlacementEnum 10 | { 11 | HeadingAtTop = 46337, 12 | HeadingAtBottom, 13 | NoHeading 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorHorizontalTextAlignment.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorHorizontalTextAlignment 10 | { 11 | AlignTextCenter = 19969, 12 | AlignTextLeft, 13 | AlignTextRight 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorLineSpacingEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorLineSpacingEnum 10 | { 11 | DoubleLine = 45826, 12 | SingleLine = 45825, 13 | TripleLine = 45827 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorPartsListLevelEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorPartsListLevelEnum 10 | { 11 | Structured = 46593, 12 | FirstLevelComponents = 46593, 13 | PartsOnly = 46594, 14 | StructuredAllLevels = 46595 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorStyleTypeEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorStyleTypeEnum 10 | { 11 | StandardStyleType = 71425, 12 | BalloonStyleType = 71426, 13 | CentermarStyleType = 71427, 14 | DatumTargetStyleType = 71428, 15 | DimensionStyleType = 71429, 16 | FeatureControlFrameStyleType = 71430, 17 | HatchStyleType = 71431, 18 | HoleTableStyleType = 71432, 19 | IDStyleType = 71433, 20 | LayerStyleType = 71434, 21 | LeaderStyleType = 71435, 22 | ObjectDefaultsStyleType = 71436, 23 | PartsListStyleType = 71437, 24 | RevisionTableStyleType = 71438, 25 | SurfaceTextureStyleType = 71439, 26 | TableStyleType = 71440, 27 | TextStyleType = 71441, 28 | ViewAnnotationStyleType = 71444, 29 | WeldSymbolStyleType = 71442, 30 | WeldBeadStyleType = 71443, 31 | SheetMetalStyleType = 71445, 32 | UnfoldMethodType = 71446 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorTableDirectionEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorTableDirectionEnum 10 | { 11 | BottomUp = 46082, 12 | TopDown = 46081 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorTextLineSpacingTypeEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorTextLineSpacingTypeEnum 10 | { 11 | Exact = 29185, 12 | Multiple = 29186 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorTitleBlockLocationEnum.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum InventorTitleBlockLocationEnum 4 | { 5 | kTopLeftPosition = 29441, // 0x00007301 6 | kTopRightPosition = 29442, // 0x00007302 7 | kBottomLeftPosition = 29443, // 0x00007303 8 | kBottomRightPosition = 29444, // 0x00007304 9 | } 10 | } -------------------------------------------------------------------------------- /Drawings/Enums/InventorVerticalTextAlignmentEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum InventorVerticalTextAlignmentEnum 10 | { 11 | BaseLine = 25604, 12 | Lower = 25603, 13 | Middle = 25601, 14 | Upper = 25602 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drawings/Enums/InventorViewOrientaionType.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum InventorViewOrientaionType 4 | { 5 | // 6 | // Summary: 7 | // Specifies the default setting to use. Inquiry methods/properties always return 8 | // the more strongly typed values. 9 | DefaultView = 10753, 10 | // 11 | // Summary: 12 | // Top View. 13 | TopView, 14 | // 15 | // Summary: 16 | // Right View. 17 | RightView, 18 | // 19 | // Summary: 20 | // Bac View. 21 | BacView, 22 | // 23 | // Summary: 24 | // Bottom View. 25 | BottomView, 26 | // 27 | // Summary: 28 | // Left View. 29 | LeftView, 30 | // 31 | // Summary: 32 | // Isometric -- Top Right View. 33 | IsoTopRightView, 34 | // 35 | // Summary: 36 | // Isometric -- Top Left View. 37 | IsoTopLeftView, 38 | // 39 | // Summary: 40 | // Isometric -- Bottom Right View. 41 | IsoBottomRightView, 42 | // 43 | // Summary: 44 | // Isometric -- Bottom Left View. 45 | IsoBottomLeftView, 46 | // 47 | // Summary: 48 | // Arbitrary View. 49 | ArbitraryView, 50 | // 51 | // Summary: 52 | // Front View. 53 | FrontView, 54 | // 55 | // Summary: 56 | // Current View. 57 | CurrentView, 58 | // 59 | // Summary: 60 | // Saved camera View. 61 | SavedCameraView, 62 | // 63 | // Summary: 64 | // Sheet metal flat pattern pivot right. 65 | FlatPivotRightView, 66 | // 67 | // Summary: 68 | // Sheet metal flat pattern pivot left. 69 | FlatPivotLeftView, 70 | // 71 | // Summary: 72 | // Sheet metal flat pattern pivot 180 degrees. 73 | FlatPivot180View, 74 | // 75 | // Summary: 76 | // Sheet metal flat pattern bacside. 77 | FlatBacsideView, 78 | // 79 | // Summary: 80 | // Sheet metal flat pattern bacside pivot right. 81 | FlatBacsidePivotRightView, 82 | // 83 | // Summary: 84 | // Sheet metal flat pattern bacside pivot left. 85 | FlatBacsidePivotLeftView, 86 | // 87 | // Summary: 88 | // Sheet metal flat pattern bacside pivot 180 degrees. 89 | FlatBacsidePivot180View 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Drawings/Enums/PointType.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum PointType 4 | { 5 | EndPoint, 6 | TopLeftPoint, 7 | TopRightPoint, 8 | BottomLeftPoint, 9 | BottomRightPoint, 10 | CenterPoint, 11 | MidPoint, 12 | VertexPoint 13 | } 14 | } -------------------------------------------------------------------------------- /Drawings/Enums/ProjectedViewDirection.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum ProjectedViewDirection 10 | { 11 | Top, 12 | Left, 13 | Right, 14 | Bottom, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drawings/Enums/RotationEnum.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum RotationEnum 10 | { 11 | i0 = 0, 12 | i90 = 1, 13 | i180 = 2, 14 | i360 = 3, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drawings/Enums/ShiftDirection.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 InventorWrapper.Drawings.Enums 8 | { 9 | public enum ShiftDirection 10 | { 11 | Horizontal, 12 | Vertical 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Drawings/Enums/ViewSide.cs: -------------------------------------------------------------------------------- 1 | namespace InventorWrapper.Drawings.Enums 2 | { 3 | public enum ViewSide 4 | { 5 | Top, 6 | Bottom, 7 | Left, 8 | Right 9 | } 10 | } -------------------------------------------------------------------------------- /Drawings/Helpers/DTO/InventorTableDto.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using InventorWrapper.Drawings.Enums; 8 | 9 | namespace InventorWrapper.Drawings.Helpers.DTO 10 | { 11 | /// 12 | /// Object structure to build inventor tables. 13 | /// Inventor tables are built of three arrays. 14 | /// titles 15 | /// contents 16 | /// width 17 | /// Goals is make a standard dto to elimate process 18 | /// 19 | public class InventorTableDto 20 | { 21 | public string Title { get; set; } 22 | 23 | public List Columns { get; private set; } 24 | 25 | public int ColumnQty => Columns.Count; 26 | 27 | public int RowQty { get; private set; } 28 | 29 | /// 30 | /// Provide inventor table column dto and number of rows 31 | /// 32 | /// Column row qty cannot be greater the provided row qty 33 | /// Total number of rows for the table 34 | /// If row data isn't provided for one then a default value will be added 35 | public InventorTableDto(string title, List columns, int rowQty, string defaultValue = "-") 36 | { 37 | Title = title; 38 | 39 | Columns = columns; 40 | 41 | RowQty = rowQty; 42 | 43 | foreach (var column in columns) 44 | { 45 | if (column.RowData.Count > rowQty) 46 | { 47 | throw new Exception("Column row data cannot be greater than row qty"); 48 | } 49 | 50 | if (column.RowData.Count < rowQty) 51 | { 52 | var numberOfRowsToAdd = rowQty - column.RowData.Count; 53 | 54 | for (var i = column.RowData.Count; i < numberOfRowsToAdd; i++) 55 | { 56 | column.RowData.Add(defaultValue); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | 63 | public class InventorTableColumnDto 64 | { 65 | public InventorTableColumnDto(string title, List rowData) 66 | { 67 | Title = title; 68 | RowData = rowData; 69 | } 70 | 71 | public InventorTableColumnDto() 72 | { 73 | RowData = new List(); 74 | } 75 | 76 | public string Title { get; set; } 77 | 78 | /// 79 | /// Defaults to 1/2 an centimeter 80 | /// 81 | public double Width { get; set; } = 0.5; 82 | 83 | public InventorHeaderPlacementEnum HeaderPlacement { get; set; } = InventorHeaderPlacementEnum.HeadingAtTop; 84 | 85 | public InventorHorizontalTextAlignment HeaderTextAlignment { get; set; } = 86 | InventorHorizontalTextAlignment.AlignTextCenter; 87 | 88 | public InventorHorizontalTextAlignment DataTextAlignment { get; set; } = 89 | InventorHorizontalTextAlignment.AlignTextCenter; 90 | 91 | public List RowData { get; set; } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Drawings/Interfaces/IMajorPoints.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using InventorWrapper.Drawings.Curves; 7 | 8 | namespace InventorWrapper.Drawings.Interfaces 9 | { 10 | public interface IMajorPoints 11 | { 12 | Point TopLeftPoint { get; } 13 | 14 | Point TopRightPoint { get; } 15 | 16 | Point BottomLeftPoint { get; } 17 | 18 | Point BottomRightPoint { get; } 19 | 20 | Point CenterPoint { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Drawings/Interfaces/IlocationEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using InventorWrapper.Drawings.Curves; 7 | 8 | namespace InventorWrapper.Drawings.Interfaces 9 | { 10 | public interface ILocationEntity : IMajorPoints 11 | { 12 | string Name { get; set; } 13 | 14 | double Height { get; } 15 | 16 | double Width { get; } 17 | 18 | Point Position { get; set; } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Drawings/View/InventorDetailDrawingView.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | 3 | namespace InventorWrapper.Drawings 4 | { 5 | public class InventorDetailDrawingView : InventorView 6 | { 7 | public DetailDrawingView _detailDrawing; 8 | 9 | public InventorDetailDrawingView(DetailDrawingView view, InventorSheet parent) : base((DrawingView)view, parent) 10 | { 11 | _detailDrawing = view; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Drawings/View/InventorDrawingViewLabel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Inventor; 4 | using InventorWrapper.Drawings.DrawingSheet.Style; 5 | using InventorWrapper.Drawings.Enums; 6 | using InventorWrapper.Enums; 7 | using Point = InventorWrapper.Drawings.Curves.Point; 8 | 9 | namespace InventorWrapper.Drawings 10 | { 11 | public class InventorDrawingViewLabel : IDisposable 12 | { 13 | public DrawingViewLabel _label; 14 | 15 | private InventorColor _color; 16 | 17 | public InventorDrawingViewLabel(DrawingViewLabel label) 18 | { 19 | _label = label; 20 | } 21 | 22 | public InventorColor Color 23 | { 24 | get 25 | { 26 | if (_color == null ) 27 | { 28 | _color = new InventorColor(_label.Color); 29 | } 30 | 31 | return _color; 32 | } 33 | } 34 | 35 | public bool ConstrainToBorder 36 | { 37 | get => _label.ConstrainToBorder; 38 | set => _label.ConstrainToBorder = value; 39 | } 40 | 41 | public InventorHorizontalTextAlignment HorizontalJustification 42 | { 43 | get => (InventorHorizontalTextAlignment)_label.HorizontalJustification; 44 | set => _label.HorizontalJustification = (HorizontalTextAlignmentEnum)value; 45 | } 46 | 47 | public double LineSpacing 48 | { 49 | get => _label.LineSpacing; 50 | set => _label.LineSpacing = value; 51 | } 52 | 53 | public InventorLineSpacingEnum LineSpacingType 54 | { 55 | get => (InventorLineSpacingEnum)_label.LineSpacingType; 56 | set => _label.LineSpacingType = (TextLineSpacingTypeEnum)value; 57 | } 58 | 59 | public Curves.Point Position 60 | { 61 | get => new Point(_label.Position); 62 | set => _label.Position = value.CreatePoint(); 63 | } 64 | 65 | public InventorVerticalTextAlignmentEnum StackedTextPosition 66 | { 67 | get => (InventorVerticalTextAlignmentEnum)_label.StackedTextPosition; 68 | set => _label.StackedTextPosition = (VerticalTextAlignmentEnum)value; 69 | } 70 | 71 | public string Text => _label.Text; 72 | 73 | public InventorVerticalTextAlignmentEnum VerticalJustification 74 | { 75 | get => (InventorVerticalTextAlignmentEnum)_label.VerticalJustification; 76 | set => _label.VerticalJustification = (VerticalTextAlignmentEnum)value; 77 | } 78 | 79 | public InventorObjectTypes Type => (InventorObjectTypes)_label.Type; 80 | 81 | public void Dispose() 82 | { 83 | if (_label != null) 84 | { 85 | Marshal.ReleaseComObject(_label); 86 | } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Drawings/View/InventorSectionDrawingView.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | 3 | namespace InventorWrapper.Drawings 4 | { 5 | public class InventorSectionDrawingView : InventorView 6 | { 7 | public SectionDrawingView _sectionDrawingView; 8 | 9 | public InventorSectionDrawingView(SectionDrawingView view, InventorSheet parent) : base((DrawingView)view, parent) 10 | { 11 | _sectionDrawingView = view; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Extensions/ComponentOccurenceExtensions.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.Extensions 9 | { 10 | /// 11 | /// Extensions for component occurrences 12 | /// 13 | public static class ComponentOccurenceExtensions 14 | { 15 | /// 16 | /// Get the occurrence path as a list of strings 17 | /// 18 | /// 19 | /// 20 | public static List GetOccurencePath(this ComponentOccurrence occurrence) 21 | { 22 | var tempList = new List(); 23 | 24 | if (occurrence != null) 25 | { 26 | foreach (ComponentOccurrence c in occurrence.OccurrencePath) 27 | { 28 | tempList.Add(c.Name); 29 | } 30 | } 31 | 32 | return tempList; 33 | } 34 | 35 | /// 36 | /// Gets the occurrence path as large string 37 | /// 38 | /// 39 | /// 40 | public static string GetOccurencePathString(this ComponentOccurrence occurrence) 41 | { 42 | string temp = ""; 43 | 44 | if (occurrence != null) 45 | { 46 | foreach (ComponentOccurrence c in occurrence.OccurrencePath) 47 | { 48 | temp += c.Name; 49 | } 50 | } 51 | 52 | return temp; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Extensions/Curves/CurveExtension.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.Components; 2 | using InventorWrapper.Drawings.Curves; 3 | using InventorWrapper.Drawings.Enums; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Net.NetworkInformation; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.Extensions.Curves 12 | { 13 | public static class CurveExtensions 14 | { 15 | public static List FilterByType(this IEnumerable curves, CurveTypes curveType) 16 | { 17 | return curves.Where(x => x.CurveType == curveType).ToList(); 18 | } 19 | 20 | public static List GetLinearCurves(this IEnumerable curves) 21 | { 22 | return curves.Where(x => x.CurveType == CurveTypes.LineCurve || x.CurveType == CurveTypes.LineSegmentCurve || x.CurveType == CurveTypes.PolylineCurve).ToList(); 23 | } 24 | 25 | public static List RemoveCircularCurves(this IEnumerable curves) 26 | { 27 | return curves.Where(x => 28 | x.CurveType != CurveTypes.CircleCurve || x.CurveType != CurveTypes.CircularArcCurve || 29 | x.CurveType != CurveTypes.EllipseFullCurve || x.CurveType != CurveTypes.EllipticalArcCurve).ToList(); 30 | } 31 | 32 | public static List GetCircularCurves(this IEnumerable curves) 33 | { 34 | return FilterByType(curves, CurveTypes.CircleCurve); 35 | } 36 | 37 | public static List RemoveCurvesWithoutComponent(this IEnumerable curves) 38 | { 39 | return curves.Where(x => x.Component!= null).ToList(); 40 | } 41 | 42 | /// 43 | /// Get the unique components by checking the path list 44 | /// 45 | /// 46 | /// 47 | public static List GroupCurvesByComponent(this IEnumerable curves) 48 | { 49 | var tempList = new List(); 50 | 51 | var filteredCurves = curves.RemoveCurvesWithoutComponent(); 52 | 53 | foreach (var curve in filteredCurves) 54 | { 55 | if (tempList.Count == 0) 56 | { 57 | var dto = new ComponentCurveGroupDto(curve.Component); 58 | 59 | dto.Curves.Add(curve); 60 | 61 | tempList.Add(dto); 62 | 63 | continue; 64 | } 65 | 66 | var match = tempList.FirstOrDefault(x => x.Component.PathList == curve.Component.PathList); 67 | 68 | if (match != null) 69 | { 70 | match.Curves.Add(curve); 71 | } 72 | else 73 | { 74 | var dto = new ComponentCurveGroupDto(curve.Component); 75 | 76 | dto.Curves.Add(curve); 77 | 78 | tempList.Add(dto); 79 | } 80 | } 81 | 82 | return tempList; 83 | } 84 | 85 | } 86 | 87 | public class ComponentCurveGroupDto 88 | { 89 | public InventorComponent Component { get; set; } 90 | 91 | public List Curves { get; set; } 92 | 93 | public ComponentCurveGroupDto(InventorComponent component) 94 | { 95 | Component = component; 96 | Curves = new List(); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Extensions/Curves/GeometryPointExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.NetworkInformation; 5 | using Inventor; 6 | using InventorWrapper.Drawings.Curves; 7 | using InventorWrapper.Drawings.Enums; 8 | 9 | namespace InventorWrapper.Extensions.Curves 10 | { 11 | public static class GeometryPointExtensions 12 | { 13 | /// 14 | /// Get the max x points for the given curves 15 | /// 16 | /// 17 | public static double Tolerance { get; set; } = 0.005; 18 | 19 | public static List Points(this IEnumerable curves) 20 | { 21 | var points = new List(); 22 | 23 | foreach (var curve in curves) 24 | { 25 | foreach (var p in curve.Points()) 26 | { 27 | if (p == null) continue; 28 | 29 | points.Add(p); 30 | } 31 | } 32 | 33 | return points; 34 | } 35 | 36 | public static List MaxXPoints(this IEnumerable points) 37 | { 38 | if (points == null || points.Count() == 0) return points.ToList(); 39 | 40 | var maxXValue = points.Max(point => point.X); 41 | 42 | return points.Where(point => Math.Abs(point.X - maxXValue) < Tolerance).ToList(); 43 | } 44 | 45 | /// 46 | /// Get the min x points for the given curves 47 | /// 48 | /// 49 | public static List MinXPoints(this IEnumerable points) 50 | { 51 | if (points == null || points.Count() == 0) return points.ToList(); 52 | 53 | var minXValue = points.Min(point => point.X); 54 | 55 | return points.Where(point => Math.Abs(point.X - minXValue) < Tolerance).ToList(); 56 | } 57 | 58 | /// 59 | /// Get the max y points for the given curves 60 | /// 61 | /// 62 | public static List MaxYPoints(this IEnumerable points) 63 | { 64 | if (points == null || points.Count() == 0) return points.ToList(); 65 | 66 | var maxYValue = points.Max(point => point.Y); 67 | 68 | return points.Where(point => Math.Abs(point.Y - maxYValue) < Tolerance).ToList(); 69 | } 70 | 71 | /// 72 | /// Get the min y points for the given curves 73 | /// 74 | /// 75 | public static List MinYPoints(this IEnumerable points) 76 | { 77 | if (points == null || points.Count() == 0) return points.ToList(); 78 | 79 | var minYValue = points.Min(point => point.Y); 80 | 81 | return points.Where(point => Math.Abs(point.Y - minYValue) < Tolerance).ToList(); 82 | } 83 | 84 | /// 85 | /// Get the first max x point 86 | /// 87 | /// 88 | public static GeometryPoint MaxXPoint(this IEnumerable points) => points.MaxXPoints().FirstOrDefault(); 89 | 90 | /// 91 | /// Get the first min x point 92 | /// 93 | /// 94 | public static GeometryPoint MinXPoint(this IEnumerable points) => points.MinXPoints().FirstOrDefault(); 95 | 96 | /// 97 | /// Get the first Max y point 98 | /// 99 | /// 100 | public static GeometryPoint MaxYPoint(this IEnumerable points) => points.MaxYPoints().FirstOrDefault(); 101 | 102 | /// 103 | /// Get the first min y point 104 | /// 105 | /// 106 | public static GeometryPoint MinYPoint(this IEnumerable points) => points.MinYPoints().FirstOrDefault(); 107 | 108 | /// 109 | /// Gets the center points from circular curves in the list 110 | /// 111 | /// 112 | public static List CenterPoints(this IEnumerable points) 113 | { 114 | return points.Where(point => point.PointType == PointType.CenterPoint).ToList(); 115 | } 116 | 117 | public static List MidAndCenterPoints(this IEnumerable points) 118 | { 119 | return points.Where(x => x.PointType == PointType.MidPoint || x.PointType == PointType.CenterPoint).ToList(); 120 | } 121 | 122 | public static List MidPoints(this IEnumerable points) 123 | { 124 | return points.Where(x => x.PointType == PointType.MidPoint).ToList(); 125 | } 126 | 127 | public static List RemoveCenterPoints(this IEnumerable points) 128 | { 129 | return points.Where(point => point.PointType != PointType.CenterPoint).ToList(); 130 | } 131 | 132 | public static List RemoveMidPoints(this IEnumerable points) 133 | { 134 | return points.Where(point => point.PointType != PointType.MidPoint).ToList(); 135 | } 136 | 137 | public static GeometryPoint MaxXMaxYPoint(this IEnumerable points) => 138 | points.MaxXPoints().MaxYPoint(); 139 | 140 | public static GeometryPoint MaxXMinYPoint(this IEnumerable points) => 141 | points.MaxXPoints().MinYPoint(); 142 | 143 | public static GeometryPoint MinXMaxYPoint(this IEnumerable points) => 144 | points.MinXPoints().MaxYPoint(); 145 | 146 | public static GeometryPoint MinXMinYPoint(this IEnumerable points) => 147 | points.MinXPoints().MinYPoint(); 148 | 149 | public static List RemoveDuplicates(this IEnumerable points, double variance = 0.005) 150 | { 151 | var tempList = new List(); 152 | 153 | foreach (var point in points) 154 | { 155 | if (tempList.Count == 0) 156 | { 157 | tempList.Add(point); 158 | } 159 | else 160 | { 161 | var matching = tempList.Any(p => Math.Abs(point.X - p.X) < 0.005 && (Math.Abs(point.Y - p.Y) < variance)); 162 | 163 | if (!matching) 164 | { 165 | tempList.Add(point); 166 | } 167 | } 168 | } 169 | 170 | return tempList; 171 | } 172 | 173 | public static List RemoveDuplicateX(this IEnumerable points, double variance = 0.005) 174 | { 175 | var tempList = new List(); 176 | 177 | foreach (var point in points) 178 | { 179 | if (tempList.Count == 0) 180 | { 181 | tempList.Add(point); 182 | } 183 | else 184 | { 185 | var matchingX = tempList.Any(p => Math.Abs(point.X - p.X) < variance); 186 | 187 | if (!matchingX) 188 | { 189 | tempList.Add(point); 190 | } 191 | } 192 | } 193 | 194 | return tempList; 195 | } 196 | 197 | public static bool HasSameX(this GeometryPoint point, GeometryPoint pointToCompare, double variance = 0.005) 198 | { 199 | return Math.Abs(point.X - pointToCompare.X) < variance; 200 | } 201 | 202 | public static bool HasSameY(this GeometryPoint point, GeometryPoint pointToCompare, double variance = 0.005) 203 | { 204 | return Math.Abs(point.Y - pointToCompare.Y) < variance; 205 | } 206 | 207 | public static List RemoveDuplicateY(this IEnumerable points, double variance = 0.005) 208 | { 209 | var tempList = new List(); 210 | 211 | foreach (var point in points) 212 | { 213 | if (tempList.Count == 0) 214 | { 215 | tempList.Add(point); 216 | } 217 | else 218 | { 219 | var matchingY = tempList.Any(p => Math.Abs(point.Y - p.Y) < variance); 220 | 221 | if (!matchingY) 222 | { 223 | tempList.Add(point); 224 | } 225 | } 226 | } 227 | 228 | return tempList; 229 | } 230 | } 231 | } -------------------------------------------------------------------------------- /Features/FeatureTypes.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 InventorWrapper.Features 8 | { 9 | public enum FeatureTypes 10 | { 11 | WorkPlane = 0, 12 | WorkPoint = 1, 13 | SurfaceBody = 2, 14 | Face = 3, 15 | Edge = 4, 16 | } 17 | 18 | public enum HoleTypes 19 | { 20 | CounterBore = 21507, 21 | CounterSink = 21506, 22 | Drilled = 21505, 23 | SpotFace = 21508 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Features/InventorFace.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Features 10 | { 11 | public class InventorFace : IDisposable 12 | { 13 | public Face _face; 14 | 15 | public InventorFace(Face face) 16 | { 17 | _face = face; 18 | } 19 | 20 | public void Dispose() 21 | { 22 | if ( _face != null ) 23 | { 24 | Marshal.ReleaseComObject(_face); 25 | _face = null; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Features/InventorFeature.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Features 10 | { 11 | /// 12 | /// Manages the status of the features 13 | /// 14 | public class InventorFeature : IDisposable 15 | { 16 | public PartFeature _feature; 17 | 18 | /// 19 | /// Get the name of the feature 20 | /// 21 | public string Name => _feature.Name; 22 | 23 | /// 24 | /// Sets the status of the feature 25 | /// 26 | public bool Suppressed 27 | { 28 | get => _feature.Suppressed; 29 | set => _feature.Suppressed = value; 30 | } 31 | 32 | public InventorFeature(PartFeature feature) 33 | { 34 | _feature = feature; 35 | } 36 | 37 | public void Dispose() 38 | { 39 | if (_feature != null) 40 | { 41 | Marshal.ReleaseComObject(_feature); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Features/InventorHoleFeature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Inventor; 4 | using InventorWrapper.General; 5 | using InventorWrapper.Parameters; 6 | 7 | namespace InventorWrapper.Features 8 | { 9 | public class InventorHoleFeature : IDisposable 10 | { 11 | public HoleFeature _holeFeature; 12 | 13 | public HoleFeatures _collectionRef; 14 | 15 | public InventorHoleFeature(HoleFeature feature, HoleFeatures collectionRef) 16 | { 17 | _holeFeature = feature; 18 | _collectionRef = collectionRef; 19 | } 20 | 21 | private InventorParameter _bottomTipAngle; 22 | 23 | public InventorParameter BottomTipAngle 24 | { 25 | get 26 | { 27 | if (_bottomTipAngle == null) 28 | { 29 | _bottomTipAngle = new InventorParameter(_holeFeature.BottomTipAngle); 30 | } 31 | 32 | return _bottomTipAngle; 33 | } 34 | } 35 | 36 | private InventorParameter _cBoreDepth; 37 | 38 | public InventorParameter CBoreDepth 39 | { 40 | get 41 | { 42 | if (_cBoreDepth == null) 43 | { 44 | _cBoreDepth = new InventorParameter(_holeFeature.CBoreDepth); 45 | } 46 | 47 | return _cBoreDepth; 48 | } 49 | } 50 | 51 | public double Depth => _holeFeature.Depth; 52 | 53 | public double ConvertedDepth => UnitManager.UnitsFromInventor(_holeFeature.Depth); 54 | 55 | private InventorParameter _holeDiameter; 56 | 57 | public InventorParameter HoleDiameter 58 | { 59 | get 60 | { 61 | if (_holeDiameter == null) 62 | { 63 | _holeDiameter = new InventorParameter(_holeFeature.HoleDiameter); 64 | } 65 | 66 | return _holeDiameter; 67 | } 68 | } 69 | 70 | public HoleTypes HoleType => (HoleTypes)_holeFeature.HoleType; 71 | 72 | public string Name 73 | { 74 | get => _holeFeature.Name; 75 | set => _holeFeature.Name = value; 76 | } 77 | 78 | public void Delete() => _holeFeature.Delete(); 79 | 80 | public bool Tapped => _holeFeature.Tapped; 81 | 82 | private InventorParameter _spotFaceDepth; 83 | 84 | public InventorParameter SpotFaceDepth 85 | { 86 | get 87 | { 88 | if (_spotFaceDepth == null) 89 | { 90 | _spotFaceDepth = new InventorParameter(_holeFeature.SpotFaceDepth); 91 | } 92 | 93 | return _spotFaceDepth; 94 | } 95 | } 96 | 97 | private InventorParameter _spotFaceDiameter; 98 | 99 | public InventorParameter SpotFaceDiameter 100 | { 101 | get 102 | { 103 | if (_spotFaceDiameter == null) 104 | { 105 | _spotFaceDiameter = new InventorParameter(_holeFeature.SpotFaceDiameter); 106 | } 107 | 108 | return _spotFaceDiameter; 109 | } 110 | } 111 | 112 | public object TapInfo 113 | { 114 | get => _holeFeature.TapInfo; 115 | set => _holeFeature.TapInfo = value; 116 | } 117 | 118 | public bool Suppressed 119 | { 120 | get => _holeFeature.Suppressed; 121 | set => _holeFeature.Suppressed = value; 122 | } 123 | 124 | public void SetTapInfo(bool rightHanded, string threadType, string threadDesignation, string threadClass, bool fullTapDpth, object threadDepth = null) 125 | { 126 | _holeFeature.TapInfo = _collectionRef.CreateTapInfo(rightHanded, threadType, threadDesignation, threadClass, fullTapDpth, threadDepth); 127 | } 128 | 129 | public void Dispose() 130 | { 131 | if (_holeFeature != null) 132 | { 133 | Marshal.ReleaseComObject(_holeFeature); 134 | _holeFeature = null; 135 | } 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /General/AngularUnits.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 InventorWrapper.General 8 | { 9 | /// 10 | /// Types of angular units 11 | /// 12 | public enum AngularUnits 13 | { 14 | Degrees, 15 | Radians 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /General/DefaultOptions.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.Components.Options; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.General 9 | { 10 | public static class DefaultOptions 11 | { 12 | public const string LevelOfDetailRepresentation = "LevelOfDetailRepresentation"; 13 | 14 | public const string ILogic = "Ilogic"; 15 | 16 | public static List DefaultNameValueOptions => new List 17 | { 18 | new InventorNameValueMapOptions(LevelOfDetailRepresentation, ILogic) 19 | }; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /General/LengthUnits.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 InventorWrapper.General 8 | { 9 | /// 10 | /// Types of length units 11 | /// 12 | public enum LengthUnits 13 | { 14 | In, 15 | M, 16 | MM 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /General/UnitManager.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 InventorWrapper.General 8 | { 9 | /// 10 | /// Used for managing unit interaction with inventor 11 | /// 12 | public static class UnitManager 13 | { 14 | /// 15 | /// Length units the wrapper is sending to inventor 16 | /// 17 | public static LengthUnits LengthUnits { get; set; } = LengthUnits.In; 18 | 19 | /// 20 | /// Angular units the wrapper is sending to inventor 21 | /// 22 | public static AngularUnits AngularUnits { get; set; } = AngularUnits.Degrees; 23 | 24 | /// 25 | /// List of the length units 26 | /// 27 | public static List MeasurementUnits 28 | { 29 | get 30 | { 31 | return new List { LengthUnits.In, LengthUnits.M, LengthUnits.MM }; 32 | } 33 | } 34 | 35 | /// 36 | /// List of angular units 37 | /// 38 | public static List AngularMeasurementUnits 39 | { 40 | get 41 | { 42 | return new List { AngularUnits.Degrees, AngularUnits.Radians }; 43 | } 44 | } 45 | 46 | /// 47 | /// Takes given value and sends to inventor 48 | /// If the unit type is length then the value is converted to centimeters 49 | /// If the unit type is angular then the value is converted to radians 50 | /// Other units types are sent as is 51 | /// 52 | /// 53 | /// 54 | /// 55 | public static double UnitsToInventor(double value, UnitTypes unitTypes = UnitTypes.Length) 56 | { 57 | switch (unitTypes) 58 | { 59 | case UnitTypes.Length: 60 | switch (LengthUnits) 61 | { 62 | case LengthUnits.In: 63 | return value * 2.54; 64 | case LengthUnits.M: 65 | return value * 10; 66 | case LengthUnits.MM: 67 | return value / 10; 68 | default: 69 | return value; 70 | } 71 | case UnitTypes.Angular: 72 | switch (AngularUnits) 73 | { 74 | case AngularUnits.Degrees: 75 | return ConvertDegrees(value); 76 | default: 77 | return value; 78 | } 79 | default: 80 | return value; 81 | } 82 | } 83 | 84 | /// 85 | /// Takes given value from inventor and converts to user specified 86 | /// If the unit type is length then the value is converted to user specified length units 87 | /// If the unit type is angular then the value is converted to user specified angular units 88 | /// Other unit types are retrieved as is 89 | /// 90 | /// 91 | /// 92 | /// 93 | public static double UnitsFromInventor(double value, UnitTypes unitTypes = UnitTypes.Length) 94 | { 95 | switch (unitTypes) 96 | { 97 | case UnitTypes.Length: 98 | switch (LengthUnits) 99 | { 100 | case LengthUnits.In: 101 | return value / 2.54; 102 | case LengthUnits.M: 103 | return value / 10; 104 | case LengthUnits.MM: 105 | return value * 10; 106 | default: 107 | return value; 108 | } 109 | case UnitTypes.Angular: 110 | switch (AngularUnits) 111 | { 112 | case AngularUnits.Degrees: 113 | return ConvertRadians(value); 114 | default: 115 | return value; 116 | } 117 | default: 118 | return value; 119 | } 120 | 121 | } 122 | 123 | /// 124 | /// Converts degrees to radians 125 | /// 126 | /// 127 | /// 128 | public static double ConvertDegrees(double value) 129 | { 130 | double constant = Math.PI / 180; 131 | 132 | return value * constant; 133 | } 134 | 135 | /// 136 | /// Convert radians to degrees 137 | /// 138 | /// 139 | /// 140 | public static double ConvertRadians(double value) 141 | { 142 | double constant = 180 / Math.PI; 143 | 144 | return value * constant; 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /General/UnitTypes.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 InventorWrapper.General 8 | { 9 | /// 10 | /// Type of units for interacting with inventor 11 | /// 12 | public enum UnitTypes 13 | { 14 | Length, 15 | Text, 16 | Unitless, 17 | Angular, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Geometry/InventorProxy.cs: -------------------------------------------------------------------------------- 1 | using InventorWrapper.Features; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Geometry 10 | { 11 | public class InventorProxy : IDisposable 12 | { 13 | /// 14 | /// Inventor interop 15 | /// 16 | public object _reference; 17 | 18 | public FeatureTypes Type; 19 | 20 | public string Name { get; set; } 21 | 22 | public string Value { get; set; } 23 | 24 | public InventorProxy(object reference, FeatureTypes type, string name, string value) 25 | { 26 | _reference = reference; 27 | Type = type; 28 | Name = name; 29 | Value = value; 30 | } 31 | 32 | public void Dispose() 33 | { 34 | if (_reference != null ) 35 | { 36 | Marshal.ReleaseComObject(_reference); 37 | _reference = null; 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Geometry/InventorWorkAxes.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Geometry 10 | { 11 | public class InventorWorkAxes : List, IDisposable 12 | { 13 | public InventorWorkAxes(AssemblyComponentDefinition adef) 14 | { 15 | foreach (WorkAxis axis in adef.WorkAxes) 16 | { 17 | Add(new InventorWorkAxis(axis)); 18 | } 19 | } 20 | 21 | public InventorWorkAxes(PartComponentDefinition pdef) 22 | { 23 | foreach (WorkAxis axis in pdef.WorkAxes) 24 | { 25 | Add(new InventorWorkAxis(axis)); 26 | } 27 | } 28 | 29 | public void Dispose() 30 | { 31 | if (Count == 0) return; 32 | 33 | foreach (var axis in this) 34 | { 35 | axis.Dispose(); 36 | } 37 | 38 | Clear(); 39 | } 40 | } 41 | 42 | public class InventorWorkAxis : IDisposable 43 | { 44 | public WorkAxis _axis; 45 | 46 | public string Name => _axis.Name; 47 | 48 | public InventorWorkAxis(WorkAxis axis) 49 | { 50 | _axis = axis; 51 | } 52 | 53 | public void Dispose() 54 | { 55 | if (_axis != null) 56 | { 57 | Marshal.ReleaseComObject(_axis); 58 | _axis = null; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Geometry/InventorWorkPlanes.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Geometry 10 | { 11 | public class InventorWorkPlanes : List, IDisposable 12 | { 13 | public InventorWorkPlanes(AssemblyComponentDefinition adef) 14 | { 15 | foreach (WorkPlane plane in adef.WorkPlanes) 16 | { 17 | Add(new InventorWorkPlane(plane)); 18 | } 19 | } 20 | 21 | public InventorWorkPlanes(PartComponentDefinition pdef) 22 | { 23 | foreach (WorkPlane plane in pdef.WorkPlanes) 24 | { 25 | Add(new InventorWorkPlane(plane)); 26 | } 27 | } 28 | 29 | public void Dispose() 30 | { 31 | if (Count == 0) return; 32 | 33 | foreach (var plane in this) 34 | { 35 | plane.Dispose(); 36 | } 37 | 38 | Clear(); 39 | } 40 | } 41 | 42 | public class InventorWorkPlane : IDisposable 43 | { 44 | public WorkPlane _workPlane; 45 | 46 | public string Name => _workPlane.Name; 47 | 48 | public InventorWorkPlane(WorkPlane workPlane) 49 | { 50 | _workPlane = workPlane; 51 | } 52 | 53 | public void Dispose() 54 | { 55 | if (_workPlane != null) 56 | { 57 | Marshal.ReleaseComObject(_workPlane); 58 | _workPlane = null; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Helpers/EnumHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.Helpers 9 | { 10 | /// 11 | /// Helpers for getting metadata from enums 12 | /// 13 | public static class EnumHelpers 14 | { 15 | /// 16 | /// Get the description attribute from the enum 17 | /// 18 | /// 19 | /// 20 | public static string GetDescription(this Enum enumValue) 21 | { 22 | //Look for DescriptionAttributes on the enum field 23 | object[] attr = enumValue.GetType().GetField(enumValue.ToString()) 24 | .GetCustomAttributes(typeof(DescriptionAttribute), false); 25 | 26 | // a DescriptionAttribute exists; use it 27 | if (attr.Length > 0) 28 | { 29 | return ((DescriptionAttribute)attr[0]).Description; 30 | } 31 | else 32 | { 33 | return ""; 34 | } 35 | } 36 | 37 | /// 38 | /// Get the category attribute from the enum 39 | /// 40 | /// 41 | /// 42 | public static string GetCategory(this Enum enumValue) 43 | { 44 | //Look for DescriptionAttributes on the enum field 45 | object[] attr = enumValue.GetType().GetField(enumValue.ToString()) 46 | .GetCustomAttributes(typeof(CategoryAttribute), false); 47 | 48 | // a DescriptionAttribute exists; use it 49 | if (attr.Length > 0) 50 | { 51 | return ((CategoryAttribute)attr[0]).Category; 52 | } 53 | else 54 | { 55 | return ""; 56 | } 57 | } 58 | 59 | /// 60 | /// Converts an enum to a list of strings 61 | /// 62 | /// 63 | /// 64 | public static List EnumToList() where T : Enum 65 | { 66 | return Enum.GetValues(typeof(T)).Cast().Select(x => x.ToString()).ToList(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IProps/InventorProperties.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Helpers; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using static System.String; 9 | 10 | namespace InventorWrapper.IProps 11 | { 12 | /// 13 | /// General document properties and custom properties 14 | /// 15 | public class InventorProperties 16 | { 17 | /// 18 | /// Name of the Project tab in inventor 19 | /// 20 | public const string ProjectTab = "Design Tracking Properties"; 21 | 22 | private PropertySets _propertySets; 23 | 24 | private List> _customProperties; 25 | 26 | public InventorProperties(PropertySets propertySets) 27 | { 28 | _propertySets = propertySets; 29 | } 30 | 31 | /// 32 | /// Custom properties for the document 33 | /// 34 | public List> CustomProperties 35 | { 36 | get 37 | { 38 | var customProperties = _propertySets[IpropertyEnum.Custom.GetCategory()]; 39 | 40 | if (_customProperties == null) 41 | { 42 | _customProperties = (from Property customProperty 43 | in customProperties select ( new Tuple(customProperty.Name, customProperty.Value as string))).ToList(); 44 | } 45 | 46 | return _customProperties; 47 | } 48 | } 49 | 50 | /// 51 | /// Checks if the property exists 52 | /// 53 | /// 54 | /// 55 | public bool PropertyExists(string propertyName) => CustomProperties.Count > 0 && 56 | CustomProperties.Any(prop => prop.Item1.ToUpper() == propertyName.ToUpper()); 57 | 58 | public string GetInternalName(IpropertyEnum ipropertyEnum, string customName = "") 59 | { 60 | var property = ipropertyEnum == IpropertyEnum.Custom ? 61 | PropertyExists(customName) ? _propertySets[ipropertyEnum.GetCategory()][customName] : null : 62 | _propertySets[ipropertyEnum.GetCategory()][ipropertyEnum.GetDescription()]; 63 | 64 | if (property == null) 65 | { 66 | return ""; 67 | } 68 | 69 | return _propertySets[ipropertyEnum.GetCategory()].InternalName; 70 | } 71 | 72 | /// 73 | /// Gets the given iproperty if the custom is selected give the name 74 | /// 75 | /// 76 | /// 77 | /// 78 | public string GetPropertyValue(IpropertyEnum ipropertyEnum, string customName = "") 79 | { 80 | var property = ipropertyEnum == IpropertyEnum.Custom ? 81 | PropertyExists(customName) ? _propertySets[ipropertyEnum.GetCategory()][customName] : null : 82 | _propertySets[ipropertyEnum.GetCategory()][ipropertyEnum.GetDescription()]; 83 | 84 | if (property == null) 85 | { 86 | return ""; 87 | } 88 | 89 | return property.Value as string; 90 | } 91 | 92 | public int GetPropertyId(IpropertyEnum ipropertyEnum, string customName = "") 93 | { 94 | var property = ipropertyEnum == IpropertyEnum.Custom ? 95 | PropertyExists(customName) ? _propertySets[ipropertyEnum.GetCategory()][customName] : null : 96 | _propertySets[ipropertyEnum.GetCategory()][ipropertyEnum.GetDescription()]; 97 | 98 | if (property == null) 99 | { 100 | return 0; 101 | } 102 | 103 | return property.PropId; 104 | } 105 | 106 | /// 107 | /// Sets the value of the given property 108 | /// 109 | /// 110 | /// 111 | /// 112 | /// 113 | public void SetPropertyValue(IpropertyEnum ipropertyEnum, string value, string customName) 114 | { 115 | Property property = null; 116 | 117 | if (ipropertyEnum == IpropertyEnum.Custom) 118 | { 119 | var customProperties = _propertySets[ipropertyEnum.GetCategory()]; 120 | 121 | foreach (Property p in customProperties) 122 | { 123 | if (p.Name == customName) 124 | { 125 | property = p; 126 | break; 127 | } 128 | } 129 | } 130 | else 131 | { 132 | property = _propertySets[ipropertyEnum.GetCategory()][ipropertyEnum == IpropertyEnum.Custom ? customName : ipropertyEnum.GetDescription()]; 133 | } 134 | 135 | if (property == null) 136 | { 137 | if (ipropertyEnum == IpropertyEnum.Custom) 138 | { 139 | _propertySets[ipropertyEnum.GetCategory()].Add(value, customName); 140 | } 141 | else 142 | { 143 | throw new Exception($"Could not set {(ipropertyEnum == IpropertyEnum.Custom ? customName : ipropertyEnum.GetDescription())}"); 144 | } 145 | } 146 | else 147 | { 148 | property.Value = value; 149 | } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /IProps/InventorPropertyTypeEnum.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace InventorWrapper.IProps 8 | { 9 | public enum InventorPropertyTypeEnum 10 | { 11 | FileProperty = 45569, 12 | CustomProperty, 13 | FilenamePartsListProperty, 14 | ItemPartsListProperty, 15 | MassPartsListProperty, 16 | MaterialPartsListProperty, 17 | QuantityPartsListProperty, 18 | BaseQuantityPartsListProperty, 19 | BaseUnitPartsListProperty, 20 | ItemQuantityPartsListProperty, 21 | UnitQuantityPartsListProperty, 22 | VolumePartsListProperty 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IProps/IpropertyEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.IProps 9 | { 10 | public class IpropertyStrings 11 | { 12 | public const string DesignTrackingProperties = "Design Tracking Properties"; 13 | 14 | public const string SummaryInformation = "Summary Information"; 15 | 16 | public const string DocumentSummaryInformation = "Document Summary Information"; 17 | } 18 | 19 | /// 20 | /// Maps location of inventor properties 21 | /// Description attribute is the name of the property in inventor 22 | /// Category refers to the tab 23 | /// 24 | public enum IpropertyEnum 25 | { 26 | [Description("Description")] 27 | [Category(IpropertyStrings.DesignTrackingProperties)] 28 | Description, 29 | 30 | [Description("Revision Number")] 31 | [Category(IpropertyStrings.DesignTrackingProperties)] 32 | RevisionNumber, 33 | 34 | [Description("Project")] 35 | [Category(IpropertyStrings.DesignTrackingProperties)] 36 | Project, 37 | 38 | [Description("Designer")] 39 | [Category(IpropertyStrings.DesignTrackingProperties)] 40 | Desinger, 41 | 42 | [Description("Engineer")] 43 | [Category(IpropertyStrings.DesignTrackingProperties)] 44 | Engineer, 45 | 46 | [Description("Authority")] 47 | [Category(IpropertyStrings.DesignTrackingProperties)] 48 | Authority, 49 | 50 | [Description("Estimated Cost")] 51 | [Category(IpropertyStrings.DesignTrackingProperties)] 52 | EstimatedCost, 53 | 54 | [Description("Creation Date")] 55 | [Category(IpropertyStrings.DesignTrackingProperties)] 56 | CreationDate, 57 | 58 | [Description("Vendor")] 59 | [Category(IpropertyStrings.DesignTrackingProperties)] 60 | Vendor, 61 | 62 | [Description("Part Number")] 63 | [Category(IpropertyStrings.DesignTrackingProperties)] 64 | PartNumber, 65 | 66 | [Description("Stock Number")] 67 | [Category(IpropertyStrings.DesignTrackingProperties)] 68 | StockNumber, 69 | 70 | [Description("Cost Center")] 71 | [Category(IpropertyStrings.DesignTrackingProperties)] 72 | CostCenter, 73 | 74 | [Description("Custom")] 75 | [Category("Inventor User Defined Properties")] 76 | Custom, 77 | 78 | [Description("Title")] 79 | [Category(IpropertyStrings.SummaryInformation)] 80 | Title, 81 | 82 | [Description("Subject")] 83 | [Category(IpropertyStrings.SummaryInformation)] 84 | Subject, 85 | 86 | [Description("Author")] 87 | [Category(IpropertyStrings.SummaryInformation)] 88 | Author, 89 | 90 | [Description("Manager")] 91 | [Category(IpropertyStrings.SummaryInformation)] 92 | Manager, 93 | 94 | [Description("Company")] 95 | [Category(IpropertyStrings.SummaryInformation)] 96 | Company, 97 | 98 | [Description("Category")] 99 | [Category(IpropertyStrings.SummaryInformation)] 100 | Category, 101 | 102 | [Description("Keywords")] 103 | [Category(IpropertyStrings.SummaryInformation)] 104 | Keywords, 105 | 106 | [Description("Comments")] 107 | [Category(IpropertyStrings.SummaryInformation)] 108 | Comments, 109 | } 110 | } 111 | 112 | //Inventor Document Summary Information 113 | //Inventor Summary Information 114 | //Design Tracking Properties 115 | //Inventor User Defined Properties -------------------------------------------------------------------------------- /InventorWrapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {31D2045E-03A5-4638-99CD-9535790A70D2} 8 | Library 9 | Properties 10 | InventorWrapper 11 | InventorWrapper 12 | v4.8 13 | 512 14 | true 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | false 35 | 36 | 37 | 38 | References\Autodesk.Inventor.Interop.dll 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /InventorWrapper.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | InventorWrapper 5 | 1.0.20 6 | InventorWrapper 7 | jraleigdev 8 | false 9 | MIT 10 | https://github.com/jraleighdev/InventorWrapper 11 | Dotnet wrapper for autodesk inventor 12 | Added support to retreive immediate children of a document. 13 | Copyright 2023 14 | Autodesk Inventor 15 | 16 | -------------------------------------------------------------------------------- /InventorWrapper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InventorWrapper", "InventorWrapper.csproj", "{31D2045E-03A5-4638-99CD-9535790A70D2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {31D2045E-03A5-4638-99CD-9535790A70D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {31D2045E-03A5-4638-99CD-9535790A70D2}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {31D2045E-03A5-4638-99CD-9535790A70D2}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {31D2045E-03A5-4638-99CD-9535790A70D2}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {ABC78586-A779-4939-8845-7E7B8DAC6F27} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Parameters/InventorParameter.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.General; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace InventorWrapper.Parameters 11 | { 12 | public class InventorParameter : IDisposable 13 | { 14 | private Parameter _parameter; 15 | 16 | public UnitTypes UnitType { get; private set; } 17 | 18 | public LengthUnits LengthUnit { get; private set; } 19 | 20 | public AngularUnits AngularUnit { get; private set; } 21 | 22 | public string Name 23 | { 24 | get => _parameter.Name; 25 | 26 | set => _parameter.Name = value; 27 | } 28 | 29 | /// 30 | /// Base value from inventor 31 | /// Centimeters if it is a length unit 32 | /// Radians if a angular unit 33 | /// 34 | public dynamic Value 35 | { 36 | get => _parameter.Value; 37 | 38 | set => _parameter.Value = value; 39 | } 40 | 41 | /// 42 | /// Returns the units converted to the standard specified in the unit manager 43 | /// 44 | public dynamic ConvertedValue 45 | { 46 | get 47 | { 48 | if (_parameter.Value == null) return null; 49 | 50 | var result = double.TryParse(_parameter.Value?.ToString(), out double tempValue); 51 | 52 | if (UnitType == UnitTypes.Length && result) 53 | { 54 | return UnitManager.UnitsFromInventor(tempValue); 55 | } 56 | else if (UnitType == UnitTypes.Angular && result) 57 | { 58 | return UnitManager.UnitsFromInventor(tempValue, UnitTypes.Angular); 59 | } 60 | 61 | return _parameter.Value; 62 | } 63 | } 64 | 65 | /// 66 | /// If Parameter is a user created parameter 67 | /// 68 | public bool IsUser => _parameter.ParameterType == ParameterTypeEnum.kUserParameter; 69 | 70 | /// 71 | /// Get the expression that evaluates to the parameter 72 | /// 73 | public string Expression 74 | { 75 | get => _parameter.Expression; 76 | 77 | set => _parameter.Expression = value; 78 | } 79 | 80 | /// 81 | /// The type of units for the parameter 82 | /// 83 | public string Units 84 | { 85 | get => _parameter.get_Units(); 86 | 87 | set => _parameter.set_Units(value); 88 | } 89 | 90 | public InventorParameter(Parameter parameter) 91 | { 92 | _parameter = parameter; 93 | 94 | SetUnitTypes(); 95 | } 96 | 97 | private void SetUnitTypes() 98 | { 99 | string formattedUnits = Units.ToUpper(); 100 | 101 | switch (formattedUnits) 102 | { 103 | case "IN": 104 | LengthUnit = LengthUnits.In; 105 | UnitType = UnitTypes.Length; 106 | break; 107 | case "MM": 108 | LengthUnit = LengthUnits.MM; 109 | UnitType = UnitTypes.Length; 110 | break; 111 | case "M": 112 | LengthUnit = LengthUnits.M; 113 | UnitType = UnitTypes.Length; 114 | break; 115 | case "RAD": 116 | AngularUnit = AngularUnits.Radians; 117 | UnitType = UnitTypes.Angular; 118 | break; 119 | case "RADIAN": 120 | AngularUnit = AngularUnits.Radians; 121 | UnitType = UnitTypes.Angular; 122 | break; 123 | case "DEG": 124 | AngularUnit = AngularUnits.Degrees; 125 | UnitType = UnitTypes.Angular; 126 | break; 127 | case "DEGREES": 128 | AngularUnit = AngularUnits.Degrees; 129 | UnitType = UnitTypes.Angular; 130 | break; 131 | case "UL": 132 | case "UNITLESS": 133 | UnitType = UnitTypes.Unitless; 134 | break; 135 | case "TEXT": 136 | UnitType = UnitTypes.Text; 137 | break; 138 | } 139 | } 140 | 141 | public void Dispose() 142 | { 143 | if (_parameter != null) 144 | { 145 | Marshal.ReleaseComObject(_parameter); 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Parameters/InventorParameters.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.Parameters 9 | { 10 | public class InventorParameters : List 11 | { 12 | private Inventor.Parameters _parameters; 13 | 14 | public InventorParameters(Inventor.Parameters parameters) 15 | { 16 | _parameters = parameters; 17 | 18 | foreach(Parameter p in parameters) 19 | { 20 | Add(new InventorParameter(p)); 21 | } 22 | } 23 | 24 | public InventorParameter GetParameter(string name) 25 | { 26 | return this.FirstOrDefault(x => x.Name == name); 27 | } 28 | 29 | /// 30 | /// Returns true or false if the parameter is found 31 | /// 32 | /// 33 | /// 34 | /// 35 | public bool SetParameter(string name, dynamic value) 36 | { 37 | var parameter = this.FirstOrDefault(x => x.Name == name); 38 | 39 | if (parameter != null) 40 | { 41 | parameter.Value = value; 42 | } 43 | 44 | return parameter != null; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Patterns/InventorPattern.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Components; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Security.Policy; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace InventorWrapper.Patterns 12 | { 13 | /// 14 | /// Inventor pattern 15 | /// 16 | public class InventorPattern : IDisposable 17 | { 18 | /// 19 | /// Occurrence pattern interop reference 20 | /// 21 | public OccurrencePattern _pattern; 22 | 23 | private List _occurences; 24 | 25 | /// 26 | /// Gets all the occurrences in the pattern 27 | /// 28 | public List Occurences 29 | { 30 | get 31 | { 32 | if (_occurences == null) 33 | { 34 | _occurences = new List(); 35 | 36 | int count = _pattern.OccurrencePatternElements.Count; 37 | 38 | for (int i = 1; i <= count; i++) 39 | { 40 | OccurrencePatternElement occelement = _pattern.OccurrencePatternElements[i]; 41 | 42 | ComponentOccurrencesEnumerator occenum = occelement.Occurrences; 43 | 44 | foreach (ComponentOccurrence occ in occenum) 45 | { 46 | _occurences.Add(new InventorComponent(occ)); 47 | } //next 48 | } 49 | } 50 | 51 | return _occurences; 52 | } 53 | } 54 | 55 | /// 56 | /// Name of the pattern 57 | /// 58 | public string Name => _pattern.Name; 59 | 60 | /// 61 | /// If this item is a pattern element 62 | /// 63 | public bool IsPatternElement => _pattern.IsPatternElement; 64 | 65 | /// 66 | /// I the item is suppressed 67 | /// 68 | public bool IsSuppressed => Occurences.Any(x => x.Suppressed); 69 | 70 | public InventorPattern(OccurrencePattern pattern) 71 | { 72 | _pattern = pattern; 73 | } 74 | 75 | public void Dispose() 76 | { 77 | if (_pattern != null) 78 | { 79 | Marshal.ReleaseComObject(_pattern); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Patterns/InventorPatterns.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Documents; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Patterns 10 | { 11 | /// 12 | /// Patterns in the for the referenced assembly document 13 | /// 14 | public class InventorPatterns : List 15 | { 16 | private InventorAssemblyDocument _adoc; 17 | 18 | public InventorPatterns(InventorAssemblyDocument adoc) 19 | { 20 | _adoc = adoc; 21 | 22 | GetPatterns(); 23 | } 24 | 25 | /// 26 | /// Suppresses a pattern by the given name 27 | /// 28 | /// 29 | /// 30 | /// 31 | public void SuppressPattern(string pattern, bool status) 32 | { 33 | OccurrencePattern occPattern = null; 34 | 35 | try 36 | { 37 | occPattern = _adoc._adef.OccurrencePatterns[pattern]; 38 | } 39 | catch 40 | { 41 | throw new Exception("Could not find pattern " + pattern); 42 | } 43 | 44 | int count = occPattern.OccurrencePatternElements.Count; 45 | 46 | for (int i = 1; i <= count; i++) 47 | { 48 | OccurrencePatternElement occelement = occPattern.OccurrencePatternElements[i]; 49 | 50 | ComponentOccurrencesEnumerator occenum = occelement.Occurrences; 51 | 52 | foreach (ComponentOccurrence occ in occenum) 53 | { 54 | if (status) 55 | { 56 | occ.BOMStructure = BOMStructureEnum.kReferenceBOMStructure; 57 | occ.Suppress(); 58 | } 59 | else 60 | { 61 | occ.Unsuppress(); 62 | occ.BOMStructure = BOMStructureEnum.kDefaultBOMStructure; 63 | } 64 | } //next 65 | } 66 | } 67 | 68 | /// 69 | /// Gets all the patterns 70 | /// 71 | private void GetPatterns() 72 | { 73 | foreach (OccurrencePattern pattern in _adoc._adef.OccurrencePatterns) 74 | { 75 | Add(new InventorPattern(pattern)); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Project/InventorDesignProject.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Enums; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Web; 10 | 11 | namespace InventorWrapper.Project 12 | { 13 | public class InventorDesignProject : IDisposable 14 | { 15 | private List _libraryPaths; 16 | 17 | public DesignProject _designProject; 18 | 19 | public InventorDesignProject(DesignProject design) 20 | { 21 | _designProject = design; 22 | } 23 | 24 | public InventorObjectTypes Type => (InventorObjectTypes)_designProject.Type; 25 | 26 | public string Name => _designProject.Name; 27 | 28 | public string FullFileName => _designProject.FullFileName; 29 | 30 | public string TemplatesPath => _designProject.TemplatesPath; 31 | 32 | public string WorkSpacePath => _designProject.WorkspacePath; 33 | 34 | public List LibraryPaths 35 | { 36 | get 37 | { 38 | if (_libraryPaths == null) 39 | { 40 | _libraryPaths = new List(); 41 | 42 | foreach (ProjectPath l in _designProject.LibraryPaths) 43 | { 44 | _libraryPaths.Add(new InventorProjectPath(l, this)); 45 | } 46 | } 47 | 48 | return _libraryPaths; 49 | } 50 | } 51 | 52 | public void Dispose() 53 | { 54 | if (_designProject!= null) 55 | { 56 | Marshal.ReleaseComObject(_designProject); 57 | _designProject = null; 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Project/InventorDesignProjectManager.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace InventorWrapper.Project 10 | { 11 | public class InventorDesignProjectManager : IDisposable 12 | { 13 | private List _projects; 14 | 15 | public DesignProjectManager _designProjectManager; 16 | 17 | public List Errors { get; private set; } = new List(); 18 | 19 | public InventorDesignProject ActiveProject 20 | { 21 | get => new InventorDesignProject(_designProjectManager.ActiveDesignProject); 22 | } 23 | 24 | public string ResolveFile(string sourcePath, string fileName) 25 | { 26 | return _designProjectManager.ResolveFile(sourcePath, fileName); 27 | } 28 | 29 | public List DesignProjects 30 | { 31 | get 32 | { 33 | if (_projects == null) 34 | { 35 | _projects = new List(); 36 | 37 | foreach (DesignProject d in _designProjectManager.DesignProjects) 38 | { 39 | _projects.Add(new InventorDesignProject(d)); 40 | } 41 | } 42 | 43 | return _projects; 44 | } 45 | } 46 | 47 | public InventorDesignProjectManager(DesignProjectManager designProjectManager) 48 | { 49 | _designProjectManager = designProjectManager; 50 | } 51 | 52 | public void Dispose() 53 | { 54 | if (_designProjectManager != null) 55 | { 56 | try 57 | { 58 | if (_projects != null && _projects.Count > 0) 59 | { 60 | foreach (var project in _projects) 61 | { 62 | project.Dispose(); 63 | } 64 | } 65 | 66 | ActiveProject?.Dispose(); 67 | } 68 | catch (Exception ex) 69 | { 70 | Errors.Add(ex); 71 | } 72 | 73 | 74 | Marshal.ReleaseComObject(_designProjectManager); 75 | _designProjectManager = null; 76 | 77 | 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Project/InventorProjectPath.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using InventorWrapper.Enums; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace InventorWrapper.Project 11 | { 12 | public class InventorProjectPath : IDisposable 13 | { 14 | public ProjectPath _projectPath; 15 | 16 | public string Name => _projectPath.Name; 17 | 18 | public InventorDesignProject Parent { get; private set; } 19 | 20 | public InventorObjectTypes Type => (InventorObjectTypes)_projectPath.Type; 21 | 22 | public string Path => _projectPath.Path; 23 | 24 | public InventorProjectPath(ProjectPath projectPath, InventorDesignProject parent) 25 | { 26 | _projectPath = projectPath; 27 | Parent = parent; 28 | } 29 | 30 | public void Dispose() 31 | { 32 | if (_projectPath != null ) 33 | { 34 | Marshal.ReleaseComObject(_projectPath); 35 | _projectPath = null; 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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("InventorWrapper")] 9 | [assembly: AssemblyDescription("Dot net wrapper for Autodesk Inventor")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("jraleighdev")] 12 | [assembly: AssemblyProduct("InventorWrapper")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 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("31d2045e-03a5-4638-99cd-9535790a70d2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Representation/InventorRepresentationManager.cs: -------------------------------------------------------------------------------- 1 | using Inventor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InventorWrapper.Representation 9 | { 10 | /// 11 | /// Manages the representation in the active document 12 | /// 13 | public class InventorRepresentationManager 14 | { 15 | private RepresentationsManager _representationsManager; 16 | 17 | public InventorRepresentationManager(RepresentationsManager representationsManager) 18 | { 19 | _representationsManager = representationsManager; 20 | } 21 | 22 | /// 23 | /// Activates the level of detail in the model 24 | /// 25 | /// 26 | public void ActivateLevelOfDetail(string name) => _representationsManager.LevelOfDetailRepresentations[name].Activate(true); 27 | 28 | /// 29 | /// Gets the active level of detail in the model 30 | /// 31 | public string ActiveLevelOfDetail => _representationsManager.ActiveLevelOfDetailRepresentation.Name; 32 | 33 | /// 34 | /// Activate the design view in the model 35 | /// 36 | /// 37 | public void ActivateDesignView(string name) => _representationsManager.DesignViewRepresentations[name].Activate(); 38 | 39 | /// 40 | /// Gets the Active design view 41 | /// 42 | public string ActiveDesignView => _representationsManager.ActiveDesignViewRepresentation.Name; 43 | 44 | /// 45 | /// Get the design view reps in the active model 46 | /// 47 | /// 48 | public List GetDesignReps() 49 | { 50 | return (from DesignViewRepresentation r in _representationsManager.DesignViewRepresentations select r.Name).ToList(); 51 | } 52 | 53 | /// 54 | /// Gets the level details in the active model 55 | /// 56 | /// 57 | public List GetLevelDetails() 58 | { 59 | return (from LevelOfDetailRepresentation r in _representationsManager.LevelOfDetailRepresentations 60 | select r.Name).ToList(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/Autodesk.Inventor.Interop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jraleighdev/InventorWrapper/4be06ba0294042283d9c2559c077722a6d0a3a86/lib/Autodesk.Inventor.Interop.dll -------------------------------------------------------------------------------- /lib/References/Autodesk.Inventor.Interop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jraleighdev/InventorWrapper/4be06ba0294042283d9c2559c077722a6d0a3a86/lib/References/Autodesk.Inventor.Interop.dll --------------------------------------------------------------------------------