I've told my self to not continue creating more scripts and REALLY starting to make some animation once and for all!...
But I said "what the hell! I get fun creating scripts!, so go fot it!" and here I am with an new adventure.
Someone said that my sort_shapes script need the other 3D scripts to perform a Z sort of shapes. That's completely true and one cannot work with the other.
But it is true also that the sort-shapes scritp don't need to retrieve the information from the 3D script exclusively. It can obtain the "Z value" from any other source.
I have figured out how to do it.
First I have to create an script that (at frame 0) create a bone for the selected shape. That bone would have special characteristics:
1.- Its name is based on Shape's ID + a extension (it maybe ".sh"). For example Shape 23 would have a associated bone called "23.sh"
2.- The bone's relative X position would represent the shape "Z position". It is 3D meanless and its only porpouse is that the embedded script can perform the "Z" sort.
In this way it is so easy to retrieve the "Z" of a shape. Just composite its corresponding bone's name based on shape's ID, locate the bone and get its "Z value" (represented by the X value of the bone).
The problem comes when the embedded script raise or lower a shape based on its "Z" value. Then the link with the bone is broken due to the fact that the every shape's ID is also its staking order (so the script change its internal shape's ID everytime it rasie or lower it)
To solve that I have realizaed that I can make the same change into the bones's names. Just warp the bone corresponding to the shape to be raised (lower) and its upper (lower) bone and change its name accordingly.
In this way I don't need to store any information on the shape and probably the script would work better that the other for 3D (besides that it would do less calculations). Bone's names are changing by frames as well as shapes changes its ID.
The user only would take care about bone's X positions.
Let's do it! It would be SO FUN!

-G