There are several common objects/variables that are defined for us behind the scenes within every iLogic rule, that we never see how their values are set. These are known as 'Rule Objects', and you can see a list of most of them at the following link.
https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=4ccb78b0-c35c-4d38-943a-854117da6ced
In order to use those objects/variables within our externally sources files, we must re-declare those variables locally in our external resources, then 'pass' these objects from the regular iLogic rule, to the external resource, as a way of setting the values of those variables in our external resources. There may be a couple we can get the values of in other ways, but that is the primary way. So, if your external resource is a Class, you might use its 'New' Sub routine to 'set' the values of those variables. Or a 'Initialize' routine for setting their values. Or just have public properties where you can set their values directly from the regular rule.
Edit: The 'ThisApplication' variable is not listed on that linked page, but is a similar type of object reference, and is often handled the same way. Or, some folks just declare their own variable to use as Inventor.Application, then use something like GetObject() or CreateObject() to set its value.
Wesley Crihfield

(Not an Autodesk Employee)