├── .gitattributes ├── .gitignore ├── .vscode └── settings.json ├── AddRemove ├── De-Author.iLogicVb ├── Dedupe_and_Hash.iLogicVb ├── Delete empty folders.iLogicVb ├── DeleteConstructionWorkGeometry.iLogicVb ├── Embed inventor drawings.iLogicVb ├── Remove Missing OLE Links.iLogicVb ├── Remove Unwanted Linked Parameter Tables.iLogicVb ├── Remove Unwanted OLE Links in Inventor Files.iLogicVb └── RemoveColourOverrides.ilogicVb ├── App.config ├── Assembling Parts (Inventor iLogic).pdf ├── Autodesk ├── Brian Ekins │ ├── Balloon Report.iLogicVb │ ├── Boolean Example.iLogicVb │ └── Renumber Balloons To First Sheet.iLogicVb ├── Phillipe Leefsma │ └── Find Component Occurrence from Balloon.iLogicVb └── Thomas Fitzgerald │ ├── Balloons.iLogicVb │ ├── Dimensions.iLogicVb │ ├── Parts List.iLogicVb │ ├── Reorder Parts List.iLogicVb │ ├── Sheets.iLogicVb │ ├── Sketched Symbols.iLogicVb │ └── Views.iLogicVb ├── Book2.xml ├── C360 ├── C360PatternFootwalk.iLogicVb ├── ColumnA.iLogicVb ├── FilterColumnE.iLogicVb ├── FilterColumnG.iLogicVb ├── FilterColumnI.iLogicVb ├── FilterColumnL.iLogicVb ├── FilterColumnN.iLogicVb ├── FilterColumnO.iLogicVb ├── FilterColumnR.iLogicVb ├── FilterColumnRule.iLogicVb ├── FolderSearching.iLogicVb ├── PopulateMultivalueLists.iLogicVb ├── RulesOnEvents.xml ├── SuppressOccurrences.iLogicVb ├── UpdateMultivalueLists.iLogicVb └── UpdatePartNum.iLogicVb ├── CM Examples └── Pyramid.iLogicVB ├── Class1.vb ├── CommandNames.txt ├── Create_standard_parts_from_Excel.vsdx ├── Drawings ├── Add blank rows to parts list.iLogicVb ├── AlignDrawingViews.iLogicVb ├── Automatic Drawing dimensions.iLogicVb ├── Balloon Filtering iLogic.iLogicVb ├── Batch PDFs from Drawings.iLogicVb ├── ChangeLayerofOccurrences.iLogicVb ├── CopySheet.iLogicVb ├── Create DT- Drawings From Assembly.iLogicVb ├── Create Drawings From Assembly.iLogicVb ├── CreateLeader.iLogicVb ├── Create_View_Reps.iLogicVb ├── Drawing Automation Code.iLogicVb ├── Drawing Create Balloon.iLogicVb ├── Drawing Creation Code.iLogicVb ├── Drawing Template - Move and Resize View Code.iLogicVb ├── DrawingTextBoxQualityAssurance.iLogicVb ├── Drawings - Auto-Drawing dims using named geometry.iLogicVb ├── Export Open Inventor dwgs to AutoCAD.iLogicVb ├── FindReferencedModels.iLogicVb ├── GenerateBendDimensions.iLogicVb ├── GroupBalloons.iLogicVb ├── Insert Revision Table.iLogicVb ├── Inventor 2014 - View Representations with iLogic – Part 1 – Create – Cadline Community.pdf ├── Inventor 2014 - View Representations with iLogic – Part 2 – Update – Cadline Community.pdf ├── Inventor 2014 - View Representations with iLogic – Part 3 – Check – Cadline Community.pdf ├── ModifySketchEntities.iLogicVb ├── Prompted Entry To iProperty.iLogicVb ├── RunPlatformDrawings.iLogicVb ├── SaveAs DXF and Attach result.iLogicVb ├── SaveAs PDF checking Description for disallowed characters.iLogicVb ├── SaveAs_PDF_(Single_Or_Multi-sheet).iLogicVb ├── Sketch Symbol Text Changer.iLogicVb ├── Synchronize iProperties between parts and drawings.iLogicVb ├── Text_Changer.iLogicVb ├── Title Block Definition Create and Insert API Sample.iLogicVb ├── Turn Sketch Symbol Leaders on.iLogicVb └── Turn View Labels on.iLogicVb ├── Forms ├── Click Me!.state.xml ├── Click Me!.xml └── iLogicBrowserUiFormSpecification.xml ├── Forums └── how-to-know-when-to-change-naturalaxisdirection │ └── Create Holes.iLogicVb ├── Goddensee └── ChangeStyle.docx ├── Helper Rules ├── AddDockableWindow.iLogicVb ├── AddParamsFromList.iLogicVb ├── AlphaSortRepresentations.iLogicVb ├── BuildNamedGeometryForTesting.iLogicVb ├── Check for OLE Attachments.iLogicVb ├── CheckforcheckedOut.iLogicVb ├── Checkout Requested File From Vault.iLogicVb ├── Collapsible iLogic Test.iLogicVb ├── Collate Content Centre Parts.iLogicvb ├── CopyiPropertiesBetweenFiles.iLogicVb ├── CountFaces.iLogicVb ├── CreateHiddenProperty.iLogicVb ├── CreateModelStatesFromSubAssemblyNames.iLogicVb ├── Create_virtual_parts_from_Excel.iLogicVb ├── DebugBrowserNodes.iLogicVb ├── DeleteUnreferencedSketchEntities.iLogicVb ├── Design Checker │ ├── Fillet Size.iLogicVb │ ├── MaterialCheck.iLogicVb │ ├── iLogic-FeatureBased Template.iLogicVb │ └── iLogic-General Template.iLogicVb ├── DumpInternaliLogicRulesToExternalFolder.iLogicVb ├── DumpPartGeometrySetDefinitionToFile.iLogicVb ├── DumpRepresentationNamesToFile.iLogicVb ├── Eventdrivenrulescopy.ilogicvb ├── Export iFactory to Multiple Formats.iLogicVb ├── ExportSinglePDFFromDrawing.iLogicVb ├── ExportToPDFAndAttachOutput.iLogicVb ├── ExportToStepAndAttachOutput.iLogicVb ├── ExtBatchPdfs.iLogicVb ├── FinishFeatures │ ├── CreateFinishFeature.iLogicVb │ └── CreateFinishFeaturesFromLibrary.iLogicVb ├── Generate iFactory Members from Parent Assemblies.iLogicVb ├── GetProperties.iLogicVb ├── Ground selected in current location.iLogicVb ├── Ground_and_Root.iLogicVb ├── GroupAndSortPartsList.iLogicVb ├── LoopTest.iLogicVb ├── MeasureComponents.iLogicVb ├── Parameters.iLogicVb ├── PartsandAssemblies.iLogicVb ├── Place_And_Ground_Known_Part.iLogicVb ├── PrintCommandNames.iLogicVb ├── ProcessPartFilesInaFolder.iLogicVb ├── PushPartBoundariesToCustomiProperties.iLogicVb ├── Pusher │ ├── DIMS.ilogicVb │ └── Trigger Generator.iLogicVb ├── RecomputeFailureCheck.iLogicVb ├── RenumberItems.iLogicVb ├── Runextdebug.iLogicVb ├── SQLite connection.iLogicVb ├── TryCatchCatch.iLogicVb ├── Vault Browser Refresh Files.iLogicVb ├── While away the hours.iLogicVb ├── Wibble.iLogicVb ├── iLogicDeleteAllNamedGeometry.iLogicVb ├── iLogicFeatureNameCollector.iLogicVb ├── iLogicFeatureSelectorForDebugging.iLogicVb ├── iLogicNamedGeometryConnector.iLogicVb ├── iLogicWindowSelectExample.iLogicVb ├── iProperties.iLogicVb ├── wibble.bmp ├── wibble.dark.large.png ├── wibble.dark.small.png ├── wibble.jpg ├── wibble.large.bmp ├── wibble.png └── wibble.small.bmp ├── LICENSE ├── Modelling ├── 50m Turbine Test_Shape Generator_1.stl ├── Active Lighting Style.ilogicvb ├── Add CC Part as Custom using Vault Naming Scheme.iLogicVb ├── AlignUCSToAssy.iLogicVb ├── All Sketches Off In Assembly.iLogicVb ├── All Sketches Off In Part.iLogicVb ├── Appearance Overrides.iLogicVb ├── Assembly get current relevant Occurrences.iLogicVb ├── AssemblyCheckHoleAlignment.iLogicVb ├── AssemblyCreateExtrusion.iLogicVb ├── CS Data Standards.iLogicVb ├── CaptureSketchBlockLocations.iLogicVb ├── CascadingLists.iLogicVb ├── Check Geometry Situated within Part.iLogicVb ├── Check Sketch Constraints.iLogicVb ├── CheckCurrentPosRep.iLogicVb ├── CheckForCURequired.iLogicVb ├── CheckiPartForErrors.iLogicVb ├── Compare File volumes.iLogicVb ├── Contact Constraint Simulation.iLogicVb ├── Copy_Camera_to_open_documents.iLogicVb ├── Create DT- View Reps From Assembly.iLogicVb ├── Create a New iLogic Rule automatically.iLogicVb ├── Create3DCircleBy3Points.iLogicVb ├── CreateCofGsForAssembly.iLogicVb ├── Create_Assembly_from_Excel.iLogicVb ├── Create_Balconies.iLogicVb ├── Create_Cables.iLogicVb ├── Create_Labels.Vb ├── Create_Labels.iLogicVb ├── Create_standard_parts_from_Excel.iLogicVb ├── Crossrail │ ├── Add Mates.iLogicVb │ ├── Crossrail Tunnels.iLogicVb │ ├── Named Geometry Pusher.iLogicVb │ ├── Place & Stack Boxes.iLogicVb │ └── Stack Boxes.iLogicVb ├── DesignCheckerResultsFromAssembly.iLogicVb ├── Engraving.iLogicVb ├── Explode Assembly.iLogicVb ├── Export Part to Step (Based on iProperty Values).iLogicVb ├── Export Part to Step (Stage by Stage).iLogicVb ├── Export to 3D PDF and Attach or Embed.iLogicVb ├── FEATURECOUNT.iLogicVb ├── Flange Face Material Retainer.iLogicVb ├── Flat pattern save as dxf.iLogicVb ├── Generate factory Members.iLogicVb ├── Generate iPart Members from Folder.iLogicVb ├── Generate iPart Members from Parent Assemblies.iLogicVb ├── GetHoleCountAndDiameters.iLogicVb ├── Ground&RootSelectedComponents.iLogicVb ├── HyperLink to Excel.iLogicVb ├── IPT Bend Marker.iLogicVb ├── IPart Row Changer.iLogicVb ├── Import DWG into sketch.iLogicVb ├── Inventor 2016 - ILogic to write Parameter to every part in the Assembly.iLogicVb ├── MakeComponentsProgramatically.iLogicVb ├── MetalShopPn.iLogicVb ├── MirrorPartInAssembly.iLogicVb ├── Move EOPs In Assembly.iLogicVb ├── MoveItMoveIt.bas ├── MoveToPlane.iLogicVb ├── OldVersions │ └── ProjectCurveToSurface.0001.ipt ├── PartCreator.iLogicVb ├── PartFeatureNamesList.xml ├── PartPatternTester.iLogicVb ├── Pattern Footwalks.iLogicVb ├── Place Named UCS.iLogicVb ├── PrintRibbonInformation.iLogicVb ├── ProjectCurveToSurface.iLogicVb ├── ProjectCurveToSurface.ipt ├── Rename Assembly Browser Nodes.iLogicVb ├── Rename Parameters.iLogicVb ├── Replace references from external list.iLogicVb ├── Run design checker on each component.iLogicVb ├── RunCorrectBomForExcel.iLogicVb ├── RunCreateAssemblyFromiLogic.iLogicVb ├── RunCreateAssemblyFromiLogic_UPLOAD.iLogicVb ├── RunExportToMultipleFormats.iLogicVb ├── RunFeatureCountonAssembly.iLogicVb ├── RunPartCreator.iLogicVb ├── SaveCopyAsFromComponentNames.iLogicVb ├── Selective Colour Change.iLogicVb ├── SetAppearance.iLogicVb ├── Shrinkwrap Substitute in assembly.iLogicVb ├── SlicePartAndExport.iLogicVb ├── SlicePartUsingWorkplanesAndExport.iLogicVb ├── Suppress Weld Prep.iLogicVb ├── SuppressPatternedHolesBasedOnBoundarySketch.iLogicVb ├── Swap Extrusions to holes.iLogicVb ├── SwapPositions.iLogicVb ├── Sweep-length-code-snippet.iLogicVb ├── Synchronize iProperties between part parameters and iProperties.iLogicVb ├── TFI Dome thingy.iLogicVb ├── Toggle Sketches and Workplanes.iLogicVb ├── Toggle Workfeatures and Sketches in Assembly SelectionSet.iLogicVb ├── Traverse an Assembly API Sample.pdf ├── Turn On-Off all Workfeatures in an Assembly.iLogicVb ├── Under constrained sketches.iLogicVb ├── Update Embossing.iLogicVb ├── UpdatedCurrentlyOpenDocuments.iLogicVb └── Workplane Grid Creator.iLogicVb ├── Module Rules ├── Modules.ilogicvb ├── Modules.xsd └── Update.iLogicVb ├── PJ └── 06 Add Size To Parts.iLogicVb ├── README.md ├── RibbonNames.txt ├── Rule Exports ├── 00003-DW-BS-DT-01-101-iLogicRules.xml ├── 00025-DW-VIV-DT-01-001-iLogicRules.xml ├── 11916-DW-PBBM-DT-01-101-iLogicRules.xml ├── 20 & 40 standard & high cube-iLogicRules.xml ├── 6025-201-iLogicRules.xml ├── Balmoral Drawing Template Rev 03-iLogicRules.xml ├── BenK Auto extrude example-iLogicRules.xml ├── Change iParts from form-iLogicRules.xml ├── Configuration Top Level Assembly-iLogicRules-2019-03-01.xml └── Lv1_ct_assy-iLogicRules.xml ├── Spreadsheet for Create Assembly From Excel & Create Standard Parts From Excel.xlsx ├── VBAExport ├── AlphaSortViewReps.bas ├── AnchoredClientGraphics.bas ├── BomTools.bas ├── ClientGraphicsPrimitives.bas ├── ClientGraphicsText.bas ├── DebugExcelRangeObject.bas ├── DebugObject.bas ├── DrawingOverlayGraphics.bas ├── ExcelHelpers.bas ├── ExportTableDataToWord.cls ├── HideTitleBar.bas ├── InventorSurvey.bas ├── OleOle.bas ├── OnFaceCurveSample.bas ├── Place_And_Ground_Known_Part.bas ├── PrintRibbonNames.bas ├── RenameAssemblyBrowserNodes.bas ├── Sheet1.cls ├── Sheet11.cls ├── Sheet12.cls ├── Sheet2.cls ├── Sheet3.cls ├── Sheet4.cls ├── Sheet6.cls ├── Sheet7.cls ├── Sheet8.cls ├── Sheet9.cls ├── ThisWorkbook.cls ├── VBAHelpers.bas ├── WebBrowserDialog.bas ├── WordHelpers.bas ├── Word_Add_Image_Caption_Tables.cls ├── clsSelect.cls ├── ufProgress.frm └── ufProgress.frx ├── iLogic Collection.sln ├── iLogic Collection.vbproj ├── iLogic Workspace.code-workspace ├── iLogic XLS iFeature Pattern.zip ├── iLogic.7z ├── iLogic.zip ├── iLogicOptions.xml ├── iLogicOptions2017.xml ├── iLogicOptions2019 (Work).xml ├── iLogicOptions2020(MandM).xml ├── iLogicOptions2022 (Home).xml ├── iLogicOptions2022 (Work).xml ├── iLogicOptions_2024 (Home).xml ├── iLogic_Access_Example.accdb ├── ilogic_iproperties_test.dwg ├── ilogicoptions2018.xml └── ruleslist.txt /.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 | *.iLogicVb linguist-language=visual-basic-.net 65 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | } -------------------------------------------------------------------------------- /AddRemove/De-Author.iLogicVb: -------------------------------------------------------------------------------- 1 | Dim oProperty 2 | oProperty = ThisApplication.ActiveDocument.PropertySets.Item("32853F0F-3444-11d1-9E93-0060B03C1CA6").ItemByPropId(56) 3 | oProperty.Value = "" 4 | 5 | -------------------------------------------------------------------------------- /AddRemove/Delete empty folders.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | 3 | oDoc = ThisDoc.Document 4 | oPane = oDoc.BrowserPanes("Model") 5 | oTopNode = oPane.TopNode 6 | 7 | 'Iterate through the browser folders 8 | For Each oFolder In oTopNode.BrowserFolders 9 | i = 0 10 | 'Iterate through the nodes in the folder 11 | oFolderNodes = oFolder.BrowserNode.BrowserNodes 12 | For Each oNode As BrowserNode In oFolderNodes 13 | 'count the nodes 14 | i = i+1 15 | Next 16 | 'delete the folder if the count = 0 17 | If i = 0 Then 18 | oFolder.Delete 19 | Else 20 | End If 21 | Next 22 | -------------------------------------------------------------------------------- /AddRemove/DeleteConstructionWorkGeometry.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub main() 2 | Dim AssyDoc As AssemblyDocument = Nothing 3 | Dim PartDoc As PartDocument = Nothing 4 | 5 | Dim ThisDef As ComponentDefinition = Nothing 6 | 7 | If TypeOf ThisApplication.ActiveDocument Is AssemblyDocument Then 8 | AssyDoc = ThisApplication.ActiveDocument 9 | Else If TypeOf ThisApplication.ActiveDocument Is PartDocument Then 10 | PartDoc = ThisApplication.ActiveDocument 11 | End If 12 | 13 | If Not AssyDoc Is Nothing Then 14 | ThisDef = AssyDoc.ComponentDefinition 15 | End If 16 | 17 | If Not PartDoc Is Nothing Then 18 | ThisDef = PartDoc.ComponentDefinition 19 | End If 20 | 21 | If Not ThisDef Is Nothing Then 22 | For Each wp As WorkPoint In ThisDef.WorkPoints 23 | If wp.Construction Then 24 | wp.Delete 25 | End If 26 | Next 27 | For Each wa As WorkAxis In ThisDef.WorkAxes 28 | If wa.Construction Then 29 | wa.Delete 30 | End If 31 | Next 32 | End If 33 | End Sub -------------------------------------------------------------------------------- /AddRemove/Embed inventor drawings.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub Main() 3 | 4 | 'current document 5 | Dim doc as Inventor.Document = ThisDoc.Document 6 | 7 | 'Verify the current document has been saved. 8 | If doc.FullFileName = "" Then 9 | MessageBox.Show("This document must be saved first.") 10 | Exit Sub 11 | End If 12 | 13 | 'default folder 14 | Dim FolderName As String = System.IO.Path.GetDirectoryName(doc.FullFileName) 15 | Dim selectedfile As String = String.Empty 16 | Dim oFileDlg As inventor.FileDialog = Nothing 17 | InventorVb.Application.CreateFileDialog(oFileDlg) 18 | oFileDlg.Filter = "Step files (*.stp;*.step;*.stpz)|*.stp;*.step;*.stpz|Dwg files (*.dwg)|*.dwg|Excel files (*.xlsx)|*.xlsx|pdf files (*.pdf)|*.pdf|Inventor parts (*.ipt)|*.ipt|Inventor iFeatures (*.ide)|*.ide|XML Parameter files (*.xml)|*.xml|Other files (*.*)|*.*" 19 | oFileDlg.InitialDirectory = FolderName 20 | oFileDlg.CancelError = True 21 | oFileDlg.MultiSelectEnabled = True 22 | 23 | Try 24 | oFileDlg.ShowOpen() 25 | selectedfile = oFileDlg.FileName 26 | Catch 27 | Return 'operation was cancelled by the user 28 | End Try 29 | AddReferences(doc, selectedfile) 30 | End Sub 31 | Public Sub AddReferences(ByVal odoc as Inventor.Document, ByVal selectedfile As String) 32 | Dim oleReference As ReferencedOLEFileDescriptor 33 | If selectedfile.Contains("|") Then ' we have multiple files selected. 34 | Dim file As String() = selectedfile.Split("|") 35 | For Each s as String in file 36 | oleReference = odoc.ReferencedOLEFileDescriptors _ 37 | .Add(s, OLEDocumentTypeEnum.kOLEDocumentLinkObject) 38 | oleReference.BrowserVisible = True 39 | oleReference.Visible = False 40 | oleReference.DisplayName = Mid$(s, InStrRev(s, "\") + 1) 41 | Next 42 | Else 43 | oleReference = odoc.ReferencedOLEFileDescriptors _ 44 | .Add(selectedFile,OLEDocumentTypeEnum.kOLEDocumentLinkObject) 45 | oleReference.BrowserVisible = True 46 | oleReference.Visible = False 47 | oleReference.DisplayName = Mid$(selectedFile, InStrRev(selectedFile, "\") + 1) 48 | End If 49 | End Sub 50 | -------------------------------------------------------------------------------- /AddRemove/Remove Missing OLE Links.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main() 2 | oleLinksDelete() 3 | End Sub 4 | 5 | 6 | Public Sub oleLinksDelete() 7 | 8 | ThisApplication.SilentOperation = True 9 | 'Dim oAssyDoc As AssemblyDocument 10 | 'Dim oPartDoc As PartDocument 11 | Dim oDrawingDoc As DrawingDocument 12 | 'oPartDoc = ThisApplication.ActiveDocument 13 | 'oAssyDoc = ThisApplication.ActiveDocument 14 | oDrawingDoc = ThisApplication.ActiveDocument 15 | 16 | Dim bSaveDoc As Boolean 17 | bSaveDoc = False 18 | 19 | Dim oRefOleFileDesc As ReferencedOLEFileDescriptor 20 | 'If oAssyDoc.ReferencedOLEFileDescriptors.Count > 0 Then 21 | 'If oPartDoc.ReferencedOLEFileDescriptors.Count > 0 Then 22 | If oDrawingDoc.ReferencedOLEFileDescriptors.Count > 0 Then 23 | 'For Each oRefOleFileDesc In oAssyDoc.ReferencedOLEFileDescriptors 24 | 'For Each oRefOleFileDesc In oPartDoc.ReferencedOLEFileDescriptors 25 | For Each oRefOleFileDesc In oDrawingDoc.ReferencedOLEFileDescriptors 26 | 'Debug.Print oRefOleFileDesc.ReferenceStatus 27 | 28 | If oRefOleFileDesc.ReferenceStatus = ReferenceStatusEnum.kMissingReference Then 29 | ' Debug.Print oRefOleFileDesc.DisplayName 30 | oRefOleFileDesc.Delete 31 | 'oPartDoc.Dirty = True 32 | oDrawingDoc.Dirty = True 33 | 'oAssyDoc.Dirty = True 34 | bSaveDoc = True 35 | End If 36 | Next oRefOleFileDesc 37 | 38 | If bSaveDoc = True Then 39 | 'oAssyDoc.Save 40 | 'oPartDoc.Save 41 | oDrawingDoc.Save 42 | bSaveDoc = False 43 | End If 44 | End If 45 | ' Be sure to set this back to False 46 | ThisApplication.SilentOperation = False 47 | End Sub 48 | -------------------------------------------------------------------------------- /AddRemove/Remove Unwanted Linked Parameter Tables.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | 'DeleteLinkedParameterTablesAutodesk() 3 | DeleteLinkedParameterTables() 4 | End Sub 5 | 6 | Public Sub DeleteLinkedParameterTables() 7 | Dim oDoc As Document 8 | oDoc = ThisApplication.ActiveDocument 9 | If oDoc.ComponentDefinition.Parameters.ParameterTables.Count = 0 Then 10 | MsgBox ("There aren't any linked parameter tables in this document.") 11 | Exit Sub 12 | Else 13 | MsgBox ("Proceeding to selection of parameter tables") 14 | Dim pt As ParameterTable 15 | For Each pt In oDoc.ComponentDefinition.Parameters.ParameterTables 16 | 'For i = 1 To oDoc.ComponentDefinition.Parameters.ParameterTables.Count 17 | If MsgBox("Delete """ & pt.FileName & """?", vbYesNo) = vbYes Then 18 | pt.Delete 19 | End If 20 | Next 21 | End If 22 | End Sub 23 | -------------------------------------------------------------------------------- /AddRemove/Remove Unwanted OLE Links in Inventor Files.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | DeleteOLEReference() 3 | End Sub 4 | 5 | Public Sub DeleteOLEReference() 6 | Dim oDoc As Document 7 | oDoc = ThisApplication.ActiveDocument 8 | 9 | If oDoc.ReferencedOLEFileDescriptors.Count = 0 Then 10 | MsgBox ("There aren't any OLE references in this document.") 11 | Exit Sub 12 | End If 13 | 14 | Dim aOLERefs() As ReferencedOLEFileDescriptor 15 | ReDim aOLERefs(oDoc.ReferencedOLEFileDescriptors.Count - 1) 16 | 17 | Dim iRefCount As Integer 18 | iRefCount = oDoc.ReferencedOLEFileDescriptors.Count 19 | Dim i As Integer 20 | For i = 1 To iRefCount 21 | aOLERefs(i - 1) = oDoc.ReferencedOLEFileDescriptors.Item(i) 22 | Next 23 | 24 | For i = 1 To iRefCount 25 | If MsgBox("Delete """ & aOLERefs(i - 1).FullFileName & """?", vbQuestion + vbYesNo) = vbYes Then 26 | aOLERefs(i - 1).Delete 27 | End If 28 | Next 29 | End Sub 30 | -------------------------------------------------------------------------------- /AddRemove/RemoveColourOverrides.ilogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | Dim oAsmCompDef As AssemblyComponentDefinition 3 | oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 4 | 5 | 'set Master view rep active 6 | Dim oViewRep As DesignViewRepresentation 7 | oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Master") 8 | oViewRep.Activate 9 | 10 | 'Define the open document 11 | Dim openDoc As Document 12 | openDoc = ThisDoc.Document 13 | 14 | 'Look at all of the files referenced in the open document 15 | Dim docFile As Document 16 | 17 | For each docFile in openDoc.AllReferencedDocuments 18 | RemoveColourOverrides(docFile) 19 | next 20 | iLogicVb.UpdateWhenDone = True 21 | End Sub 22 | Sub RemoveColourOverrides(ByVal DocFile as Inventor.Document) 23 | If docfile.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then 24 | Dim oCompDef As Inventor.PartComponentDefinition 25 | oCompDef = docFile.ComponentDefinition 26 | 27 | 'Iterate through all features 28 | Dim oFeature As PartFeature 29 | For Each oFeature In oCompDef.Features 30 | 'Set the render style to be "As Body" 31 | oFeature.SetRenderStyle(37125) 32 | Next 33 | 34 | 'Iterate through all solids 35 | For Each Solid In oCompDef.SurfaceBodies 36 | 'Set the render style to be "As Part" 37 | Solid.SetRenderStyle(37121, True) 38 | 'Iterate through all faces. 39 | Dim oFace As Face 40 | For Each oFace In Solid.Faces 41 | ' Set the render style to be "As Feature" 42 | oFace.SetRenderStyle(37122) 43 | Next 44 | Next 45 | Else 46 | 'Call RemoveColourOverrides(docFile) 47 | End If 48 | End Sub -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Assembling Parts (Inventor iLogic).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Assembling Parts (Inventor iLogic).pdf -------------------------------------------------------------------------------- /Autodesk/Phillipe Leefsma/Find Component Occurrence from Balloon.iLogicVb: -------------------------------------------------------------------------------- 1 | ' Assumes the drawing view is created from a assembly. 2 | 3 | ' Select a balloon manually before running this procedure 4 | 5 | Private Sub test(ByVal app As Inventor.Application) 6 | 7 | 8 | 9 | Dim doc As DrawingDocument = app.ActiveDocument 10 | 11 | 12 | 13 | Dim balloon As Balloon = doc.SelectSet(1) 14 | 15 | 16 | 17 | Dim leader As Leader = balloon.Leader 18 | 19 | 20 | 21 | 'assuming the leader is a single line segment 22 | 23 | Dim leaderNode As LeaderNode = leader.AllNodes(2) 24 | 25 | 26 | 27 | Dim intent As GeometryIntent = leaderNode.AttachedEntity 28 | 29 | 30 | 31 | Dim curve As DrawingCurve = intent.Geometry 32 | 33 | 34 | 35 | Dim edgePx As EdgeProxy = curve.ModelGeometry 36 | 37 | 38 | 39 | Dim occurrence As ComponentOccurrence = edgePx.ContainingOccurrence 40 | 41 | 42 | 43 | Debug.Print(vbCrLf + "Occurrence Name: " + occurrence.Name) 44 | 45 | 46 | 47 | End Sub -------------------------------------------------------------------------------- /Autodesk/Thomas Fitzgerald/Parts List.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | Dim invDoc As DrawingDocument = ThisApplication.ActiveDocument 3 | Dim oSheet As Sheet = invDoc.ActiveSheet 4 | Try 5 | DeletePartsList(oSheet) 6 | Catch 7 | End Try 8 | Dim oDrawingView As DrawingView = oSheet.DrawingViews(1) 9 | Dim oBorder As Border = oSheet.Border 10 | Dim oPlacementPoint As Point2d 11 | If Not oBorder Is Nothing Then 12 | oPlacementPoint = oBorder.RangeBox.MaxPoint 13 | Else 14 | oPlacementPoint = 15 | ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height) 16 | End If 17 | Dim partsListBomType As PartsListLevelEnum = 46593 18 | Dim oPartsList As PartsList = oSheet.PartsLists.Add(oDrawingView, 19 | oPlacementPoint, partsListBomType) 20 | End Sub 21 | Private Sub DeletePartsList(oSheet As Sheet) 22 | Dim oPartList As PartsList 23 | For Each oPartList In oSheet.PartsLists 24 | oPartList.Delete() 25 | Next 26 | End Sub -------------------------------------------------------------------------------- /Autodesk/Thomas Fitzgerald/Reorder Parts List.iLogicVb: -------------------------------------------------------------------------------- 1 | Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 2 | Dim oPartList As PartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1) 3 | oPartList.Renumber() 4 | oPartList.SaveItemOverridesToBOM() -------------------------------------------------------------------------------- /Autodesk/Thomas Fitzgerald/Sheets.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | Dim sheetNames As New List(Of String) 3 | sheetNames.Add("MAIN") 4 | sheetNames.Add("Detail") 5 | Dim sheetSize As DrawingSheetSizeEnum = 9988 6 | Dim invDoc As DrawingDocument = ThisApplication.ActiveDocument 7 | Dim oSheet As Sheet = Nothing 8 | '*** Add the number of Sheets and name the Sheets 9 | For index As Integer = 1 To oSheets.Count 10 | oSheet = invDoc.Sheets.Add(sheetSize, ,sheetNames(index - 1)) 11 | Next 12 | '*** Delete Sheet:1 13 | For Each oSheet In invDoc.Sheets 14 | If oSheet.Name = "Sheet:1" Then 15 | oSheet.Delete 16 | End If 17 | Next 18 | '*** Activate the MAIN Sheet 19 | For Each oSheet In invDoc.Sheets 20 | If oSheet.Name = oSheets(0) & ":1" Then 21 | oSheet.Activate 22 | End If 23 | Next 24 | End Sub -------------------------------------------------------------------------------- /Autodesk/Thomas Fitzgerald/Sketched Symbols.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | Dim symbolCount As Integer = 2 3 | Dim sketchSymbolName As String = "TestSymbol" 4 | Dim someValue1 As String = "This Works!" 5 | Dim someValue2 As String = "You Betcha" 6 | Dim rotation As Double = 0 7 | Dim scaleFactor As Double = 1 8 | Dim xValue As Integer = 5 9 | Dim yValue As Integer = 2 10 | Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 11 | Dim oSketchedSymbolDef As SketchedSymbolDefinition = 12 | oDrawDoc.SketchedSymbolDefinitions.Item(sketchSymbolName) 13 | Dim oSheet As Sheet = oDrawDoc.ActiveSheet 14 | ' This sketched symbol definition contains one prompted string input. An 15 | array must be input that contains the strings for the prompted strings. 16 | Dim oPromptStrings(symbolCount - 1) As String 17 | oPromptStrings(0) = someValue1 18 | oPromptStrings(1) = someValue2 19 | Dim oTG As TransientGeometry = ThisApplication.TransientGeometry 20 | Dim oSketchedSymbol As SketchedSymbol 21 | oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, 22 | oTG.CreatePoint2d(xValue, yValue), rotation, scaleFactor, oPromptStrings) 23 | End Sub -------------------------------------------------------------------------------- /Book2.xml: -------------------------------------------------------------------------------- 1 | "/> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /C360/ColumnA.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit on 2 | Dim p = Parameter("columnA") 3 | logger.Debug("columnA updated") 4 | -------------------------------------------------------------------------------- /C360/FilterColumnE.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub main() 2 | If Not RuleArguments.Exists("ParameterValue") Then 3 | MessageBox.Show("How did we get here?") 4 | Else 5 | 'Column E changes nothing currently 6 | 'MessageBox.Show("Hello World") 7 | End If 8 | 9 | End Sub 10 | -------------------------------------------------------------------------------- /C360/FilterColumnG.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub main() 3 | If Not RuleArguments.Exists("ParameterValue") Then 4 | MessageBox.Show("How did we get here?") 5 | Else 6 | 'Column G changes nothing currently 7 | 'MessageBox.Show("Hello World") 8 | End If 9 | 10 | End Sub 11 | -------------------------------------------------------------------------------- /C360/FilterColumnI.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub main() 3 | If Not RuleArguments.Exists("ParameterValue") Then 4 | MessageBox.Show("How did we get here?") 5 | Else 6 | 'Column I changes nothing currently 7 | 'MessageBox.Show("Hello World") 8 | End If 9 | 10 | End Sub 11 | -------------------------------------------------------------------------------- /C360/FilterColumnL.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub main() 3 | If Not RuleArguments.Exists("ParameterValue") Then 4 | MessageBox.Show("How did we get here?") 5 | Else 6 | 'Column L 7 | Dim paramValue As String = RuleArguments.Value("ParameterValue") 8 | Dim FilterArguments As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() 9 | 'this needs to be a list of values to remove/add from the next column along. 10 | Dim filterList As List(Of String) = New List(Of String) 11 | Select paramValue 12 | Case "L" 13 | filterList.Add("C") 14 | filterList.Add("K") 15 | filterList.Add("S") 16 | Case "R" 17 | filterList.Add("F") 18 | filterList.Add("K") 19 | filterList.Add("M") 20 | filterList.Add("S") 21 | filterList.Add("T") 22 | Case Else 23 | End Select 24 | FilterArguments.Value("UniqueValues") = filterList 25 | FilterArguments.Value("ColumnToFilter") = cNextColumn 26 | iLogicVb.RunExternalRule("FilterColumnRule", FilterArguments) 27 | End If 28 | 29 | End Sub 30 | 31 | Public Const cNextColumn As String = "N" -------------------------------------------------------------------------------- /C360/FilterColumnN.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub Main() 3 | If Not RuleArguments.Exists("ParameterValue") Then 4 | MessageBox.Show("How did we get here?") 5 | Else 6 | 'Column N 7 | Dim paramValue As String = RuleArguments.Value("ParameterValue") 8 | Dim FilterArguments As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() 9 | 'this needs to be a list of values to remove/add from the next column along. 10 | Dim filterList As List(Of String) = New List(Of String) 11 | Select paramValue 12 | Case "C" 13 | filterList.Add("M") 14 | Case "F" 15 | filterList.Add("M") 16 | Case "K" 17 | filterList.Add("M") 18 | filterList.Add("S") 19 | Case "M" 20 | filterList.Add("M") 21 | Case "S" 22 | filterList.Add("M") 23 | filterList.Add("S") 24 | Case "T" 25 | filterList.Add("S") 26 | Case Else 27 | End Select 28 | FilterArguments.Value("UniqueValues") = filterList 29 | FilterArguments.Value("ColumnToFilter") = cNextColumn 30 | iLogicVb.RunExternalRule("FilterColumnRule", FilterArguments) 31 | End If 32 | 33 | End Sub 34 | 35 | Public Const cNextColumn As String = "O" -------------------------------------------------------------------------------- /C360/FilterColumnO.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub Main() 3 | If Not RuleArguments.Exists("ParameterValue") Then 4 | MessageBox.Show("How did we get here?") 5 | Else 6 | 'Column O 7 | Dim paramValue As String = RuleArguments.Value("ParameterValue") 8 | Dim FilterArguments As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() 9 | 'this needs to be a list of values to remove/add from the next column along. 10 | Dim filterList As List(Of String) = New List(Of String) 11 | Select paramValue 12 | Case "M" 13 | filterList.Add("L0") 14 | filterList.Add("L1") 15 | filterList.Add("P0") 16 | Case "S" 17 | filterList.Add("LN") 18 | filterList.Add("PN") 19 | filterList.Add("L0") 20 | filterList.Add("PM") 21 | filterList.Add("L1") 22 | Case Else 23 | End Select 24 | FilterArguments.Value("UniqueValues") = filterList 25 | FilterArguments.Value("ColumnToFilter") = cNextColumn 26 | iLogicVb.RunExternalRule("FilterColumnRule", FilterArguments) 27 | End If 28 | 29 | End Sub 30 | 31 | Public Const cNextColumn As String = "R" -------------------------------------------------------------------------------- /C360/FilterColumnR.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Dim p = Parameter("columnE") 3 | logger.Debug("columnE updated") 4 | -------------------------------------------------------------------------------- /C360/FilterColumnRule.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub Main() 3 | If Not RuleArguments.Exists("UniqueValues") And Not RuleArguments.Exists("ColumnToFilter")Then 4 | MessageBox.Show("How did we get here?") 5 | Else 6 | Dim Doc As AssemblyDocument = ThisApplication.ActiveDocument 7 | Dim columnToEdit As Inventor.Parameter = (From param As Inventor.Parameter In Doc.ComponentDefinition.Parameters 8 | Where param.Name = "column" & RuleArguments.Value("ColumnToFilter") 9 | Select param).FirstOrDefault() 10 | ' Dim columnToEdit As Inventor.Parameter = Parameter.Param("column" & RuleArguments.Value("ColumnToFilter")) 11 | Dim listofUniqueValues As List(Of String) = RuleArguments.Value("UniqueValues") 12 | Logger.Debug(columnToEdit.Name) 13 | Logger.Debug(debugListValues(listofUniqueValues)) 14 | If Not listofUniqueValues Is Nothing And Not columnToEdit Is Nothing Then 15 | listofUniqueValues.Sort() 16 | Dim tmpArraylist As ArrayList = New ArrayList(listofUniqueValues) 17 | MultiValue.List(columnToEdit.Name) = tmpArraylist 18 | End If 19 | End If 20 | End Sub 21 | 22 | Function debugListValues(ByVal listofValues As List(Of String)) As String 23 | For Each Val As String In listofValues 24 | debugListValues = Val & "," & debugListValues 25 | Next 26 | End Function -------------------------------------------------------------------------------- /C360/RulesOnEvents.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /C360/SuppressOccurrences.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main() 2 | Dim fileName As String = InputBox("What file are we suppressing?", "Type the filename", "COTS-100200.ipt") 3 | 'change this inside Inventor 4 | Dim ThisDoc As AssemblyDocument = ThisApplication.ActiveDocument 5 | Dim oCompDef As ComponentDefinition = ThisDoc.ComponentDefinition 6 | 'need to do this for speed: 7 | ' get filename 8 | ' look for filename in allreferenceddocuments and their children 9 | ' collect all occurrences and the parent assembly file for each 10 | ' iterate collection and suppress relevant occurrences 11 | ' 12 | ' the really slow way would be to iterate the entire set of occurrences but that could take forever. 13 | ' also need to check current level of detail is set to iLogic to prevent errors when suppressing. 14 | Call SuppressOccurrenceByFileName(fileName, oCompDef) 15 | End Sub 16 | 17 | Public Function SuppressOccurrenceByFileName(occName As String, parentCompDef As ComponentDefinition) 18 | For Each item As ComponentOccurrence In parentCompDef.Occurrences 19 | Dim current 20 | If item Is compOcc Then 21 | Component.Suppress(item) 22 | End If 23 | Next 24 | End Function 25 | -------------------------------------------------------------------------------- /C360/UpdateMultivalueLists.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub Main() 3 | If Not RuleArguments.Exists("ParameterName") Then 'not fired from relevant rule 4 | MessageBox.Show("This rule only works from the context-sensitive files we need!") 5 | Exit Sub 6 | Else 7 | Dim paramName As String = RuleArguments.Value("ParameterName") 8 | Dim p As Parameter = Parameter.Param(paramName) 9 | Logger.Debug(paramName & " updated value = " & p.Value) 10 | Dim FilterArguments As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() 11 | FilterArguments.Value("ParameterValue") = p.Value 12 | iLogicVb.RunExternalRule("Filter" & paramName, FilterArguments) 13 | End If 14 | End Sub -------------------------------------------------------------------------------- /C360/UpdatePartNum.iLogicVb: -------------------------------------------------------------------------------- 1 | 'this format only works correctly when placed in an internal rule! 2 | PartNum = PartPrefix & columnE & "/" & columnG & "-" & columnI & columnL & columnN & columnO & "-" & columnR -------------------------------------------------------------------------------- /CM Examples/Pyramid.iLogicVB: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Public Sub Main() 3 | If TypeOf ThisApplication.ActiveDocument Is PartDocument Then 4 | 5 | Dim pyramidheight As String = InputBox("How high?", "Pyramid height", "10") 6 | GeneratePyramid(pyramidheight) 7 | Else 8 | MessageBox.Show("Suggest you create a new part file and run this rule again!") 9 | End If 10 | End Sub 11 | 12 | Public Sub GeneratePyramid(ByVal pyramidHeight As String) 13 | 14 | Dim height As Integer = Convert.ToInt32(pyramidheight) 15 | Dim rowCount As Integer = 1 16 | Dim spacing As Double = 10 'units = cm 17 | Dim oPartDocument As PartDocument = ThisApplication.ActiveDocument 18 | Dim oCompDef As PartComponentDefinition = oPartDocument.ComponentDefinition 19 | Dim oTrans As TransientGeometry = ThisApplication.TransientGeometry 20 | 21 | Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(oPartDocument, "Create pyramid of points") 22 | 23 | 'Dim partOrigin As Point = oTrans.CreatePoint(0, 0, 0) 24 | 25 | 'i = row 26 | 'j = column 27 | Dim XSpacing As Double = 0 28 | Dim YSpacing As Double = 0 29 | Dim ZSpacing As Double = 0 30 | For i As Integer = height To 0 Step -1 31 | 'Dim tmpPoint As Point = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0) 32 | 33 | 34 | For j As Integer = 1 To i 35 | Dim wp As WorkPoint = oCompDef.WorkPoints.AddFixed(oTrans.CreatePoint(XSpacing, YSpacing, ZSpacing)) 36 | wp.Name = "WP" & i.ToString() & "." & j.ToString() 37 | 'set up X Spacing 38 | XSpacing += spacing 39 | Next 40 | 41 | 'For j As Integer = 1 To rowCount 42 | YSpacing += spacing 43 | XSpacing = (spacing * rowCount) / 2 44 | 'Next 45 | rowCount += 1 46 | Next 47 | 48 | trans.End() 49 | End Sub 50 | 51 | Sub updatestatusbar(ByVal message As String) 52 | ThisApplication.statusbartext = message 53 | End Sub 54 | 55 | Sub updatestatusbar(ByVal percent As Double, ByVal message As String) 56 | ThisApplication.statusbartext = message + " (" & percent.ToString("P1") + ")" 57 | End Sub 58 | -------------------------------------------------------------------------------- /Class1.vb: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace iLogic_Collection 8 | { 9 | public class Class1 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CommandNames.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/CommandNames.txt -------------------------------------------------------------------------------- /Create_standard_parts_from_Excel.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Create_standard_parts_from_Excel.vsdx -------------------------------------------------------------------------------- /Drawings/Add blank rows to parts list.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main() 2 | Dim trans as transaction = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument,"Add Blank Rows") 3 | Try 4 | Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 5 | Dim oPartList As PartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1) 6 | oPartList.Sort("VENDOR",True,"PART NUMBER",True) 7 | Dim i As Long = 1 8 | For i = 1 To 500 'oPartList.PartsListRows.Count 9 | Dim thisCell As PartsListCell = oPartList.PartsListRows.Item(i).Item("VENDOR") 10 | If Not thisCell.Value = "" Then 11 | Dim nextrowint As Integer = i + 1 12 | If nextrowint > oPartList.PartsListRows.Count Then Exit For 13 | Dim nextCell As PartsListCell = oPartList.PartsListRows.Item(nextrowint).Item("VENDOR") 14 | If Not thisCell.Value = nextCell.Value Then 15 | oPartList.PartsListRows.Add(i, False) 16 | oPartList.PartsListRows.Add(i, False) 17 | oPartList.PartsListRows.Add(i, False) 18 | End If 19 | End If 20 | Next 21 | oPartList.Renumber 22 | oPartList.SaveItemOverridesToBOM 23 | Catch 24 | trans.Abort() 25 | Finally 26 | trans.End() 27 | End Try 28 | End Sub 29 | -------------------------------------------------------------------------------- /Drawings/Automatic Drawing dimensions.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | Sub Main() 3 | 'This rule will create delete any existing iLogic-created dimensions before replacing them anew 4 | Dim oDWG As DrawingDocument = ThisDoc.Document 5 | 6 | Dim oSht As Sheet = oDWG.ActiveSheet 7 | 8 | Dim oView As DrawingView = ActiveSheet.View("VIEW1").View 9 | 10 | Dim oAssy As AssemblyDocument = ActiveSheet.View("VIEW1").ModelDocument 11 | 12 | Dim TransG As TransientGeometry = ThisApplication.TransientGeometry 13 | 14 | Dim oGenDims As GeneralDimensions = oSht.DrawingDimensions.GeneralDimensions 15 | 'messagebox.show("Setup complete") 16 | 'Dim oObjs as Object = Nothing 17 | 18 | Dim aoEdge1 As face 19 | 20 | oObjs = oAssy.AttributeManager.FindObjects("DIM", "Datum1", "1") 21 | 22 | aoEdge1 = oobjs.Item(1) 23 | 24 | 'messagebox.show("Got face 1") 25 | 26 | Dim aoEdge2 As face 27 | 28 | oObjs = oAssy.AttributeManager.FindObjects("DIM", "Edge1", "1") 29 | 30 | aoEdge2 = oObjs.Item(1) 31 | 32 | 'messagebox.show("Got face 2") 33 | 34 | 'Dim oDrawingCurves as Object = Nothing 35 | 36 | Dim oDrawCurve1 As DrawingCurve 37 | 38 | oDrawingCurves = oView.DrawingCurves(aoEdge1) 39 | 40 | oDrawCurve1 = oDrawingCurves.Item(1) 41 | 42 | 'messagebox.show("Got first set of drawing curves") 43 | 44 | Dim oDrawCurve2 As drawingcurve 45 | 46 | oDrawingCurves = oview.DrawingCurves(aoEdge2) 47 | 48 | oDrawCurve2 = oDrawingCurves.Item(1) 49 | 50 | 'messagebox.show("Got second set of drawing curves") 51 | 52 | Dim oPt1 As Point2d = TransG.Createpoint2d(oView.left + (oView.Width / 4), oView.Top - (oView.Height) - 1) 53 | 54 | messagebox.show("Got dimension line point position: " & oPt1.X.ToString() & "," & oPt1.Y.ToString()) 55 | 56 | Dim oDim1 As GeneralDimension = oGenDims.AddLinear(oPt1, oSht.CreateGeometryintent(oDrawCurve1, PointIntentEnum.kStartPointIntent), oSht.CreateGeometryIntent(oDrawCurve2, PointIntentEnum.kEndPointIntent), DimensionTypeEnum.kHorizontalDimensionType) 57 | 58 | messagebox.show("Dimension Added.") 59 | 60 | Dim odimatt1 As Attributeset = oDim1.Attributesets.add("iLogic_Created") 61 | 62 | End Sub -------------------------------------------------------------------------------- /Drawings/CopySheet.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit 2 | 3 | ''' 4 | ''' Copied from this post: 5 | ''' http://forums.autodesk.com/t5/inventor-general-discussion/how-To-copy-sheet-within-idw/m-p/2897684/highlight/True#M393400 6 | ''' 7 | ''' 8 | Sub Main() 9 | Dim oDrawingDocument1 As DrawingDocument = ThisApplication.ActiveDocument 10 | Dim oDrawingDocument2 As DrawingDocument = ThisApplication.Documents.Add(kDrawingDocumentObject, , False) 11 | Dim oSheet As Sheet = oDrawingDocument1.ActiveSheet 12 | oSheet.CopyTo(oDrawingDocument2) 13 | oSheet = oDrawingDocument2.Sheets.Item(oDrawingDocument2.Sheets.Count) 14 | oSheet.CopyTo(oDrawingDocument1) 15 | oDrawingDocument2.Close (True) 16 | End Sub 17 | -------------------------------------------------------------------------------- /Drawings/CreateLeader.iLogicVb: -------------------------------------------------------------------------------- 1 | 'The setup 2 | Dim invApp As Inventor.Application 3 | invApp = ThisApplication 4 | Dim oDrawDoc As DrawingDocument 5 | oDrawDoc = invApp.ActiveEditDocument 6 | Dim oActiveSheet As Sheet 7 | oActiveSheet = oDrawDoc.ActiveSheet 8 | 'Looks up existing placed assembly 9 | 'oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 10 | 'sets model parameter frame as oFrame 11 | 'oFrame = Parameter(oModelDoc, "frame") 12 | 'creates fake parameter for example purposes 13 | oFrame = "X" 14 | For Each oSheet As Sheet In oDrawDoc.Sheets 15 | Dim Xcoord = 12.25 16 | Dim Ycoord = 17.25 17 | Dim LS = 0.4 18 | Dim oTG As Inventor.TransientGeometry = invApp.TransientGeometry 19 | Dim leaderPoints As ObjectCollection = invApp.TransientObjects.CreateObjectCollection() 20 | leaderPoints.Add(oTG.CreatePoint2d(oSheet.Width - Xcoord, Ycoord)) 21 | Dim oNote As LeaderNote = oSheet.DrawingNotes.LeaderNotes.Add(leaderPoints, "Model " & oFrame) 22 | leaderPoints.Clear() 23 | ' oNote = oSheet.DrawingNotes.GeneralNotes.AddFitted(oTG.CreatePoint2d(oSheet.Width - Xcoord, Ycoord), "Model " & oFrame) 24 | Ycoord = Ycoord - LS 25 | leaderPoints.Add(oTG.CreatePoint2d(oSheet.Width - Xcoord, Ycoord)) 26 | oNote = oSheet.DrawingNotes.LeaderNotes.Add(leaderPoints, "Note 2") 27 | ' oNote = oSheet.DrawingNotes.GeneralNotes.AddFitted(oTG.CreatePoint2d(oSheet.Width - Xcoord, Ycoord), "Note 2") 28 | oDrawDoc.Update() 29 | ' With oNote 30 | ' .HorizontalJustification = Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter 31 | ' .VerticalJustification = Inventor.VerticalTextAlignmentEnum.kAlignTextMiddle 32 | ' .TextStyle.FontSize = 0.203 33 | ' End With 34 | Next 35 | -------------------------------------------------------------------------------- /Drawings/Drawing Creation Code.iLogicVb: -------------------------------------------------------------------------------- 1 | Imports Inventor.ViewOrientationTypeEnum 2 | Imports Inventor.DrawingViewStyleEnum 3 | 4 | Dim oDrawingDoc as DrawingDocument 5 | Dim oPartDoc as Document 6 | Dim oSheet As sheet 7 | Dim oTG As TransientGeometry 8 | Dim oView1 as DrawingView 9 | Dim oView2 as DrawingView 10 | Dim oView3 as DrawingView 11 | Dim oView4 as DrawingView 12 | 13 | ViewScale = 1/10 14 | 15 | 'Ask to create drawing? 16 | dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection") 17 | If dwgQuery = vbYes Then 18 | oPartDoc = ThisDoc.Document 19 | 20 | 'Define IDW Template File Location 21 | oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2017\Templates\APS Standard.dwg", True) 22 | ' oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True) 23 | oSheet = oDrawingDoc.Sheets.Item(1) 24 | 25 | 'Define 2d view bottom left corner points for four views 26 | oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(1, 1) 27 | oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(1, 6) 28 | oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(5, 1) 29 | 30 | oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle)', KTANGENTEDGESON) 31 | 32 | oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle,ViewScale) 33 | oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale) 34 | 35 | End If 36 | -------------------------------------------------------------------------------- /Drawings/DrawingTextBoxQualityAssurance.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | oDocument = ThisApplication.ActiveDocument 3 | Dim oSheets As Sheets 4 | Dim oPar As UserParameter 5 | 6 | For i = 1 To oDocument.Sheets.Count 7 | oDocument.Sheets(i).Activate 8 | oSheet = oDocument.Sheets(i) 9 | oTitleBlock = oDocument.Sheets(i).TitleBlock 10 | For Each oTextBox As Inventor.TextBox In oTitleBlock.Definition.Sketch.TextBoxes 11 | If oTextBox.Text <> "" Then 12 | CompareTextToExpected(oTextBox, oTitleBlock.GetResultText(oTextBox)) 13 | End If 14 | Next 15 | Next 16 | End Sub 17 | 18 | Public oDocument As DrawingDocument = Nothing 19 | Public oSheet As Sheet = Nothing 20 | Public oTitleBlock As TitleBlock = Nothing 21 | 22 | Function CompareTextToExpected(byval textBox as Inventor.TextBox, byval textBoxContents as string) as Boolean 23 | select case textBox.Text 24 | Case "" : 25 | if not textBoxContents = "your expected string" then MarkTextBoxContentsAsIncorrect(textBox, "Text doesn't match expected Title") 26 | case "<PART NUMBER>" : 27 | if not textBoxContents = "your expected string" then MarkTextBoxContentsAsIncorrect(textBox, "Text doesn't match expected Part Number") 28 | end select 29 | End Function 30 | 31 | Sub MarkTextBoxContentsAsIncorrect(byval textbox as Inventor.TextBox, byval ErrorText as string) 32 | Call CreateText(textbox.Origin, ErrorText) 33 | End Sub 34 | 35 | Sub CreateText(ByVal textlocation As Point2d, ByVal QAText As String) 36 | Call textlocation.transformby(oTitleBlock.Transformation) 37 | Dim oTG As TransientGeometry = ThisApplication.TransientGeometry 38 | Dim TextPoint As Point2d = oTG.CreatePoint2d(textLocation.X, textlocation.Y) 39 | 40 | Dim oGeneralNotes As GeneralNotes 41 | oGeneralNotes = oSheet.DrawingNotes.GeneralNotes 42 | 43 | Dim oGeneralNote As GeneralNote 44 | oGeneralNote = oGeneralNotes.AddFitted(TextPoint, QAText) 45 | End Sub 46 | -------------------------------------------------------------------------------- /Drawings/Export Open Inventor dwgs to AutoCAD.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | Sub Main() 3 | Dim sw As New Stopwatch() 4 | sw.Start() 5 | Dim newPath As String = String.Empty '"C:\Users\alex.fielder\OneDrive\Inventor\Designs\sapphire\Cassette Master\Exported dwgs\" 6 | 'copied from https://forums.autodesk.com/t5/inventor-customization/ilogic-rule-to-ask-yes-or-no-for-dxf-export-when-saving-idw/td-p/3939068 7 | 8 | ' Get the DXF translator Add-In. 9 | 'path_and_nameDXF = ThisDoc.PathAndFileName(False) 10 | Dim DWGAddIn As TranslatorAddIn 11 | DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") 12 | Dim percent As Double = Nothing 13 | Dim i As Integer = 0 14 | Dim dwglist As New list(Of Document) 15 | For Each doc as document In ThisApplication.documents 16 | If TypeOf doc Is DrawingDocument Then 17 | dwglist.add(doc) 18 | End If 19 | Next 20 | For Each dwgdoc As Document In dwglist 21 | percent = (CDbl(i) / ThisApplication.Documents.Count) 22 | i += 1 23 | updatestatusbar(percent,"Exporting: " & System.IO.Path.GetFileNameWithoutExtension(dwgdoc.fulldocumentname) & ".dwg") 24 | 'dwgdoc.activate 25 | Dim oContext As TranslationContext 26 | oContext = ThisApplication.TransientObjects.CreateTranslationContext 27 | oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism 28 | ' Create a NameValueMap object 29 | Dim oOptions As NameValueMap 30 | oOptions = ThisApplication.TransientObjects.CreateNameValueMap 31 | ' Create a DataMedium object 32 | Dim oDataMedium As DataMedium 33 | oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 34 | If DWGAddIn.HasSaveCopyAsOptions(dwgdoc, oContext, oOptions) Then 35 | Dim strIniFile As String 36 | strIniFile = "C:\Users\alex.fielder\OneDrive\AutoCAD\Inventor dwg to AutoCAD 2013 configuration.ini" 37 | oOptions.Value("Export_Acad_IniFile") = strIniFile 38 | End If 39 | newPath = System.IO.Path.GetDirectoryName(dwgdoc.FullDocumentName) 40 | oDataMedium.FileName = newPath & "\" & System.IO.Path.GetFileNameWithoutExtension(dwgdoc.FullDocumentName) & "-Exported.dwg" 41 | break 42 | Call DWGAddIn.SaveCopyAs(dwgdoc, oContext, oOptions, oDataMedium) 43 | Next 44 | sw.Stop() 45 | MessageBox.Show("Operation took: " & sw.Elapsed.Seconds.ToString() & " seconds to complete.") 46 | 47 | End Sub 48 | 49 | Sub updatestatusbar(ByVal message As String) 50 | ThisApplication.statusbartext = message 51 | End Sub 52 | 53 | Sub updatestatusbar(ByVal percent As Double, ByVal message As String) 54 | ThisApplication.statusbartext = message + " (" & percent.tostring("P1") + ")" 55 | End Sub 56 | -------------------------------------------------------------------------------- /Drawings/FindReferencedModels.iLogicVb: -------------------------------------------------------------------------------- 1 | 'Imports Autodesk.Inventor 2 | ''' <summary> 3 | ''' getViewsInfo 4 | ''' 5 | ''' </summary> 6 | Sub Main() 7 | Dim oDoc As Document = ThisApplication.ActiveDocument 8 | 9 | If oDoc.DocumentType = kDrawingDocumentObject Then 10 | 11 | Dim csvFile As System.IO.File 12 | csvWriter = csvFile.CreateText(ThisDoc.PathAndFileName(False) & ".csv") 13 | csvWriter.WriteLine("Referenced Models present in this Assembly:") 14 | csvWriter.WriteLine() 15 | 16 | Dim oDrgDoc As DrawingDocument = oDoc 17 | 18 | Dim oSheets As Sheets = oDrgDoc.Sheets 19 | For Each oSheet As Sheet In oSheets 20 | Dim oDrgViews As DrawingViews = oSheet.DrawingViews 21 | Dim oDrgView As DrawingView 22 | Dim msg As String 23 | Dim i As Integer 24 | i = 1 25 | For Each oDrgView In oDrgViews 26 | Dim scl As Double 27 | scl = oDrgView.Scale 28 | Dim oRefFileDesc As ReferencedFileDescriptor = oDrgView.ReferencedFile 29 | 30 | 31 | If (TypeOf oRefFileDesc.ReferencedDocument Is PartDocument) Then 32 | Dim oPartDoc As PartDocument = oRefFileDesc.ReferencedDocument 33 | ElseIf (TypeOf oRefFileDesc.ReferencedDocument Is AssemblyDocument) Then 34 | Dim oAsmDoc As AssemblyDocument = oRefFileDesc.ReferencedDocument 35 | Else 36 | Dim oPresDoc As PresentationDocument = oRefFileDesc.ReferencedDocument 37 | End If 38 | 39 | csvWriter.WriteLine("Sheet Name" & oSheet.Name & vbCr & "View No: " & i & vbCr & "File Refered: " & oRefFileDesc.FullFileName & vbCr & "View Scale : " & scl) 40 | 'msg = "View No: " & i & vbCr & "File Refered: " & oRefFileDesc.FullFileName & vbCr & "View Scale : " & scl 41 | i = i + 1 42 | Next 43 | Next 44 | End If 45 | End Sub 46 | 47 | Public csvWriter As System.IO.StreamWriter 48 | 49 | -------------------------------------------------------------------------------- /Drawings/GroupBalloons.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | BalloonColl = SelectBalloons() 3 | 4 | MsgBox ("No of balloons selected for attachment : " & BalloonColl.Count) 5 | 6 | Dim oBalloon As Balloon = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Select a balloon to attach our group to.") 7 | 8 | If Not oBalloon Is Nothing And BalloonColl.Count > 0 Then 9 | MessageBox.Show("Grouping Balloons") 10 | Dim attachBalloon As Balloon 11 | For Each attachBalloon In BalloonColl 12 | Call oBalloon.BalloonValueSets.Add(attachBalloon.BalloonValueSets(1).ReferencedRow) 13 | Call attachBalloon.Delete 14 | Next 15 | End If 16 | End Sub 17 | 18 | Public BalloonColl as ObjectCollection = Nothing 19 | 20 | Function SelectBalloons() As ObjectCollection 21 | 22 | Dim coll As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection 23 | Dim obj As Balloon 24 | Do 25 | obj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Select balloons") 26 | 27 | If Not obj Is Nothing Then 28 | Call coll.Add(obj) 29 | End If 30 | Loop While Not obj Is Nothing 31 | 32 | Return coll 33 | 34 | End Function 35 | -------------------------------------------------------------------------------- /Drawings/Inventor 2014 - View Representations with iLogic – Part 1 – Create – Cadline Community.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Drawings/Inventor 2014 - View Representations with iLogic – Part 1 – Create – Cadline Community.pdf -------------------------------------------------------------------------------- /Drawings/Inventor 2014 - View Representations with iLogic – Part 2 – Update – Cadline Community.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Drawings/Inventor 2014 - View Representations with iLogic – Part 2 – Update – Cadline Community.pdf -------------------------------------------------------------------------------- /Drawings/Inventor 2014 - View Representations with iLogic – Part 3 – Check – Cadline Community.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Drawings/Inventor 2014 - View Representations with iLogic – Part 3 – Check – Cadline Community.pdf -------------------------------------------------------------------------------- /Drawings/Prompted Entry To iProperty.iLogicVb: -------------------------------------------------------------------------------- 1 | On Error Resume Next 2 | 'https://www.cadlinecommunity.co.uk/hc/en-us/articles/203292761 3 | Dim oDoc As DrawingDocument 4 | oDoc = ThisApplication.ActiveDocument 5 | Dim oSheet As Sheet 6 | Dim oPromptEntry 7 | 8 | Dim oCurrentSheet 9 | oCurrentSheet = oDoc.ActiveSheet.Name 10 | 11 | i = 1 12 | For Each oSheet In oDoc.Sheets 13 | 'i = i+1 14 | ThisApplication.ActiveDocument.Sheets.Item(i).Activate 15 | oTitleBlock=oSheet.TitleBlock 16 | oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes 17 | For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes 18 | Select oTextBox.Text 19 | Case "DRAWING NUMBER" 20 | oPromptEntry = oTitleBlock.GetResultText(oTextBox) 21 | iProperties.Value("Project", "Part Number")=oPromptEntry 22 | 23 | End Select 24 | Next 25 | Next 26 | 27 | ThisApplication.ActiveDocument.Sheets.Item(oCurrentSheet).Activate 28 | 29 | ddoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 30 | 'iProperties.Value(ddoc, "Project", "Part Number") = iProperties.Value("Project", "Part Number") 31 | iProperties.Value(ddoc, "Custom", "Drawing No") = iProperties.Value("Project", "Part Number") 32 | iLogicVb.UpdateWhenDone = True 33 | -------------------------------------------------------------------------------- /Drawings/RunPlatformDrawings.iLogicVb: -------------------------------------------------------------------------------- 1 | AddReference "System.Core" 2 | AddReference "PlatformDrawings.dll" 'relies upon the dll building to: "..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2015\Bin\iLogicAdd\" 3 | Imports PlatformDrawings 4 | Imports System 5 | Imports System.IO 6 | Sub Main() 7 | Dim XTPD As New PlatformDrawings.ExternalVBClass 8 | XTPD.InventorApplication = ThisApplication 9 | If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then 10 | MessageBox.Show("Please run this rule from the assembly file.", "iLogic") 11 | Exit Sub 12 | End If 13 | 14 | 'define the active document as an assembly file 15 | Dim oAsmDoc As AssemblyDocument 16 | oAsmDoc = ThisApplication.ActiveDocument 17 | 18 | Dim ProjectCode As String = iProperties.Value("Project", "Project") 19 | 'MessageBox.Show("getting startfolder! for: " & oAsmDoc.File.FullFileName) 20 | 'XTPD.StartFolder = System.IO.Path.GetDirectoryName(ThisApplication.ActiveDocument.FullDocumentName) 21 | XTPD.StartFolder = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(oAsmDoc.File.FullFileName)) 22 | XTPD.ProjectCode = ProjectCode 23 | XTPD.AssyDoc = oAsmDoc 24 | 'MessageBox.Show("Preparing to run PlatformDrawings.ExternalVBClass!") 25 | 26 | Call XTPD.BeginPlatformDrawings() 27 | InventorVb.DocumentUpdate() 28 | End Sub 29 | -------------------------------------------------------------------------------- /Drawings/Sketch Symbol Text Changer.iLogicVb: -------------------------------------------------------------------------------- 1 | '''Changes the format of sketch symbol Text values to UPPERCASE if the user selects yes, Titlecase if the user selects no and does nothing if the user selects cancel. 2 | Sub Main() 3 | Dim oDoc As DrawingDocument = ThisDoc.Document 4 | oModel = ThisDoc.ModelDocument 5 | 6 | Dim Result As DialogResult = MessageBox.Show("Turn all sketch symbol leaders on?","Sketch symbol leaders toggle",MessageBoxButtons.YesNoCancel) 7 | Dim viewlabelresult As Boolean = False 8 | If Result = dialogresult.yes Then 9 | viewlabelresult = True 10 | ElseIf Result = dialogresult.cancel Then 11 | viewlabelresult = False 12 | Else 13 | Exit Sub 14 | End If 15 | Dim oSheets As Sheets 16 | Dim oSheet As Sheet 17 | Dim oSketchedSymbol As SketchedSymbol 18 | oSheets = oDoc.Sheets 19 | For Each oSheet In oSheets 20 | For Each oSketchedSymbol in oSheet.SketchedSymbols 21 | 'oSketchedSymbol.leadervisible = viewlabelresult 22 | 23 | Next 24 | Next 25 | End Sub 26 | -------------------------------------------------------------------------------- /Drawings/Synchronize iProperties between parts and drawings.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main 2 | BeginSyncProps() 3 | End Sub 4 | 5 | Public Sub BeginSyncProps() 6 | booleanParam = InputRadioBox("Synchronize iProperties between Models and Drawings:", _ 7 | "All Drawings", _ 8 | "This Drawing", _ 9 | booleanParam, Title := "Single or Multiple files?") 10 | If booleanParam Then 11 | For Each oDoc in ThisApplication.Documents 12 | If oDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then 13 | oDoc.Activate 14 | SyncProps() 15 | End If 16 | Next 17 | Else 18 | Dim ThisDoc = ThisApplication.ActiveDocument 19 | If ThisDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then 20 | SyncProps() 21 | End If 22 | End If 23 | 24 | End Sub 25 | 26 | Public Sub SyncProps() 27 | MessageBox.Show("Model name: " & ThisDrawing.ModelDocument.FullFileName) 28 | If (ThisDrawing.ModelDocument Is Nothing) Then Return 29 | 30 | 'get the filename of the doc the drawing points to 31 | 32 | modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 33 | 34 | 'read the values from the Custom iProperties in the part file 35 | 36 | 'and apply them to the Custom iProperties with the same name in the drawing 37 | 38 | iProperties.Value("Project", "Description") = iProperties.Value(modelName, "Project", "Description") 39 | iProperties.Value("Summary", "Subject") = iProperties.Value(modelName, "Summary", "Subject") 40 | iProperties.Value("Summary", "Title") = iProperties.Value(modelName, "Summary", "Title") 41 | iProperties.Value("Project", "Part Number") = iProperties.Value(modelName, "Project", "Part Number") 42 | 'If iProperties.Value("Summary", "Title") = "" And Not iProperties.Value(modelName, "Project", "Description") = "" Then 43 | ' iProperties.Value("Summary", "Title") = iProperties.Value(modelName, "Project", "Description") 44 | 'End If 45 | End Sub 46 | -------------------------------------------------------------------------------- /Drawings/Turn Sketch Symbol Leaders on.iLogicVb: -------------------------------------------------------------------------------- 1 | '''Turns sketch symbol leaders off if the user selects yes, turns them off 2 | '''if the user selects no, does nothing if the user selects cancel. 3 | Sub Main() 4 | Dim oDoc As DrawingDocument = ThisDoc.Document 5 | oModel = ThisDoc.ModelDocument 6 | 7 | Dim Result As DialogResult = MessageBox.Show("Turn all sketch symbol leaders on?","Sketch symbol leaders toggle",MessageBoxButtons.YesNoCancel) 8 | Dim viewlabelresult As Boolean = False 9 | If Result = dialogresult.yes Then 10 | viewlabelresult = True 11 | ElseIf Result = dialogresult.no Then 12 | viewlabelresult = False 13 | ElseIf Result = dialogresult.cancel Then 14 | Exit Sub 15 | Else 16 | Exit Sub 17 | End If 18 | Dim oSheets As Sheets 19 | Dim oSheet As Sheet 20 | Dim oSketchedSymbol As SketchedSymbol 21 | 22 | 23 | oSheets = oDoc.Sheets 24 | 25 | For Each oSheet In oSheets 26 | For Each oSketchedSymbol in oSheet.SketchedSymbols 27 | If oSketchedSymbol.Name = "View Title Block" Then 28 | oSketchedSymbol.leadervisible = viewlabelresult 29 | Else 30 | 'turn everything else on regardless 31 | oSketchedSymbol.leadervisible = True 32 | End If 33 | Next 34 | Next 35 | End Sub 36 | -------------------------------------------------------------------------------- /Drawings/Turn View Labels on.iLogicVb: -------------------------------------------------------------------------------- 1 | '''Turns view labels off if the user selects yes, turns them off 2 | '''if the user selects no, does nothing if the user selects cancel. 3 | Sub Main() 4 | Dim oDoc As DrawingDocument = ThisDoc.Document 5 | oModel = ThisDoc.ModelDocument 6 | 7 | Dim Result As DialogResult = MessageBox.Show("Turn all drawing view labels on?","Drawing view label toggle",MessageBoxButtons.YesNoCancel) 8 | Dim viewlabelresult As Boolean = False 9 | If Result = dialogresult.yes Then 10 | viewlabelresult = True 11 | ElseIf Result = dialogresult.no Then 12 | viewlabelresult = False 13 | ElseIf Result = dialogresult.cancel Then 14 | Exit Sub 15 | Else 16 | Exit Sub 17 | End If 18 | Dim oSheets As Sheets 19 | Dim oSheet As Sheet 20 | Dim oViews As DrawingViews 21 | Dim oView As DrawingView 22 | 23 | oSheets = oDoc.Sheets 24 | 25 | For Each oSheet In oSheets 26 | 27 | oViews = oSheet.DrawingViews 28 | For Each oView In oViews 29 | 'set view to messagebox result 30 | oView.ShowLabel = viewlabelresult 31 | Next 32 | 33 | Next 34 | End Sub 35 | -------------------------------------------------------------------------------- /Forms/Click Me!.state.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <FormStatePersist xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <Size> 4 | <Width>0</Width> 5 | <Height>0</Height> 6 | </Size> 7 | <Location> 8 | <X>0</X> 9 | <Y>0</Y> 10 | </Location> 11 | <SplitterLocations /> 12 | <GroupExpansionStateList /> 13 | <TabGroupSelectedPageList /> 14 | </FormStatePersist> -------------------------------------------------------------------------------- /Forms/Click Me!.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <FormSpecification xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <Name>Click Me!</Name> 4 | <Guid>5ebaba98-6475-4676-b37d-e8a64fe5444c</Guid> 5 | <Items> 6 | <UiElementSpec xsi:type="iLogicRuleControlSpec"> 7 | <Name>get current relevant iPart occurrences:</Name> 8 | <Guid>87aa6951-ed50-4c8e-b981-13cb936ebc2d</Guid> 9 | <Image> 10 | <BitmapByteArray /> 11 | </Image> 12 | <TextVisible>true</TextVisible> 13 | <RuleName>get current relevant iParts</RuleName> 14 | <RuleButtonBehavior>RunRule</RuleButtonBehavior> 15 | </UiElementSpec> 16 | <UiElementSpec xsi:type="MultiValueTextParameterControlSpec"> 17 | <Name>Current Relevant Occurrences:</Name> 18 | <Guid>b7d55e1b-3819-4188-b030-c3fe1842e568</Guid> 19 | <ToolTip /> 20 | <ParameterName>CurrentRelevantOccurrences</ParameterName> 21 | <EditControlType>ComboBox</EditControlType> 22 | <AllowCustomValues>false</AllowCustomValues> 23 | <MinimumItemsToShow>2</MinimumItemsToShow> 24 | <RadioGroupColumnCount>1</RadioGroupColumnCount> 25 | </UiElementSpec> 26 | <UiElementSpec xsi:type="MultiValueNumericParameterControlSpec"> 27 | <Name>Occurrence To Replace Selected With:</Name> 28 | <Guid>e9469e0d-98d6-4287-9637-d180a4c53f5f</Guid> 29 | <ToolTip /> 30 | <ParameterName>iPartToReplace</ParameterName> 31 | <EditControlType>ComboBox</EditControlType> 32 | <AllowCustomValues>false</AllowCustomValues> 33 | <MinimumItemsToShow>2</MinimumItemsToShow> 34 | <RadioGroupColumnCount>1</RadioGroupColumnCount> 35 | </UiElementSpec> 36 | <UiElementSpec xsi:type="iLogicRuleControlSpec"> 37 | <Name>replace iParts</Name> 38 | <Guid>513d98d5-c15b-4078-98ac-53726be46f44</Guid> 39 | <Image> 40 | <BitmapByteArray /> 41 | </Image> 42 | <TextVisible>true</TextVisible> 43 | <RuleName>replace iParts</RuleName> 44 | <RuleButtonBehavior>RunRule</RuleButtonBehavior> 45 | </UiElementSpec> 46 | </Items> 47 | <StyleAndSkinName> 48 | <StyleName>Default</StyleName> 49 | </StyleAndSkinName> 50 | <AllowCustomization>true</AllowCustomization> 51 | <PredefinedButtons>None</PredefinedButtons> 52 | <Modal>false</Modal> 53 | </FormSpecification> -------------------------------------------------------------------------------- /Forms/iLogicBrowserUiFormSpecification.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <FormSpecification xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <Name>iLogicBrowserUiFormSpecification</Name> 4 | <Guid>68d8dacd-6d95-4bd7-8d2f-84a728f67969</Guid> 5 | <Items> 6 | <UiElementSpec xsi:type="FormButtonControlSpec"> 7 | <Name>Click Me!</Name> 8 | <Guid>0a71eaa4-9c69-49f7-9cfd-ccf2868d98b3</Guid> 9 | <Image> 10 | <BitmapByteArray /> 11 | </Image> 12 | <TextVisible>true</TextVisible> 13 | </UiElementSpec> 14 | </Items> 15 | <StyleAndSkinName> 16 | <StyleName>Default</StyleName> 17 | </StyleAndSkinName> 18 | <AllowCustomization>false</AllowCustomization> 19 | <PredefinedButtons>None</PredefinedButtons> 20 | <Modal>false</Modal> 21 | <IsLauncherPage>true</IsLauncherPage> 22 | </FormSpecification> -------------------------------------------------------------------------------- /Goddensee/ChangeStyle.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Goddensee/ChangeStyle.docx -------------------------------------------------------------------------------- /Helper Rules/AlphaSortRepresentations.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Option Compare Text 3 | 4 | Imports System.Collections.Generic 5 | 6 | Public Sub Main() 7 | If TypeOf ThisApplication.Activedocument Is AssemblyDocument Then 8 | ActiveCompDef = ThisApplication.Activedocument.Componentdefinition 9 | Dim repsToProcess as New ArrayList 10 | repstoProcess.add("Design Views") 11 | repstoProcess.add("Pos Reps") 12 | repstoProcess.add("LODs") 13 | Dim result As String = InputListBox("What to sort?", repstoProcess, "", Title := "Select a collection to sort", ListName := "Available Collections") 14 | Select Case result 15 | Case "Design Views" 16 | Throw New notimplementedException 17 | Case "Pos Reps" 18 | BeginSortPosReps() 19 | Case "LODs" 20 | Throw New notimplementedException 21 | End Select 22 | Else 23 | MessageBox.Show("Only works with Assemblies") 24 | Exit Sub 25 | End If 26 | 27 | End Sub 28 | 29 | Private unsortedDesignViews as List(Of String) 30 | Private unsortedPosReps as List(Of String) 31 | Private unsortedLoDs as List(Of String) 32 | Private ActiveCompDef as AssemblyComponentDefinition 33 | Private oPosReps as PositionalRepresentations 34 | Private DesignViews as DesignViewRepresentations 35 | Private LODs as LevelofDetailRepresentations 36 | 37 | Public Sub BeginSortPosReps() 38 | unsortedPosReps = New List(Of String) 39 | oPosReps = ActiveCompDef.RepresentationsManager.PositionalRepresentations 40 | For Each oPosRep As PositionalRepresentation In oPosReps 41 | If Not oPosRep.Name = "Master" Then 42 | unsortedPosReps.Add(oPosRep.Name) 43 | End If 44 | Next 45 | 'MessageBox.Show(unsortedPosReps.Count) 46 | 'sortedPosReps = unsortedPosReps.Orderby(Function(x) x.Name) 47 | unsortedPosReps.Sort() 48 | ' For Each oPosRep As String In unsortedPosReps 49 | ' MessageBox.Show(oposrep) 50 | ' Next 51 | SortPosReps() 52 | End Sub 53 | 54 | Public Sub SortPosReps() 55 | Dim name As String 56 | Dim oldname As String 57 | For i As Integer = 0 To unsortedPosReps.count -1 58 | name = unsortedPosReps(i) 59 | 'MessageBox.Show("original name: " & name) 60 | oldname = name & "_old" 61 | 'MessageBox.Show("old name: " & oldname) 62 | oPosReps.Item(name).Name = oldName 63 | Call oPosReps.Item(oldname).copy(Name) 64 | Call oPosReps.Item(oldName).Delete 65 | Next 66 | End Sub 67 | -------------------------------------------------------------------------------- /Helper Rules/Check for OLE Attachments.iLogicVb: -------------------------------------------------------------------------------- 1 | Imports System.IO 2 | ''' 3 | ''' This rule is designed for use in the "Triggers" part of the iLogic tool chain. 4 | ''' It's purpose is to check for any OLEReferences and check them out. 5 | ''' 6 | Sub Main() 7 | ' If ThisApplication.CommandManager.ControlDefinitions.Item("VaultDataCardtop").Enabled = True And _ 8 | ' ThisApplication.CommandManager.ControlDefinitions.Item("VaultUndoCheckouttop").Enabled = True Then 9 | ' Dim oDoc As Document = ThisApplication.ActiveDocument 10 | ' Logger.Debug("Newly opened file: " & oDoc.FullFileName & " in vault checked out" & vbCrLf & "Proceeding to check out OLE Referenced files") 11 | CheckForVaultedOLEReference() 12 | ' End If 13 | 14 | End Sub 15 | 16 | Public Sub CheckForVaultedOLEReference() 17 | Try 18 | Dim oDoc As Document = ThisApplication.ActiveDocument 19 | 20 | If oDoc.ReferencedOLEFileDescriptors.Count = 0 Then 21 | Logger.Info(oDoc.FullFileName & " doesn't contain any OLE References") 22 | Exit Sub 23 | End If 24 | 25 | Dim aOLERefs() As ReferencedOLEFileDescriptor 26 | ReDim aOLERefs(oDoc.ReferencedOLEFileDescriptors.Count - 1) 27 | 28 | Dim iRefCount As Integer = oDoc.ReferencedOLEFileDescriptors.Count 29 | For i As Integer = 1 To iRefCount 30 | Dim OLEreference As ReferencedOLEFileDescriptor = oDoc.ReferencedOLEFileDescriptors.Item(i) 31 | Dim RuleArguments As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap 32 | RuleArguments.Value("filename") = System.IO.Path.GetFileName(OLEreference.FullFileName) 33 | iLogicVb.RunExternalRule("Checkout Requested File From Vault", RuleArguments) 34 | Logger.Info(OLEreference.FullFileName & " checked for Vaulted status") 35 | Next 36 | Catch ex As Exception 37 | logger.Error(ex.Message) 38 | End Try 39 | End Sub -------------------------------------------------------------------------------- /Helper Rules/Collapsible iLogic Test.iLogicVb: -------------------------------------------------------------------------------- 1 | 'this is a brief test of the collapsible code function. 2 | '[collapse this region 3 | ' collapse this 4 | Sub Main() 5 | MessageBox.Show("Hello world!") 6 | Main2() 7 | End Sub 8 | 'collapsible 9 | '] 10 | 11 | #Region "Collapsible" 12 | Sub Main2() 13 | Main3() 14 | End Sub 15 | 16 | Sub Main3() 17 | MessageBox.Show("Hello again!") 18 | End Sub 19 | 'another collapsible region 20 | 'that may be better than the one above! 21 | #End Region -------------------------------------------------------------------------------- /Helper Rules/CopyiPropertiesBetweenFiles.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | 3 | 'copy custom iProperties between files 4 | 5 | dim oPropsets as PropertySets 6 | Dim oDoc As Document = ThisApplication.ActiveDocument 7 | 8 | If TypeOf oDoc Is DrawingDocument Then 9 | Dim drawingDoc As DrawingDocument = oDoc 10 | oPropsets = drawingDoc.PropertySets.Item("User Defined Properties") 11 | 12 | End If 13 | 'oPropsets = oDoc.PropertySets.Item("User Defined Properties") 14 | Logger.Info(oPropsets.Count) 15 | -------------------------------------------------------------------------------- /Helper Rules/CountFaces.iLogicVb: -------------------------------------------------------------------------------- 1 | Imports System.LINQ 2 | AddReference "System.Core" 3 | ''' <summary> 4 | ''' Copied from here: https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/fastest-way-to-sort-faces-by-type/m-p/9342098 5 | ''' </summary> 6 | Sub Main 7 | Dim oIPT As PartDocument=ThisDoc.Document 8 | Dim oCD As ComponentDefinition=oIPT.ComponentDefinition 9 | Dim PFQ As Integer 10 | Break 11 | For Each oWS As WorkSurface In oCD.WorkSurfaces 12 | For Each oSB1 As SurfaceBody In oWS.SurfaceBodies 13 | Dim F1 = From x In oSB1.Faces Where x.SurfaceType=SurfaceTypeEnum.kPlaneSurface 14 | PFQ += F1.Count 15 | Next 16 | Next 17 | 18 | For Each oSB2 As SurfaceBody In oCD.SurfaceBodies 19 | Dim F2 = From x In oSB2.Faces Where x.SurfaceType=SurfaceTypeEnum.kPlaneSurface 20 | PFQ += F2.Count 21 | Next 22 | MsgBox("Plane faces QTY=" & PFQ,, "Finished") 23 | End Sub -------------------------------------------------------------------------------- /Helper Rules/CreateHiddenProperty.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 'CreateInvisiblePropertySet() 2 | Break 3 | Dim oDoc As Document = ThisApplication.ActiveDocument 4 | If Not oDoc.PropertySets.Item("MyCustomPropertySet") Is Nothing Then oDoc.PropertySets.Item("MyCustomPropertySet").Delete 5 | Dim oCustomPropertySet As PropertySet = oDoc.PropertySets.Add("MyCustomPropertySet") 6 | Dim myCar As Car = New Car 7 | myCar.EngineSize = 1100 8 | myCar.Make = "Ford" 9 | myCar.Model = "Focus" 10 | 'Dim oCustomProperty As Inventor.Property = oCustomPropertySet.Add("MyValue", "InvisibleProperty") 11 | Dim prop As String = WriteClassPropertiesToString(myCar) 12 | Dim oCustomProperty As Inventor.Property = oCustomPropertySet.Add(prop, "Car001") 13 | 14 | call ShowValueOfHiddenPropertySet() 15 | 16 | End Sub 17 | 18 | Sub ShowValueOfHiddenPropertySet() 19 | 20 | Dim oDoc As Document = ThisApplication.ActiveDocument 21 | Dim oCustomPropertySet As PropertySet = oDoc.PropertySets.Item("MyCustomPropertySet") 22 | Dim oCustomProperty As Inventor.Property = oCustomPropertySet.Item( "Car001")'"InvisibleProperty") 23 | 24 | MessageBox.Show(oCustomProperty.Value) 25 | 26 | End Sub 27 | 28 | Public Function WriteClassPropertiesToString(ByVal myobj As Car) As String 29 | For Each prop In myobj.GetType.GetProperties() 30 | WriteClassPropertiesToString = WriteClassPropertiesToString & prop.GetValue(myobj, Nothing) & "|" 31 | next 32 | End function 33 | 34 | Public Class Car 35 | Public Property Make As String 36 | Public Property Model As String 37 | Public Property EngineSize As Double 38 | End Class 39 | -------------------------------------------------------------------------------- /Helper Rules/DebugBrowserNodes.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | Sub Main() 3 | break 4 | If Not RuleArguments.Exists("filename") Then 5 | If Not TypeOf ThisApplication.ActiveDocument Is PartDocument Then 6 | MessageBox.Show("not a part file!") 7 | Exit Sub 8 | End If 9 | Dim partDoc As PartDocument = ThisApplication.ActiveDocument 10 | reprocessDerivedcomponent(partDoc) 11 | Else 12 | Dim filename As String = RuleArguments.Value("filename") 13 | logger.Debug("processing: " & filename) 14 | Dim partDoc As PartDocument = ThisApplication.Documents.Item(filename) 15 | ' Dim partDoc As PartDocument = ThisApplication.Documents.Open(filename) 16 | reprocessDerivedcomponent(partDoc) 17 | partDoc.Save() 18 | ' partDoc.Close() 19 | End If 20 | End Sub 21 | 22 | Sub reprocessDerivedcomponent(ByVal partDoc As PartDocument) 23 | Dim top As BrowserNode = partDoc.BrowserPanes("Model").TopNode 24 | For Each node As BrowserNode In top.BrowserNodes 25 | If Not node.NativeObject Is Nothing Then 26 | ' break 27 | If TypeOf (node.NativeObject) Is DerivedPartComponent Then 28 | partDoc.SelectSet.Clear 29 | partDoc.SelectSet.Select(node.NativeObject) 30 | ThisApplication.CommandManager.ControlDefinitions.Item("PartEditDerivedPartCtxCmd").Execute2(True) 31 | End If 32 | End If 33 | Next 34 | End Sub -------------------------------------------------------------------------------- /Helper Rules/DeleteUnreferencedSketchEntities.iLogicVb: -------------------------------------------------------------------------------- 1 | ''' <summary> 2 | ''' Allows an iLogic user to remove broken "pink" unreferenced sketch entities. 3 | ''' </summary> 4 | Sub Main() 5 | Dim i, j As Integer 6 | If TypeOf(ThisApplication.ActiveDocument) Is PartDocument Then 7 | Dim doc As PartDocument = ThisApplication.ActiveDocument 8 | 9 | For Each sk As Sketch In doc.ComponentDefinition.Sketches 10 | For Each ske As SketchEntity In sk.SketchEntities 11 | If ske.Reference And ske.ReferencedEntity Is Nothing Then 12 | i = i + 1 13 | On Error Resume Next 14 | ske.Delete 15 | If Err.Number = 0 Then 16 | j = j + 1 17 | End If 18 | On Error GoTo 0 19 | End If 20 | Next ske 21 | Next sk 22 | Messagebox.Show(Str(i) & " broken links were found in the sketches. " & Str(j) & " got deleted.") 23 | End If 24 | End Sub 25 | -------------------------------------------------------------------------------- /Helper Rules/Design Checker/Fillet Size.iLogicVb: -------------------------------------------------------------------------------- 1 |  Sub Main() 2 | featName = RuleArguments("FeatureName") 3 | feat = Feature.InventorFeature(featName) 4 | 5 | retval = -1 6 | 'don't allow fillets smaller than 1/8" or larger than 1" 7 | If feat.Type = ObjectTypeEnum.kFilletFeatureObject Then 8 | 'parameter values are in cm, so convert to inches. 9 | filletSize = feat.FeatureDimensions(1).Parameter.Value / 2.54 10 | 11 | If filletSize < .125 Then 12 | msg = "Fillet size (" + Str(FilletSize) + ") is too small (less than 1/8"")" 13 | retval = 0 14 | Else If filletSize > 1 Then 15 | msg = "Fillet size (" + Str(FilletSize) + ") is too big (larger than 1"")" 16 | retval = 0 17 | Else 18 | msg = "Fillet size (" + Str(FilletSize) + ") is valid" 19 | retval = 1 20 | End If 21 | End If 22 | 23 | RuleArguments.Arguments.Value("ReturnValue") = retval 24 | RuleArguments.Arguments.Value("Description") = msg 25 | End Sub 26 | 27 | -------------------------------------------------------------------------------- /Helper Rules/Design Checker/MaterialCheck.iLogicVb: -------------------------------------------------------------------------------- 1 | ' <FireOthersImmediately>False</FireOthersImmediately> 2 | Sub Main 3 | allowedMaterials = New String(){"Steel, Mild", "Steel", "Stainless steel", _ 4 | "Titanium", "Alloy Steel", "Aluminum-6061" } 5 | 6 | materialName = iProperties.Material 7 | materialValid = False 8 | 9 | retval = 0 10 | For Each matl in allowedMaterials 11 | If matl = materialName Then 12 | retval = 1 13 | Exit For 14 | End If 15 | Next 16 | 17 | If retval = 1 Then 18 | msg = materialName & " is Valid" 19 | Else 20 | msg = materialName & " is not a Valid Material" 21 | End If 22 | 23 | RuleArguments.Arguments.Value("ReturnValue") = retval 24 | RuleArguments.Arguments.Value("Description") = msg 25 | End Sub 26 | 27 | -------------------------------------------------------------------------------- /Helper Rules/Design Checker/iLogic-FeatureBased Template.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | ' Design Checker fixed code starts here: 3 | app = ThisApplication 4 | 5 | featName = RuleArguments("FeatureName") 6 | feat = Feature.InventorFeature(featName) 7 | 8 | 9 | 'Insert your rule logic here. 10 | 11 | 12 | 'Tasks: 13 | retval = -1 14 | 'set return values as desired. 15 | 'if ReturnValue= 16 | ' -1, don't show any results 17 | ' 0, rule failed, show results in tree 18 | ' 1, rule passed, show results 19 | 20 | ' Set msg to a string to be used as the tooltip. It should be a description of why the check passed/failed. 21 | 22 | RuleArguments.Arguments.Value("ReturnValue") = retval 23 | RuleArguments.Arguments.Value("Description") = msg 24 | End Sub 25 | 26 | -------------------------------------------------------------------------------- /Helper Rules/Design Checker/iLogic-General Template.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | ' Design Checker fixed code starts here: 3 | app = ThisApplication 4 | 5 | 6 | 'Insert your rule logic here. 7 | 8 | 'Tasks: 9 | retval = -1 10 | 'set return values as desired. 11 | 'if ReturnValue= 12 | ' -1, don't show any results 13 | ' 0, rule failed, show results in tree 14 | ' 1, rule passed, show results 15 | 16 | ' Set msg to a string to be used as the tooltip. It should be a description of why the check passed/failed. 17 | 18 | RuleArguments.Arguments.Value("ReturnValue") = retval 19 | RuleArguments.Arguments.Value("Description") = msg 20 | End Sub 21 | 22 | -------------------------------------------------------------------------------- /Helper Rules/DumpRepresentationNamesToFile.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | 3 | ''' <summary> 4 | ''' This rule is intended to dump the representations in the current parent assembly file to a text file for ease of copying. 5 | ''' </summary> 6 | Public Sub Main() 7 | Dim ThisAssyDoc As AssemblyDocument = ThisApplication.ActiveDocument 8 | Dim oAsmCompDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition 9 | 10 | Dim csvFile As System.IO.File 11 | csvWriter = csvFile.CreateText(ThisDoc.PathAndFileName(False) & ".csv") 12 | csvWriter.WriteLine("Positional Representations present in this Assembly:") 13 | csvWriter.WriteLine() 14 | 15 | 'Not implemented pseudo-code: 16 | 'call iterateViewReps(ThisAssyDoc) 17 | 'call iterateLevelofDetailReps(ThisAssyDoc) 18 | 19 | Call iteratePosReps(oAsmCompDef) 20 | csvWriter.Close() 21 | End Sub 22 | 23 | Public csvWriter As System.IO.StreamWriter 24 | 25 | Public Sub iteratePosReps(ByVal CurrentAssemblyDocDef As AssemblyComponentDefinition) 26 | For Each PosRep As PositionalRepresentation In CurrentAssemblyDocDef.RepresentationsManager.PositionalRepresentations 27 | csvWriter.WriteLine(PosRep.Name) 28 | Next 29 | End Sub 30 | 31 | Public Sub iterateViewReps(ByVal CurrentAssemblyDocDef As AssemblyComponentDefinition) 32 | Throw New System.NotImplementedException 33 | End Sub 34 | 35 | Public Sub iterateLevelofDetailReps(ByVal CurrentAssemblyDocDef As AssemblyComponentDefinition) 36 | Throw New System.NotImplementedException 37 | End Sub 38 | -------------------------------------------------------------------------------- /Helper Rules/ExtBatchPdfs.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | AddReference "IlogicExternalDebug.dll" 3 | Imports iLogicExternalDebug 4 | Imports System.IO 5 | 'Imports Microsoft.office.interop.excel 6 | Private Sub Main() 7 | If TypeOf(ThisDoc.Document) Is assemblydocument Then 8 | xtClass.ThisApplication = ThisApplication 9 | xtClass.DocToUpdate = ThisDoc 10 | xtClass.ThisDoc = ThisDoc 11 | xtclass.assydef = ThisDoc.Document.componentdefinition 12 | Call xtClass.BatchPDFsFromAssembly 13 | 'Call insertdummyfiles 14 | Else 15 | MessageBox.Show("Rule must be run in assembly!", "Error!") 16 | End If 17 | End Sub 18 | Public xtClass As New iLogicExternalDebug.ExtClass() 19 | -------------------------------------------------------------------------------- /Helper Rules/FinishFeatures/CreateFinishFeaturesFromLibrary.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | 3 | ' Get a feature selection from the user 4 | Dim oObject As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a face") 5 | Dim oGeometries As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection 6 | 7 | oGeometries.Add(oObject) 8 | 9 | Dim AssetLibraryList As List(Of String) = (From AL As AssetLibrary In ThisApplication.AssetLibraries 10 | Select AL.DisplayName).ToList() 11 | 12 | Dim SelectedLibrary As String = InputListBox("Select an existing, connected Asset Library:", AssetLibraryList, Nothing, Title := "Inventor Asset Libraries", ListName := "Library List") 13 | 14 | If SelectedLibrary = "" Then Throw New Exception("You didn't pick anything!") 15 | 16 | CreateFinishFeaturesForLibrary(SelectedLibrary, oGeometries) 17 | 18 | End Sub 19 | 20 | Public Sub CreateFinishFeaturesForLibrary(ByVal libraryName As String, ByVal oGeometries As FaceCollection, Optional ProcessName As String = "") 21 | If Not TypeOf ThisApplication.ActiveDocument Is PartDocument Then Throw New Exception("NOt a part file!") 22 | 23 | Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument 24 | 25 | Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition 26 | Dim oFinishFeatures As FinishFeatures = oCompDef.Features.FinishFeatures 27 | 28 | Dim oAppearanceLibrary As AssetLibrary = ThisApplication.AssetLibraries(libraryName) 29 | 30 | Dim i As Integer = 0 31 | 32 | For Each oAppearanceAsset As Asset In oAppearanceLibrary.AppearanceAssets 33 | if i = 10 then exit for 34 | Dim oAppearanceName As String = oAppearanceAsset.DisplayName 35 | Dim oAppearance As Asset = oAppearanceAsset.CopyTo(oPartDoc) 36 | Dim oFinishDef As FinishDefinition = oFinishFeatures.CreateFinishDefinition(oGeometries, FinishTypeEnum.kAppearanceFinishType, ProcessName, oAppearance) 37 | Dim myFinishFeature As FinishFeature = oFinishFeatures.Add(oFinishDef) 38 | myFinishFeature.Name = oAppearance.DisplayName 39 | i += 1 40 | Next 41 | 42 | End Sub 43 | -------------------------------------------------------------------------------- /Helper Rules/Ground selected in current location.iLogicVb: -------------------------------------------------------------------------------- 1 | ''' <summary> 2 | ''' Prior to running this tool something must be selected inside of the assembly modelling window. 3 | ''' </summary> 4 | Public Sub Main() 5 | Dim assemblydoc As AssemblyDocument = ThisApplication.ActiveDocument 6 | dim assemblyCompDef as AssemblyComponentDefinition = assemblyDoc.componentdefinition 7 | dim qGround as boolean = InputRadioBox("Select one:", "Ground", "Un-Ground", True, "ilogic") 8 | ' Get the occurrences in the select set. 9 | Dim occurrenceList As New Collection 10 | Dim entity As Object 11 | For Each entity In assemblyCompDef.Occurrences 'assemblydoc.SelectSet 12 | If TypeOf entity Is ComponentOccurrence Then 13 | occurrenceList.Add(entity) 14 | End If 15 | Next 16 | 17 | If occurrenceList.Count < 1 Then 18 | MsgBox("At least one occurrence must be selected.") 19 | Exit Sub 20 | End If 21 | 22 | 'need to enclose this next part inside a transaction so we have the option of rolling back the changes in one go, otherwise 23 | 'the Undo history doesn't always go far enough! 24 | Dim GroundAndRootTr As Transaction = ThisApplication.TransactionManager.StartTransaction(assemblydoc, "Ground in current location") 25 | 26 | Try 27 | ' Iterate through the other occurrences 28 | Dim i As Integer 29 | For i = 1 To occurrenceList.Count 30 | Dim thisOcc As ComponentOccurrence = occurrenceList.Item(i) 31 | thisOcc.grounded = qGround 32 | Next 33 | 34 | Catch ex As Exception 35 | MsgBox("Unrecoverable error occurred during the operation" & vbCrLf & ex.Message) 36 | GroundAndRootTr.Abort() 37 | Exit Sub 38 | Finally 39 | GroundAndRootTr.End() 40 | End Try 41 | End Sub 42 | -------------------------------------------------------------------------------- /Helper Rules/LoopTest.iLogicVb: -------------------------------------------------------------------------------- 1 | ''' <summary> 2 | ''' uses c# code from here: https://stackoverflow.com/a/19347286/572634 3 | ''' </summary> 4 | Public Sub Main() 5 | For i = 1 To 10 6 | call runloop() 7 | Next i 8 | End Sub 9 | 10 | Public Sub runloop() 11 | Dim watch = New Stopwatch() 12 | ' Dim array As Integer() = New Integer(99999999) {} 13 | Dim array As Long() = New Long(99999999) {} 14 | 15 | For i As Long = 0 To array.LongLength - 1 16 | array(i) = 1 17 | Next 18 | 19 | watch.Restart() 20 | Dim sum As Long = 0 21 | 22 | For i As Long = 0 To array.LongLength - 1 23 | sum += array(i) 24 | Next 25 | 26 | Logger.Debug("for loop:" & watch.ElapsedMilliseconds.ToString() & "ms, result:" + sum.ToString()) 27 | sum = 0 28 | watch.Restart() 29 | sum = array.Sum() 30 | Logger.Debug("linq sum:" & watch.ElapsedMilliseconds.ToString() & "ms, result:" + sum.ToString()) 31 | sum = 0 32 | watch.Restart() 33 | Dim length As Long = array.LongLength 34 | 35 | For i As Long = 0 To length - 1 36 | sum += array(i) 37 | Next 38 | 39 | Logger.Debug("for loop fixed:" & watch.ElapsedMilliseconds.ToString() & "ms, result:" + sum.ToString()) 40 | sum = 0 41 | watch.Restart() 42 | 43 | For Each i As Long In array 44 | sum += i 45 | Next 46 | 47 | Logger.Debug("foreach sum:" & watch.ElapsedMilliseconds.ToString() & "ms, result:" + sum.ToString()) 48 | sum = 0 49 | watch.Restart() 50 | sum = array.AsParallel().Sum() 51 | Logger.Debug("linq parallel sum:" & watch.ElapsedMilliseconds & "ms, result:" + sum.ToString()) 52 | End Sub -------------------------------------------------------------------------------- /Helper Rules/MeasureComponents.iLogicVb: -------------------------------------------------------------------------------- 1 | 'MEASURE PANEL DIMS' 2 | 3 | 'Measure The object and create variables 4 | 'Logger.Debug(ThisDoc.Document.FullFileName) 'always shows as the assembly name 5 | Dim editingDoc As Document = ThisApplication.ActiveDocument 6 | Logger.Debug(editingDoc.FullFileName) 7 | 8 | L1 = Measure.ExtentsLength 9 | L2 = Measure.ExtentsWidth 10 | L3 = Measure.ExtentsHeight 11 | 12 | 'Sort measurements 13 | 14 | THK = MinOfMany(L1,L2,L3) 15 | LTH = MaxOfMany(L1,L2,L3) 16 | WTH = L1 + L2 + L3 - THK - LTH 17 | 18 | 'Create external custom parameters, parameters rounded to 1 dec point 19 | 20 | iProperties.Value(editingDoc.FullFileName,"custom","LENGTH") = Round(LTH,1) 21 | iProperties.Value(editingDoc.FullFileName,"custom","WIDTH") = Round(WTH, 1) 22 | iProperties.Value(editingDoc.FullFileName,"custom", "THICKNESS") = Round(THK,1) 23 | 24 | iProperties.Value(editingDoc.FullFileName,"custom","DATE_MEASURED") = Now() 25 | 26 | -------------------------------------------------------------------------------- /Helper Rules/PartsandAssemblies.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Class PartsandAssemblies 2 | 3 | Friend Shared Function GetParameterCount(thisAssy As AssemblyDocument) As String 4 | Dim oParams As Inventor.Parameters = thisAssy.ComponentDefinition.Parameters 5 | Return oParams.count 6 | End Function 7 | 8 | Friend Shared Function GetFeatureCount(subAssy As AssemblyDocument) As String 9 | Dim oFeats As Features = subAssy.ComponentDefinition.Features 10 | Return oFeats.Count 11 | End Function 12 | 13 | Friend Shared Function GetOccurrenceCount(thisAssy As AssemblyDocument) As String 14 | Dim Occs As ComponentOccurrences = thisAssy.ComponentDefinition.Occurrences 15 | Return Occs.Count 16 | End Function 17 | 18 | Friend Shared Function GetConstraintCount(thisAssy As AssemblyDocument) As String 19 | Return thisAssy.ComponentDefinition.Constraints.Count 20 | End Function 21 | 22 | Friend Shared Function GetParameterCount(thispart As PartDocument) As String 23 | Dim oParams As Inventor.Parameters = thispart.ComponentDefinition.Parameters 24 | Return oParams.Count 25 | End Function 26 | 27 | Friend Shared Function GetFeatureCount(thispart As PartDocument) As String 28 | Dim oFeats As PartFeatures = thispart.ComponentDefinition.Features 29 | Return oFeats.Count 30 | End Function 31 | End Class -------------------------------------------------------------------------------- /Helper Rules/Place_And_Ground_Known_Part.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | Dim filename As String = "C:\Users\Alex.Fielder\OneDrive\Inventor\Designs\C360\Part5.ipt" 3 | If TypeOf ThisDoc.Document Is AssemblyDocument Then 4 | Place_and_Ground_Part(ThisApplication, filename) 5 | ElseIf TypeOf ThisDoc.Document Is DrawingDocument Then 6 | PlaceDrawingView(ThisApplication, filename) 7 | End If 8 | End Sub 9 | 10 | Public Function Place_and_Ground_Part(ByVal invApp As Inventor.Application, 11 | ByVal path As String) As ComponentOccurrence 12 | 13 | ' Post the filename to the private event queue. 14 | invApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, path) 15 | 16 | ' Get the control definition for the Place Component command. 17 | Dim ctrlDef As Inventor.ControlDefinition 18 | ctrlDef = invApp.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd") 19 | 20 | ' Execute the command. 21 | ctrlDef.Execute() 22 | 23 | Return Nothing 24 | End Function 25 | 26 | Public Function PlaceDrawingView(ByVal invApp As Inventor.Application, 27 | ByVal path As String) As DrawingView 28 | 'MessageBox.Show("Filename: " & path) 29 | ' Post the filename to the private event queue. 30 | invApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, path) 31 | 32 | ' Get the control definition for the Place Component command. 33 | Dim ctrlDef As Inventor.ControlDefinition 34 | ctrlDef = invApp.CommandManager.ControlDefinitions.Item("DrawingBaseViewCmd") 35 | 36 | ' Execute the command. 37 | ctrlDef.Execute() 38 | 39 | End Function 40 | -------------------------------------------------------------------------------- /Helper Rules/PrintCommandNames.iLogicVb: -------------------------------------------------------------------------------- 1 | imports System.IO 2 | 3 | Sub Main() 4 | Dim oControlDefs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions 5 | 6 | Dim oControlDef As ControlDefinition 7 | 8 | Dim oFile As StreamWriter = System.IO.File.CreateText("c:\temp\CommandNames.txt") 9 | oFile.WriteLine("Command Name" & "|" & "Description") 10 | For Each oControlDef In oControlDefs 11 | oFile.WriteLine(oControlDef.InternalName & "|" & oControlDef.DescriptionText) 12 | Next 13 | oFile.Close() 14 | End Sub 15 | -------------------------------------------------------------------------------- /Helper Rules/Pusher/DIMS.ilogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | 3 | Dim oAsmDoc As Inventor.AssemblyDocument = ThisDoc.Document 4 | Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document, "Push Parameter Values to referenced documents") 5 | Try 6 | Dim oPars As Inventor.Parameters = oAsmDoc.ComponentDefinition.Parameters 7 | 8 | Dim oList As Collection = New Collection 9 | For Each oPar As Inventor.Parameter In oPars 10 | If (oPar.Name.StartsWith("A:")) Then 11 | oList.Add(oPar.Name) 12 | End If 13 | Next 14 | 15 | If oList.Count = 0 Then 16 | MsgBox("Empty list :(") 17 | Else 18 | For Each oDoc As Document In oAsmDoc.AllReferencedDocuments 19 | If Not oDoc.FullFileName.Contains("Content Center") Then 'not CC file 20 | If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then 21 | Dim oPartDoc As PartDocument = oDoc 22 | Dim partDef As ComponentDefinition = oPartDoc.ComponentDefinition 23 | For Each ParName As String In oList 24 | Try 25 | Dim oParam As Parameter = partDef.Parameters(ParName) 26 | oParam.Value = Parameter(ParName) / 10 27 | Catch 28 | End Try 29 | Next 30 | ElseIf oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 31 | Dim oAssyDoc As AssemblyDocument = oDoc 32 | Dim assyDef As ComponentDefinition = oAssyDoc.ComponentDefinition 33 | For Each ParName As String In oList 34 | Try 35 | Dim oParam As Parameter = assyDef.Parameters(ParName) 36 | oParam.Value = Parameter(ParName) / 10 37 | Catch 38 | End Try 39 | Next 40 | End If 41 | End If 42 | Next 43 | End If 44 | Catch ex As exception 45 | MessageBox.Show("Something is broken: " & ex.message & " " & ex.stacktrace) 46 | trans.abort() 47 | Finally 48 | 'Update the document to see the changes 49 | iLogicVb.UpdateWhenDone = True 50 | trans.End() 51 | End Try 52 | End Sub 53 | -------------------------------------------------------------------------------- /Helper Rules/RenumberItems.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | AddReference "IlogicExternalDebug.dll" 3 | Imports iLogicExternalDebug 4 | Imports System.IO 5 | 'Imports Microsoft.office.interop.excel 6 | Private Sub Main() 7 | If TypeOf(ThisDoc.Document) Is assemblydocument Then 8 | xtClass.ThisApplication = ThisApplication 9 | xtClass.DocToUpdate = ThisDoc 10 | xtclass.assydef = ThisDoc.Document.componentdefinition 11 | Dim result As dialogresult = MessageBox.Show("Is this the top-level assembly we need to produce a BOM from?", "Title",MessageBoxButtons.YesNo) 12 | If result = vbYes Then 13 | xtclass.Bomlevels = False 14 | Else If result = vbNo Then 15 | xtclass.Bomlevels = True 16 | End If 17 | 18 | Call xtClass.BeginRenumberItems 19 | 'Call insertdummyfiles 20 | Else 21 | MessageBox.Show("Rule must be run in assembly!", "Error!") 22 | End If 23 | End Sub 24 | Public xtClass As New iLogicExternalDebug.ExtClass() 25 | -------------------------------------------------------------------------------- /Helper Rules/Runextdebug.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | AddReference "IlogicExternalDebug.dll" 3 | Imports iLogicExternalDebug 4 | Imports System.IO 5 | 'Imports Microsoft.office.interop.excel 6 | Private Sub Main() 7 | xtClass.ThisApplication = ThisApplication 8 | xtClass.DocToUpdate = ThisDoc 9 | 'Call xtClass.SaveCopyAsFromBrowserNodeNames 10 | 'Call insertdummyfiles 11 | 'Call xtclass.CheckiPartTableForErrors 12 | Call xtclass.beginaligndrawingviews 13 | End Sub 14 | Public xtClass As New iLogicExternalDebug.ExtClass() 15 | -------------------------------------------------------------------------------- /Helper Rules/SQLite connection.iLogicVb: -------------------------------------------------------------------------------- 1 | Option explicit On 2 | AddReference "System.Data.SQLite.dll" 3 | AddReference "System.Data" 4 | Imports System.Data 5 | Imports System.Data.SQLite 6 | Dim sqlite_conn As SQLiteConnection 7 | ' create a new database connection: 8 | sqlite_conn = New SQLiteConnection("Data Source=F:\Onedrive For Business\OneDrive - GRAITEC\Inventor\Designs\Inventor 2019\iLogic Test.db;Version=3;") 9 | 10 | sqlite_conn.Open() 11 | 12 | Dim sqlite_cmd As SQLiteCommand = sqlite_conn.CreateCommand() 13 | 14 | sqlite_cmd.CommandText = "CREATE TABLE test (id integer primary key, text varchar(100));" 15 | 16 | sqlite_cmd.ExecuteNonQuery() 17 | -------------------------------------------------------------------------------- /Helper Rules/TryCatchCatch.iLogicVb: -------------------------------------------------------------------------------- 1 | ''' <summary> 2 | ''' Demonstrates how to catch errors with a line number for debuggering purposes 3 | ''' </summary> 4 | Sub Main() 5 | Dim exceptionInt As Integer = 5 6 | Try 7 | 'Do something here that might cause one of the following: 8 | MessageBox.Show("Boom: " & exceptionInt.ToString()) 9 | exceptionInt = 9 10 | MessageBox.Show("Boom: " & exceptionInt.ToString()) 11 | exceptionInt = 11 12 | Threading.Thread.Sleep(500) 13 | MessageBox.Show("Boom: " & exceptionInt.ToString()) 14 | exceptionInt = 14 15 | Threading.Thread.Sleep(500) 16 | MessageBox.Show("Boom: " & exceptionInt.ToString()) 17 | exceptionInt = 17 18 | Threading.Thread.Sleep(5000) 19 | Parameter(L33thaxxor) = "L33t haxxor" 20 | MessageBox.Show("Kaboom: " & exceptionInt.ToString()) 21 | exceptionInt = 21 22 | Catch ArgEx As ArgumentException 23 | MessageBox.Show("Caught an Argument Exception after line: " & exceptionInt & " " & ArgEx.Message, "Title") 24 | ' Catch ComEx As System.COMException 25 | ' MessageBox.Show("Caught a COM Exception after line: " & exceptionInt & " " & ComEx.Message, "Title") 26 | Catch Ex As Exception 27 | MessageBox.Show("Caught a general Exception after line: " & exceptionInt & " " & Ex.Message, "Title") 28 | End Try 29 | 30 | End Sub 31 | -------------------------------------------------------------------------------- /Helper Rules/While away the hours.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | 'this will demonstrate the Do While loop concept: 3 | 4 | Dim IsItTrueYet As Boolean = False 5 | 6 | Do While IsItTrueYet = False 7 | IsItTrueYet = InputBox("Is it true yet?", "Do While Demo") 8 | 9 | If IsItTrueYet Then 10 | MessageBox.Show("True at last!") 11 | Else 12 | MessageBox.Show("Still False, sorry!") 13 | End If 14 | Loop 15 | End Sub -------------------------------------------------------------------------------- /Helper Rules/Wibble.iLogicVb: -------------------------------------------------------------------------------- 1 | messagebox.Show("Hello World") -------------------------------------------------------------------------------- /Helper Rules/iLogicDeleteAllNamedGeometry.iLogicVb: -------------------------------------------------------------------------------- 1 | Imports AII = Autodesk.iLogic.Interfaces 2 | Sub main() 3 | namedEnts = ThisDoc.NamedEntities 4 | 5 | 'doesn't work: 6 | ' For i = namedEnts.Entities.Count To 1 7 | ' Dim namedEntToDelete As NameValueMap = namedEnts.Entities.Item(i) 8 | ' namedEntToDelete.Remove(1) 9 | ' Next i 10 | 'break 11 | ' For Each namedEnt As NameValueMap In namedEnts.Entities 12 | ' namedEnts.DeleteName(namedEnt) 13 | ' Next 14 | 15 | End Sub 16 | 17 | Public namedEnts As AII.NamedEntities = Nothing -------------------------------------------------------------------------------- /Helper Rules/iLogicFeatureNameCollector.iLogicVb: -------------------------------------------------------------------------------- 1 | Imports AII = Autodesk.iLogic.Interfaces 2 | Sub main() 3 | Dim oObj As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select a Face, Edge or Vertex") 4 | If Not oObj Is Nothing Then 5 | namedEnts = ThisDoc.NamedEntities 6 | Dim geomInt As Integer = 1 7 | Dim newAttributeName As String = GetNewOrDefaultNameFromEntities(oObj, "", geomInt) 8 | 9 | newAttributeName = InputBox("What name For the Geometry?", "Naming Day", newAttributeName) 10 | 'Break 11 | newAttributeName = GetNewOrDefaultNameFromEntities(oObj, newAttributeName, geomInt) 12 | namedEnts.SetName(oObj, newAttributeName) 13 | End If 14 | End Sub 15 | 16 | Public namedEnts As AII.NamedEntities = Nothing 17 | 18 | ''' <summary> 19 | ''' Gets a default result which matches the manual approach. 20 | ''' </summary> 21 | ''' <param name="oobj"></param> 22 | ''' <param name="geomInt"></param> 23 | ''' <returns></returns> 24 | Function GetDefaultResponseFromType(ByVal oobj As Object, ByVal geomInt As Integer) As String 25 | Dim defaultResponseFromType As String = String.Empty 26 | Select Case TypeName(oobj) 27 | Case "Vertex" 28 | defaultResponseFromType = TypeName(oobj) & geomInt.ToString("0") 29 | Case Else 30 | defaultResponseFromType = TypeName(oobj) & "Geom" & geomInt.ToString("000") 31 | End Select 32 | Return defaultResponseFromType 33 | End Function 34 | 35 | ''' <summary> 36 | ''' Returns the expected name based on 37 | ''' </summary> 38 | ''' <param name="attrName"></param> 39 | ''' <param name="geomInt"></param> 40 | ''' <returns></returns> 41 | Function GetNewOrDefaultNameFromEntities(ByVal oobj As Object, ByVal attrName As String, ByVal geomInt As Integer) As String 42 | If attrName = String.Empty 43 | attrName = GetDefaultResponseFromType(oobj, geomInt) 44 | End If 45 | 46 | Do While namedEnts.NameExists(attrName) 47 | If Not namedEnts.NameExists(attrName) Then 48 | Return attrName 49 | Else 50 | geomInt += 1 51 | attrName = GetDefaultResponseFromType(oobj, geomInt) 52 | If Not namedEnts.NameExists(attrName) Then 53 | Return attrName 54 | Exit Do 55 | End If 56 | End If 57 | Loop 58 | If Not namedEnts.NameExists(attrName) Then Return attrName 59 | End Function 60 | -------------------------------------------------------------------------------- /Helper Rules/iLogicFeatureSelectorForDebugging.iLogicVb: -------------------------------------------------------------------------------- 1 | Dim ofeature As Face 2 | 3 | ofeature = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select first feature") 4 | break 5 | -------------------------------------------------------------------------------- /Helper Rules/iLogicNamedGeometryConnector.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | 3 | 'Constraints.AddFlush("Flush1", "PartForiLogicFeatureNameCollector:1", "Work Plane1", "Part2:1", "Work Plane1", 4 | ' offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing) 5 | -------------------------------------------------------------------------------- /Helper Rules/wibble.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.bmp -------------------------------------------------------------------------------- /Helper Rules/wibble.dark.large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.dark.large.png -------------------------------------------------------------------------------- /Helper Rules/wibble.dark.small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.dark.small.png -------------------------------------------------------------------------------- /Helper Rules/wibble.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.jpg -------------------------------------------------------------------------------- /Helper Rules/wibble.large.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.large.bmp -------------------------------------------------------------------------------- /Helper Rules/wibble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.png -------------------------------------------------------------------------------- /Helper Rules/wibble.small.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Helper Rules/wibble.small.bmp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to <http://unlicense.org> 25 | -------------------------------------------------------------------------------- /Modelling/Active Lighting Style.ilogicvb: -------------------------------------------------------------------------------- 1 | Dim oAssy As AssemblyDocument = ThisApplication.ActiveDocument 2 | 3 | Dim oLightStyleName As String 4 | 5 | oLightStyleName = oAssy.ActiveLightingStyle.Name 6 | 7 | MessageBox.Show(oLightStyleName, "Title") 8 | 9 | Dim lightingstyletochangeto As LightingStyle = oAssy.LightingStyles.Item("Grid Light") 10 | If Not oAssy.ActiveLightingStyle.Name = lightingstyletochangeto.Name Then 11 | oAssy.ActiveLightingStyle = lightingstyletochangeto 12 | InventorVb.DocumentUpdate() 13 | Else 14 | MessageBox.Show("We're already using the desired lighting style!") 15 | End If 16 | -------------------------------------------------------------------------------- /Modelling/AlignUCSToAssy.iLogicVb: -------------------------------------------------------------------------------- 1 | Dim assyDoc As AssemblyDocument = ThisApplication.ActiveDocument 2 | Dim ss As SelectSet = assyDoc.SelectSet 3 | 4 | ' assumes part occurrence is selected in assy 5 | Dim occur As ComponentOccurrence = ss(0) 6 | 7 | Dim partDef As PartComponentDefinition = occur.Definition 8 | 9 | ' assumes ucs of interest is first ucs in the part 10 | Dim alignUcs As UserCoordinateSystem = partDef.UserCoordinateSystems(1) 11 | 12 | ' create a proxy of the ucs in the context of the assembly 13 | Dim alignUcsProxy As UserCoordinateSystemProxy 14 | Call occur.CreateGeometryProxy(alignUcs, alignUcsProxy) 15 | 16 | ' get the matrix describing the position and orientation of the proxy object 17 | Dim ucsAlignProxyTransform As Matrix = alignUcsProxy.Transformation 18 | 19 | ' create a transient matrix 20 | Dim trans As Matrix = ThisApplication.TransientGeometry.CreateMatrix 21 | 22 | ' copy the proxy matrix to the transient matrix 23 | trans = ucsAlignProxyTransform.Copy 24 | 25 | ' invert the transient matrix to translate from the proxy back to the assembly coordinate system 26 | trans.Invert 27 | 28 | ' transform the occurrence by applying the inverted matrix 29 | occur.Transformation = trans 30 | -------------------------------------------------------------------------------- /Modelling/All Sketches Off In Assembly.iLogicVb: -------------------------------------------------------------------------------- 1 | Private Sub Main() 2 | Call AllSketchesOffInAssembly 3 | End Sub 4 | Private Sub AllSketchesOffInAssembly() 5 | Dim oApp As Inventor.Application = ThisApplication 6 | Dim oAssy As Inventor.AssemblyDocument = oApp.ActiveDocument 7 | Dim oSubDoc As Inventor.Document 8 | Dim oPartDoc As PartDocument 9 | Dim partDef As PartComponentDefinition 10 | 11 | EOPQuery = MsgBox("Would you like to turn visibility of all sketches off?" _ 12 | & vbCrLf & "Click 'Yes' to turn off." _ 13 | & vbCrLf & "Click 'No' to turn on." _ 14 | , vbYesNo, "Sketch Visibility") 15 | 16 | For Each oSubDoc in oAssy.AllReferencedDocuments 17 | If oSubDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then 18 | oPartDoc = oSubDoc 19 | partDef = oPartDoc.ComponentDefinition 20 | Dim osketches as PlanarSketches 21 | osketches = partDef.Sketches 22 | Dim osketch As planarsketch 23 | Dim osketches3D As Sketches3D 24 | osketches3D = partDef.Sketches3D 25 | Dim osketch3D As Sketch3D 26 | If EOPQuery = vbYes Then 27 | For Each osketch In osketches 28 | osketch.Visible = False 29 | Next 30 | For Each osketch3D In osketches3D 31 | osketch3D.Visible = False 32 | Next 33 | ElseIf EOPQuery = vbNo Then 34 | For Each osketch In osketches 35 | osketch.Visible = True 36 | Next 37 | For Each osketch3D In osketches3D 38 | osketch3D.Visible = True 39 | Next 40 | End If 41 | End If 42 | Next 43 | oAssy.Update 44 | End Sub 45 | -------------------------------------------------------------------------------- /Modelling/All Sketches Off In Part.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | ' Set a reference to the Sketches collection. This assumes 3 | ' that a part document containing a sketch is active. 4 | Dim oSketches As PlanarSketches 5 | oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches 6 | 7 | ' Get whether the sketch visibility should be turned on or off. 8 | Dim bVisibleOn As Boolean 9 | If MsgBox("Do you want to turn all sketches on?", vbYesNo + vbQuestion) = vbYes Then 10 | bVisibleOn = True 11 | Else 12 | bVisibleOn = False 13 | End If 14 | 15 | ' Iterate through all of the sketches and set their visibility. 16 | Dim oSketch As PlanarSketch 17 | For Each oSketch In oSketches 18 | If bVisibleOn Then 19 | oSketch.Visible = True 20 | Else 21 | oSketch.Visible = False 22 | End If 23 | Next 24 | 25 | Dim partDef As PartComponentDefinition 26 | partDef = ThisApplication.ActiveDocument.ComponentDefinition 27 | Dim o3DSketches As Sketches3D 28 | o3DSketches = partDef.Sketches3D 29 | Dim oSketch3D As Sketch3D 30 | For Each oSketch3D In o3DSketches 31 | If bVisibleOn Then 32 | oSketch3D.Visible = True 33 | Else 34 | oSketch3D.Visible = False 35 | End If 36 | Next -------------------------------------------------------------------------------- /Modelling/Assembly get current relevant Occurrences.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub main() 2 | GetCurrentRelevantOccurences() 3 | End Sub 4 | 5 | Sub GetCurrentRelevantOccurences() 6 | If TypeOf ThisApplication.ActiveDocument Is AssemblyDocument Then 7 | Dim AssyDoc As AssemblyDocument = ThisApplication.ActiveDocument 8 | Dim assyDef As AssemblyComponentDefinition = AssyDoc.ComponentDefinition 9 | 10 | Dim occurrenceList As List(Of String) = New List(Of String) 11 | Dim allowedList As List(Of String) = ListOfAllowedOccurrences 12 | For Each allowedOcc As String In allowedList 13 | Dim DocTocheck As Document = ThisApplication.Documents.ItemByName(IO.Path.GetDirectoryName(AssyDoc.FullDocumentName) & "\" & allowedOcc) 14 | If Not DocTocheck Is Nothing Then 15 | For Each compOcc As ComponentOccurrence In assyDef.Occurrences.AllReferencedOccurrences(DocTocheck) 16 | Dim tmpDoc As PartDocument = compOcc.Definition.Document 17 | If Not tmpDoc Is Nothing Then 18 | occurrenceList.Add(compOcc.Name) 19 | End If 20 | Next 21 | End If 22 | Next 23 | occurrenceList.Sort() 24 | MultiValue.List("CurrentRelevantOccurrences").Clear 25 | MultiValue.List("CurrentRelevantOccurrences") = occurrenceList 26 | End If 27 | End Sub 28 | 29 | Function ListOfAllowedOccurrences() As List(Of String) 30 | Dim tmpList As List(Of String) = New List(Of String) 31 | tmpList.Add("1000.ipt") 32 | tmpList.Add("1500.ipt") 33 | tmpList.Add("2000.ipt") 34 | Return tmpList 35 | End Function -------------------------------------------------------------------------------- /Modelling/Check Sketch Constraints.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main() 2 | CheckSketchConstraints() 3 | End Sub 4 | 5 | Public Sub CheckSketchConstraints() 6 | ' Check to make sure a sketch is open. 7 | If Not TypeOf ThisApplication.ActiveEditObject Is Sketch Then 8 | MsgBox ("A sketch must be active.") 9 | Exit Sub 10 | End If 11 | 12 | ' Set a reference to the active sketch. 13 | Dim oSketch As Sketch 14 | oSketch = ThisApplication.ActiveEditObject 15 | 16 | Dim oSketchObjects As ObjectCollection 17 | oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection 18 | 19 | ' Get all entities in the sketch 20 | Dim oSketchEntity As SketchEntity 21 | For Each oSketchEntity In oSketch.SketchEntities 22 | If Not oSketchEntity.[_GeometryMoveableStatus] = kFixedGeometryMoveableStatus Then 23 | If Not oSketchEntity.ConstraintStatus = kFullyConstrainedConstraintStatus Then 24 | oSketchObjects.Add(oSketchEntity) 25 | End If 26 | End If 27 | Next 28 | 29 | If oSketchObjects.Count > 0 Then 30 | ' the sketch has unconstrained objects and is broken? 31 | MsgBox ("this sketch needs some constraints!") 32 | Else 33 | MsgBox ("Nothing to see here, move along!") 34 | End If 35 | osketchobjects = Nothing 36 | End Sub 37 | 38 | 39 | -------------------------------------------------------------------------------- /Modelling/CheckiPartForErrors.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | Sub Main() 3 | CheckiPartTableForErrors() 4 | End Sub 5 | Sub CheckiPartTableForErrors() 6 | Dim oErrorManager As ErrorManager = ThisApplication.ErrorManager 7 | 8 | If TypeOf (ThisApplication.activedocument) Is partdocument Then 9 | Dim oDoc As PartDocument = ThisApplication.ActiveDocument 10 | Dim oiPart As iPartFactory = oDoc.ComponentDefinition.iPartFactory 11 | Dim oTop As BrowserNode = oDoc.BrowserPanes("Model").TopNode 12 | Dim bHasErrorOrWarning As Boolean 13 | Dim i As Integer 14 | InventorVb.DocumentUpdate() 15 | ThisApplication.SilentOperation = True 16 | For i = 1 To oiPart.TableRows.Count 'use first 10 rows only for debugging purposes! 17 | ' Highlight the 3rd iPart table row which has invalid data 18 | oTop.BrowserNodes("Table").BrowserNodes.Item(i).DoSelect 19 | 20 | ' Activate the iPart table row 21 | Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd") 22 | oCommand.Execute 23 | 24 | ThisApplication.SilentOperation = False 25 | ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute 26 | If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then 27 | MessageBox.Show(oErrorManager.LastMessage, "Title") 28 | End If 29 | Next i 30 | MessageBox.Show("No errors shown = None found!", "Title") 31 | ElseIf TypeOf (ThisApplication.activedocument) Is assemblydocument Then 32 | Dim odoc As assemblydocument = ThisApplication.activedocument 33 | Dim iAssy As iAssemblyFactory = odoc.componentdefinition.iassemblyfactory 34 | Dim oTop As BrowserNode = odoc.BrowserPanes("Model").TopNode 35 | Dim bHasErrorOrWarning As Boolean 36 | Dim i As Integer 37 | InventorVb.DocumentUpdate() 38 | ThisApplication.SilentOperation = True 39 | For rowIndex = 1 To iAssy.tablerows.count 40 | oTop.BrowserNodes("Table").BrowserNodes.Item(i).DoSelect 41 | Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd") 42 | oCommand.Execute 43 | ThisApplication.SilentOperation = False 44 | ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute 45 | If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then 46 | MessageBox.Show(oErrorManager.LastMessage, "Title") 47 | End If 48 | 49 | Next 50 | End If 51 | End Sub 52 | -------------------------------------------------------------------------------- /Modelling/Contact Constraint Simulation.iLogicVb: -------------------------------------------------------------------------------- 1 | 'reset the key parameters 2 | Parameter("spacing") = 40 3 | Parameter("AngleB") = 35 4 | Dim AngleBDouble As Double = Parameter("ShortSideDistance") / Parameter("lengthc") 5 | ThisApplication.StatusBarText = CStr(AngleBDouble * (180/PI)) 6 | 'then run the simulation 7 | Dim spacingDouble As Double 8 | For spacingDouble = 40 To 30 Step -0.01 9 | Parameter("spacing") = spacingDouble 10 | If Parameter("IntersectionDistance") <= 12 Then 11 | AngleBDouble = Parameter("ShortSideDistance") / Parameter("lengthc") 12 | ThisApplication.StatusBarText = CStr(AngleBDouble * (180/PI)) 13 | Parameter("AngleB") = AngleBDouble * (180/PI) 14 | InventorVb.DocumentUpdate() 15 | End If 16 | InventorVb.DocumentUpdate() 17 | Next 18 | -------------------------------------------------------------------------------- /Modelling/Create a New iLogic Rule automatically.iLogicVb: -------------------------------------------------------------------------------- 1 | 'copied from here: https://inventorlogicblog.wordpress.com/2016/04/20/autodesk-inventor-ilogic-create-a-new-ilogic-rule-automatically/ 2 | ' Start of iLogic rule ================================================= 3 | ' This iLogic rule automatically creates a new iLogic rule called 'Luke's Amazing iLogic Rule' in the active document. 4 | 5 | Dim RuleName As String = "Lukes Amazing iLogic Rule" 6 | Dim RuleText As String = "' Hello - This is an automatically created iLogic rule" & vbCrLf & _ 7 | "' What does it do?" & vbCrLf & _ 8 | "' Just changes the title of your Inventor application I'm afraid" & vbCrLf & _ 9 | "' You'll have to come up with something more exciting.... " & vbCrLf & vbCrLf & _ 10 | "ThisApplication.Caption = ThisApplication.Username" 11 | 12 | Dim oDoc As Document = ThisApplication.ActiveEditDocument 13 | Dim RuleAlreadyExists As Boolean = False 14 | ' Define the iLogic addin 15 | Dim iLogicAddIn As ApplicationAddIn = ThisApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}") 16 | ' Get the iLogic automation object 17 | Dim iLogic As Object = iLogicAddIn.Automation 18 | ' Get the list of iLogic rules in the current Inventor document 19 | Dim RuleList As Object = iLogic.Rules(oDoc) 20 | 21 | ' Loop through all rules in document 22 | For Each R As Object In RuleList 23 | If R.Name = RuleName Then 24 | ' A rule with the same name already exists... 25 | RuleAlreadyExists = True 26 | Exit For 27 | End If 28 | Next 29 | 30 | If RuleAlreadyExists Then 31 | Dim ReplaceRule As MsgBoxResult = MsgBox("A rule called '" & RuleName & "' already exists - replace it?", 36, "Excitech iLogic") 32 | If ReplaceRule = vbYes Then 33 | ' Delete the existing rule 34 | iLogic.DeleteRule(oDoc, RuleName) 35 | ' Add the new rule 36 | iLogic.AddRule(oDoc, RuleName, RuleText) 37 | Else 38 | MsgBox("Operation cancelled...", 64, "Excitech iLogic") 39 | Exit Sub 40 | End If 41 | Else 42 | ' No existing rule to delete - simply add the new rule 43 | iLogic.AddRule(oDoc, RuleName, RuleText) 44 | End If 45 | 46 | ' End of iLogic rule ================================================= -------------------------------------------------------------------------------- /Modelling/CreateCofGsForAssembly.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main() 2 | iLogicVb.UpdateWhenDone = True 3 | Dim AssyDoc As AssemblyDocument = TryCast(ThisApplication.ActiveDocument, AssemblyDocument) 4 | If Not AssyDoc Is Nothing Then 5 | currentCOGpoint(ThisApplication.ActiveDocument) 6 | For Each Doc As Document In AssyDoc.AllReferencedDocuments 7 | If Not TypeOf(doc) Is PartDocument Then 8 | currentCOGpoint(Doc) 9 | End If 10 | Next 11 | Else If TypeOf(ThisApplication.ActiveDocument) Is PartDocument Then 12 | currentCOGpoint(ThisApplication.ActiveDocument) 13 | End If 14 | End Sub 15 | 16 | Public Sub currentCOGpoint(oDoc As Document) 17 | Dim COGpresent As Boolean = False 18 | 19 | If ThisApplication.ActiveDocument Is Nothing Then 20 | messagebox.Show( " ! ! ! no active document ! ! !" & vbCr & "command will be terminated", "! ! unable to proceed ! !", MessageBoxButtons.OK) 21 | Exit Sub 22 | End If 23 | 24 | ' Dim oDoc As Document = ThisApplication.ActiveDocument 25 | If (oDoc.DocumentType = kPartDocumentObject Or oDoc.DocumentType = kAssemblyDocumentObject) Then 26 | 27 | 'read center of gravity coordinates 28 | Dim oDef As ComponentDefinition = oDoc.ComponentDefinition 29 | Dim oMassProperties As MassProperties = oDef.MassProperties 30 | Dim oControlDef As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("AppCenterOfGravityCmd") 31 | oControlDef.Execute 32 | 33 | Dim COGx As Double = oMassProperties.CenterOfMass.X 34 | Dim COGy As Double = oMassProperties.CenterOfMass.Y 35 | Dim COGz As Double = oMassProperties.CenterOfMass.Z 36 | 37 | 'update eventually present COG workpoint 38 | For Each wp In oDef.WorkPoints 39 | If wp.Name = "COG" Then 40 | Call wp.SetFixed(ThisApplication.TransientGeometry.CreatePoint(COGx, COGy, COGz)) 41 | wp.Visible = False 42 | COGpresent = True 43 | Exit For 44 | End If 45 | Next 46 | 47 | 'create COG point if not present 48 | If COGpresent = False Then 49 | Dim wp As WorkPoint = oDef.WorkPoints.AddFixed(ThisApplication.TransientGeometry.CreatePoint(COGx, COGy, COGz)) 50 | wp.Name = "COG" 51 | wp.Visible = False 52 | End If 53 | Else 54 | messagebox.Show( "wrong active document type" & vbCr & "command will be terminated", "! ! unable to proceed ! !", MessageBoxButtons.OK) 55 | End If 56 | End Sub 57 | -------------------------------------------------------------------------------- /Modelling/Crossrail/Add Mates.iLogicVb: -------------------------------------------------------------------------------- 1 | Dim NumBlocksHigh As Integer = Convert.ToInt32(InputBox("How many rows high?", "Num blocks high", "3")) 2 | Dim numrows As Integer = Convert.ToInt32(InputBox("Number of Rows?", "Number of rows high", "3")) 3 | Dim staggeredbuild As Boolean = MessageBox.Show("Number of Rows?", "Number of rows high", MessageBoxButtons.YesNo) 4 | break '< use this With Visual Studio To debug iLogic! 5 | Console.WriteLine("Hello World!") 6 | Debug.Print(NumBlocksHigh & " " & numrows & " " & staggeredbuild) 7 | 8 | Constraints.AddMate("Mate:11", "Snow Block:12", "SIDE01", "Snow Box:10", 9 | "BOTTOM") -------------------------------------------------------------------------------- /Modelling/Crossrail/Place & Stack Boxes.iLogicVb: -------------------------------------------------------------------------------- 1 | Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document, "Place & Stack blocks") 2 | Dim numblocks As Integer = Convert.ToInt32(InputBox("How many blocks?", "Number of blocks", 10)) 3 | Try 4 | For i As Integer = 1 To numblocks 5 | Dim componentA = Components.Add("Snow Block:" & (i).ToString(), "Snow Block.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing) 6 | componentA = Components.Add("Snow Block:" & (i+1).ToString(), "Snow Block.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing) 7 | If (i < numblocks + 1) 8 | Constraints.AddMate("Mate:" & i.ToString(), "Snow Block:" & i.ToString(), "Top","Snow Block:" & (i+1).ToString(), "Bottom", 9 | offset := 0.0, e1InferredType := InferredTypeEnum.kNoInference, e2InferredType := InferredTypeEnum.kNoInference, 10 | solutionType := MateConstraintSolutionTypeEnum.kNoSolutionType, 11 | biasPoint1 := Nothing, biasPoint2 := Nothing) 12 | Constraints.AddFlush("FlushXY:" & i.ToString(), "Snow Block:" & i.ToString(), "XY Plane", "Snow Block:" & (i+1).ToString(), "XY Plane", 13 | offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing) 14 | Constraints.AddFlush("FlushYZ:" & i.ToString(), "Snow Block:" & i.ToString(), "YZ Plane", "Snow Block:" & (i+1).ToString(), "YZ Plane", 15 | offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing) 16 | End If 17 | Next i 18 | trans.End() 19 | Catch ex As Exception 20 | MessageBox.Show(ex.Message) 21 | trans.Abort() 22 | End Try -------------------------------------------------------------------------------- /Modelling/Crossrail/Stack Boxes.iLogicVb: -------------------------------------------------------------------------------- 1 | imports System 2 | Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document,"Stack boxes") 3 | Try 4 | For i As Integer = 1 To 9 5 | If (i < 9) 6 | Constraints.AddMate("Mate:" & i.ToString(), "Snow Box:" & i.ToString(), "Top","Snow Box:" & (i+1).ToString(), "Bottom", 7 | offset := 0.0, e1InferredType := InferredTypeEnum.kNoInference, e2InferredType := InferredTypeEnum.kNoInference, 8 | solutionType := MateConstraintSolutionTypeEnum.kNoSolutionType, 9 | biasPoint1 := Nothing, biasPoint2 := Nothing) 10 | Constraints.AddFlush("FlushXY:" & i.ToString(), "Snow Box:" & i.ToString(), "XY Plane", "Snow Box:" & (i+1).ToString(), "XY Plane", 11 | offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing) 12 | Constraints.AddFlush("FlushYZ:" & i.ToString(), "Snow Box:" & i.ToString(), "YZ Plane", "Snow Box:" & (i+1).ToString(), "YZ Plane", 13 | offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing) 14 | End If 15 | Next i 16 | trans.End() 17 | Catch ex As Exception 18 | trans.Abort() 19 | End Try 20 | -------------------------------------------------------------------------------- /Modelling/Engraving.iLogicVb: -------------------------------------------------------------------------------- 1 | iLogicVb.UpdateWhenDone = True 2 | 3 | Select Case HoleAngle 4 | Case 20 5 | PartMarking = "20/50" 6 | Case 25 7 | PartMarking = "25/45" 8 | Case 30 9 | PartMarking = "30/40" 10 | Case 35 11 | PartMarking = "35/35" 12 | Case 40 13 | PartMarking = "40/30" 14 | Case 45 15 | PartMarking = "45/25" 16 | 'Case 1 17 | ' MultiValue.SetList("PartMarking", "20/50", "35/35", "40/30", "45/25") 18 | ' PartMarking = "45/25" 19 | ' MultiValue.SetList("PartMarkingAlt", "25/45", "30/40", "35/35") 20 | ' PartMarkingAlt = "25/45" 21 | 'Case 2 22 | ' MultiValue.SetList("PartMarking", "20/50", "35/35", "40/30", "45/25") 23 | ' PartMarking = "40/30" 24 | ' MultiValue.SetList("PartMarkingAlt", "25/45", "30/40", "35/35") 25 | ' PartMarkingAlt = "30/40" 26 | 'Case 3 27 | ' MultiValue.SetList("PartMarking", "20/50", "35/35", "40/30", "45/25") 28 | ' PartMarking = "35/35" 29 | ' MultiValue.SetList("PartMarkingAlt", "25/45", "30/40", "35/35") 30 | ' PartMarkingAlt = "HIDEME" 31 | 'Case 4 32 | ' MultiValue.SetList("PartMarking", "20/50", "35/35", "40/30", "45/25") 33 | ' PartMarking = "20/50" 34 | ' MultiValue.SetList("PartMarkingAlt", "25/45", "30/40", "35/35") 35 | ' PartMarkingAlt = "HIDEME" 36 | End Select -------------------------------------------------------------------------------- /Modelling/FEATURECOUNT.iLogicVb: -------------------------------------------------------------------------------- 1 | option explicit on 2 | Sub Main() 3 | If TypeOf ThisDoc.Document Is PartDocument Then 4 | If Not ThisDoc.Document.File.FullFileName.Contains("Content") Then 'skip CC and FACILITY files 5 | If Not ThisDoc.Document.File.fullfilename.contains("FACILITY") Then 6 | Dim oFeats As PartFeatures = ThisDoc.Document.ComponentDefinition.Features 7 | iProperties.Value("Custom", "FEATURECOUNT") = oFeats.Count 8 | 'MessageBox.Show("Feature Count for this part is: " & oFeats.Count, "FEATURECOUNT") 9 | Dim oParams As Parameters = ThisDoc.Document.ComponentDefinition.Parameters 10 | iProperties.Value("Custom", "PARAMETERCOUNT") = oParams.Count 11 | MessageBox.Show("Parameter Count for " & ThisDoc.Document.File.fullfilename & " is: " & oParams.Count, "PARAMETERCOUNT") 12 | End If 13 | End If 14 | ElseIf TypeOf ThisDoc.Document Is AssemblyDocument Then 15 | If Not ThisDoc.Document.File.FullFileName.Contains("Content") Then 'skip CC and FACILITY files 16 | If Not ThisDoc.Document.file.fullfilename.contains("FACILITY") Then 17 | Dim oFeats As Features = ThisDoc.Document.ComponentDefinition.Features 18 | iProperties.Value("Custom", "FEATURECOUNT") = oFeats.Count 19 | 'MessageBox.Show("Feature Count for this assembly is: " & oFeats.Count, "FEATURECOUNT") 20 | Dim Occs As ComponentOccurrences = ThisDoc.Document.ComponentDefinition.Occurrences 21 | iProperties.Value("Custom", "OCCURRENCECOUNT") = Occs.Count 22 | MessageBox.Show("Occurrence Count for " & ThisDoc.Document.File.fullfilename & " is: " & Occs.Count, "OCCURRENCECOUNT") 23 | Dim oParams As Parameters = ThisDoc.Document.ComponentDefinition.Parameters 24 | iProperties.Value("Custom", "PARAMETERCOUNT") = oParams.Count 25 | 'MessageBox.Show("Parameter Count for this part is: " & oParams.Count, "PARAMETERCOUNT") 26 | End If 27 | End If 28 | End If 29 | End Sub 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Modelling/Flange Face Material Retainer.iLogicVb: -------------------------------------------------------------------------------- 1 | option explicit on 2 | '''Will set the appearance of a part file expect for those faces which have a name. 3 | ''' 4 | ''' 5 | Public Sub Main() 6 | If TypeOf ThisApplication.ActiveDocument Is PartDocument Then 7 | ResetNamedFacesToDesiredAppearance(ThisApplication.ActiveDocument) 8 | Else 9 | MessageBox.Show("Only runs in part files!") 10 | End If 11 | End Sub 12 | 13 | Public machinedFaceMaterialName As String = "Machined - Aluminum" 14 | Public flangeFaceNamePrefix As String = "FlangeFace*" 15 | 16 | ''' <summary> 17 | ''' Resets named faces whose prefix matches that above to the desired material 18 | ''' </summary> 19 | ''' <param name="partDoc"></param> 20 | Public Sub ResetNamedFacesToDesiredAppearance(ByVal partDoc As PartDocument) 21 | 'unecessary, but *should* IMHO work? 22 | ' Dim assetLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Autodesk Appearance Library") 23 | 'language-agnostic: 24 | ' assetLib = ThisApplication.AssetLibraries.Item("AD121259-C03E-4A1D-92D8-59A22B4807AD") 25 | Dim appearanceObjs As ObjectCollection = partDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", flangeFaceNamePrefix) 26 | If appearanceObjs.Count > 0 Then 27 | For Each obj As Object In appearanceObjs 28 | If TypeOf obj Is SurfaceBody Then 29 | 30 | ElseIf TypeOf obj Is PartFeature Then 31 | 32 | ElseIf TypeOf obj Is Face Then 33 | Dim thisFace As Face = obj 34 | 'this doesn't work but I'll leave it for others to comment upon! 35 | ' Dim faceAppearance As Asset = assetLib.AppearanceAssets(machinedFaceMaterialName) 36 | ' thisFace = faceAppearance ' faceName 37 | Dim oStyle As RenderStyle = partDoc.RenderStyles.Item(machinedFaceMaterialName) 38 | Call thisFace.SetRenderStyle(kOverrideRenderStyle, oStyle) 39 | 40 | End If 41 | Next 42 | End If 43 | End Sub -------------------------------------------------------------------------------- /Modelling/Flat pattern save as dxf.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main 2 | 3 | DefaultChoice = True 4 | 5 | 'CadlinePathProperty() 6 | 7 | Cadline() 8 | 9 | End Sub 10 | 11 | 12 | 13 | REM Sub CadlinePathProperty() 14 | 15 | REM Dim FilePATH As String = "FilePATH" 16 | 17 | REM customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") 18 | 19 | REM Try 20 | 21 | REM prop= customPropertySet.Item(FilePATH) 22 | 23 | REM Catch 24 | 25 | REM customPropertySet.Add("", FilePATH) 26 | 27 | REM End Try 28 | 29 | REM 'If iProperties.Value("Custom", "FilePATH") = "" Then 30 | 31 | REM 'iProperties.Value("Custom", "FilePATH") = "C:\" 32 | 33 | REM 'Else 34 | 35 | REM 'End If 36 | 37 | REM Dim partDoc As PartDocument 38 | 39 | REM If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then 40 | 41 | REM MessageBox.Show ("Please open a part document", "iLogic") 42 | 43 | REM End If 44 | 45 | REM 'FilePATH = InputBox("Enter a FilePATH for part file", "iLogic", iProperties.Value("Custom", "FilePATH")) 46 | 47 | REM 'iProperties.Value("Custom", "FilePATH") = FilePATH 48 | 49 | REM End Sub 50 | 51 | 52 | 53 | Public Sub Cadline() 54 | 55 | Dim oDoc As PartDocument 56 | 57 | oDoc = ThisApplication.ActiveDocument 58 | 59 | Dim oCompDef As SheetMetalComponentDefinition 60 | 61 | oCompDef = oDoc.ComponentDefinition 62 | 63 | If oCompDef.HasFlatPattern = False Then 64 | 65 | oCompDef.Unfold 66 | 67 | Else 68 | 69 | oCompDef.FlatPattern.Edit 70 | 71 | End If 72 | 73 | Dim sOut As String 74 | 75 | 'Dim sPATH As String 76 | 77 | 'sPATH = iProperties.Value("Custom", "FilePATH") 78 | 79 | sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES" 80 | 81 | Dim sFname As String 82 | 83 | sFname = ThisDoc.Path & "\" & ThisDoc.FileName(False) & ".dxf" 84 | 85 | MessageBox.Show("DXF SAVED TO: " & sFname ,"DXF Saved", MessageBoxButtons.OK) 86 | 87 | oCompDef.DataIO.WriteDataToFile( sOut, sFname) 88 | 89 | oDoc = ThisApplication.ActiveDocument 90 | 91 | Dim oSMDef As SheetMetalComponentDefinition 92 | 93 | oSMDef = oDoc.ComponentDefinition 94 | 95 | oSMDef.FlatPattern.ExitEdit 96 | 97 | 'This code has been adapted from http://www.cadlinecommunity.co.uk/Blogs/Blog.aspx?ScoId=4733ef2d-cd48-4bd9-a280-1d88dbbf3556&returnTo=%2fBlogs%2fclintonbrown%2fDefault.aspx&returnTitle=Clinton+Brown%20Blog 98 | 99 | End Sub -------------------------------------------------------------------------------- /Modelling/Generate factory Members.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub main() 2 | Dim sw As New Stopwatch() 3 | sw.Start() 4 | 5 | If TypeOf (thisdoc.document) Is partdocument Then 6 | Dim oDoc As PartDocument = ThisDoc.Document 7 | Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition 8 | Dim initRowIndex As Integer 9 | Dim oFactory As iPartFactory = oDef.iPartFactory 10 | ' Edit row 1 & 2 of table 11 | 'oFactory.TableRows.Item(1).Item(3).Value = 2322 12 | 'oFactory.TableRows.Item(2).Item(3).Value = 4444 13 | ' Iterate All Rows of iPart 14 | Dim oRow As iPartTableRow 15 | For Each oRow In oFactory.TableRows 16 | ' Generate the member and file, (overwrites member file or creates new file) 17 | oFactory.CreateMember(oRow) 18 | Next 19 | ElseIf TypeOf (thisdoc.document) Is assemblydocument Then 20 | Dim oDoc As assemblyDocument = ThisDoc.Document 21 | Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition 22 | Dim initRowIndex As Integer 23 | Dim oFactory As iAssemblyFactory = oDef.iassemblyfactory 24 | ' Edit row 1 & 2 of table 25 | 'oFactory.TableRows.Item(1).Item(3).Value = 2322 26 | 'oFactory.TableRows.Item(2).Item(3).Value = 4444 27 | ' Iterate All Rows of iPart 28 | For Each oRow As iassemblytablerow In oFactory.TableRows 29 | ' Generate the member and file, (overwrites member file or creates new file) 30 | oFactory.CreateMember(oRow) 31 | Next 32 | End If 33 | iLogicVb.UpdateWhenDone = True 34 | 35 | sw.Stop() 36 | Dim timeElapsed As Timespan = sw.elapsed 37 | messagebox.show("Processing took: " & String.Format("{0:00}:{1:00}:{2:00}.{3:00}", 38 | timeElapsed.Hours, 39 | timeElapsed.Minutes, 40 | timeElapsed.Seconds, 41 | timeElapsed.Milliseconds / 10)) 42 | End Sub 43 | -------------------------------------------------------------------------------- /Modelling/Generate iPart Members from Parent Assemblies.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main() 2 | Dim sw As New Stopwatch() 3 | sw.Start() 4 | Dim thisAssy As assemblydocument = ThisApplication.activeDocument 5 | MessageBox.Show(thisAssy.ReferencedDocuments.count, "Referenced Document count") 6 | For Each subdoc As Inventor.Document In thisAssy.ReferencedDocuments 7 | If TypeOf subdoc Is PartDocument Then 8 | If subdoc.componentdefinition.isiPartFactory Then 9 | updatestatusbar(subdoc.FullFileName) 10 | GenerateiPartFactoryMembers(subdoc) 11 | End If 12 | Else 'Assembly 13 | ProcessSubAssemblies(subdoc) 14 | End If 15 | Next 16 | 17 | sw.Stop() 18 | Dim timeElapsed As Timespan = sw.elapsed 19 | MessageBox.Show("Processing took: " & String.Format("{0:00}:{1:00}:{2:00}.{3:00}", 20 | timeElapsed.Hours, 21 | timeElapsed.Minutes, 22 | timeElapsed.Seconds, 23 | timeElapsed.Milliseconds / 10)) 24 | End Sub 25 | 26 | 'this should work recursively but it may take some time...? 27 | Public Sub ProcessSubAssemblies(ByVal AssyDoc as AssemblyDocument) 28 | For Each subdoc as Inventor.Document In AssyDoc.ReferencedDocuments 29 | If TypeOf subdoc Is PartDocument Then 30 | If subdoc.componentdefinition.isiPartFactory Then 31 | updatestatusbar(subdoc.FullFileName) 32 | GenerateiPartFactoryMembers(subdoc) 33 | End If 34 | Else 'Assembly 35 | ProcessSubAssemblies(subdoc) 36 | End If 37 | Next 38 | End Sub 39 | 40 | Public Sub GenerateiPartFactoryMembers(ByVal partdoc as PartDocument) 41 | Dim oDoc As PartDocument = partdoc 42 | Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition 43 | Dim initRowIndex As Integer 44 | Dim oFactory As iPartFactory = oDef.iPartFactory 45 | ' Edit row 1 & 2 of table 46 | 'oFactory.TableRows.Item(1).Item(3).Value = 2322 47 | 'oFactory.TableRows.Item(2).Item(3).Value = 4444 48 | ' Iterate All Rows of iPart 49 | Dim oRow As iPartTableRow 50 | For Each oRow In oFactory.TableRows 51 | ' Generate the member and file, (overwrites member file or creates new file) 52 | oFactory.CreateMember(oRow) 53 | Next 54 | iLogicVb.UpdateWhenDone = True 55 | End Sub 56 | 57 | 58 | Sub updatestatusbar(ByVal message As String) 59 | ThisApplication.statusbartext = message 60 | End Sub 61 | 62 | Sub updatestatusbar(ByVal percent As Double, ByVal message As String) 63 | ThisApplication.statusbartext = message + " (" & percent.tostring("P1") + ")" 64 | End Sub 65 | -------------------------------------------------------------------------------- /Modelling/GetHoleCountAndDiameters.iLogicVb: -------------------------------------------------------------------------------- 1 | Function _GetHoleCountAndDiameters(oPartDoc As PartDocument) As Double(,) 2 | Dim oTG As TransientGeometry = ThisApplication.TransientGeometry 3 | Dim oTO As TransientObjects = ThisApplication.TransientObjects 4 | Dim oPartDef As PartComponentDefinition = oPartDoc.ComponentDefinition 5 | Dim oSizes As New List(Of Double)() 6 | Dim oLines As ObjectCollection = oTO.CreateObjectCollection 7 | Dim oTestLine As Line 8 | Dim oIsExisting As Boolean 9 | For Each oFace As Face In oPartDef.SurfaceBodies.Item(1).Faces 10 | If oFace.SurfaceType = 5891 Then 11 | oTestLine = oTG.CreateLine(oFace.Geometry.BasePoint,oFace.Geometry.AxisVector.AsVector) 12 | oIsExisting = False 13 | For Each oLine As Line In oLines 14 | If oLine.IsColinearTo(oTestLine) Then oIsExisting = True 15 | Next 16 | If Not oIsExisting Then 17 | oLines.Add(oTestLine) 18 | oSizes.Add(oFace.Geometry.Radius*2) 19 | End If 20 | End If 21 | Next 22 | Dim oUniqueSizeList As New List(Of Double)() 23 | For Each oSize As Double In oSizes 24 | If Not oUniqueSizeList.Contains(oSize) Then oUniqueSizeList.Add(oSize) 25 | Next 26 | oUniqueSizeList.Sort 27 | Dim oHoles(oUniqueSizeList.Count-1,1) As Double 28 | For i As Integer = 0 To oUniqueSizeList.Count-1 29 | oHoles(i,0) = oUniqueSizeList.Item(i) 30 | oHoles(i,1) = 0 31 | Next 32 | For Each oSize As Double In oSizes 33 | oHoles(oUniqueSizeList.IndexOf(oSize),1) = oHoles(oUniqueSizeList.IndexOf(oSize),1) + 1 34 | Next 35 | Return oHoles 36 | End Function -------------------------------------------------------------------------------- /Modelling/Ground&RootSelectedComponents.iLogicVb: -------------------------------------------------------------------------------- 1 | ' Keep track of selected entities 2 | 3 | 4 | Sub Main() 5 | SelectObjects() 6 | GroundObjects() 7 | End Sub 8 | 9 | Sub SelectObjects() 10 | Dim oSet As HighlightSet 11 | 12 | ' Check to make sure the active document is an assembly. 13 | If ThisApplication.ActiveDocumentType <> 14 | DocumentTypeEnum.kAssemblyDocumentObject Then 15 | MsgBox("An Assembly document must be open.") 16 | Exit Sub 17 | End If 18 | 19 | ' Initialize the entity collection 20 | ' If you want to keep track of the previously 21 | ' selected entitites then only initialize this variable 22 | ' if it has not been initialized before 23 | If oSelectedEnts Is Nothing Then 24 | oSelectedEnts = ThisApplication.TransientObjects.CreateObjectCollection() 25 | End If 26 | 27 | oDoc = ThisDoc.Document 28 | oSet = oDoc.CreateHighlightSet 29 | 30 | ' Show the previously selected entities 31 | For Each ent In oSelectedEnts 32 | oSet.AddItem(ent) 33 | Next 34 | 35 | While True 36 | Dim oOcc As Object 37 | oOCc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select an occurrence") 38 | 39 | ' If nothing gets selected then we're done 40 | If IsNothing(oOcc) Then Exit While 41 | 42 | oSet.AddItem(oOcc) 43 | oSelectedEnts.Add(oOcc) 44 | End While 45 | 46 | oSet.Clear() 47 | End Sub 48 | 49 | Public Sub GroundObjects() 50 | For Each oOcc as Object In oSelectedEnts 51 | oOcc.Select() 52 | ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBonusTools_GroundAndRootComponentCmd").Execute 53 | Next 54 | End Sub 55 | Shared oSelectedEnts As ObjectCollection 56 | -------------------------------------------------------------------------------- /Modelling/HyperLink to Excel.iLogicVb: -------------------------------------------------------------------------------- 1 | 'copied from here: https://inventorlogicblog.wordpress.com/2016/04/22/autodesk-inventor-ilogic-create-a-hyperlink-in-excel/ 2 | ' Start of iLogic rule ======================================================= 3 | ' Note this iLogic rule requires a spreadsheet "C:\MASTER SPREADSHEET 123.xlsx" to exist, otherwise you'l get an error. 4 | ' Note you'll get an error if you try running this rule in a new document that hasn't yet been saved, as it won't have a filename yet! 5 | 6 | ' Define Excel Application object 7 | oExcel = CreateObject("Excel.Application") 8 | 9 | ' Make Excel invisible 10 | oExcel.Visible = False 11 | 12 | ' Suppress all Excel prompts 13 | oExcel.DisplayAlerts = False 14 | 15 | Dim oSourceBook = oExcel.Workbooks.Open("C:\MASTER SPREADSHEET 123.xlsx") 16 | 17 | ' Select the worksheet we want 18 | Dim SourceWorksheet = oSourceBook.Worksheets("Sheet1") 19 | 20 | ' Add hyperlink to cell C3 - in this case the hyperlink points to this Inventor file. We are also setting a 'tooltip' for the hyperlink to be the name of the active file in Inventor. 21 | ' The visible text for the hyperlink is 'Link to Inventor Model' 22 | SourceWorksheet.Hyperlinks.Add(SourceWorksheet.Range("C3"), ThisApplication.ActiveEditDocument.FullDocumentName,,ThisApplication.ActiveEditDocument.FullDocumentName, "Link to Inventor Model") 23 | 24 | ' Save the spreadsheet 25 | oSourceBook.Save 26 | oSourceBook.Close 27 | oExcel.Quit 28 | oExcel = Nothing 29 | 30 | ' Open the spreadsheet... 31 | Process.Start("C:\MASTER SPREADSHEET 123.xlsx") 32 | 33 | ' End of iLogic rule ======================================================= -------------------------------------------------------------------------------- /Modelling/IPT Bend Marker.iLogicVb: -------------------------------------------------------------------------------- 1 | Messagebox.Show("IPT Bend Marker!") -------------------------------------------------------------------------------- /Modelling/IPart Row Changer.iLogicVb: -------------------------------------------------------------------------------- 1 |  2 | 'for debugging: 3 | MessageBox.Show("parameter changed: " & Parameter("iPartSizeChange").ToString()) 4 | If TypeOf ThisDoc.Document Is PartDocument Then 5 | Dim odoc As PartDocument = ThisDoc.Document 6 | Dim oTop As BrowserNode = odoc.BrowserPanes("Model").TopNode 7 | Dim def As PartComponentDefinition = odoc.ComponentDefinition 8 | 9 | If Not def.iPartFactory Is Nothing Then 10 | Dim factory As iPartFactory = def.iPartFactory 11 | Dim desiredActiveRow As iPartTableRow = Nothing 12 | For Each row As iPartTableRow In factory.TableRows 13 | If row.MemberName.Contains(Parameter("iPartSizeChange")) 14 | desiredActiveRow = Row 15 | Logger.Debug(desiredActiveRow.Membername) 16 | End If 17 | Next 18 | If Not desiredActiveRow Is Nothing Then 19 | oTop.BrowserNodes("Table").BrowserNodes.Item(desiredActiveRow.Item(1).Row).DoSelect 20 | Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd") 21 | oCommand.Execute 22 | End If 23 | End If 24 | End If 25 | -------------------------------------------------------------------------------- /Modelling/Inventor 2016 - ILogic to write Parameter to every part in the Assembly.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | Dim oAsmDoc As AssemblyDocument 3 | oAsmDoc = ThisApplication.ActiveDocument 4 | Call Iterate(oAsmDoc.ComponentDefinition.Occurrences, 1) 5 | End Sub 6 | 7 | Private Sub Iterate(Occurrences As ComponentOccurrences, Level As Integer) 8 | 'Iterate through Assembly 9 | 10 | Dim oOcc As ComponentOccurrence 11 | For Each oOcc In Occurrences 12 | 13 | 'Find Parts in Assembly 14 | Dim CadlinePart As String 15 | CadlinePart = oOcc.Name 16 | Try 17 | 'Write iProps to Parts 18 | iProperties.Value(CadlinePart, "Summary", "Comments") = "Hello World" 19 | Catch 20 | 'MsgBox("Message!") 21 | End Try 22 | 23 | 'Run through the sub assemblies 24 | If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then 25 | Call Iterate(oOcc.SubOccurrences, Level + 1) 26 | End If 27 | Next 28 | End Sub -------------------------------------------------------------------------------- /Modelling/MakeComponentsProgramatically.iLogicVb: -------------------------------------------------------------------------------- 1 | ' Run this inside a Multi-Solid part 2 | Sub MakeComponentsProgrammatically() 3 | ' Folder to place the new components: 4 | ' assembly and subcomponents 5 | Dim f As String: f = "C:\temp\test1\" 6 | 7 | ' Make sure the folder exists 8 | Dim fso As Object 9 | Set fso = ThisApplication.FileManager.FileSystemObject 10 | If Not fso.FolderExists(f) Then Call fso.CreateFolder(f) 11 | 12 | Dim doc As PartDocument 13 | Set doc = ThisApplication.ActiveDocument 14 | 15 | ' Create the assembly 16 | Dim asm As AssemblyDocument 17 | Set asm = ThisApplication.Documents.Add(kAssemblyDocumentObject) 18 | 19 | Dim sb As SurfaceBody 20 | For Each sb In doc.ComponentDefinition.SurfaceBodies 21 | ' Create part for each body 22 | Dim prt As PartDocument 23 | Set prt = ThisApplication.Documents.Add(kPartDocumentObject) 24 | 25 | ' Set iProperties >> Project >> Description 26 | ' It's inside "Design Tracking Properties" 27 | Dim p As Property 28 | Set p = prt.PropertySets( _ 29 | "{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Description") 30 | p.Expression = sb.name 31 | 32 | Dim dpcs As DerivedPartComponents 33 | Set dpcs = prt.ComponentDefinition.ReferenceComponents. _ 34 | DerivedPartComponents 35 | 36 | Dim dpd As DerivedPartUniformScaleDef 37 | Set dpd = dpcs.CreateUniformScaleDef(doc.FullDocumentName) 38 | 39 | ' Exclude the other solid bodies 40 | Dim dpe As DerivedPartEntity 41 | For Each dpe In dpd.Solids 42 | If Not dpe.ReferencedEntity Is sb Then 43 | dpe.IncludeEntity = False 44 | End If 45 | Next 46 | 47 | Call dpcs.Add(dpd) 48 | 49 | ' Could have any name but we use the solid body's name 50 | Call prt.SaveAs(f + sb.name + ".ipt", False) 51 | 52 | ' Place an instance of it inside the assembly 53 | Dim mx As Matrix 54 | Set mx = ThisApplication.TransientGeometry.CreateMatrix() 55 | Call asm.ComponentDefinition.Occurrences. _ 56 | AddByComponentDefinition(prt.ComponentDefinition, mx) 57 | 58 | ' Don't need it anymore 59 | Call prt.Close 60 | Next 61 | 62 | Call asm.SaveAs( _ 63 | f + Left(doc.DisplayName, Len(doc.DisplayName) - 4) + _ 64 | ".iam", False) 65 | Call asm.Close 66 | End Sub -------------------------------------------------------------------------------- /Modelling/MirrorPartInAssembly.iLogicVb: -------------------------------------------------------------------------------- 1 |  Sub Main() 2 | MirrorPartInAssy 3 | End Sub 4 | Sub MirrorPartInAssy() 5 | 6 | Dim oAssDoc As AssemblyDocument= ThisApplication.ActiveDocument 7 | 8 | 'mirror plane 9 | Dim oMirrorWP As WorkPlane= oAssDoc.SelectSet(1) 10 | 11 | Dim oPlane As Plane = oMirrorWP.Plane 12 | 13 | 'get normal of the plane 14 | Dim oNormalX As Double = oPlane.Normal.X 15 | 16 | Dim oNormalY As Double = oPlane.Normal.Y 17 | 18 | Dim oNormalZ As Double = oPlane.Normal.Z 19 | 20 | 'create the mirroring matrix 21 | Dim oMirrorMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix() 22 | Dim oMatrixData(15) As Double 23 | oMatrixData(0) = 1 - 2 * oNormalX * oNormalX 24 | oMatrixData(1) = -2 * oNormalX * oNormalY 25 | oMatrixData(2) = -2 * oNormalX * oNormalZ 26 | oMatrixData(3) = 0 27 | 28 | oMatrixData(4) = -2 * oNormalX * oNormalY 29 | oMatrixData(5) = 1 - 2 * oNormalY * oNormalY 30 | oMatrixData(6) = -2 * oNormalZ * oNormalY 31 | oMatrixData(7) = 0 32 | 33 | oMatrixData(8) = -2 * oNormalX * oNormalZ 34 | oMatrixData(9) = -2 * oNormalZ * oNormalY 35 | oMatrixData(10) = 1 - 2 * oNormalZ * oNormalZ 36 | oMatrixData(11) = 0 37 | 38 | oMatrixData(12) = 0 39 | oMatrixData(13) = 0 40 | oMatrixData(14) = 0 41 | oMatrixData(15) = 1 42 | 43 | Call oMirrorMatrix.PutMatrixData(oMatrixData) 44 | 45 | 'get the first component 46 | Dim oOcc As ComponentOccurrence= oAssDoc.ComponentDefinition.Occurrences(1) 47 | 48 | 'multiply with the transformation of the parent component 49 | oMirrorMatrix.PostMultiplyBy (oOcc.Transformation ) 50 | 51 | Dim oParentPartPath As String = oOcc.Definition.Document.FullFileName 52 | 53 | ' Create a new part file to derive the part in. 54 | Dim oPartDoc As PartDocument = ThisApplication.Documents.Add(kPartDocumentObject, _ 55 | ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) 56 | 57 | ' Create a derived definition for the part. 58 | Dim oDerivedPartDef As DerivedPartTransformDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.CreateTransformDef(oParentPartPath) 59 | 60 | ' Create the derived part. 61 | Call oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Add(oDerivedPartDef) 62 | 'save the derived part. 63 | Call oPartDoc.SaveAs("c:\temp\mirrorPart.ipt", False) 64 | 'add the derived part as a component 65 | Call oAssDoc.ComponentDefinition.Occurrences.Add(oPartDoc.FullFileName, oMirrorMatrix) 66 | oPartDoc.Close 67 | 'activate the assembly document 68 | oAssDoc.Activate 69 | End Sub -------------------------------------------------------------------------------- /Modelling/Move EOPs In Assembly.iLogicVb: -------------------------------------------------------------------------------- 1 | Private Sub Main() 2 | Call MoveEOPMarkers 3 | End Sub 4 | Private Sub MoveEOPMarkers() 5 | Dim oApp As Inventor.Application = ThisApplication 6 | Dim oAssy As Inventor.AssemblyDocument = oApp.ActiveDocument 7 | Dim oSubDoc As Inventor.Document 8 | Dim oPartDoc As PartDocument 9 | 10 | EOPQuery = MsgBox("Would you like to move all EOP Markers thus shrinking the Assembly filesize?" _ 11 | & vbCrLf & "Click 'Yes' to shrink." _ 12 | & vbCrLf & "Click 'No' to expand" _ 13 | , vbYesNo, "EOP Move") 14 | For Each oSubDoc In oAssy.AllReferencedDocuments 15 | If Not oSubDoc.File.FullFileName.Contains("Content") Then 16 | If EOPQuery = vbYes Then 17 | If oSubDoc.DocumentType = kPartDocumentObject Then 18 | oPartDoc = oSubDoc 19 | oPartDoc.ComponentDefinition.SetEndOfPartToTopOrBottom (True) ' Set to top 20 | End If 21 | ElseIf EOPQuery = vbNo Then 22 | If oSubDoc.DocumentType = kPartDocumentObject Then 23 | oPartDoc = oSubDoc 24 | oPartDoc.ComponentDefinition.SetEndOfPartToTopOrBottom (False) ' Set to bottom 25 | End If 26 | End If 27 | End If 28 | Next 29 | oAssy.Update 30 | End Sub 31 | -------------------------------------------------------------------------------- /Modelling/MoveItMoveIt.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "MoveItMoveIt" 2 | 3 | Public Sub MoveOccurrence() 4 | ' Set a reference to the assembly component definintion. 5 | Dim oAsmCompDef As AssemblyComponentDefinition 6 | Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 7 | Dim XSpacingInc As Double 8 | XSpacingInc = CDbl(InputBox("X Offset", "X OFffset", "0")) 'default is in cm 9 | Dim YSpacingInc As Double 10 | YSpacingInc = CDbl(InputBox("Y Spacing", "Y Spacing", "30")) 'default is in cm 11 | Dim YSpacing As Double 12 | Dim XSpacing As Double 13 | XSpacing = 0 14 | YSpacing = 0 15 | Dim oSelect As New clsSelect 16 | 17 | Dim oSelectedEnts As ObjectsEnumerator 18 | Set oSelectedEnts = oSelect.PickPartToMove(kAssemblyOccurrenceFilter) 19 | 'Set oSelectedEnts = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Pick something") 20 | ' Get an occurrence from the select set. 21 | For i = 1 To oSelectedEnts.Count 22 | On Error Resume Next 23 | Dim oOccurrence As ComponentOccurrence 24 | Set oOccurrence = oSelectedEnts.Item(i) 25 | If Err Then 26 | MsgBox "An occurrence must be selected." 27 | Exit Sub 28 | End If 29 | On Error GoTo 0 30 | 31 | ' Get the current transformation matrix from the occurrence. 32 | Dim oTransform As Matrix 33 | Set oTransform = oOccurrence.Transformation 34 | 35 | ' Move the occurrence honoring any existing constraints. 36 | oTransform.SetTranslation ThisApplication.TransientGeometry.CreateVector(XSpacing + XSpacingInc, YSpacing + YSpacingInc, 0) 37 | oOccurrence.Transformation = oTransform 38 | XSpacing = XSpacing + XSpacingInc 39 | YSpacing = YSpacing + YSpacingInc 40 | ' Move the occurrence ignoring any constraints. 41 | ' Anything that causes the assembly to recompute will cause the 42 | ' occurrence to reposition itself to honor the constraints. 43 | 'oTransform.SetTranslation ThisApplication.TransientGeometry.CreateVector(3, 4, 5) 44 | 'Call oOccurrence.SetTransformWithoutConstraints(oTransform) 45 | Next i 46 | End Sub 47 | 48 | -------------------------------------------------------------------------------- /Modelling/OldVersions/ProjectCurveToSurface.0001.ipt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Modelling/OldVersions/ProjectCurveToSurface.0001.ipt -------------------------------------------------------------------------------- /Modelling/PartFeatureNamesList.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 2 | <PartFeatureNamesList> 3 | <PartFeatureTypeName name="PartFeatureNamesList"/> 4 | <PartFeatureTypeName name="AliasFreeformFeatures"/> 5 | <PartFeatureTypeName name="BendPartFeatures"/> 6 | <PartFeatureTypeName name="BossFeatures"/> 7 | <PartFeatureTypeName name="BoundaryPatchFeatures"/> 8 | <PartFeatureTypeName name="ChamferFeatures"/> 9 | <PartFeatureTypeName name="CircularPatternFeatures"/> 10 | <PartFeatureTypeName name="ClientFeatures"/> 11 | <PartFeatureTypeName name="CoilFeatures"/> 12 | <PartFeatureTypeName name="CombineFeatures"/> 13 | <PartFeatureTypeName name="DecalFeatures"/> 14 | <PartFeatureTypeName name="DeleteFaceFeatures"/> 15 | <PartFeatureTypeName name="DirectEditFeatures"/> 16 | <PartFeatureTypeName name="EmbossFeatures"/> 17 | <PartFeatureTypeName name="ExtendFeatures"/> 18 | <PartFeatureTypeName name="ExtrudeFeatures"/> 19 | <PartFeatureTypeName name="FaceDraftFeatures"/> 20 | <PartFeatureTypeName name="FilletFeatures"/> 21 | <PartFeatureTypeName name="FreeformFeatures"/> 22 | <PartFeatureTypeName name="GrillFeatures"/> 23 | <PartFeatureTypeName name="HoleFeatures"/> 24 | <PartFeatureTypeName name="iFeatures"/> 25 | <PartFeatureTypeName name="KnitFeatures"/> 26 | <PartFeatureTypeName name="LipFeatures"/> 27 | <PartFeatureTypeName name="LoftFeatures"/> 28 | <PartFeatureTypeName name="MirrorFeatures"/> 29 | <PartFeatureTypeName name="MoveFaceFeatures"/> 30 | <PartFeatureTypeName name="MoveFeatures"/> 31 | <PartFeatureTypeName name="NonParametricBaseFeatures"/> 32 | <PartFeatureTypeName name="RectangularPatternFeatures"/> 33 | <PartFeatureTypeName name="ReferenceFeatures"/> 34 | <PartFeatureTypeName name="ReplaceFaceFeatures"/> 35 | <PartFeatureTypeName name="RestFeatures"/> 36 | <PartFeatureTypeName name="RevolveFeatures"/> 37 | <PartFeatureTypeName name="RibFeatures"/> 38 | <PartFeatureTypeName name="RuledSurfaceFeatures"/> 39 | <PartFeatureTypeName name="RuleFilletFeatures"/> 40 | <PartFeatureTypeName name="SculptFeatures"/> 41 | <PartFeatureTypeName name="ShellFeatures"/> 42 | <PartFeatureTypeName name="SnapFitFeatures"/> 43 | <PartFeatureTypeName name="SplitFeatures"/> 44 | <PartFeatureTypeName name="SweepFeatures"/> 45 | <PartFeatureTypeName name="ThickenFeatures"/> 46 | <PartFeatureTypeName name="ThreadFeatures"/> 47 | <PartFeatureTypeName name="TrimFeatures"/> 48 | </PartFeatureNamesList> -------------------------------------------------------------------------------- /Modelling/PartPatternTester.iLogicVb: -------------------------------------------------------------------------------- 1 | Option explicit on 2 | Dim partDoc As PartDocument = ThisApplication.ActiveDocument 3 | Dim partCompDef As PartComponentDefinition = partDoc.ComponentDefinition 4 | 5 | Dim rectPattern As RectangularPatternFeature = partCompDef.Features.RectangularPatternFeatures.Item("Rectangular Pattern1") 6 | For Each tmpElem As FeaturePatternElement In rectPattern.PatternElements 7 | If tmpElem.Suppressed Then 8 | tmpElem.Suppressed = False 9 | End If 10 | Next 11 | Dim Generator As Random = New Random() 12 | Logger.Debug("Count of pattern elements: " & Convert.ToString(rectPattern.PatternElements.Count)) 13 | Dim randomInt As Integer = Generator.Next(1,rectPattern.PatternElements.Count) 14 | Logger.Debug("Currently selected Pattern Element: "& Convert.ToString(randomInt)) 15 | Dim patternElem As FeaturePatternElement = rectPattern.PatternElements(randomInt) 16 | patternElem.Suppressed = True 17 | iLogicVb.UpdateWhenDone = True 18 | -------------------------------------------------------------------------------- /Modelling/PrintRibbonInformation.iLogicVb: -------------------------------------------------------------------------------- 1 | Imports Microsoft.VisualBasic 2 | Public Sub Main() 3 | PrintRibbon() 4 | End Sub 5 | 6 | Public Sub PrintRibbon() 7 | Microsoft.VisualBasic.Open "C:\temp\RibbonNames.txt" For Output As #1 8 | 9 | Print #1, "File Controls (Application Menu)" 10 | Call PrintControls(ThisApplication.UserInterfaceManager.FileBrowserControls, "", 1) 11 | Print #1, "------------------------------------------------------------------" 12 | 13 | Print #1, "Help Controls" 14 | Call PrintControls(ThisApplication.UserInterfaceManager.HelpControls, "", 1) 15 | Print #1, "------------------------------------------------------------------" 16 | 17 | Dim oRibbon As Ribbon 18 | For Each oRibbon In ThisApplication.UserInterfaceManager.Ribbons 19 | Print #1, "Ribbon: " & oRibbon.InternalName 20 | 21 | Print #1, " QAT controls" 22 | Call PrintControls(oRibbon.QuickAccessControls, " ", 0) 23 | 24 | Dim oTab As RibbonTab 25 | For Each oTab In oRibbon.RibbonTabs 26 | Print #1, " Tab: " & oTab.DisplayName & ", " & oTab.InternalName & ", Visible: " & oTab.Visible 27 | 28 | Dim oPanel As RibbonPanel 29 | For Each oPanel In oTab.RibbonPanels 30 | Print #1, " Panel: " & oPanel.DisplayName & ", " & oPanel.InternalName & ", Visible: " & oPanel.Visible 31 | 32 | Call PrintControls(oPanel.CommandControls, " ", 0) 33 | 34 | If oPanel.SlideoutControls.Count > 0 Then 35 | Print #1, " --- Slideout Controls ---" 36 | Call PrintControls(oPanel.SlideoutControls, " ", 0) 37 | End If 38 | Next 39 | Next 40 | 41 | Print #1, "------------------------------------------------------------------" 42 | Next 43 | On Error Goto 0 44 | 45 | Close #1 46 | 47 | MsgBox "Result written to: C:\temp\RibbonNames.txt" 48 | End Sub 49 | 50 | Private Sub PrintControls(Controls As CommandControls, LeadingSpace As String, Level As Integer) 51 | Dim oControl As CommandControl 52 | For Each oControl In Controls 53 | If oControl.ControlType = kSeparatorControl Then 54 | Print #1, LeadingSpace & Space(Level * 4) & "Control: Seperator" 55 | Else 56 | Print #1, LeadingSpace & Space(Level * 4) & "Control: " & oControl.DisplayName & ", " & oControl.InternalName & ", Visible: " & oControl.Visible 57 | 58 | If Not oControl.ChildControls Is Nothing Then 59 | Call PrintControls(oControl.ChildControls, LeadingSpace, Level + 1) 60 | End If 61 | End If 62 | Next 63 | End Sub 64 | -------------------------------------------------------------------------------- /Modelling/ProjectCurveToSurface.ipt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Modelling/ProjectCurveToSurface.ipt -------------------------------------------------------------------------------- /Modelling/Rename Assembly Browser Nodes.iLogicVb: -------------------------------------------------------------------------------- 1 | 'credit goes to this thread: https://forums.autodesk.com/t5/inventor-customization/using-ilogic-to-rename-browser-nodes/m-p/4318636#M44814 2 | ' and PaulM for pointing me towards it. 3 | Sub Main() 4 | 'Grab the Assembly Document 5 | Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument 6 | Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "Rename Browser Nodes to Description.") 7 | Try 8 | Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition 9 | Dim oPane As BrowserPane = oDoc.BrowserPanes.Item("Model") 10 | For Each oOcc As ComponentOccurrence In oAsmCompDef.Occurrences 11 | If Not oOcc.IsSubstituteOccurrence Then 12 | Dim oCCDocument As Document = oOcc.Definition.Document 13 | If Not oCCDocument.FullFileName.Contains("Content Center") Then 14 | messagebox.show(oocc.name) 15 | ' Dim invDesignInfo As PropertySet = oCCDocument.PropertySets.Item("Design Tracking Properties") 16 | ' Dim invDescrProperty As Inventor.Property = invDesignInfo.Item("Description") 17 | Dim summaryPropSet As Inventor.PropertySet = oCCDocument.PropertySets.Item("Inventor Summary Information") 18 | Dim titleProp As Inventor.Property = summaryPropSet.Item("Title") 19 | Dim oSubAssyNode As BrowserNode = oPane.GetBrowserNodeFromObject(oOcc) 20 | If oSubAssyNode.NativeObject.Name.Contains(":") Then ' is likely one of multiple occurrences 21 | 'messagebox.Show(oSubAssyNode.NativeObject.Name) 22 | Dim oldName As String = oSubAssyNode.NativeObject.Name 23 | Dim first As Integer = oldName.IndexOf(":") 24 | 'MessageBox.Show("first= " & first) 25 | Dim last As Integer = oldName.LastIndexOf(":") 26 | 'MessageBox.Show("last= " & last) 27 | Dim occNum As String = oldName.Substring(first, oldName.Length - last) 28 | 'Messagebox.Show(occNum) 29 | If oldName <> titleProp.Value And Not titleProp.Value = String.Empty Then 30 | 'Set The name 31 | oSubAssyNode.NativeObject.Name = (titleProp.Value) & occNum 32 | End If 33 | Else 34 | If oSubAssyNode.NativeObject.Name <> titleProp.Value And Not titleProp.Value = String.Empty Then 35 | 'Set The name 36 | oSubAssyNode.NativeObject.Name = (titleProp.Value) 37 | End If 38 | End If 39 | 40 | End If 41 | End If 42 | Next 43 | trans.End() 44 | Catch Ex As Exception 45 | trans.Abort() 46 | End Try 47 | End Sub 48 | -------------------------------------------------------------------------------- /Modelling/Rename Parameters.iLogicVb: -------------------------------------------------------------------------------- 1 | For Each oval as Parameter in ThisDoc.Document.ComponentDefinition.Parameters 2 | If oval.Name.startswith("Sec") Then 3 | oval.Name.Replace("Sec","Element") 4 | MsgBox(oval.Name) 5 | End If 6 | Next 7 | -------------------------------------------------------------------------------- /Modelling/Replace references from external list.iLogicVb: -------------------------------------------------------------------------------- 1 | AddReference "System.Core" 2 | AddReference "System.Linq" 3 | Imports System.LINQ 4 | Imports System.Collections.Generic 5 | 'doesn't run in iLogic - WHAT A SURPRISE!?!?!? 6 | Private Sub Main() 7 | Dim sw As New Stopwatch() 8 | sw.Start() 9 | Dim rootFolder As String = IO.Path.GetDirectoryName(ThisApplication.ActiveDocument.FullFileName) 10 | Dim selectedfile As String = String.Empty 11 | Dim filedlg As Inventor.FileDialog = Nothing 12 | ThisApplication.CreateFileDialog(filedlg) 13 | filedlg.Filter = "txt files (*.txt)|*.txt|Other files (*.*)|*.*" 14 | filedlg.InitialDirectory = rootFolder 15 | filedlg.CancelError = True 16 | filedlg.MultiSelectEnabled = False 17 | Try 18 | filedlg.ShowOpen() 19 | selectedfile = filedlg.FileName 20 | Catch ex As Exception 21 | Return 22 | End Try 23 | 24 | Dim filelisttoreplace As New List(Of String) 25 | Dim filelisttosaveas As New List(Of String) 26 | Dim filereader As IO.StreamReader = Nothing 27 | filereader = My.Computer.FileSystem.OpenTextFileReader(selectedfile) 28 | Do While filereader.Peek >= 0 29 | filelisttoreplace.Add(filereader.ReadLine) 30 | Loop 31 | 32 | For Each filename As String In filelisttoreplace 33 | filelisttosaveas.Add(IO.Path.GetDirectoryName(filename) & "\" & 34 | IO.Path.GetFileNameWithoutExtension(filename) & ".dwg") 35 | 36 | Next 37 | 38 | If TypeOf ThisApplication.ActiveDocument Is DrawingDocument Then 39 | For Each dwgfile As String In filelisttosaveas 40 | Dim dwgdoc As DrawingDocument = ThisApplication.ActiveDocument 41 | dwgdoc.SaveAsInventorDWG(dwgfile, False) 42 | ' Dim filedescr As FileDescriptor = dwgdoc.ReferencedFileDescriptors(1) 43 | ' Dim filetoreplace As String = ( 44 | ' From f As String In filelisttoreplace 45 | ' Where IO.Path.GetFileNameWithoutExtension(f) = IO.Path.GetFileNameWithoutExtension(dwgdoc.FullFileName)).FirstOrDefault() 46 | ' If Not filetoreplace Is Nothing Then 47 | ' filedescr.ReplaceReference(filetoreplace) 48 | ' dwgdoc.Save() 49 | ' End If 50 | Next 51 | End If 52 | sw.Stop() 53 | MessageBox.Show("Operation took: " & sw.Elapsed.Seconds.ToString() & " seconds to complete.") 54 | End Sub 55 | 56 | -------------------------------------------------------------------------------- /Modelling/Run design checker on each component.iLogicVb: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Modelling/RunCreateAssemblyFromiLogic_UPLOAD.iLogicVb: -------------------------------------------------------------------------------- 1 | AddReference "CreateAssemblyFromExcelVB.dll" 2 | Imports CreateAssemblyFromExcelVB 3 | Sub Main() 4 | Dim XTVB As New CreateAssemblyFromExcelVB.ExternalVBClass 5 | Dim FilesArray As New ArrayList 6 | Dim PartsList As List(Of CreateAssemblyFromExcelVB.SubObjectCls) 7 | PartsList = New List(Of CreateAssemblyFromExcelVB.SubObjectCls) 8 | 'pass the local variables to our external .dll 9 | XTVB.InventorApplication = ThisApplication 10 | Dim filetab As String = InputBox("Which project?", "Select Sheet Name", "SHEETNAME") 11 | FilesArray = GoExcel.CellValues("C:\VAULT WORKING FOLDER\Designs\Project Tracker.xlsx", filetab, "A3", "A4") ' opens and sets excel to the correct sheet! 12 | For MyRow As Integer = 3 To 5000 ' max limit = 5000 rows but could be much higher 13 | Dim SO As CreateAssemblyFromExcelVB.SubObjectCls 14 | If GoExcel.CellValue("A" & MyRow) = "" Then Exit For 'exits when the value is empty! 15 | Dim tmpstr As String = GoExcel.CellValue("I" & MyRow) 'parent row 16 | If Not tmpstr.StartsWith("AS-") Then 17 | Continue For 18 | End If 19 | 'capture iproperties from the available Excel Data. 20 | SO = New CreateAssemblyFromExcelVB.SubObjectCls(GoExcel.CellValue("B" & MyRow), 21 | GoExcel.CellValue("K" & MyRow), 22 | GoExcel.CellValue("L" & MyRow), 23 | GoExcel.CellValue("M" & MyRow), 24 | GoExcel.CellValue("I" & MyRow)) 25 | PartsList.Add(SO) 26 | Next 27 | XTVB.PartsList = PartsList 28 | GoExcel.Close 29 | Dim tr As transaction 30 | tr = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument, "Create Standard Parts From Excel") 31 | Call XTVB.BeginCreateAssemblyStructure 32 | tr.End() 33 | InventorVb.DocumentUpdate() 34 | End Sub 35 | -------------------------------------------------------------------------------- /Modelling/RunPartCreator.iLogicVb: -------------------------------------------------------------------------------- 1 | 'Loads the My part creator 2 | Sub Main() 3 | iLogicForm.ShowGlobal("My Creator") 4 | End Sub 5 | -------------------------------------------------------------------------------- /Modelling/SaveCopyAsFromComponentNames.iLogicVb: -------------------------------------------------------------------------------- 1 | AddReference "System.core" 2 | 3 | Imports System.linq 4 | Imports System.collections.generic 5 | 6 | Sub Main() 7 | If TypeOf (ThisApplication.ActiveDocument) Is AssemblyDocument Then 8 | Dim searchstring As String = InputBox("what are we searching for?", "Search string", "Default Entry") 9 | 10 | If Not searchstring = String.Empty Then 11 | Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument 12 | Dim oPane As BrowserPane = oDoc.BrowserPanes("Model") 13 | Dim oTopNode As BrowserNode = oPane.TopNode 14 | 15 | Dim nodelist As List(Of String) = New List(Of String) 16 | 17 | nodelist = (From a As BrowserNode In oTopNode.BrowserNodes 18 | Let nodedef As BrowserNodeDefinition = a.BrowserNodeDefinition 19 | Where nodedef.Label.Contains(searchstring) 20 | Select nodedef.Label).ToList() 21 | ThisApplication.StatusBarText = searchstring 22 | 23 | ' For Each node As browsernode In oTopnode.Browsernodes 24 | ' Dim nodeDef as browsernodedefinition = node.browsernodedefinition 25 | ' If nodedef.label.startswith(searchstring) Then 26 | ' nodelist.add(nodedef.label) 27 | ' 28 | ' End If 29 | ' MessageBox.Show("browser node: " & nodedef.label) 30 | ' Next 31 | If nodelist.Count > 0 Then 32 | Dim FolderName As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName) 33 | Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) 34 | For Each nodename As String In nodelist 35 | Dim newfilename As String = FolderName & "\" & filename & "-" & nodename.Replace("°:1", "") & ".iam" 36 | 'newfilename.Replace("°:","°-") 37 | MessageBox.Show(newfilename) 38 | If Not System.IO.File.Exists(newfilename) Then 39 | ThisApplication.ActiveDocument.SaveAs(newfilename, False) 40 | End If 41 | Next 42 | End If 43 | End If 44 | End If 45 | End Sub 46 | 47 | -------------------------------------------------------------------------------- /Modelling/Selective Colour Change.iLogicVb: -------------------------------------------------------------------------------- 1 | Private Sub Main 2 | Dim oAsmCompDef As AssemblyComponentDefinition 3 | oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 4 | 'set Master view rep active 5 | Dim oViewRep As DesignViewRepresentation 6 | Try 7 | oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default") 8 | oViewRep.Activate 9 | Catch 10 | oViewRep.Add("Default") 11 | oViewRep.Activate 12 | End Try 13 | Dim partColours as New ArrayList 14 | partColours.Add("Red") 15 | partColours.Add("Green") 16 | partColours.Add("Blue - Wall Paint - Glossy") 17 | partColours.Add("Cyan") 18 | partColours.Add("Yellow") 19 | dim d0 as string = InputListBox("What Colour", partColours, "Blue - Wall Paint - Glossy", Title := "Select a Colour", ListName := "Available Colours") 20 | UpdateAssyBrowser(ThisDoc.Document,d0) 21 | iLogicVb.UpdateWhenDone = True 22 | End Sub 23 | 24 | Private Sub UpdateAssyBrowser(ByVal oDoc As Inventor.Document,ByVal d0 as string) 25 | Dim oAssy As Inventor.AssemblyDocument 26 | Dim oComp As Inventor.ComponentOccurrence 27 | Dim oSubDoc As Inventor.Document 28 | 29 | Dim NodeName() As String 30 | Dim InstNum As String 31 | 32 | If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then 33 | oAssy = CType(oDoc, AssemblyDocument) 34 | Dim oViewRep As DesignViewRepresentation 35 | oViewRep = oAssy.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Default") 36 | oViewRep.Activate 37 | For Each oComp In oAssy.ComponentDefinition.Occurrences 38 | oSubDoc = CType(oComp.Definition.Document, Document) 39 | If oSubDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then 40 | Component.Color(oComp.Name) = d0 41 | End If 42 | If oSubDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then 43 | Call UpdateAssyBrowser(oSubDoc, d0) 44 | End If 45 | Next oComp 46 | End If 47 | End Sub 48 | -------------------------------------------------------------------------------- /Modelling/SetAppearance.iLogicVb: -------------------------------------------------------------------------------- 1 | Private Sub Main() 2 | 3 | Dim oDoc As PartDocument = ThisApplication.ActiveDocument 4 | Dim Name As String 5 | 6 | 'Name = "Copper" 7 | Name = "Steel" 8 | 9 | Dim localAsset As Asset = Nothing 10 | 11 | Try 12 | localAsset = oDoc.Assets.Item(Name) 13 | Catch 14 | ' Failed to get the appearance 15 | ' in the document, so import it. 16 | 17 | ' Get an asset library by name. 18 | ' Either the displayed name (which 19 | ' can changed based on the current language) 20 | ' or the internal name 21 | ' (which is always the same) can be used. 22 | 23 | Dim assetLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Autodesk Appearance Library") 24 | 25 | ' Set assetLib = ThisApplication.AssetLibraries.Item("AD121259-C03E-4A1D-92D8-59A22B4807AD") 26 | 27 | 28 | 29 | ' Get an asset in the library 30 | 31 | ' Dim libAsset As Asset = assetLib.MaterialAssets.Item(Name) 32 | Dim libAsset As Asset = assetLib.AppearanceAssets.Item(Name) 33 | 34 | ' Copy the asset locally. 35 | localAsset = libAsset.CopyTo(oDoc) 36 | End Try 37 | 38 | ' set material to the part 39 | ' oDoc.ActiveMaterial = localAsset 40 | 41 | oDoc.ActiveAppearance = localAsset 42 | 43 | ' Select the top browser node of the model pane. 44 | ' This is a workaround to refresh materials info in the UI. 45 | 46 | Call oDoc.BrowserPanes.ActivePane.TopNode.DoSelect 47 | 48 | End Sub -------------------------------------------------------------------------------- /Modelling/Shrinkwrap Substitute in assembly.iLogicVb: -------------------------------------------------------------------------------- 1 | option explicit on 2 | Sub Main() 3 | ' Set a reference to the active assembly document 4 | Dim oDoc As AssemblyDocument= ThisApplication.ActiveDocument 5 | 6 | Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition 7 | 8 | ' Create a new part document that will be the shrinkwrap substitute 9 | Dim oPartDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False) 10 | 11 | Dim oPartDef As PartComponentDefinition = oPartDoc.ComponentDefinition 12 | 13 | Dim oDerivedAssemblyDef As DerivedAssemblyDefinition = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(oDoc.FullDocumentName) 14 | 15 | ' Set various shrinkwrap related options 16 | oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams 17 | oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedIncludeAll 18 | oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedIncludeAll 19 | oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll 20 | oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll 21 | oDerivedAssemblyDef.ReducedMemoryMode = True 22 | 'do this I think: 23 | oDerivedAssemblyDef.IndependentSolidsOnFailedBoolean = True 24 | 25 | Call oDerivedAssemblyDef.SetHolePatchingOptions(kDerivedPatchAll) 26 | Call oDerivedAssemblyDef.SetRemoveByVisibilityOptions(kDerivedRemovePartsAndFaces, 25) 27 | 28 | ' Create the shrinkwrap component 29 | Dim oDerivedAssembly As DerivedAssemblyComponent = oPartDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef) 30 | 31 | ' Save the part 32 | Dim strSubstituteFileName As String 33 | strSubstituteFileName = Left$(oDoc.FullFileName, Len(oDoc.FullFileName) - 4) 34 | strSubstituteFileName = strSubstituteFileName & "_ShrinkwrapSubstitute.ipt" 35 | 36 | ThisApplication.SilentOperation = True 37 | Call oPartDoc.SaveAs(strSubstituteFileName, False) 38 | ThisApplication.SilentOperation = False 39 | 40 | ' Create a substitute level of detail using the shrinkwrap part. 41 | Dim oSubstituteLOD As LevelOfDetailRepresentation = oDef.RepresentationsManager.LevelOfDetailRepresentations.AddSubstitute(strSubstituteFileName) 42 | 43 | ' Release reference of the invisibly opened part document. 44 | oPartDoc.ReleaseReference 45 | End Sub -------------------------------------------------------------------------------- /Modelling/Suppress Weld Prep.iLogicVb: -------------------------------------------------------------------------------- 1 | 'For Each Feature In thispart.features 2 | ' If Feature.Name.contains("*WELD PREP*") Then 3 | ' Feature.IsActive(Feature.Name) = False 4 | ' End If 5 | 'Next -------------------------------------------------------------------------------- /Modelling/Sweep-length-code-snippet.iLogicVb: -------------------------------------------------------------------------------- 1 | 'Set a reference to the active part document 2 | Dim oDoc As PartDocument 3 | oDoc = ThisApplication.ActiveDocument 4 | 5 | Dim oDef As PartComponentDefinition 6 | oDef = oDoc.ComponentDefinition 7 | 8 | 9 | ' Set a reference to the selected feature. Make sure you name the Sweep "Sweep1" or change this variable to match the Sweep you wish to calculate 10 | Dim oSweep As SweepFeature 11 | oSweep = oDef.Features.SweepFeatures.Item("Sweep1") 12 | 13 | ' Get the centroid of the sweep profile in sketch space 14 | Dim oProfileOrigin As Point2d 15 | oProfileOrigin = oSweep.Profile.RegionProperties.Centroid 16 | 17 | ' Transform the centroid from sketch space to model space 18 | Dim oProfileOrigin3D As Point 19 | oProfileOrigin3D = oSweep.Profile.Parent.SketchToModelSpace(oProfileOrigin) 20 | 21 | ' Get the set of curves that represent the true path of the sweep 22 | Dim oCurves As ObjectsEnumerator 23 | oCurves = oDef.Features.SweepFeatures.GetTruePath(oSweep.Path, oProfileOrigin3D) 24 | 25 | Dim TotalLength As Double 26 | TotalLength = 0 27 | 28 | Dim oCurve As Object 29 | For Each oCurve In oCurves 30 | 31 | Dim oCurveEval As CurveEvaluator 32 | oCurveEval = oCurve.Evaluator 33 | 34 | Dim MinParam As Double 35 | Dim MaxParam As Double 36 | Dim length As Double 37 | 38 | Call oCurveEval.GetParamExtents(MinParam, MaxParam) 39 | Call oCurveEval.GetLengthAtParam(MinParam, MaxParam, length) 40 | 41 | TotalLength = TotalLength + length 42 | Next 43 | 44 | Dim oparams As Parameters 45 | Dim oparam As Parameter 46 | oparams = oDoc.ComponentDefinition.Parameters 47 | Dim exists As Boolean 48 | exists = False 49 | 50 | 'Find out if parameter exists, if not it will create this parameter in the table, if you want another name then change Sweeplength to something else 51 | For Each oparam In oparams 52 | If oparam.Name = "Sweeplength" Then exists = True 53 | Next oparam 54 | 55 | 'Change the value if the parameter exists otherwise add the parameter 56 | If exists Then 57 | oparams.Item("Sweeplength").Value = TotalLength 58 | Else 59 | oparams.UserParameters.AddByValue ("Sweeplength", TotalLength, 11266) 60 | End If 61 | odoc.Update 62 | -------------------------------------------------------------------------------- /Modelling/Synchronize iProperties between part parameters and iProperties.iLogicVb: -------------------------------------------------------------------------------- 1 | Public Sub Main 2 | BeginSyncProps() 3 | End Sub 4 | 5 | Public Sub BeginSyncProps() 6 | Dim ThisDoc = ThisApplication.ActiveDocument 7 | If ThisDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then 8 | SyncProps() 9 | End If 10 | End Sub 11 | 12 | Public Sub SyncProps() 13 | If iProperties.Value("Summary", "Subject") = "" Then 14 | iProperties.Value("Summary", "Subject") = Parameter("CABLE_ID") 15 | End If 16 | End Sub 17 | -------------------------------------------------------------------------------- /Modelling/Toggle Sketches and Workplanes.iLogicVb: -------------------------------------------------------------------------------- 1 | Option Explicit On 2 | 3 | Sub Main() 4 | 'catch and skip errors 5 | On Error Resume Next 6 | 'define the active assembly 7 | Dim PartDoc As Inventor.Document 8 | PartDoc = ThisApplication.ActiveDocument 9 | 10 | 'get user input as True or False 11 | Dim wfBoolean As Boolean = InputRadioBox("Toggle Sketches On/Off", "On", "Off", False, "iLogic") 12 | 13 | For Each o2DSketch As Sketch In PartDoc.ComponentDefinition.Sketches 14 | o2DSketch.Visible = wfBoolean 15 | Next 16 | 17 | For Each o3DSketch As Sketch3D In PartDoc.ComponentDefinition.Sketches3D 18 | o3DSketch.Visible = wfBoolean 19 | Next 20 | 21 | wfBoolean = InputRadioBox("Toggle Sketch Dimension display On/Off", "On", "Off", False, "iLogic") 22 | For Each o2DSketch As Sketch In PartDoc.ComponentDefinition.Sketches 23 | o2DSketch.DimensionsVisible = wfBoolean 24 | Next 25 | 26 | wfBoolean = InputRadioBox("Toggle Workplanes On/Off", "On", "Off", False, "iLogic") 27 | For Each wp As WorkPlane In PartDoc.ComponentDefinition.WorkPlanes 28 | wp.Visible = wfBoolean 29 | Next 30 | 31 | wfboolean = InputRadioBox("Toggle Workaxes On/Off?", "On", "Off", False, "iLogic") 32 | For Each wa As WorkAxis In PartDoc.ComponentDefinition.WorkAxes 33 | wa.Visible = wfBoolean 34 | Next 35 | ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute 36 | InventorVb.DocumentUpdate() 37 | 38 | End Sub 39 | -------------------------------------------------------------------------------- /Modelling/Traverse an Assembly API Sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Modelling/Traverse an Assembly API Sample.pdf -------------------------------------------------------------------------------- /Modelling/Update Embossing.iLogicVb: -------------------------------------------------------------------------------- 1 | Parameter("Emboss") = iProperties.Value("Project", "Part Number") 2 | iLogicVb.UpdateWhenDone = True 3 | -------------------------------------------------------------------------------- /Modelling/UpdatedCurrentlyOpenDocuments.iLogicVb: -------------------------------------------------------------------------------- 1 | Sub Main() 2 | 'FOR SAPPHIRE ONLY CURRENTLY! 3 | 'should hopefully perform an update on each open assembly file skeleton base part 4 | For Each oDoc In ThisApplication.Documents 5 | If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then 'And Not oDoc.FullFilename.Contains("Panel") Then 6 | 'MessageBox.Show(odoc.fullfilename,"Parent Assembly file") 7 | ' Dim AssemblyRootFolder As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName) 8 | ' Dim PartFileNameToOpen As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) 9 | ' Dim filepathtoopen As String = AssemblyRootFolder & "\" & PartFileNameToOpen & ".ipt" 10 | ' 'MessageBox.Show(filepathtoopen, "Title") 11 | ' Dim partToUpdate As PartDocument = ThisApplication.Documents.Open(filepathtoopen, True) 12 | ' partToUpdate.Activate 13 | ' 'this is the one that actually forces the update! 14 | ' partToUpdate.Rebuild2(True) 15 | ' partToUpdate.Update2(True) 16 | ' InventorVb.DocumentUpdate() 17 | ' partToUpdate.Save() 18 | ' partToUpdate.Close 19 | Dim AssyDoc As AssemblyDocument = oDoc 20 | AssyDoc.Rebuild2(True) 21 | AssyDoc.Update2(True) 22 | AssyDoc.Save() 23 | AssyDoc.Close() 24 | End If 25 | Next 26 | 27 | End Sub 28 | 29 | -------------------------------------------------------------------------------- /Modelling/Workplane Grid Creator.iLogicVb: -------------------------------------------------------------------------------- 1 | ' Start of iLogic code - remember to subscribe to Luke Davenport's blog 2 | ' http://www.cadlinecommunity.co.uk/Blogs/LukeDavenport/Default.aspx 3 | ' And why not follow him on twitter @LukeCadline 4 | 5 | Imports Inventor.SelectionFilterEnum 6 | 7 | Sub Main 8 | Dim Title As String = "Cadline iLogic" 9 | Dim Cont As Boolean = True 10 | Dim Counter As Integer = 1 11 | 12 | oDoc = ThisDoc.Document 13 | If oDoc.DocumentType = kAssemblyDocumentObject OrElse oDoc.DocumentType = kDrawingDocumentObject Then 14 | MessageBox.Show("This tool can only be used in a part file!", Title, _ 15 | MessageBoxButtons.Ok,MessageBoxIcon.Exclamation, _ 16 | MessageBoxDefaultButton.Button1) 17 | Return 18 | End If 19 | 20 | Dim oPartCompDef As PartComponentDefinition = oDoc.ComponentDefinition 21 | Dim oWorkPlanes As WorkPlanes = oPartCompDef.WorkPlanes 22 | Dim oFilter As SelectionFilterEnum 23 | oFilter = kWorkPlaneFilter 24 | 25 | ' Turn origin planes on 26 | For a = 1 To 3 27 | oWorkPlanes.Item(a).Visible = True 28 | Next 29 | 30 | ' Get start plane from user 31 | oStartPlane = ThisApplication.CommandManager.Pick(oFilter, "Select Start Plane") 32 | GridlineName = InputBox("Enter Name of Grid Planes", Title, "GL") 33 | 34 | If GridlineName = "" Then 35 | Cleanup(oWorkPlanes) 36 | Return 37 | End If 38 | 39 | Call MakePlane(oStartPlane, oWorkPlanes, GridlineName, Counter, Title, False,1000) 40 | Cleanup(oWorkPlanes) 41 | End Sub 42 | 43 | 44 | 45 | Sub MakePlane(ByVal oPlane As WorkPlane, ByRef oWorkPlanes As WorkPlanes, ByVal GridlineName As String, ByRef Counter As Integer, ByVal Title As String, ByRef Finish As Boolean, ByRef StartNo As Double) 46 | 47 | Do While Finish = False 48 | CountString = Counter.ToString("D4") 49 | Offset = InputBox("Enter Plane Offset in mm (From Previous)" & vbLf & vbLf & "Hit cancel to finish", Title, StartNo) 50 | If Offset = "" Then 51 | Exit Sub 52 | Else If Not IsNumeric(Offset) Then 53 | Exit Sub 54 | End If 55 | ' Create work plane 56 | Dim oNewWorkPlane As WorkPlane 57 | oNewWorkPlane = oWorkPlanes.AddByPlaneAndOffset(oPlane, GridlineName & CountString & " = " & CDbl(Offset)) 58 | Try 59 | oNewWorkPlane.Name = GridlineName & CountString 60 | Catch 61 | End Try 62 | ' Increment counter 63 | Counter += 1 64 | MakePlane(oNewWorkPlane, oWorkPlanes, GridlineName, Counter, Title, False, Offset) 65 | Return 66 | Loop 67 | 68 | End Sub 69 | 70 | 71 | 72 | Sub Cleanup(ByVal oWorkPlanes As WorkPlanes) 73 | ' Turn origin planes off 74 | For a = 1 To 3 75 | oWorkPlanes.Item(a).Visible = False 76 | Next 77 | 78 | End Sub 79 | 80 | ' ********************** End of iLogic code ********************** -------------------------------------------------------------------------------- /Module Rules/Modules.xsd: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <xsd:schema id="Modules" 3 | targetNamespace="http://tempuri.org/Modules.xsd" 4 | elementFormDefault="qualified" 5 | xmlns="http://tempuri.org/Modules.xsd" 6 | xmlns:mstns="http://tempuri.org/Modules.xsd" 7 | xmlns:xsd="http://www.w3.org/2001/XMLSchema" 8 | > 9 | <xsd:element name="root" type="FilterHouse" /> 10 | 11 | <xsd:complexType name="FilterHouseVariants"> 12 | <xsd:sequence> 13 | <xsd:element name="FHOption" type="FilterHouse" minOccurs="0" maxOccurs="unbounded"/> 14 | </xsd:sequence> 15 | </xsd:complexType> 16 | 17 | <xsd:complexType name="FilterHouse"> 18 | <xsd:sequence> 19 | <xsd:element name="Doors"> 20 | <xsd:complexType> 21 | <xsd:sequence> 22 | <xsd:element name="door" 23 | type="FilterHouseDoor" 24 | minOccurs="0" 25 | maxOccurs="unbounded" /> 26 | </xsd:sequence> 27 | </xsd:complexType> 28 | </xsd:element> 29 | <xsd:element name="Modules" type="ModulesType" /> 30 | </xsd:sequence> 31 | </xsd:complexType> 32 | 33 | <xsd:complexType name="ModulesType"> 34 | <xsd:sequence> 35 | <xsd:element name="Elements"> 36 | <xsd:complexType> 37 | <xsd:sequence> 38 | <xsd:element name="property" 39 | type="FModuleElement" 40 | minOccurs="0" 41 | maxOccurs="unbounded" /> 42 | </xsd:sequence> 43 | </xsd:complexType> 44 | </xsd:element> 45 | </xsd:sequence> 46 | </xsd:complexType> 47 | 48 | <xsd:complexType name="FModuleElement"> 49 | <xsd:attribute type="xsd:string" name="ParentModuleID" /> 50 | <xsd:attribute type="xsd:boolean" name="ElementBracingLeftFront" /> 51 | <xsd:attribute type="xsd:boolean" name="ElementBracingLeftRear" /> 52 | <xsd:attribute type="xsd:boolean" name="ElementBracingRightFront" /> 53 | <xsd:attribute type="xsd:boolean" name="ElementBracingRightRear" /> 54 | <xsd:attribute type="xsd:integer" name="ElementWidth" /> 55 | </xsd:complexType> 56 | 57 | <xsd:complexType name="FilterHouseDoor"> 58 | <xsd:attribute type="xsd:string" name="ParentHouseID" /> 59 | <xsd:attribute type="xsd:boolean" name="RightHandedFront" /> 60 | <xsd:attribute type="xsd:boolean" name="LeftHandedFront" /> 61 | <xsd:attribute type="xsd:boolean" name="RightHandedRear" /> 62 | <xsd:attribute type="xsd:boolean" name="LeftHandedRear" /> 63 | </xsd:complexType> 64 | </xsd:schema> 65 | -------------------------------------------------------------------------------- /Module Rules/Update.iLogicVb: -------------------------------------------------------------------------------- 1 | AddReference "IlogicExternalDebug.dll" 2 | Imports iLogicExternalDebug 3 | Imports Inventor 4 | Sub Main() 5 | Dim xtClass As New iLogicExternalDebug.ExtClass() 6 | xtClass.ThisApplication = ThisApplication 7 | xtClass.DocToUpdate = ThisDoc 8 | Call xtClass.Update() 9 | End Sub 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iLogic 2 | 3 | This repo contains the iLogic rules I have collated over the course of my adventure with Autodesk Inventor. 4 | 5 | If you wish to contribute, please either fork my repo, make your changes and request a merge. 6 | 7 | If anything is unclear, please ask. 8 | 9 | If anything can be improved, please raise an issue. 10 | -------------------------------------------------------------------------------- /Rule Exports/11916-DW-PBBM-DT-01-101-iLogicRules.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0"?> 2 | <root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/iLogicRules.xsd"> 3 | <Rule ParentFileName="C:\Users\alex.fielder\OneDrive\Inventor\Designs\Balmoral\11916-DW-PBBM-DT-01-101.ipt" Name="sweep" IsActive="true" AutomaticOnParameterChange="true" Silentoperation="true"> 4 | <Text> 'Set a reference to the active part document 5 | Dim oDoc As PartDocument 6 | oDoc = ThisApplication.ActiveDocument 7 | 8 | Dim oDef As PartComponentDefinition 9 | oDef = oDoc.ComponentDefinition 10 | 11 | Dim opath As Path 12 | opath = oDef.Features.SweepFeatures.Item("TheSweep").Path 13 | 14 | Dim TotalLength As Double 15 | TotalLength = 0 16 | 17 | Dim oCurve As Object 18 | Dim i As Integer 19 | 20 | For i = 1 To opath.Count 21 | oCurve = opath.Item(i).Curve 22 | 23 | Dim oCurveEval As CurveEvaluator 24 | oCurveEval = oCurve.Evaluator 25 | 26 | Dim MinParam As Double 27 | Dim MaxParam As Double 28 | Dim length As Double 29 | 30 | Call oCurveEval.GetParamExtents(MinParam, MaxParam) 31 | Call oCurveEval.GetLengthAtParam(MinParam, MaxParam, length) 32 | 33 | TotalLength = TotalLength + length 34 | Next i 35 | 36 | Dim oparams As Parameters 37 | Dim oparam As Parameter 38 | oparams = oDoc.ComponentDefinition.Parameters 39 | Dim exists As Boolean 40 | exists = False 41 | 42 | 'Find out if parameter exists 43 | For Each oparam In oparams 44 | If oparam.Name = "Sweeplength" Then exists = True 45 | Next oparam 46 | 47 | 'Change the value if the parameter exists otherwise add the parameter 48 | If exists Then 49 | oparams.Item("Sweeplength").Value = TotalLength 50 | Else 51 | oparams.UserParameters.AddByValue( "Sweeplength", TotalLength, 11266) 52 | End If 53 | oDoc.Update</Text> 54 | </Rule> 55 | <Rule ParentFileName="C:\Users\alex.fielder\OneDrive\Inventor\Designs\Balmoral\11916-DW-PBBM-DT-01-101.ipt" Name="Run Form" IsActive="true" AutomaticOnParameterChange="true" Silentoperation="true"> 56 | <Text>iLogicForm.Show("Plough Bridle Module")</Text> 57 | </Rule> 58 | <Rule ParentFileName="C:\Users\alex.fielder\OneDrive\Inventor\Designs\Balmoral\11916-DW-PBBM-DT-01-101.ipt" Name="Rule2" IsActive="true" AutomaticOnParameterChange="true" Silentoperation="true"> 59 | <Text>iLogicVb.RunRule("Run Form") 60 | </Text> 61 | </Rule> 62 | </root> 63 | -------------------------------------------------------------------------------- /Spreadsheet for Create Assembly From Excel & Create Standard Parts From Excel.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/Spreadsheet for Create Assembly From Excel & Create Standard Parts From Excel.xlsx -------------------------------------------------------------------------------- /VBAExport/AnchoredClientGraphics.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "AnchoredClientGraphics" 2 | Public Sub AnchoredClientGraphics() 3 | ' Set a reference to the document. 4 | Dim oDoc As Document 5 | Set oDoc = ThisApplication.ActiveDocument 6 | 7 | ' Set a reference to the component definition. 8 | ' This assumes that the active document is a part or an assembly. 9 | Dim oCompDef As ComponentDefinition 10 | Set oCompDef = oDoc.ComponentDefinition 11 | 12 | ' Attempt to get the existing client graphics object. If it exists 13 | ' delete it so the rest of the code can continue as if it never existed. 14 | Dim oClientGraphics As ClientGraphics 15 | On Error Resume Next 16 | Set oClientGraphics = oCompDef.ClientGraphicsCollection.Item("Anchored Text") 17 | If Err.Number = 0 Then 18 | oClientGraphics.Delete 19 | End If 20 | On Error GoTo 0 21 | ThisApplication.ActiveView.Update 22 | 23 | ' Create a new ClientGraphics object. 24 | Set oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Anchored Text") 25 | 26 | ' Create a graphics node. 27 | Dim oNode As GraphicsNode 28 | Set oNode = oClientGraphics.AddNode(1) 29 | 30 | ' Create text graphics. 31 | Dim oTextGraphics As TextGraphics 32 | Set oTextGraphics = oNode.AddTextGraphics 33 | 34 | ' Set the properties of the text. 35 | oTextGraphics.Text = "Anchored text." 36 | oTextGraphics.Bold = True 37 | oTextGraphics.FontSize = 30 38 | Call oTextGraphics.PutTextColor(47, 47, 48) '(117, 76, 45) 39 | 40 | Dim oAnchorPoint As Point 41 | Set oAnchorPoint = ThisApplication.TransientGeometry.CreatePoint(1, 1, 1) 42 | 43 | ' Set the text's anchor in model space. 44 | oTextGraphics.Anchor = oAnchorPoint 45 | 46 | ' Anchor the text graphics in the view. 47 | Call oTextGraphics.SetViewSpaceAnchor( _ 48 | oAnchorPoint, ThisApplication.TransientGeometry.CreatePoint2d(150, 30), ViewLayoutEnum.kBottomRightViewCorner) 49 | 50 | ' Update the view to see the text. 51 | ThisApplication.ActiveView.Update 52 | End Sub 53 | 54 | -------------------------------------------------------------------------------- /VBAExport/ClientGraphicsText.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "ClientGraphicsText" 2 | Public Sub ClientGraphicsText() 3 | ' Set a reference to the document. This will work with 4 | ' either a part or assembly document. 5 | Dim oDoc As Document 6 | Set oDoc = ThisApplication.ActiveDocument 7 | 8 | ' Set a reference to the component definition. 9 | Dim oCompDef As ComponentDefinition 10 | Set oCompDef = oDoc.ComponentDefinition 11 | 12 | ' Attempt to get the existing client graphics object. If it exists 13 | ' delete it so the rest of the code can continue as if it never existed. 14 | Dim oClientGraphics As ClientGraphics 15 | On Error Resume Next 16 | Set oClientGraphics = oCompDef.ClientGraphicsCollection.Item("Text Test") 17 | If Err.Number = 0 Then 18 | oClientGraphics.Delete 19 | End If 20 | On Error GoTo 0 21 | ThisApplication.ActiveView.Update 22 | 23 | ' Create a new ClientGraphics object. 24 | Set oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Text Test") 25 | 26 | ' Create a graphics node. 27 | Dim oNode As GraphicsNode 28 | Set oNode = oClientGraphics.AddNode(1) 29 | 30 | ' Create text graphics. 31 | Dim oTextGraphics As TextGraphics 32 | Set oTextGraphics = oNode.AddTextGraphics 33 | 34 | ' Set the properties of the text. 35 | oTextGraphics.Text = "This is the sample text." 36 | oTextGraphics.Anchor = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0) 37 | oTextGraphics.Bold = True 38 | oTextGraphics.Font = "Arial" 39 | oTextGraphics.FontSize = 40 40 | oTextGraphics.HorizontalAlignment = kAlignTextLeft 41 | oTextGraphics.Italic = True 42 | Call oTextGraphics.PutTextColor(0, 255, 0) 43 | oTextGraphics.VerticalAlignment = kAlignTextMiddle 44 | 45 | ' Update the view to see the text. 46 | ThisApplication.ActiveView.Update 47 | End Sub 48 | 49 | -------------------------------------------------------------------------------- /VBAExport/DebugExcelRangeObject.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "DebugExcelRangeObject" 2 | Sub DebugSelectedCell() 3 | Dim wb As Workbook 4 | Set wb = ActiveWorkbook 5 | Dim ws As Worksheet 6 | Set ws = wb.ActiveSheet 7 | Dim cell As Range 8 | Set cell = ActiveCell 9 | Stop 10 | End Sub 11 | -------------------------------------------------------------------------------- /VBAExport/DebugObject.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "DebugObject" 2 | Public Sub DebugObject() 3 | Dim oDoc As Document 4 | Set oDoc = ThisApplication.ActiveDocument 5 | Dim oObj As Object 6 | Set oObj = oDoc.SelectSet.Item(1) 7 | Stop 8 | End Sub 9 | -------------------------------------------------------------------------------- /VBAExport/HideTitleBar.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "HideTitleBar" 2 | 'PLACE IN STANDARD MODULE 3 | Option Explicit 4 | Option Private Module 5 | 6 | Public Const GWL_STYLE = -16 7 | Public Const WS_CAPTION = &HC00000 8 | #If VBA7 Then 9 | Public Declare PtrSafe Function GetWindowLong _ 10 | Lib "user32" Alias "GetWindowLongA" ( _ 11 | ByVal hWnd As Long, _ 12 | ByVal nIndex As Long) As Long 13 | Public Declare PtrSafe Function SetWindowLong _ 14 | Lib "user32" Alias "SetWindowLongA" ( _ 15 | ByVal hWnd As Long, _ 16 | ByVal nIndex As Long, _ 17 | ByVal dwNewLong As Long) As Long 18 | Public Declare PtrSafe Function DrawMenuBar _ 19 | Lib "user32" ( _ 20 | ByVal hWnd As Long) As Long 21 | Public Declare PtrSafe Function FindWindowA _ 22 | Lib "user32" (ByVal lpClassName As String, _ 23 | ByVal lpWindowName As String) As Long 24 | #Else 25 | ' Public Declare Function GetWindowLong _ 26 | ' Lib "user32" Alias "GetWindowLongA" ( _ 27 | ' ByVal hWnd As Long, _ 28 | ' ByVal nIndex As Long) As Long 29 | ' Public Declare Function SetWindowLong _ 30 | ' Lib "user32" Alias "SetWindowLongA" ( _ 31 | ' ByVal hWnd As Long, _ 32 | ' ByVal nIndex As Long, _ 33 | ' ByVal dwNewLong As Long) As Long 34 | ' Public Declare Function DrawMenuBar _ 35 | ' Lib "user32" ( _ 36 | ' ByVal hWnd As Long) As Long 37 | ' Public Declare Function FindWindowA _ 38 | ' Lib "user32" (ByVal lpClassName As String, _ 39 | ' ByVal lpWindowName As String) As Long 40 | #End If 41 | Sub HideTitleBar(frm As Object) 42 | Dim lngWindow As Long 43 | Dim lFrmHdl As Long 44 | lFrmHdl = FindWindowA(vbNullString, frm.Caption) 45 | lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE) 46 | lngWindow = lngWindow And (Not WS_CAPTION) 47 | Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow) 48 | Call DrawMenuBar(lFrmHdl) 49 | End Sub 50 | 51 | -------------------------------------------------------------------------------- /VBAExport/OnFaceCurveSample.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "OnFaceCurveSample" 2 | Sub OnFaceCurveSample() 3 | Dim oDoc As PartDocument 4 | Set oDoc = ThisApplication.ActiveDocument 5 | 6 | Dim oFace As Face 7 | Set oFace = oDoc.ComponentDefinition.SurfaceBodies(1).Faces(1) 8 | 9 | Dim oSk3D As Sketch3D 10 | Set oSk3D = oDoc.ComponentDefinition.Sketches3D.Add 11 | 12 | Dim oFaces As NameValueMap 13 | Dim oFitPoints As NameValueMap 14 | 15 | Set oFaces = ThisApplication.TransientObjects.CreateNameValueMap 16 | Set oFitPoints = ThisApplication.TransientObjects.CreateNameValueMap 17 | 18 | Dim i As Long, oTempFace As Face, oCol As ObjectCollection 19 | For i = 1 To oFace.FaceShell.Faces.Count 20 | Set oCol = ThisApplication.TransientObjects.CreateObjectCollection 21 | 22 | Set oTempFace = oFace.FaceShell.Faces(i) 23 | oCol.Add oTempFace.PointOnFace 24 | 25 | oFaces.Add "Face" & i, oTempFace 26 | oFitPoints.Add "Face" & i, oCol 27 | Next 28 | 29 | Dim oOnFaceCurve As OnFaceCurve 30 | 31 | Set oOnFaceCurve = oSk3D.OnFaceCurves.Add(oFaces, oFitPoints) 32 | End Sub 33 | -------------------------------------------------------------------------------- /VBAExport/Place_And_Ground_Known_Part.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "Place_And_Ground_Known_Part" 2 | Sub Main() 3 | Dim filename As String 4 | filename = "C:\Users\Alex.Fielder\OneDrive\Inventor\Designs\C360\Part5.ipt" 5 | Call Place_and_Ground_Part(ThisApplication, filename) 6 | End Sub 7 | 8 | Public Function Place_and_Ground_Part(ByVal invApp As Application, ByVal path As String) As ComponentOccurrence 9 | 10 | ' Post the filename to the private event queue. 11 | Call invApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, path) 12 | 13 | ' Get the control definition for the Place Component command. 14 | Dim ctrlDef As Inventor.ControlDefinition 15 | Set ctrlDef = invApp.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd") 16 | 17 | ' Execute the command. 18 | Call ctrlDef.Execute 19 | 20 | 'Return Nothing 21 | End Function 22 | -------------------------------------------------------------------------------- /VBAExport/PrintRibbonNames.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "PrintRibbonNames" 2 | Public Sub PrintRibbon() 3 | Open "F:\Dropbox\iLogic\RibbonNames.txt" For Output As #1 '"C:\temp\RibbonNames.txt" For Output As #1 4 | 5 | Print #1, "File Controls (Application Menu)" 6 | Call PrintControls(ThisApplication.UserInterfaceManager.FileBrowserControls, "", 1) 7 | Print #1, "------------------------------------------------------------------" 8 | 9 | Print #1, "Help Controls" 10 | Call PrintControls(ThisApplication.UserInterfaceManager.HelpControls, "", 1) 11 | Print #1, "------------------------------------------------------------------" 12 | 13 | Dim oRibbon As Ribbon 14 | For Each oRibbon In ThisApplication.UserInterfaceManager.Ribbons 15 | Print #1, "Ribbon: " & oRibbon.InternalName 16 | 17 | Print #1, " QAT controls" 18 | Call PrintControls(oRibbon.QuickAccessControls, " ", 0) 19 | 20 | Dim oTab As RibbonTab 21 | For Each oTab In oRibbon.RibbonTabs 22 | Print #1, " Tab: " & oTab.DisplayName & ", " & oTab.InternalName & ", Visible: " & oTab.Visible 23 | 24 | Dim oPanel As RibbonPanel 25 | For Each oPanel In oTab.RibbonPanels 26 | Print #1, " Panel: " & oPanel.DisplayName & ", " & oPanel.InternalName & ", Visible: " & oPanel.Visible 27 | 28 | Call PrintControls(oPanel.CommandControls, " ", 0) 29 | 30 | If oPanel.SlideoutControls.Count > 0 Then 31 | Print #1, " --- Slideout Controls ---" 32 | Call PrintControls(oPanel.SlideoutControls, " ", 0) 33 | End If 34 | Next 35 | Next 36 | 37 | Print #1, "------------------------------------------------------------------" 38 | Next 39 | On Error GoTo 0 40 | 41 | Close #1 42 | 43 | MsgBox "Result written to: F:\Dropbox\iLogic\RibbonNames.txt" 44 | End Sub 45 | 46 | Private Sub PrintControls(Controls As CommandControls, LeadingSpace As String, Level As Integer) 47 | Dim oControl As CommandControl 48 | For Each oControl In Controls 49 | If oControl.ControlType = kSeparatorControl Then 50 | Print #1, LeadingSpace & Space(Level * 4) & "Control: Seperator" 51 | Else 52 | Print #1, LeadingSpace & Space(Level * 4) & "Control: " & oControl.DisplayName & ", " & oControl.InternalName & ", Visible: " & oControl.Visible 53 | 54 | If Not oControl.ChildControls Is Nothing Then 55 | Call PrintControls(oControl.ChildControls, LeadingSpace, Level + 1) 56 | End If 57 | End If 58 | Next 59 | End Sub 60 | -------------------------------------------------------------------------------- /VBAExport/Sheet1.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet1" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet11.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet11" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet12.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet12" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet2.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet2" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet3.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet3" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet4.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet4" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet6.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet6" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet7.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet7" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet8.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet8" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/Sheet9.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "Sheet9" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/ThisWorkbook.cls: -------------------------------------------------------------------------------- 1 | VERSION 1.0 CLASS 2 | BEGIN 3 | MultiUse = -1 'True 4 | END 5 | Attribute VB_Name = "ThisWorkbook" 6 | Attribute VB_GlobalNameSpace = False 7 | Attribute VB_Creatable = False 8 | Attribute VB_PredeclaredId = True 9 | Attribute VB_Exposed = True 10 | -------------------------------------------------------------------------------- /VBAExport/VBAHelpers.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "VBAHelpers" 2 | Option Explicit 3 | ' copied from here: https://gist.github.com/steve-jansen/7589478 4 | ' Excel macro to export all VBA source code in this project to text files for proper source control versioning 5 | ' Requires enabling the Excel setting in Options/Trust Center/Trust Center Settings/Macro Settings/Trust access to the VBA project object model 6 | Public Sub ExportVisualBasicCode() 7 | Const Module = 1 8 | Const ClassModule = 2 9 | Const Form = 3 10 | Const Document = 100 11 | Const Padding = 24 12 | 13 | Dim VBComponent As Object 14 | Dim count As Integer 15 | Dim path As String 16 | Dim directory As String 17 | Dim extension As String 18 | Dim fso As New FileSystemObject 19 | 20 | 'directory = ActiveWorkbook.path & "\VisualBasic" 21 | directory = "F:\Dropbox\iLogic" 22 | count = 0 23 | 24 | If Not fso.FolderExists(directory) Then 25 | Call fso.CreateFolder(directory) 26 | End If 27 | Set fso = Nothing 28 | 29 | For Each VBComponent In ActiveWorkbook.VBProject.VBComponents 30 | Select Case VBComponent.Type 31 | Case ClassModule, Document 32 | extension = ".cls" 33 | Case Form 34 | extension = ".frm" 35 | Case Module 36 | extension = ".bas" 37 | Case Else 38 | extension = ".txt" 39 | End Select 40 | 41 | 42 | On Error Resume Next 43 | Err.Clear 44 | 45 | path = directory & "\" & VBComponent.Name & extension 46 | Call VBComponent.Export(path) 47 | 48 | If Err.Number <> 0 Then 49 | Call MsgBox("Failed to export " & VBComponent.Name & " to " & path, vbCritical) 50 | Else 51 | count = count + 1 52 | Debug.Print "Exported " & Left$(VBComponent.Name & ":" & Space(Padding), Padding) & path 53 | End If 54 | 55 | On Error GoTo 0 56 | Next 57 | 58 | Application.StatusBar = "Successfully exported " & CStr(count) & " VBA files to " & directory 59 | MsgBox "Successfully exported " & CStr(count) & " VBA files to " & directory 60 | Application.StatusBar = False 61 | End Sub 62 | -------------------------------------------------------------------------------- /VBAExport/WebBrowserDialog.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "WebBrowserDialog" 2 | 3 | Private oWebBrowserDialog As WebBrowserDialog 4 | 5 | Sub DismissWebBrowser() 6 | Set oWebBrowserDialog = Nothing 7 | End Sub 8 | 9 | Sub WebBrowserDialogSample() 10 | ' Create a WebBrowserDialog 11 | Set oWebBrowserDialog = ThisApplication.WebBrowserDialogs.Add("MyBrowser", False) 12 | oWebBrowserDialog.WindowState = kNormalWindow 13 | 14 | ' Nagigate to a web site 15 | Call oWebBrowserDialog.Navigate("http://www.autodesk.com") 16 | 17 | ' Play a tutorial video if you have the Interactive Tutorial installed 18 | ' Call oWebBrowserDialog.Navigate("C:\Users\Public\Documents\Autodesk\Inventor 2017\Interactive Tutorial\en-US\Fundamentals\Video\Drawings.webm") 19 | 20 | ' Delete it - commenteted 21 | ' oWebBrowserDialog.Delete 22 | End Sub 23 | 24 | -------------------------------------------------------------------------------- /VBAExport/ufProgress.frm: -------------------------------------------------------------------------------- 1 | VERSION 5.00 2 | Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} ufProgress 3 | Caption = "Running..." 4 | ClientHeight = 1620 5 | ClientLeft = 120 6 | ClientTop = 465 7 | ClientWidth = 4560 8 | OleObjectBlob = "ufProgress.frx":0000 9 | ShowModal = 0 'False 10 | StartUpPosition = 1 'CenterOwner 11 | End 12 | Attribute VB_Name = "ufProgress" 13 | Attribute VB_GlobalNameSpace = False 14 | Attribute VB_Creatable = False 15 | Attribute VB_PredeclaredId = True 16 | Attribute VB_Exposed = False 17 | 'PLACE IN YOUR USERFORM CODE 18 | ' copied from here: https://wellsr.com/vba/2017/excel/beautiful-vba-progress-bar-with-step-by-step-instructions/ 19 | Private Sub UserForm_Initialize() 20 | #If IsMac = False Then 21 | 'hide the title bar if you're working on a windows machine. Otherwise, just display it as you normally would 22 | Me.Height = Me.Height - 10 23 | HideTitleBar.HideTitleBar Me 24 | #End If 25 | End Sub 26 | -------------------------------------------------------------------------------- /VBAExport/ufProgress.frx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/VBAExport/ufProgress.frx -------------------------------------------------------------------------------- /iLogic Collection.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "iLogic Collection", "iLogic Collection.vbproj", "{144BFD27-131A-4F35-9B85-847E44FC38F4}" 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 | {144BFD27-131A-4F35-9B85-847E44FC38F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {144BFD27-131A-4F35-9B85-847E44FC38F4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {144BFD27-131A-4F35-9B85-847E44FC38F4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {144BFD27-131A-4F35-9B85-847E44FC38F4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /iLogic Workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /iLogic XLS iFeature Pattern.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/iLogic XLS iFeature Pattern.zip -------------------------------------------------------------------------------- /iLogic.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/iLogic.7z -------------------------------------------------------------------------------- /iLogic.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/iLogic.zip -------------------------------------------------------------------------------- /iLogicOptions.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>C:\Users\alex.fielder\Dropbox\iLogic\AddRemove</string> 5 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Drawings</string> 6 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Helper Rules</string> 7 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Modelling</string> 8 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Properties</string> 9 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Misc</string> 10 | </ExternalRuleDirectories> 11 | <ExternalRuleFilenames /> 12 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 13 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogicOptions2017.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>F:\Dropbox\iLogic\C360</string> 5 | <string>F:\Dropbox\iLogic\AddRemove</string> 6 | <string>F:\Dropbox\iLogic\CM Examples</string> 7 | <string>F:\Dropbox\iLogic\Drawings</string> 8 | <string>F:\Dropbox\iLogic\Helper Rules</string> 9 | <string>F:\Dropbox\iLogic\Misc</string> 10 | <string>F:\Dropbox\iLogic\Modelling</string> 11 | <string>F:\Dropbox\iLogic\Module Rules</string> 12 | </ExternalRuleDirectories> 13 | <ExternalRuleFilenames /> 14 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 15 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogicOptions2019 (Work).xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>f:\Dropbox\iLogic\C360</string> 5 | <string>f:\Dropbox\iLogic\AddRemove</string> 6 | <string>f:\Dropbox\iLogic\CM Examples</string> 7 | <string>f:\Dropbox\iLogic\Drawings</string> 8 | <string>f:\Dropbox\iLogic\Helper Rules</string> 9 | <string>f:\Dropbox\iLogic\Misc</string> 10 | <string>f:\Dropbox\iLogic\Modelling</string> 11 | <string>f:\Dropbox\iLogic\Module Rules</string> 12 | </ExternalRuleDirectories> 13 | <ExternalRuleFilenames /> 14 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 15 | <RulesOnEventsFilter>RunAll</RulesOnEventsFilter> 16 | <RuleSecurityInspectionEnabled>false</RuleSecurityInspectionEnabled> 17 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogicOptions2020(MandM).xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>C:\Users\alex.fielder\Dropbox\iLogic\C360</string> 5 | <string>C:\Users\alex.fielder\Dropbox\iLogic\AddRemove</string> 6 | <string>C:\Users\alex.fielder\Dropbox\iLogic\CM Examples</string> 7 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Drawings</string> 8 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Helper Rules</string> 9 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Misc</string> 10 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Modelling</string> 11 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Module Rules</string> 12 | </ExternalRuleDirectories> 13 | <ExternalRuleFilenames /> 14 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 15 | <RulesOnEventsFilter>RunAll</RulesOnEventsFilter> 16 | <RuleSecurityInspectionEnabled>false</RuleSecurityInspectionEnabled> 17 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogicOptions2022 (Home).xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>C:\Users\alex_\Dropbox\iLogic\C360</string> 5 | <string>C:\Users\alex_\Dropbox\iLogic\AddRemove</string> 6 | <string>C:\Users\alex_\Dropbox\iLogic\CM Examples</string> 7 | <string>C:\Users\alex_\Dropbox\iLogic\Drawings</string> 8 | <string>C:\Users\alex_\Dropbox\iLogic\Helper Rules</string> 9 | <string>C:\Users\alex_\Dropbox\iLogic\Misc</string> 10 | <string>C:\Users\alex_\Dropbox\iLogic\Modelling</string> 11 | <string>C:\Users\alex_\Dropbox\iLogic\Module Rules</string> 12 | <string>C:\Users\alex_\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\Stormking</string> 13 | <string>C:\Users\alex_\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\ThrislingtonCubiclesLtd</string> 14 | <string>C:\Users\alex_\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\Vista</string> 15 | </ExternalRuleDirectories> 16 | <ExternalRuleFilenames /> 17 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 18 | <CustomAddinPath /> 19 | <RulesOnEventsFilter>RunAll</RulesOnEventsFilter> 20 | <RuleSecurityInspectionEnabled>false</RuleSecurityInspectionEnabled> 21 | <ExcelEngine>Internal</ExcelEngine> 22 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogicOptions2022 (Work).xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>C:\Users\alex.fielder\Dropbox\iLogic\C360</string> 5 | <string>C:\Users\alex.fielder\Dropbox\iLogic\AddRemove</string> 6 | <string>C:\Users\alex.fielder\Dropbox\iLogic\CM Examples</string> 7 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Drawings</string> 8 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Helper Rules</string> 9 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Misc</string> 10 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Modelling</string> 11 | <string>C:\Users\alex.fielder\Dropbox\iLogic\Module Rules</string> 12 | <string>C:\Users\alex.fielder\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\MIDFIX</string> 13 | <string>C:\Users\alex.fielder\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\Stormking</string> 14 | <string>C:\Users\alex.fielder\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\ThrislingtonCubiclesLtd</string> 15 | <string>C:\Users\alex.fielder\OneDrive\Documents\GitHub\ManAndMachine\MandM-iLogic\Vista</string> 16 | </ExternalRuleDirectories> 17 | <ExternalRuleFilenames /> 18 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 19 | <CustomAddinPath /> 20 | <RulesOnEventsFilter>RunAll</RulesOnEventsFilter> 21 | <RuleSecurityInspectionEnabled>false</RuleSecurityInspectionEnabled> 22 | <ExcelEngine>Internal</ExcelEngine> 23 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogicOptions_2024 (Home).xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>C:\Users\alex_\Dropbox\iLogic\C360</string> 5 | <string>C:\Users\alex_\Dropbox\iLogic\AddRemove</string> 6 | <string>C:\Users\alex_\Dropbox\iLogic\CM Examples</string> 7 | <string>C:\Users\alex_\Dropbox\iLogic\Drawings</string> 8 | <string>C:\Users\alex_\Dropbox\iLogic\Helper Rules</string> 9 | <string>C:\Users\alex_\Dropbox\iLogic\Misc</string> 10 | <string>C:\Users\alex_\Dropbox\iLogic\Modelling</string> 11 | <string>C:\Users\alex_\Dropbox\iLogic\Module Rules</string> 12 | <string>C:\Users\alex_\OneDrive\Documents\GitHub\ManAndMachine\MandMGeneral\General\iLogic</string> 13 | <string>C:\Users\alex_\OneDrive\Documents\GitHub\ManAndMachine\MandMGeneral\Projects</string> 14 | </ExternalRuleDirectories> 15 | <ExternalRuleFilenames /> 16 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 17 | <CustomAddinPath /> 18 | <RulesOnEventsFilter>RunAll</RulesOnEventsFilter> 19 | <RuleSecurityInspectionEnabled>false</RuleSecurityInspectionEnabled> 20 | <ExcelEngine>Internal</ExcelEngine> 21 | </ShareableOptions> -------------------------------------------------------------------------------- /iLogic_Access_Example.accdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/iLogic_Access_Example.accdb -------------------------------------------------------------------------------- /ilogic_iproperties_test.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexFielder/iLogic/d2f3b703ee797cc415aa4e5de1c31bb29520a27a/ilogic_iproperties_test.dwg -------------------------------------------------------------------------------- /ilogicoptions2018.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <ShareableOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 | <ExternalRuleDirectories> 4 | <string>d:\Dropbox\iLogic\C360</string> 5 | <string>d:\Dropbox\iLogic\AddRemove</string> 6 | <string>d:\Dropbox\iLogic\CM Examples</string> 7 | <string>d:\Dropbox\iLogic\Drawings</string> 8 | <string>d:\Dropbox\iLogic\Helper Rules</string> 9 | <string>d:\Dropbox\iLogic\Misc</string> 10 | <string>d:\Dropbox\iLogic\Modelling</string> 11 | <string>d:\Dropbox\iLogic\Module Rules</string> 12 | </ExternalRuleDirectories> 13 | <ExternalRuleFilenames /> 14 | <ExternalRuleDefaultExtension>.iLogicVb</ExternalRuleDefaultExtension> 15 | </ShareableOptions> --------------------------------------------------------------------------------