Hi @Darkforce_the_ilogic_guy. Here are some coding tips for if you only want to work on the 'active' document, and if you only want to work on a specific sub type of document. There are several ways to do something like that. It all depends on which way suits both your coding style and needs best.
Sub Main
Dim oInvApp As Inventor.Application = ThisApplication
Dim oADoc As Inventor.AssemblyDocument = TryCast(oInvApp.ActiveDocument, Inventor.AssemblyDocument)
If oADoc Is Nothing Then
'MessageBox.Show("An Assembly Document must be active when you run this rule.", "Wrong Document Type", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Logger.Debug("Rule named '" & iLogicVb.RuleName & "' did not run because no assembly obtained!")
Return
End If
'only work on a Weldment type assembly
If TypeOf oADoc.ComponentDefinition Is WeldmentComponentDefinition Then
'your code here
End If
'another example of how to only work on a Weldment type assembly
Dim sDocSubTypeName As String = oADoc.PropertySets.Item(3).Item(17).Value
If sDocSubTypeName = "Weldment" Then
'your code here
End If
'...your other code here
'OtherRoutine(oADoc)
'Dim oReturned = OtherFunction(oADoc)
End Sub
'Sub OtherRoutine(oDocToWorkOn As Inventor.Document) 'or (oADoc As Inventor.AssemblyDocument)
'End Sub
'Function OtherFunction(oDocToWorkOn As Inventor.Document) As WhatTypeFunctionShouldReturn
'End Function
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)