Forums > MaxMSP

jython: instantiating max class

Jan 11 2010 | 1:59 am

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

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

did i forget something?

Jan 11 2010 | 2:44 am


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

Jan 11 2010 | 2:48 am

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?


Jan 11 2010 | 2:49 am
Jan 11 2010 | 10:48 am

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.

Jan 11 2010 | 6:59 pm

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

Jan 13 2010 | 6:23 pm

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.

Viewing 7 posts - 1 through 7 (of 7 total)

Forums > MaxMSP