Are you planning on handling its triggering entirely with iLogic rules, or do you intend to use an add-in? Add-ins load when Inventor starts, and iLogic itself is an add-in. Plus, the iLogic add-in doesn't really initialize in the user interface until we either open an existing Inventor file, or start a 'New' one for the first time after starting Inventor. So, if you wanted to keep it simple, you could put it in the iLogic 'Event Triggers' dialog, on the 'All Documents' tab, under the 'New Document' event, and under the 'After Open Document' event. But if you do it that way, the rule will likely get ran a lot of times, so it should be pretty efficient. If using an add-in, I think they can use the ApplicationEvents.OnReady Event which is associated with the Application.Ready property, but I am not experienced in add-in development yet.
By the way, here is another example you can review or modify however you want. I intentionally made the hardcoded file path & name generic, so you would have to edit those before testing it. The first 2 are not being used right now, so they could be eliminated. There are other properties or methods related to the projects which can use them, but they are not present in this example.
Sub Main
Const sProjPath As String = "C:\Temp\"
Const sProjFileName As String = "MyInventorProject.ipj"
Const sProjFile As String = "C:\Temp\MyInventorProject.ipj"
Dim oProjMgr As Inventor.DesignProjectManager = ThisApplication.DesignProjectManager
'get FullFileName of active DesignProject
Dim sActiveProj As String = oProjMgr.ActiveDesignProject.FullFileName
'only react if it is not the one expected / wanted
If Not sActiveProj = sProjFile Then
'Log it, or let user know
Logger.Info("Active Project File Is: " & sActiveProj)
'MessageBox.Show("Active Project File Is: " & sActiveProj)
'try to find / get the DesignProject we want, by its FullFileName
Dim oMyProj As Inventor.DesignProject = Nothing
Try
oMyProj = oProjMgr.DesignProjects.ItemByName(sProjFile)
Catch
Logger.Warn("Specified Inventor DesignProject Not Fount In Projects Collection!")
End Try
'if it was not found in that collection, then add it
If oMyProj Is Nothing Then
Try
oMyProj = oProjMgr.DesignProjects.AddExisting(sProjFile)
Catch
Logger.Error("Error Adding Specified DesignProject To Projects Collection!")
End Try
End If
'if we now have it, then activate it
If oMyProj IsNot Nothing Then
Try
'True = Set as Default Project
oMyProj.Activate(True)
Catch
Logger.Error("Error Activating Specified DesignProject!")
End Try
End If
End If
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)