Mapping patch structure
Is there a (non-manual!) way to "extract" the structure of a large patch? I'd like to see a tree structure diagram of all the external patchers and bpatchers that are contained within the top level patch.
My expectation is that I'm going to have to do this by hand, but I thought I'd ask, just in case ...
thanks
David
Here is some javascript that will walk the structure of a patch.
You can then format the output how you please...
-----------------------
autowatch = 1;
var n = "";
function list(x, y)
{
var p = max.frontpatcher;
var w = p.wind;
var o = p.firstobject;
x -= p.wind.location[0];
y -= p.wind.location[1];
post("xy(" + x + ", " + y + ")n");
post(p.wind.location[1] + " " + p.wind.location[1] + " " + "n");
while (o)
{
r = o.rect;
post(o.rect[0] + " " + o.rect[1] + " " + o.rect[2] + " " + o.rect[3] + "n");
if (x >= o.rect[0] && x = o.rect[1] && y
{
n = o.varname;
post("name = " + n + "n");
if (n)
{
post(getfullname(p, n),"n");
return;
}
}
o = o.nextobject;
}
post("nothing foundn")
}
function getfullname(p, n)
{
if (!p)
{
return n;
}
var o = p.box;
if (!o)
{
return n;
}
if (!o.varname)
{
post("parent patcher of", n, "has no namen");
return "";
}
else
{
n = o.varname + "::" + n;
return getfullname(p.parentpatcher, n);
}
}
hi Anthony, and thanks. Unfirtunately I know nothing about javascript, so apart from pasting the code into a js object (presumably at the top level of the patcher I want to trawl?) I have no idea what to do with this. Would yu mind enlightening me?
thanks
Davvid
Javascript is a very easy scripting language to
learn. You should definitely look at the javascript
tutorials. Javascript greatly enhances max's design
capabilities. Sometimes it is easier to do things
in code rather than building it graphically.
Save the file above as patch_traverse.js
Than save the following patch file...
This example shows you how to traverse a patch and find the
object you are clicking on. It should form a good basis for
what you want to do.
Thanks again Anthony. In the end it was easier to create a mind map by opening up each level of the patcher in turn and just seeing what's there. Took me about half an hour so that's ok.
I've made a couple of attempts to start getting my head around javascript, but I find there's to many bits mssing in my understanding for me to be able to make much sense of the help files. I may need something more basic to get me going.