MoI discussion forum
MoI discussion forum

Full Version: Suggestion : Distribute objects

Show messages:  1-20  21-40  41-53

From: Marc (TELLIER)
3 Jul 2017   [#1]
Hi,

Maybe this has been suggested before but it would be nice to have a distribute objects command that would divide equal spaces between objects within the limits of the selection.

It could be a sub category of align...




Marc

Image Attachments:
Screen Shot 2017-07-03 at 10.39.46 AM.png 


From: Frenchy Pilou (PILOU)
3 Jul 2017   [#2] In reply to [#1]
Scale array ? ;)

Video in French! :)
http://piloumaison.weebly.com/le-scale-array.html
From: OSTexo
3 Jul 2017   [#3]
Hello,

+1 for Marcs suggestion. A true distribution feature integrated into the Align tool would be great, handy for exploded diagramming.
From: Michael Gibson
3 Jul 2017   [#4] In reply to [#1]
Hi Marc, I could probably write a script for this. If I understand correctly, the first and last one stay where they are and only the interior ones move?

Would there be a drop-down control for whether to do it in the x-axis, y-axis, or z-axis direction?

- Michael
From: Marc (TELLIER)
4 Jul 2017   [#5] In reply to [#4]
Hi Michael,

Yes, it would behave exactly as you described.
A drop down or radio butons would be nice.

Hi Pilou,

I dont think this command distribute the space in between objects.

Marc
From: Frenchy Pilou (PILOU)
4 Jul 2017   [#6] In reply to [#5]
There is ScriptArray! ;)
http://moi3d.com/forum/get_attachment.php?webtag=MOI&hash=f9e73123b45bafc8ff16093567a709d9&filename=ScriptArray.js

but you must edit the code for have that you want!



And I am sure that a little "Elephant" node can easily mke that you want!
From: Michael Gibson
4 Jul 2017   [#7] In reply to [#5]
Hi Marc, one thing that I'm not sure about is what to do if the objects overlap each other and there isn't room to make any spacing between them.

- Michael
From: Marc (TELLIER)
5 Jul 2017   [#8] In reply to [#7]
Hi Michael,

That's a good one, maybe distribute the by the object's center in this situation ?
Would it make sense in the command process ?

Marc
From: AlexPolo
6 Jul 2017   [#9]
here is the Illustrator align and distribute tool set - just as a possible future reference



From: Colin
6 Jul 2017   [#10]
Hi Michael,

Maybe I'm not fully understanding the original question correctly, but couldn't the "ArrayGem" script work for this?

I previously collected info & made myself notes on this script, they read as such:

>>This is for replicating a gemstone along a set of curves on a surface, aligning the gem to the surface normal. It uses a different spacing method than the other array commands - along with the objects to be arrayed you also specify a base circle and the spacing that you provide becomes the separating distance between each placed circle along the target area. For the targets you pick a surface, and a set of curves that have been projected on to that surface.

So note there that for this command to work properly, there must be a base circle also included among the objects that you want to have copied and the base circle should be selected along with the objects to copy at the same time. The center of the base circle will become the point that is placed on to the surface, and the diameter of the base circle will be taken as the size of the object.

Even though this is oriented towards placing gemstones for jewelry design, it could also be used for replicating quantities of any kind of object oriented normal to a target surface.<<

HTH, Colin
From: Michael Gibson
6 Jul 2017   [#11] In reply to [#10]
Hi Colin, well ArrayGem does do this type of spacing, but it makes copies of one single base object, it does not take a set of already existing objects and arrange them which is what Marc is asking for.

@Marc - I'll try either tonight or tomorrow to cook up a script for you.

- Michael
From: Colin
7 Jul 2017   [#12] In reply to [#11]
Hi Michael,

> it does not take a set of already existing objects and arrange them which is what Marc is asking for.<

Ahh, that's what I misunderstood.
Thanks for the clarification.

regards Colin
From: Michael Gibson
8 Jul 2017   [#13] In reply to [#1]
Hi Marc, please give the attached distribute plug-in a try, hopefully it will do what you were asking. Instructions for installing a plug-in here.

It works with an object's bounding box and an axis direction of x,y, or z that you can pick, it will move objects in that direction so they have equal distances between their bounding boxes like this:






The first and last objects stay in place, and if there's not enough room to fit all the objects in the space between the first and last they will have equal overlapping distances instead like this:






Hope that will be useful for now!

- Michael

EDIT: Jun 6, 2022 - updated Distribute script to have an option to set overall width to a specified value.

EDIT: Jul 22, 2022 - updated Distribute script to work with groups.

EDIT: Jul 24, 2022 - updated Distribute script to work in active construction plane.

Attachments:
Distribute.zip

Image Attachments:
distribute1.jpg  distribute2.jpg  distribute3.jpg  distribute4.jpg 


From: Frenchy Pilou (PILOU)
8 Jul 2017   [#14]
When objects are distributed can we have an option for have regrouped objets with o distance?
Or maybe it's yet integrated ? (but i don't find the trick with "Distribute" :)


From: Frenchy Pilou (PILOU)
8 Jul 2017   [#15]
Explode Move can make something for re-group but it's by "eyes", or numeric but not by snaping Bounding Box ! :)
And not sure that is easy to choose the good Origine Point with spheric or complex object!



PS Have also a no regular distribution can be also cool! (additive, multiplicative, Fibonacci, etc...)
From: Marc (TELLIER)
8 Jul 2017   [#16] In reply to [#13]
Hi Michael,

Thanks, it looks great !
I'll try this as soon as I can.

Marc
From: Michael Gibson
8 Jul 2017   [#17] In reply to [#14]
Hi Pilou,

> When objects are distributed can we have an option for have regrouped objets with o distance?
> Or maybe it's yet integrated ? (but i don't find the trick with "Distribute" :)

Well, earlier in this thread I had asked:

"If I understand correctly, the first and last one stay where they are and only the interior ones move?"

The one you're showing there has the last one moving, so it doesn't fit with the requirements.

But it is possible to make some modifications to the script so it will behave like you want, try saving Distribute.js and Distribute.htm to new files DistributePilou.js and DistributePilou.htm , then on line 48 there's a section of code that calculates the space, it looks like this:

code:
	var total_space = sorted[sorted.length-1].bounds.min[dir] - sorted[0].bounds.max[dir];
		
	var occupied_space = 0;
	for ( var i = 1; i < sorted.length-1; ++i )
		occupied_space += sorted[i].bounds.max[dir] - sorted[i].bounds.min[dir];
		
	var available_space = total_space - occupied_space;
		
	var target_space_between = available_space / (sorted.length-1);


Comment out that entire section and replace it with just var target_space_between = 0, so it should look like this:

code:
	/*
	var total_space = sorted[sorted.length-1].bounds.min[dir] - sorted[0].bounds.max[dir];
		
	var occupied_space = 0;
	for ( var i = 1; i < sorted.length-1; ++i )
		occupied_space += sorted[i].bounds.max[dir] - sorted[i].bounds.min[dir];
		
	var available_space = total_space - occupied_space;
		
	var target_space_between = available_space / (sorted.length-1);
	*/
	
	var target_space_between = 0;



Then the only other change is a couple lines below that is the loop that moves the objects, it looks like this:

code:
	for ( var i = 1; i < sorted.length-1; ++i )
	{


That loop needs to be adjusted to loop through sorted.length instead of sorted.length-1 , so if you take off the -1 so it looks like this:

code:
	for ( var i = 1; i < sorted.length; ++i )
	{


Then after that you should have a DistributePilou command that works like you wanted.

- Michael
From: Frenchy Pilou (PILOU)
9 Jul 2017   [#18] In reply to [#17]
Excellent! Bravo!
With the native Align functions that will be very helping for grouping objects!

French Version : http://moiscript.weebly.com/distributions.html

I believe that you must integrate this useful thing in the future V4! :)
(in Menu Align & Distribute? )

Function alone

With Align native. What a simplicity!

From: BurrMan
9 Jul 2017   [#19] In reply to [#18]
If someone could take the pilou version and add ui to allow a value entered for the space, that would make it "distribute" as i know it. That would be cool.
From: mkdm
9 Jul 2017   [#20] In reply to [#19]
Hi BurrMan.

This is the updated version I wrote some minutes ago.

Please check if all works fine.

The file to download : http://take.ms/qT3oZ

The UI's screenshot :



The numeric input accept also negative values.

Ciao.

Show messages:  1-20  21-40  41-53