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.

[code]
import win32com.client
from win32com.client import gencache

mod=gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
oApp=win32com.client.Dispatch("Inventor.Application")
oApp.Visible=True
oApp_m=mod.Application(oApp)

button=oApp_m.CommandManager.ControlDefinitions.AddButtonDefinition("Dxf
Update", "dxf", 4)
button.AutoAddToGUI()

class BEvent():
    def OnExecute(self, Context):
        oPartDoc=oApp_m.Documents.Open("C:\\inventor\\2415 TRUNKING.ipt")

win32com.client.DispatchWithEvents(button, BEvent)
[/code]

All the code works expect for BEvent isn't called when button is pressed. I
am not sure where to go from here.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to