'Check whether open document is an assembly and exit rule if not
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject Then
MessageBox.Show("This rule can only be run in an assembly file - exiting rule", "iLogic")
Return
End If
Dim targetOcc As ComponentOccurrence = Nothing
Do While True
' Note the below line will prompt the user to pick an assembly occurrence (this can be a single part file or a sub-assembly of the active document...
targetOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Occurrence to Modify...(Press ESC to cancel)")
If Not targetOcc Is Nothing Then
Exit Do
Else
Dim Res As MsgBoxResult = MsgBox("No model selected - exit?", 36, "iLogic")
If Res = vbYes Then
Return
Else
' Do nothing - keep on looping...
End If
End If
Loop
Try
iLogicVb.RunRule(targetOcc.Name, "Show Form")
Catch
MsgBox("Error - There needs to be an iLogic rule called 'Show Form' in the assembly occurrence you have selected. This rule needs to contain code in 'show' the iLogic form you want to display. The code to do this will need to be similar to: ""iLogicForm.Show(""Form 1"")""", 64, "iLogic")
End Try
' End of iLogic Rule ===============================================================================