MoI discussion forum
MoI discussion forum

Full Version: Suggestion : Distribute objects

Show messages:  1-16  17-36  37-53

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.
From: Frenchy Pilou (PILOU)
9 Jul 2017   [#21] In reply to [#20]
Seems working fine for me! :)
Champagne!

The Manual button is tricky for have possibility (or not) to have the 0 distance (or numeric more or less) !

With a touch of native Align!


Of course a new Align Bottom on Front view will be necessary for align bottom the sphere!

French version tomorrow! ;)

PS Now a factor or something else for have a ruled distribution...will be a task!with

Here French Version ( with the error message when you select less than 3 objects! ;)
Will be named Distribution
http://moiscript.weebly.com/distributions.html

From: BurrMan
9 Jul 2017   [#22] In reply to [#20]
Thanks Marco,
Seems to work great!
From: BurrMan
9 Jul 2017   [#23] In reply to [#22]
Hey Marco,
As an added note (not really a request) instead of the manual tick, if the box just readout the distance from the original method. Then you can type from there (and someone can add viewport picking to the value too. It would save a step!

Anyway, thanks again!
From: Frenchy Pilou (PILOU)
10 Jul 2017   [#24]
So with Flow function! :)



or Script Array



or Scale Array


From: mkdm
10 Jul 2017   [#25] In reply to [#23]
Hi BurrMan.

You're welcome.

@You : "if the box just readout the distance from the original method."

I will try to add this feature later today.

See you.
From: mkdm
10 Jul 2017   [#26] In reply to [#24]
Hi Pilou.

@You : "So with Flow function! :)"

Kepp in mind that for this situation, if you don't use the "Rigid" option of the Flow command, the resulting surfaces will be deformed.
That is they will not have the same topology of the input objects and you will have a resulting objects with much more control points.

See you.

P.S. Maybe, besides NodeEditor, it should be some other different ways to perform a a REAL distribution of a bunch of objects along a defined curve.
If remember correctly, the Max's VSeed + VCLone scripts will do the job.

I have to try.

See you.
From: mkdm
10 Jul 2017   [#27]
Hi everyone.

I haven't found any good way to perform the "distribution and replication" of a bunch of objects along a target curve with Max's "Scatter" script family,
but maybe I did something wrong.

Anyway, speaking about the standard manual way, and not the Nodeeditor way, I've found a good solution using these bunch of commands/scripts :

UnwrapCurve, move, arraycurve, Flow, PointToMultiBolundsCenter (a simple script that places a point to a bounding box's center of an object).

This is the example video tutorial (112 MB, you can download it or view in streaming) : http://take.ms/fbBCt

See you.
From: Frenchy Pilou (PILOU)
10 Jul 2017   [#28] In reply to [#26]
< if you don't use the "Rigid" option of the Flow command
Yes it's for that my Spheres are not Ellipsoïd 3D! ;)
Ps and the first time i use rigid! :)
From: Frenchy Pilou (PILOU)
10 Jul 2017   [#29] In reply to [#27]
There is cool but semi manual method for distribute as you want some Objects
Moveslicetopoint! :)

http://moi3d.com/forum/index.php?webtag=MOI&msg=2749.36
From: mkdm
10 Jul 2017   [#30] In reply to [#29]
Thanks for the tip Pilou, but for what I remember about Moveslicetopoint, it's not meant to be used for distribution of objects along a path curve.

It's for other purposes.

Anyway, thanks for the reminder and I'm glad to know that my latest video tutorial was useful for you :)

Bye!
From: Marc (TELLIER)
11 Jul 2017   [#31]
Hi,

Thanks for taking the time to cook this Michael, works A-1.
Excellent Ideal Pilou about the fixed distance, thanks Marco !

I would definitely see these options in the align panel, just as a button that unfold the options once you press it.
Perhaps randomize command would also be nice to have in there too!

-Happy camper
From: Mindset (IGNITER)
20 Jun 2021   [#32] In reply to [#20]
Hey Marco,

The link no longer works... do you still have the file set?
If so, would you post them both here please?

Thanks,
Mindset
From: BurrMan
20 Jun 2021   [#33] In reply to [#32]
Hey Mindset,
Frenchy has archives too... see this post from a couple back....

https://moi3d.com/forum/lmessages.php?webtag=MOI&msg=8503.21
From: Mindset (IGNITER)
22 Jun 2021   [#34] In reply to [#33]
Thank you BurrMan and Pilou,

Translated into English via Microsoft Translator

Many Thanks.
Mindset
From: mk (MARKY)
3 Jun 2022   [#35] In reply to [#17]
Hi Michael,

I wonder if you can modify this script like this:

1. You have several objects selected.
2. You call the command.
3. It is asking you to set the distribution distance either by a numeric distance or by picking the desired point location, from the first to the last one, something like in image Alignment procedure.
4. The objects are evenly distributed within that distance.

Thanks,
Marek
From: Michael Gibson
3 Jun 2022   [#36] In reply to [#35]
Hi Marek, if you can post a .3dm model file with an example of before and after it was applied that would help me to make sure I understand what you are asking for.

- Michael

Show messages:  1-16  17-36  37-53