getting presentation coordinates of object

Feb 21, 2010 at 9:22pm

getting presentation coordinates of object

I would like to be able to get the coordinates of an object, knowing the object’s scripting name. I am currently using this message in Javascript, which works fine when not in presentation mode:

this.patcher.getnamed(the_object_scripting_name).rect

However what I really want to do is to get the presentation coordinates of the object, when in presentation mode. How do I do that?

BTW, if there’s a non-Javascript way to do this, I’m all ears.

Thanks!

#48683
Feb 21, 2010 at 9:37pm

Figured it out on my own – the coordinates delivered by the Javascript change to the presentation coords when in presentation mode. Still, interested if there’s a non-Javascript way to do it…

#174953
Feb 21, 2010 at 10:21pm

pattr can bind to many attributes, I know patching_rect is one of them, not sure about presentation_rect. check pattr for the right syntax ::

binding gives some interesting possibilities for UI layout, user customization, presets etc. of the positions of objects, not just windows.

#174954
Feb 22, 2010 at 5:10pm

Seejay, thanks very much — I had overlooked thinking about the pattr family for this. That said, I have never tried to use pattr to get/set some of these “common box attributes”, and after mucking about for a while I still can’t seem to do it. Can you give an example of how you can query a pattr for its bound-to object’s patching_rect for example?

Thank…

#174955
Feb 22, 2010 at 7:53pm

pattr my_pattr_name @bindto my_object_scripting_name::patching_rect

Not all the attributes can be bound, I don’t think, but probably most can. You could keep track of whatever info you want about your objects, and it updates as you edit, kind of the reverse of what we generally do—we use the mouse to move and resize, or send messages/use the Inspector to change attributes of objects. Now we’re getting the info from the “other side”, so we can mess with it or store it if we want… make different object layouts, appearance presets, restrict edit values to a range, fun stuff.

– Pasted Max Patch, click to expand. –
#174956
Feb 23, 2010 at 1:33am

Wow, that’s very cool – I never knew that pattr could do that! But now another question – all of my pattr bindings are taken care of by an autopattr object in my patches. Do you know how I can specify a specific attribute of my objects to bind to using an autopattr? Or am I really going to have to bind all my UI objects manually using this pattr syntax?

Thanks again!

#174957
Feb 23, 2010 at 2:17am

autopattr directly binds to the object (value) itself. If you need to bind to specific attribute of an object, then pattr @bindto theobject::somegreatattribtue is required.

#174958
Feb 23, 2010 at 7:27am

Not sure if this is especially helpful for you, as you can’t really bind to the object to make a preset in the same way that you can using pattr, but you can use pattrstorage/autopattr to send get and set attributes of bound objects:

– Pasted Max Patch, click to expand. –
#174959
Feb 23, 2010 at 3:16pm

Emmanuel and Ben – thanks very much.

Ben – that example is *very* helpful to me!! The documentation would benefit to get this level of detail in there at some point… (or perhaps I’ve just missed it?)

Dan

#174960
Feb 23, 2010 at 4:32pm

Wow, nice tricks are being shown here!
Randomly reading topics on the forum has its benefits!

#174961
Feb 23, 2010 at 6:13pm

you can take it a bit further, it’s nice to be able to get/set all the attributes from one place (pattrstorage). You could use [route] on the values that come out and are sent back in, and keep everything hidden away in a subpatch. And the same [pattrstorage] which remembers the attributes of certain numbers can also remember the values of other numbers, like the ones that set those attributes:

– Pasted Max Patch, click to expand. –
#174962
May 14, 2013 at 11:56pm

Or you can do that in this way…in presentation mode, whit different ways to store your presets…

– Pasted Max Patch, click to expand. –
#249362
May 19, 2013 at 2:52am

brilliant stuff…. this needs to be in doc!

#249805

You must be logged in to reply to this topic.