<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254107</link>
    <title>MATLAB Central Newsreader - Calling a Python COM object from MATLAB</title>
    <description>Feed for thread: Calling a Python COM object from MATLAB</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 18 Jun 2009 22:00:04 -0400</pubDate>
      <title>Calling a Python COM object from MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254107#658615</link>
      <author>Santiago Balestrini</author>
      <description>Okay, so I need to call a Python COM object from MATLAB. I can do it from Excel just fine, but when I use ACTXSERVER it seems to load it but when queried for methods and other things it just seems to be empty.&lt;br&gt;
&lt;br&gt;
In MATLAB I type the call below to get a handle h to the Python object (the Python code is at the end of the post)&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; h = actxserver('python.try2')&lt;br&gt;
&amp;nbsp;&lt;br&gt;
h =&lt;br&gt;
&amp;nbsp;&lt;br&gt;
	COM.python_try2&lt;br&gt;
&lt;br&gt;
when I use the methods function to see what methods the object has, I only get the MATLAB ones:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; methods(h)&lt;br&gt;
&lt;br&gt;
Methods for class COM.python_try2:&lt;br&gt;
&lt;br&gt;
addproperty      deleteproperty   interfaces       move             save             &lt;br&gt;
constructorargs  events           invoke           propedit         send             &lt;br&gt;
delete           get              load             release          set    &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
This is the Python test code:&lt;br&gt;
&lt;br&gt;
class PythonUtilities:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_public_methods_ = ['hello']&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_reg_progid_ = &quot;Python.Try2&quot;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_reg_clsid_ = &quot;{19353e9b-964a-4b1c-8cd1-baccc0209af3}&quot;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;def hello(self, string):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return string&lt;br&gt;
&lt;br&gt;
if __name__=='__main__':&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;Registering COM server...&quot;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;import win32com.server.register&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;win32com.server.register.UseCommandLine(PythonUtilities)&lt;br&gt;
&lt;br&gt;
Any ideas are welcome, at the very least, thanks for reading this post.&lt;br&gt;
&lt;br&gt;
-Santiago</description>
    </item>
    <item>
      <pubDate>Sat, 20 Jun 2009 19:02:02 -0400</pubDate>
      <title>Re: Calling a Python COM object from MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254107#659005</link>
      <author>Yair Altman</author>
      <description>I'm guessing you need to load your Python class object before being able to use it.&lt;br&gt;
&lt;br&gt;
In any case, try using my UIINSPECT utility on the file exchange instead of the built-in methods function: &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/17935&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/17935&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Yair Altman &lt;br&gt;
&lt;a href=&quot;http://UndocumentedMatlab.com&quot;&gt;http://UndocumentedMatlab.com&lt;/a&gt; &lt;br&gt;
&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Mon, 22 Jun 2009 18:14:01 -0400</pubDate>
      <title>Re: Calling a Python COM object from MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254107#659456</link>
      <author>Christopher Taylor</author>
      <description>&quot;Yair Altman&quot; &amp;lt;altmanyDEL@gmailDEL.comDEL&amp;gt; wrote in message &amp;lt;h1jbna$t8c$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I'm guessing you need to load your Python class object before being able to use it.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In any case, try using my UIINSPECT utility on the file exchange instead of the built-in methods function: &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/17935&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/17935&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yair Altman &lt;br&gt;
&amp;gt; &lt;a href=&quot;http://UndocumentedMatlab.com&quot;&gt;http://UndocumentedMatlab.com&lt;/a&gt; &lt;br&gt;
&lt;br&gt;
Hello, &lt;br&gt;
&amp;nbsp;&amp;nbsp;I am the other person working on this project.  Thanks for the reply, when I run your uiinspect, I have the same problem of not being able to see the 'hello' method from the python class. I just get the same methods if I call the built in methods functions.  When you say the python class object needs to be loaded, what did you mean by this? I thought that by calling the actxserver('python.try2')  function I was loading the python class.  Is there something else that I have to do to load the object?&lt;br&gt;
Again thank you for the reply.&lt;br&gt;
-Christopher Taylor</description>
    </item>
  </channel>
</rss>

