Hi everyone. I am trying to write a small addin for Autodesk Inventor using COM but I am having trouble getting events to work with my script. I can type my code out in PythonWin and everything works as expected but when I save it out to .py file it just runs though and exits. The same thing seems to happen when I register it on my system as an inventor addin. Here is a small piece of sample code I have been using to try to sort this out.<br>
<br>[code]<br><div style="margin-left:40px">import win32com.client<br>from win32com.client import gencache<br><br>mod=gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)<br>oApp=win32com.client.Dispatch("Inventor.Application")<br>
oApp.Visible=True<br>oApp_m=mod.Application(oApp)<br><br>button=oApp_m.CommandManager.ControlDefinitions.AddButtonDefinition("Dxf Update", "dxf", 4)<br>button.AutoAddToGUI()<br><br>class BEvent():<br>
def OnExecute(self, Context):<br>
oPartDoc=oApp_m.Documents.Open("C:\\inventor\\2415 TRUNKING.ipt")<br> <br>win32com.client.DispatchWithEvents(button, BEvent)<br></div>[/code]<br><br>All the code works expect for BEvent isn't called when button is pressed. I am not sure where to go from here.<br>