Modifications to rule to run from Visual Studio rather than just from Inventor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Currently, I have been editing rules in Notepad++, and running them from within Inventor (iLogic pane, or adding a button on ribbon). But I would like to start using Visual Studio 2019 to run/debug code while still maintaining the ability to run these rules from Inventor.
This code works fine when running from Inventor:
Public Class HelperClass
'Helper
End Class
Class ThisRule
Dim oDocument As Document 'Declaring variable here so it can be
'used across the subs/functions without having to pass it each time
Sub Main
'Code here
End Sub
Function DoStuff()
End Function
End Class
To run the above code in Visual Studio, I know I need a few differences. I have the Visual Studio project referencing "Autodesk.Inventor.Interop" and I know I need to create an object for the Inventor application:
Imports Inventor
Public Class HelperClass
'Helper
End Class
Class ThisRule
Dim ThisApplication As Inventor.Application
Dim oDocument As Document 'Declaring variable here so it can be
'used across the subs/functions without having to pass it each time
Sub Main()
ThisApplication = GetObject(, "Inventor.Application")
End Sub
Function DoStuff()
End Function
End Class
But the code above results in an error in VS2019 "No accessible 'Main' method with an appropriate signature was found". I tried various iterations of making "Main" and "ThisRule" either "Public", or "Shared", but admittedly I don't know the best way to use those keywords in practice.