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(&#39;{D98A091D-3A0F-4C3E-B36E-61F62068D488}&#39;, 0, 1, 0)<br>oApp=win32com.client.Dispatch(&quot;Inventor.Application&quot;)<br>

oApp.Visible=True<br>oApp_m=mod.Application(oApp)<br><br>button=oApp_m.CommandManager.ControlDefinitions.AddButtonDefinition(&quot;Dxf Update&quot;, &quot;dxf&quot;, 4)<br>button.AutoAddToGUI()<br><br>class BEvent():<br>
    def OnExecute(self, Context):<br>
        oPartDoc=oApp_m.Documents.Open(&quot;C:\\inventor\\2415 TRUNKING.ipt&quot;)<br>        <br>win32com.client.DispatchWithEvents(button, BEvent)<br></div>[/code]<br><br>All the code works expect for BEvent isn&#39;t called when button is pressed. I am not sure where to go from here.<br>