Distance Align Then Distribute
I would like a script that does two things with the option of doing both or each individually.
It is just like the Distribute tools for layers in Photoshop.
Example: You have a scene with a handful of objects that you want to distribute.
http://www.scriptspot.com/files/distance.png
Option 1: The script takes the selected objects and without moving/adjusting the end objects (which would be the two objects furthest from each other) the script would align them all. Think of it as if you made a straight line between the 2 end objects and then moved each object in between to match that line.
http://www.scriptspot.com/files/distancealign.png
Option 2: Would take all the objects except for the 2 end objects and then evenly distribute those objects along the virtual line that would be drawn between the 2 end objects. Which would result in all the objects being evenly space apart based on there pivot or bounding box.
http://www.scriptspot.com/files/distancedistribute.png
Thanks
JokerMartini
Attachment | Size |
---|---|
distance.png | 40.81 KB |
distancealign.png | 40.78 KB |
distancedistribute.png | 39.9 KB |
Comments
One way to get the objects
One way to get the objects furthest away from each other is to use parts of the previous scripts (you can merge them later, I don't have much time right now so I leave that part to you), like:
Again, to use it just evaluate it and then you can pass it whatever you like, e.g.
getFurthestNodes selection
It selects the resulting nodes for you this time ;)Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
This is what I was looking for.
you'll have to make two objects as your start and end and the run the script on the selected objects. It is not a streamline thing just yet but I wanted to show you what i wrote as where i was going with this.
Make sure your start object is at 0,0,0
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
This is exactly the same as
This is exactly the same as the alignAndDistribute2 function if passed the type:#evenly argument with the exception that here you have to specify one object extra (and have one object at [0,0,0] coordinates) and as you don't sort the objects, they're aligned not based on their positions but rather their positions in the selection array (i.e. you get random results depending on the way you select them. As for finding out both the "border" nodes, in some sitations it could work, but those would be quite special. You have to pick at least one object as the starting one - that's what I did. I'm not sure if you tried the function, be sure to do it and then we can discuss what you think is missing/not working as you imagined.
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
Here you go:
Here you go:
Pass it some objects, a line (to keep it simple, it has to have 2 knots and 1 spline to work as expected) and distribution type. When object will be "out of the range" of the line (i.e. somewhere else than the other objects), the sorting may give unexpected results, but for the situation on your pictures, it will work. PointLineProj function implementation comes from prettyPixel.
Example usage: alignAndDistribute (selection as array) my_line type:#evenly
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
Well, looking at it again,
Well, looking at it again, looks like I should learn to read first :) Anyway, if you want to use it for object collection without a line, use this version instead:
Pass it some border object (it's hard to find one programatically in many situations when some coordinates you'd like to test against are the same and so on) and the rest of the objects to be aligned. Now it should be roughly what you wanted in the beginning.
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters