Hey Chris,
I assume you're referring to that part:
"you're able to inherit some classes of the C++ API [..]  and create a
python binding to it using the Python API."

There is no magic.  Once you've inherited the desired class in cpp (in
which the CBase is part of the inheritance tree), write your extension
using the CPython API.  To provide a smoother inter-operability between
both, I rely on the pythoncom lib and the XSI::ConvertObject function.

I'm not going to implement a complete subclass (too lazy on a sunday), but
here is a sample that should show you the basic idea.  Note that
I omitted any security code for brevity.  For other folks, don't use that
in a production-context, it deserves much more love.
*First link of the list here. <http://www.jobenayoun.com/>*

There could be some drawbacks depending on what is your usage as well as
major differences between the two interfaces (C++ vs COM).  This is far
from being *perfect* nor *elegant*, but still, I consider this mechanism
valid for specific needs.
I would stay on my first suggestion for Jeremie tho, which is to wrap the
desired class directly in python as it's also the way recommended by Mark
Hammond himself according his book (he refers to it as the *delegate*
pattern).

=)
-- Jo






2012/7/12 Chris Chia <[email protected]>

> Will be interesting to see how u would implement that... Do share when you
> have something ;)
>
> Chris
>
> On 13 Jul, 2012, at 6:57 AM, "Jeremie Passerin" <[email protected]
> <mailto:[email protected]>> wrote:
>
> Thanks Jo,
>
> That was more a thinking I had rather than a real intention to do it...
> I'm looking for different way to organize my code. Thanks for the advice !
>
> On 11 July 2012 12:10, jo benayoun <[email protected]<mailto:
> [email protected]>> wrote:
> Hey Jeremie,
> considering the COM architecture (interfaces inheritance) + the python
> binding (dynamically invoking), this is really a bad idea to even think to
> inheritance...  The most easiest and elegant way that I think of is to wrap
> the desired object into a class.
> On another hand, you're able to inherit some classes of the C++ API (even
> if its not recommended and limited) and create a python binding to it using
> the Python API.  Not even sure, you will get what you're looking for.
> =(
> -- Jo
>
>
>
>
>
>
>
> 2012/7/10 Jeremie Passerin <[email protected]<mailto:[email protected]
> >>
> Hi list,
>
> I'm pretty sure I know the answer to that one but just wondering.
> Do we have a way in Python to create a class that inherits from a class of
> the softimage SDK ?
>
> Let's say I want to extend the SIVector3 or the Null object ?
>
> Any chance I could do something like that  ?
>
> class mySIVector3( SIVector3 )
> or
> class myCustomNull( Null )
>
>
> Jeremie
>
>
>

Reply via email to