Since most of those types of objects are an Interface, instead of a Class, we can not simply use the New keyword to create a new instance of any of them. So, once we have passed in one of these base Rule Objects like 'iLogicVb', we can use that to set the value of our internal variables. Then we can create our own internal variables for the other Rule Objects, and populate them from the first object, if it has the scope necessary, as that object does.
Below is an basic example Class that requests the iLogicVb object be passed into it within its 'New' Sub routine, like what was suggested multiple times above. It then uses that to set the value of a private, internal variable, which this Class will use for all other things requiring its capabilities. Then, from there, it starts populating the values of other similar private, internal variables. Then it uses one of those variables within a super basic function.
Public Class TestClass
Public Sub New(iLogicVb As ILowLevelSupport)
_iLogicVb = iLogicVb
_InvApp = _iLogicVb.Application
_iLogicAuto = _iLogicVb.Automation
_Doc = _iLogicVb.RuleDocument
_ObjectProvider = _iLogicVb.CreateObjectProvider(_Doc)
_ThisDoc = _ObjectProvider.ThisDocument
End Sub
Private Property _InvApp As Inventor.Application
Private Property _iLogicVb As ILowLevelSupport
Private Property _iLogicAuto As IiLogicAutomation
Private Property _ObjectProvider As IStandardObjectProvider
Private Property _Doc As Inventor.Document
Private Property _ThisDoc As ICadDoc
Public Function Prop(sPropertySetName As String, sPropertyName As String) As Object
Return _ObjectProvider.iProperties.Value(sPropertySetName, sPropertyName)
End Function
End Class
and a regular rule that creates a new instance of this Class, passed the required input, then uses its one public function to retrieve the value of a custom iProperty.
Dim oMyTestClass As New TestClass(iLogicVb)
Dim oValue As Object = oMyTestClass.Prop("Custom", "Testing")
MsgBox(oValue.ToString,,"")
However, in order for this rule to be able to access the definition of that Class, the Class definition must either also be within the same rule, or it must be within an external rule file that has had its option called "Straight VB Code" turned on (checked), and you just include the 'AddVbFile' in the header of this simple rule, followed by the quoted name of that external rule, with file extension included. And that external rule must be in one of the locations specified within your iLogic Configuration settings, so it can find it. Otherwise, you may need to specify the full file path to that file within that header line.
Edit: Almost forgot to mention that...in the external rule, where your custom Class is defined, which is set to Straight VB Code', you can include 'Imports' type lines within that rule's header, but you usually can not include 'AddReference' type lines in that rule's header. So, if that external rule is attempting to access any object Types, or methods that are defined in other references, you will need to include those 'AddReference' lines in the header of the 'regular' rule that will be referencing that external rule, and using it. In this case the required line would be:
AddReference "Autodesk.Inventor.Interop"
That reference is where the object Types 'Inventor.Application', and 'Inventor.Document' are defined. Your regular rules will include references to these, and much, much more for you, behind the scenes, where you never see it, to help you out. But it does not 'help' those externally referenced rules with 'Straight VB Code' set.
Wesley Crihfield

(Not an Autodesk Employee)