jython: instantiating max class

Jan 11, 2010 at 1:59am

jython: instantiating max class

Hi, can someone help me,
I’m using jython (loadbang.net) with maxmsp and I try to use maxmsp class in jython. But I can’t instantiate a class
Here is what i do:
===code===
import com.cycling74.max
test = com.cycling74.max.MaxObject() # or
test = com.cycling74.max.MaxObject.getInstance()

test.outlet(0,”something”)
==end code===
and max message box returns me this error:
TypeError: No visible constructors for class (com.cycling74.max.MaxObject)

did i forget something?

#47697
Jan 11, 2010 at 2:44am

Hi-

Did you study the “jython.BasicUsage.mxt” patch that’s included with the distribution? I’m not hugely familiar with how it handles the MaxObject, but I don’t think you need to import or construct a reference to it to throw something down an outlet.

Best, Charles

#171523
Jan 11, 2010 at 2:48am

hi, thanks for your reply, yes I studied it and used it greatly so far.
But for my project need, it would be so handy for me to use this function (and other functions) within a class that is called by the main script.
I posted another message just after this one that explains that, can you have a look at it?

Gus

#171524
Jan 11, 2010 at 2:49am
#171525
Jan 11, 2010 at 10:48am

You can’t instantiate a MaxObject because it’s abstract. In practice, the MXJ machinery builds a MaxObject instance for you (which, if working in Java, you sub-class) and links it into Max via JNI – you can’t just create them dynamically.

In the Jython system I make the owning MaxObject instance available in the Python namespace as “maxObject” – you’ll need to pass this around, or wrap another object around it, in order to do output.

#171526
Jan 11, 2010 at 6:59pm

oh ok, thanks.
And is it the same for other classes? can we instantiate for example MaxClock and use its methods?

#171527
Jan 13, 2010 at 6:23pm

Depends: look at the javadocs (bundled in the Max distribution) to see which classes are abstract, and/or which ones have constructors which need arguments.

#171528

You must be logged in to reply to this topic.