referencing vb.net external rules

referencing vb.net external rules

snappyjazz
Collaborator Collaborator
507 Views
1 Reply
Message 1 of 2

referencing vb.net external rules

snappyjazz
Collaborator
Collaborator

Hello,

I have typed up code in vb.net that contains several subs, functions, and classes. I would like to run those subs and functions from an ilogic rule. I have tried two different ways with failed results. Early warning, I tried posting some code, but it exceeded the 100,000 character limit; anyway... I have tried:

 

  1. dll file
    1. I converted my code into class and saved as a dll file.
    2. in ilogic in the header I tried "AddResources" to the file and imported the class.
    3. In the body of the ilogic code I have access to the imported class, so I know it connects.
    4. This fails because the only options I can access in the dll are the classes, not the subs or functions.
  2. .vb file
    1. I saved my code as a module in a ".vb" file.
    2. in ilogic in the header I tried "AddVbFile" to the file.
    3. In the body of the ilogic code I have access to the ".vb" module, so I know it connects.
    4. This fails because of errors:
      1. Declaration expected
      2. Imports statements must precede any declarations

 

image.png

 

iLogic rule:

image.png

 

 

vb file

 

 

image.png

 

 

0 Likes
508 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

I have had some of the same problems using the external ilogic rule file route.  I have used this process successfully when it is very simple, but when the code in the external file gets complicated, I start getting those same sorts of error messages.

  • No errors when saving the external file within the iLogic rule editor
  • I can see that I have access to the external file and the function(s)
  • But when trying to run them, that's when the error messages pop-up.

There is still not much documentation about doing it this way.

It seems like a such big advantage to be able to have this system set-up right, but there don't appear to be many examples of others having a similar system set-up.

I had been using a few very simple independent sample codes this way, just to test the capability.

Some work without errors, while others don't.

 

I know the external rule file is supposed to have its "Straight VB Code" option turned on.

And I was enclosing the entire code within "Class ThisRule", then all the other code, then close out with "End Class".

I know this works for simple stuff.  However, I have also see people use the Module route, as you mentioned, and that seemed to work for them too.  But I haven't found a magic code that makes all the bugs go away.

It seems that once you turn on that "Straight VB Code" option, then use a Public Sub or Public Function etc, the Objects that are normally all recognized, all seem to loose their meanings, for some reason.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes