Message 1 of 4
How to iterate and activate each row in an iAssembly or iPart without the Inventor UI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Apologies if I have overlooked an existing example but I am just about to head out for the day and wondered if I have missed or overlooked an example somewhere that shows how to iterate the table rows of an iAssembly (or iPart) without using the Inventor UI?
The working example I have that shows how to do so using the UI is as follows:
Sub Main()
CheckiTableForErrors()
End Sub
Sub CheckiTableForErrors()
Dim oErrorManager As ErrorManager = ThisApplication.ErrorManager
If TypeOf (ThisApplication.activedocument) Is partdocument Then
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oiPart As iPartFactory = oDoc.ComponentDefinition.iPartFactory
Dim oTop As BrowserNode = oDoc.BrowserPanes("Model").TopNode
Dim bHasErrorOrWarning As Boolean
Dim i As Integer
InventorVb.DocumentUpdate()
ThisApplication.SilentOperation = True
For i = 1 To oiPart.TableRows.Count 'use first 10 rows only for debugging purposes!
' Highlight the 3rd iPart table row which has invalid data
oTop.BrowserNodes("Table").BrowserNodes.Item(i).DoSelect
' Activate the iPart table row
Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
oCommand.Execute
ThisApplication.SilentOperation = False
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute
If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
MessageBox.Show(oErrorManager.LastMessage, "Title")
End If
Next i
MessageBox.Show("No errors shown = None found!", "Title")
ElseIf TypeOf (ThisApplication.activedocument) Is assemblydocument Then
Dim odoc As assemblydocument = ThisApplication.activedocument
Dim iAssy As iAssemblyFactory = odoc.componentdefinition.iassemblyfactory
Dim oTop As BrowserNode = odoc.BrowserPanes("Model").TopNode
Dim bHasErrorOrWarning As Boolean
Dim i As Integer
InventorVb.DocumentUpdate()
ThisApplication.SilentOperation = True
For rowIndex = 1 To iAssy.tablerows.count
oTop.BrowserNodes("Table").BrowserNodes.Item(i).DoSelect
Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
oCommand.Execute
ThisApplication.SilentOperation = False
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute
If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
MessageBox.Show(oErrorManager.LastMessage, "Title")
End If
Next
End If
End Sub
Which works fine if you wish to verify that each row is buildable as a user- but can I do the same without access to the Inventor UI? (for instance if the iAssembly/iPart is opened by coolOrange PowerJobs)
Thanks,
Alex.
----------------------------------------------------------------
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example