accessing objects attributes in javascript

Oct 31, 2006 at 7:52pm

accessing objects attributes in javascript

Hi all,

Since it is possible to access all objects/subpatchers in an entire patch structure from javascript, is there a way to access registered attributes of these objects/subpatchers?

As it looks to me now, the only way to do this is to have javascript output a bindto message to a pattr outside the js object and connect the output of pattr back into the js object.

If anyone has some experience with this, I would love to hear about it.

Cheers,
Mattijs

#28458
Oct 31, 2006 at 8:10pm

On 10/31/06, Mattijs Kneppers wrote:
>
>
> Since it is possible to access all objects/subpatchers in an entire patch
> structure from javascript, is there a way to access registered attributes of
> these objects/subpatchers?

hmm interesting question. I don’t think you can do it just like that, but
I’ve been getting to know the jitter sdk and since you can instantiate any
jitter object in js I’m thinking it’s possible.

-write a jitter object that uses the interface for “findregistered” etc.
-give it an interface through object methods.
-instantiate the jitter object from js

I may be completely wrong here. To me it also sounds an awful lot like the
pattr interface, so maybe a jitterfied pattr object would be a cool
solution? (Jeremy?)

just some thoughts.

cheers, -thijs

#87387
Oct 31, 2006 at 9:14pm

Quote: thijskoerselman@gmail wrote on Tue, 31 October 2006 21:10
—————————————————-
mm interesting question. I don’t think you can do it just like that, but
> I’ve been getting to know the jitter sdk and since you can instantiate any
> jitter object in js I’m thinking it’s possible.
>
> -write a jitter object that uses the interface for “findregistered” etc.
> -give it an interface through object methods.
> -instantiate the jitter object from js
>

Thanks for your reply. If I get you right, you say first create an object, connect it to the js object, let it retrieve the attribute, delete the object. Interesting thought. And do I understand it correctly if I say that the reason why you want to use a custom jitter object instead of a plain pattr is that the jitter api supports reading not only pattr’s but all attributes of all objects?

> I may be completely wrong here. To me it also sounds an awful lot like the
> pattr interface, so maybe a jitterfied pattr object would be a cool
> solution? (Jeremy?)
>
> just some thoughts.
>
> cheers, -thijs
>
>
>
—————————————————-

#87388
Oct 31, 2006 at 11:59pm

I’m currently working on an advanced object oriented max solution
which addresses this problem.

heres a quick and dirty solution. write an abstraction wrapper for a
jit.object which saves attributes sent into the left inlet into a colol.

#87389
Nov 1, 2006 at 12:00pm

On 10/31/06, Mattijs Kneppers wrote:
>
>
> Thanks for your reply. If I get you right, you say first create an object,
> connect it to the js object, let it retrieve the attribute, delete the
> object. Interesting thought. And do I understand it correctly if I say that
> the reason why you want to use a custom jitter object instead of a plain
> pattr is that the jitter api supports reading not only pattr’s but all
> attributes of all objects?
>
>
No, that’s not what I meant…, if I get wat you mean:-).

I’m thinking its possible to change the attribute of any named/ registered
object in max through the C API. You can get a pointer to the object by
calling the findregistered function. Then you can change the attributes. But
you want to do this from javascript. JS can instantiate jitter objects. So I
was thinking:

- create / write / roll your own jitter object, which accepts messages for
binding to other named objects in max, but isn’t really processing matrices.

- instantiate the object in your js code.
- interface through the object.

As I said I might be wrong about this somewhere, but I see no reason why
this can’t work.

cheers, -thijs

#87390
Nov 2, 2006 at 8:49pm

Hmm, I don’t think I understand your idea of instantiating a jitter object. I’m curious, do you mean there is another way to instantiate a jitter object in JS apart from the patcher.newobject() method?

Thanks,
Mattijs

#87391
Nov 3, 2006 at 11:46am

On 11/2/06, Mattijs Kneppers wrote:
>
>
> Hmm, I don’t think I understand your idea of instantiating a jitter
> object. I’m curious, do you mean there is another way to instantiate a
> jitter object in JS apart from the patcher.newobject() method?

There is no need for physical objects in Jitter if you’re using JS. Check
out jitter tutorials 45 to 47.

best, -thijs

#87392
Nov 3, 2006 at 2:01pm

Quote: thijskoerselman@gmail wrote on Fri, 03 November 2006 12:46
—————————————————-
> There is no need for physical objects in Jitter if you’re using JS. Check
> out jitter tutorials 45 to 47.

Ah! Thanks for the pointer (basically rtfm ;). So this is not in the Javascript In Max doc, now I understand what you mean. I think it is a good idea, I will try as soon as I find some time.

Pity that this only seems to work with jitter objects. It would be nice if it was possible to instantiate a pattr object in this way. But well, I put the pattr object permanently outside the js object and use it to retrieve any pattr value I need inside the js. That works fine for now.

Cheers,
Mattijs

#87393

You must be logged in to reply to this topic.