<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Dynamic Callbacks In Plugins</title>
	<atom:link href="http://www.softimageblog.com/archives/265/feed" rel="self" type="application/rss+xml" />
	<link>http://www.softimageblog.com/archives/265#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dynamic-callbacks-in-plugins</link>
	<description>People and thoughts behind Softimage in production...</description>
	<lastBuildDate>Fri, 23 Jul 2010 12:23:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: niko</title>
		<link>http://www.softimageblog.com/archives/265/comment-page-1#comment-17308</link>
		<dc:creator>niko</dc:creator>
		<pubDate>Wed, 09 Jul 2008 18:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=265#comment-17308</guid>
		<description>Salut Patrick,

I need to create some dynamically named functions (defs) for an adaptable creature setup. Those functions are OnChanged Event PPG functions of a customProp inside a plugin. So they need to be callable as &quot;%s_%s_OnChanged&quot; % (customProp.Name, dynamicParameter.Name). I&#039;ve downloaded your plugin and have tried to understand it but as you know I&#039;m not a pro when it comes to classes and I&#039;m still a bit lost. :S

I am wondering how to hack your code:

1- Which function do I need to modify to be able to pass customProp.Name and dynamicParameter.Name as arguments and it would give me back a callable function named: &quot;%s_%s_OnChanged&quot; % (customProp.Name, dynamicParameter.Name) ?

