We have code drawings with a lot of symbols on them, and on those drawings we also have to create a legend (the code symbols have an additional symbol that is code symbol name + " LEGEND"). I have been working on an iLogic to create a neat and tidy and in-order legend of all symbols based on which code symbols are on the drawing, and then let the user select the starting point for the legend, and insert the legend symbols within the page bounds. This would make doing these prints a lot more efficient and tidy and less time-consuming. And the iLogic works really well...until you try to save afterwards. For some reason, clicking the save button after running the iLogic does nothing. In fact, there is no response to any clicks in the Inventor ribbon at all. Additionally, Ctrl+S doesn't save, and the user is not prompted to save on closing Inventor (although close event iLogic triggers run, oddly enough), so as it stands this iLogic causes more harm than it does good.
I believe that this has to do with the code that prompts the user to click a point on the drawing sheet, and gets the start location for inserting the legend from that. The sections of the code that do that have been pasted below. I put it together referencing several posts on this forum, so there may be some redundancy in it, but hopefully someone can help me figure out why I can't click in the ribbon or save files after running this code.
Private oInsPoint As Point2d
Private bStillSelecting As Boolean
Private sheetborder As Double
Private WithEvents oInteraction As InteractionEvents
Private WithEvents oMouse As Inventor.MouseEvents
Public Sub GetPoint()
Dim oInteraction As InteractionEvents
oInteraction = ThisApplication.CommandManager.CreateInteractionEvents
Dim oMouse As MouseEvents
oMouse = oInteraction.MouseEvents
AddHandler oMouse.OnMouseDown ,AddressOf oMouse_OnMouseDown
'oInsPoint = New Point2d
oInteraction.Start
bStillSelecting = True
Do While bStillSelecting
'ThisApplication.StatusBarText = "Select Insertion Point For First Symbol In Legend"
ThisApplication.UserInterfaceManager.DoEvents
Loop
oInteraction.Stop
ThisApplication.CommandManager.StopActiveCommand
'oMouse = Nothing
'oInteraction = Nothing
'ThisApplication.CommandManager.ControlDefinitions("AppContextual_CancelCmd").Execute2(True)
'System.Windows.Forms.SendWait.SendKeys("{ESCAPE}")
End Sub
Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, View As Inventor.View)
oInsPoint = ThisApplication.TransientGeometry.CreatePoint2d(ModelPosition.X, ModelPosition.Y)
bStillSelecting = False
End Sub
Solved! Go to Solution.
Solved by Matthew_Policelli. Go to Solution.
I figured it out right after posting because of course 🙂 But for anyone who has this issue in the future, here is the issue, and the solution:
The problem was this line:
ThisApplication.UserInterfaceManager.DoEvents
Replacing it with the following did the trick:
System.Windows.Forms.Application.DoEvents()
However if there's anything else that could be improved about the cobbled together code, please let me know!
Can't find what you're looking for? Ask the community or share your knowledge.