I have a makepy generated class that returns an untyped object which needs to be cast into one of a couple other makepy generated classes.
My code starts with: import win32com.client as client mod = client.gencache.EnsureModule('{83A33D31-27C5-11CE-BFD4-00400513BB57}',0,SWAV,0) swApp = client.GetActiveObject("SldWorks.Application") model = swApp.ActiveDoc #Meant to be cast by the user to one of two interfaces. Returns a win32com.client.CDispatch CastTo (and the constructor for the generated class I need to cast to) fail to set _oleobj_ correctly. After poking around I got things to work with: swModel = mod.IModelDoc2(model) swModel.__dict__["_oleobj_"] = model._oleobj_.QueryInterface(mod.IModelDoc2.CLSID, pythoncom.IID_IDispatch) This feels like I'm doing something wrong. Is there a better way to do this?
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32