2- Which function I have to put my actual code into (the code that the properly renamed function would use - this function would need to know it&#039;s own dynamicParameter.Name to be able to find some parts of the Rig it&#039;s controlling) ? 

3- What is the best way to create and organise these functions so that I can have different code (some FK/IK switching code and some completely different code for Elbow Locking as an example) depending on different dynamicParameter.Name?

Thanks for any help!

niko</description>
		<content:encoded><![CDATA[<p>Salut Patrick,</p>
<p>I need to create some dynamically named functions (defs) for an adaptable creature setup. Those functions are OnChanged Event PPG functions of a customProp inside a plugin. So they need to be callable as &#8220;%s_%s_OnChanged&#8221; % (customProp.Name, dynamicParameter.Name). I&#8217;ve downloaded your plugin and have tried to understand it but as you know I&#8217;m not a pro when it comes to classes and I&#8217;m still a bit lost. :S</p>
<p>I am wondering how to hack your code:</p>
<p>1- Which function do I need to modify to be able to pass customProp.Name and dynamicParameter.Name as arguments and it would give me back a callable function named: &#8220;%s_%s_OnChanged&#8221; % (customProp.Name, dynamicParameter.Name) ?</p>
<p>2- Which function I have to put my actual code into (the code that the properly renamed function would use &#8211; this function would need to know it&#8217;s own dynamicParameter.Name to be able to find some parts of the Rig it&#8217;s controlling) ? </p>
<p>3- What is the best way to create and organise these functions so that I can have different code (some FK/IK switching code and some completely different code for Elbow Locking as an example) depending on different dynamicParameter.Name?</p>
<p>Thanks for any help!</p>
<p>niko</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Boucher</title>
		<link>http://www.softimageblog.com/archives/265/comment-page-1#comment-17293</link>
		<dc:creator>Patrick Boucher</dc:creator>
		<pubDate>Sat, 14 Jun 2008 02:30:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=265#comment-17293</guid>
		<description>Xavier covers two points accurately, if tersely.

As for the third, I don&#039;t know if it is a COM thing or an XSI thing but the callbacks in XSI Plugins can&#039;t just be callable items as defined by Python, they have to be methods or functions. If the callbacks could have been any callable we could have changed the call method in the Wrapper object to __call__ and we could have implemented the decorator as follows:

&lt;pre lang=&quot;python&quot; line=&quot;1&quot;&gt;def dynamic(func):
    return Wrapper(func)&lt;/pre&gt;

By doing it this way, the callback would have been the wrapper object itself and it would have eliminated the need to use im_self to go from the bound method to the instance.

In my opinion, if we could have done it that way, it would have made for cleaner code.

Hope this helps.</description>
		<content:encoded><![CDATA[<p>Xavier covers two points accurately, if tersely.</p>
<p>As for the third, I don&#8217;t know if it is a COM thing or an XSI thing but the callbacks in XSI Plugins can&#8217;t just be callable items as defined by Python, they have to be methods or functions. If the callbacks could have been any callable we could have changed the call method in the Wrapper object to __call__ and we could have implemented the decorator as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> dynamic<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> Wrapper<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>By doing it this way, the callback would have been the wrapper object itself and it would have eliminated the need to use im_self to go from the bound method to the instance.</p>
<p>In my opinion, if we could have done it that way, it would have made for cleaner code.</p>
<p>Hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xavier Lapointe</title>
		<link>http://www.softimageblog.com/archives/265/comment-page-1#comment-17292</link>
		<dc:creator>Xavier Lapointe</dc:creator>
		<pubDate>Fri, 13 Jun 2008 12:53:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=265#comment-17292</guid>
		<description>Hey Julian, 

about im_self:

&quot;Special read-only attributes: im_self is the class instance object, im_func is the function object; im_class is the class of im_self for bound methods, or the class that asked for the method for unbound methods);&quot;

See User-defined method -&gt; http://www.python.org/doc/2.2.3/ref/types.html

sys._getframe:

&quot;- A new function (python 2.1) sys._getframe(), returns the stack frame pointer of
  the caller.  This is intended only as a building block for
  higher-level mechanisms such as string interpolation.
&quot;
http://www.python.org/download/releases/2.1/NEWS.txt</description>
		<content:encoded><![CDATA[<p>Hey Julian, </p>
<p>about im_self:</p>
<p>&#8220;Special read-only attributes: im_self is the class instance object, im_func is the function object; im_class is the class of im_self for bound methods, or the class that asked for the method for unbound methods);&#8221;</p>
<p>See User-defined method -&gt; <a href="http://www.python.org/doc/2.2.3/ref/types.html" rel="nofollow">http://www.python.org/doc/2.2.3/ref/types.html</a></p>
<p>sys._getframe:</p>
<p>&#8220;- A new function (python 2.1) sys._getframe(), returns the stack frame pointer of<br />
  the caller.  This is intended only as a building block for<br />
  higher-level mechanisms such as string interpolation.<br />
&#8221;<br />
<a href="http://www.python.org/download/releases/2.1/NEWS.txt" rel="nofollow">http://www.python.org/download/releases/2.1/NEWS.txt</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julian Johnson</title>
		<link>http://www.softimageblog.com/archives/265/comment-page-1#comment-17290</link>
		<dc:creator>Julian Johnson</dc:creator>
		<pubDate>Fri, 13 Jun 2008 04:46:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=265#comment-17290</guid>
		<description>Patrick - if you get a chance could you go into more detail on sys._getframe, im_self and the use of the call method on the Wrapper object? Fascinating stuff...</description>
		<content:encoded><![CDATA[<p>Patrick &#8211; if you get a chance could you go into more detail on sys._getframe, im_self and the use of the call method on the Wrapper object? Fascinating stuff&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Boucher</title>
		<link>http://www.softimageblog.com/archives/265/comment-page-1#comment-17289</link>
		<dc:creator>Patrick Boucher</dc:creator>
		<pubDate>Thu, 12 Jun 2008 01:22:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=265#comment-17289</guid>
		<description>I should have mentioned that this idea started boiling in my subconscious after this thread on the XSI Mailing list: http://tinyurl.com/4cde9w.</description>
		<content:encoded><![CDATA[<p>I should have mentioned that this idea started boiling in my subconscious after this thread on the XSI Mailing list: <a href="http://tinyurl.com/4cde9w" rel="nofollow">http://tinyurl.com/4cde9w</a>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
