Create event trigger for when placing first DrawingView onto new DrawingDocument (iLogic/VB.NET)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to create an event trigger for when I place the first drawing view onto a new drawing.
The new drawing may be started either by manually clicking the New button (AppFileNewCmd), choosing a drawing template, then placing the view (DrawingBaseViewCmd); or by right clicking the top browser node within my model file and choosing "Create Drawing View" (UCxCreateDrawingViewCmd). I prefer the second option, because it holds the model reference needed for the drawing view.
So the main code can be triggered to run by the "New Document" event of the (all) Drawings tab within the Event Triggers dialog, for simplicity.
When the code runs, I would like it to 'listen for' when I place that first drawing view. I have a couple other external iLogic rules I would like to run at this point using something like "iLogicVb.RunExternalRule("oRuleName")."
(One of which, copies all custom iProperties from the model to the drawing for use within the title block, notes, and other uses, which needs to access the ThisDrawing.ModelDocument to work.)
I sometimes use the "Event Watcher" standalone, and can only see two events listen within it that deal with Drawings. The "DrawingEvents.OnRetrieveDimensions" and the "DrawingViewEvents.OnViewUpdate", but neither seem to be the right one. I have dabbled with using the "TransactionEvents.OnCommit" and UserInputEvents.OnActivateCommand", but I think I may be missing something, and need to see more examples of how they're used.
This is my latest attempt, but it doesn't appear to be working.
Class ThisRule
Sub Main
Dim oContext As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
UINewDrawingView_OnActivateCommand("UCxCreateDrawingViewCmd",oContext)
End Sub
Private WithEvents oUINewDrawingView As UserInputEvents
Public Sub Activate(ByVal addInSiteObject123 As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) 'Implements Inventor.ApplicationAddInServer.Activate
oUINewDrawingView = ThisApplication.ApplicationEvents
End Sub
Private Sub UINewDrawingView_OnActivateCommand(CommandName As String, Context As Inventor.NameValueMap) Handles oUINewDrawingView.OnActivateCommand
If CommandName = "UCxCreateDrawingViewCmd" Then
'If CommandName = "DrawingBaseViewCmd" Then
iLogicVb.RunExternalRule("Copy All Custom iProperties from Model to Drawing")
End If
End Sub
End Class
I would ideally like to accomplish this using iLogic/VB.NET, but would also accept VBA, but I don't have the Admin rights to work with Addins at this time.
Any help would be greatly appreciated.
Wesley Crihfield
(Not an Autodesk Employee)