Workflow for using Visual Studio to write iLogic Rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have been working on a workflow to allow me to work in Visual Studio instead of the iLogic interface.
Firstly, I create classes which referance the iLogic class librarys. Example...
Imports Inventor
Imports Autodesk.iLogic.Interfaces
Public Class UCSDKS_EDGE
Sub PROCESS(ThisDoc As Inventor.PartDocument, _invApp As Application, iLogicVb As ILowLevelSupport, iProperties As IiProperties)
iProperties.Value("Project", "Part Number") = "TEST1"
iLogicVb.DocumentUpdate()
End Sub
End Class
I can then, with Build events, get my classes to be automatically coppied to a set location so that I can call them up from internal iLogic rules. Example...
AddVbFile "Z:\Working Folder\ILOGIC EXTERNAL RULES\Residential\UCSDKS\UCSDKS_EDGE.vb"
Sub Main()
Dim edge As New UCSDKS_EDGE
edge.PROCESS(ThisDoc.Document, ThisApplication, iLogicVb, iProperties)
End Sub
This is all great but I have one small issue in that I want to be able to Debug from inside Visual Studio. To do this I somehow need to pass the 'iLogicVb' and 'iProperties' objects into the class.
Module TestModule
Sub Main()
Dim _invApp As Inventor.Application
Dim _started As Boolean = False
Dim ucs As New UCSDKS.UCSDKS_EDGE
' Add any initialization after the InitializeComponent() call.
Try
_invApp = Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
Try
Dim invAppType As Type =
GetTypeFromProgID("Inventor.Application")
_invApp = CreateInstance(invAppType)
_invApp.Visible = True
'Note: if you shut down the Inventor session that was started
'this(way) there is still an Inventor.exe running. We will use
'this Boolean to test whether or not the Inventor App will
'need to be shut down.
_started = True
Catch ex2 As Exception
MsgBox(ex2.ToString())
MsgBox("Unable to get or start Inventor")
End Try
End Try
ucs.PROCESS(_invApp.ActiveDocument, _invApp, iLogicVb, iProperties)
'Release references
_invApp = Nothing
End Sub
End Module
Does anybody know how to do this?? Thanks in advance 🙂
Inventor 2013 Certified Professional
Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit