Only the four main math families have a fixed family number: number 0 is the "math roman" font, number 1 is "math italic", number 2 is "math symbols" and number 3 is "math extensions". All the other defined alphabets or math symbol fonts get a family number (mathgroup number in LaTeXspeak) at their first use.
The main LaTeX macro that does the business of associating fonts to math families is
\check@mathfonts, that gets called for any math formula. The correspondence is not fixed, because fonts must change according to the current font size.
You can access the fontdimen parameters once a font has been associated to a mathgroup. So
should do. It's important to do it
\AtBeginDocument since many math font packages do their business at that moment.
The "box" approach is handy if what you want to access to is not one of the main four families; something has to be typeset in order to associate to, say,
\mathtt, a mathgroup number. For instance
will access the second fontdimen parameter relative to the font associated to