<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">HI,</div><div class=""><br class=""></div><div class="">I am trying to use Python to access an Application’s API that has been exposed in C#.  The API uses a client/server model via COM objects (main GUI is the client, functional blocks e.g. Schematic editor implemented as a server.</div><div class=""><br class=""></div><div class="">I have successfully called a number of API methods from python (e.g. to show a message dialog) in the application.</div><div class=""><br class=""></div><div class="">However, when I try to access the interface to the client or server, in Python I get back an object of type System.__ComObject (when these should be of type IClient or ISch_ServerInterface respectively) which then throws a method or operation not implemented error.</div><div class=""><br class=""></div><div class="">I have had some success calling methods via the unbound method e.g.</div><div class=""><br class=""></div><div class="">import DXP</div><div class="">client = DXP.GlobalVars.Client # of type System.__ComObject should be DXP.IClient</div><div class=""><br class=""></div><div class="">DXP.IClient.GetProductVersion(client) # works!</div><div class=""><br class=""></div><div class="">client.GetProductVersion() # throws method or operation not implemented error</div><div class=""><br class=""></div><div class="">Using this work-around would be fine, except that I am now encountering errors where the interface types have been extended e.g.</div><div class=""><br class=""></div><div class="">import EDP</div><div class="">import SCH</div><div class="">server = SCH.GlobalVar.SchServer # of type System.__ComObject should be SCH.ISch_ServerInterface</div><div class=""><br class=""></div><div class="">SCH.ISch_ServerInterface.CreateSchLibrary(server) # throws type has no attribute error</div><div class="">SCH.ISch_ServerInterfaceHelper.CreateSchLibrary(server) # this works</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">This works in C#</div><div class=""><br class=""></div><div class="">using EDP; // looks like the extension methods are implemented in here</div><div class="">using SCH;</div><div class=""><br class=""></div><div class="">SCH.ISch_ServerInterface server = SCH.GlobalVars.SchServer;</div><div class="">SCH.ISch_Lib lib = server.CreateSchLibrary();</div><div class=""><br class=""></div><div class="">Ideally, I would be able to do some kind of type cast in Python to allow me to use the objects naturally but can use the unbound method if the extension issue can be solved.  </div><div class="">I have tried using clr.ImportExtensons() without success.</div><div class=""><br class=""></div><div class="">Any help appreciated.</div><div class=""><br class=""></div><div class="">Best Regards,</div><div class="">Evan</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> </div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div apple-content-edited="true" class="">
<div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><b class="">Evan Davey<br class=""></b><br class=""><font face="Helvetica" color="#23aac8" style="color: rgb(35, 170, 200);" class=""><b class="">Ekidna</b></font><br class="">Email: <a href="mailto:evan.davey@ekidna.io" class="">evan.davey@ekidna.io</a><br class="">Skype: evan.j.davey<br class="">Mobile: +61 403 467 661</div><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://uk.linkedin.com/pub/evan-davey/4/982/91/" class="">uk.linkedin.com/pub/evan-davey/4/982/91/</a></div><div class=""><a href="https://twitter.com/ekidna_io" class="">https://twitter.com/ekidna_io</a></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
<br class=""></body></html>