Notifications
Clear all

[Closed] calculating distance between objects

I launch your script on my scene and try it with distance range from 0 to 1000 and nothing happen. It seems you are my only help with this so please could you check it?

Few words of explanation:
I writing tool which gonna distinguish garbage objects accidentally binded to skeleton system or garbage just in hierarchy.
I have tons of hidden objects which are binded to my base objects or some of bones on many scenes like cloned morphtargets, splines, some geometry, objects which was cloned but some how original objects has hierarchy and hierarchy was transfer to other objects where objects was cloned, etc. Those objects are in a nutshell – “garbage” and make filesize x10. On some of scenes there are hundreds of such a garbage geometry which each has thousands of polygones or more.

So I want to get rid of those objects automatically.
As impossible it sound I managed with all hidden objects except objects in hierarchy.
I can’t distinguish it because it’s hierarchy – I don’t want remove animation system by accident. I could distinguish this object as : objects in hierarchy with more then 50 polygones without materials on it which is characteristic for standard bone-/ or animated objects. But still there can be objects like bones made from geometry which don’t fit to this formula also geometry like linked to bones like character items, splines which are part of rig systems,ik point,helpers and eventually geometry linked as animation chain forming animation system it self. So the only way to distinguish this floating garbage which are in hierarchy but are not part of any animation system is to check for distance in hierarchy. If objects don’t come into contact with each other and is child +distance-gap between objects in hierarchy(distance between children and root) is large(for instance >20 which distance for farthest bone is system is not> then 10) then mean is not part of animation system. I know there is way more factor to be checked if objects are in relation in other objects etc but as complex it sound, this part is almost complete.

and by
“Dystans should be as variable version 1) and version 2) 1 distance unit=1 parent size”

I mean, I’m not sure if this same distance is equal for different objects on different scenes so best way to keep always this same dystans in this case is use object parent size as unit of distance instead of just number unit. But I’m not sure about this.

It is very hard to make a working script without your scene.
But it seems that you have your algorithm in mind so you have to learn to write this script on your own to fit your exact needs (which are very very specific, apparently).

At least, do you understand the little script i wrote ?
If not, try to understand it reading the help about the maxscript commands contained in the script, then try to update it with your needs.

To be honest, your end goal is still very obscur to me :). I don’t see what I could do more there except doing the stuff in your final scene. But we are all here to help eachother, not to do eachother’s job ;).

If you have any other specific questions, you will find someone to help here, for sure, but you have to make an effort of understanding by yourself. Happy maxscript learning !

this is an example of misleading. instead of fixing a problem of an unreasoned scene choking you are cleaning the result.
usually a target is dependent when it’s not far from a source but when it does have a dependency.
so… any node that doesn’t have reference dependency with any ‘necessary’ node might be deleted.

Ok I guess you right but how to check it. I tried like this:

deselect (for o in selection where (o.children.count != 0) or (o.parent != undefined) and (refs.dependentNodes o).count == 1 collect o)

but this way don’t work, and It seems like any object in hierarchy have no refs.dependentNodes

Page 2 / 2