To access the last head number in a document one can use: <texcode>\somestructureheadnumber[…][…]</texcode> The following example from the mailing list demonstrates how to use it.
<texcode>
}
</texcode>
For using inside a Metapost-environment you can use the expandable version:
<texcode>\somenamedheadnumber{…}{…}</texcode>