MoI discussion forum
MoI discussion forum

Full Version: Increment numbers on circular array

Show messages:  1-20  21-23

From: wisty
3 Mar   [#1]
I am trying to create a dial with the numbers 1-60 evenly spaced around the circumference. The dial and indices are simple using the circular array, and I can array a single number 60 times in the same way. What would be nice would be a way of he numbers and having a script to increment the values automatically, instead of having to rotate the dial for each position and insert a new number.
Has anyone done something like this, and cam point me at the sort of script that might do it?
From: Frenchy Pilou (PILOU)
3 Mar   [#2] In reply to [#1]
You can do anything you want with Elephant (Node Edditor)
but a little daily training is necessary! :)
https://moiscript.weebly.com/biblio-elephant.html

But you can also if the native Circular array is not sufficient
input any mathematical instruction inside the box enter!
something like 360 / 10 etc...
From: bemfarmer
3 Mar   [#3] In reply to [#1]
Hi wisty,

A search of "Draw several Numbers around a circle", yields:

https://stackoverflow.com/questions/29934480/draw-several-numbers-around-a-circle

also:

https://jsfiddle.net/ineffablep/x03f61db/

That jsfiddle code draws the numbers NON-radially, but the code provides valuable methods of generating the numbers.

The line:
code:
for(var i = 0; i < +$('input:text').val()+1; i++) {

looks like it generates the text numbers.

Then ad a For loop to place and rotate the 60 numbers... The For loop does the repetitive work.
Place i=1 (as text), at 12 O'clock, and rotate it -6 degrees. (with the rotate factory)
Place i=2 (as text), at 12 O'clock, and rotate it (-6 * i) degrees.
etc. up to i=60.

Gemarray might have useful code?

Note that to arrange 60 tangent circles with their centers on a big circle, the length of the side of the polygon, corresponding to the circle centers, is 2 TIMES the radius of the smaller circles.
This would yield the radius of the large circle. The 60 small circles could aid in sizing the text...

- Brian
(I do not have the time to do the details... and there may be a few shortcuts in MoI to generate the number texts, etc. :-)
I am a little fuzzy on how to generate the Text, and place it at 12 O,clock... and specify the text size, versus the big circle radius...

It is assumed that the numbers are to be oriented radially, like on the dial of a safe?
From: pressure (PEER)
3 Mar   [#4] In reply to [#1]
Hi Wisty,

For the rotation part it's better to use Transform > Array > Curve where the curve is a circle. I think the "Freeform" rotation option might be what you want:



But there's also a "None" option that could be a good for a stationary dial:



- Peer

Image Attachments:
wisty_freeform.png  wisty_none.png 


From: pressure (PEER)
3 Mar   [#5] In reply to [#1]
Hi wisty,

Try the attached plugin for converting a selection of non-sequenced text (i.e. the output of Array) into a sequence of numbers. If you select each number manually then the order of the sequence will be the same as the order that you select them in. If you select them all in one go with window selection then the order is determined by the arbitrary internal rules that Array follows.

If you want to try avoiding the trouble of selecting each annotation individually you'll need to play around with Array a bit to get a sense for how it orders things. You might also need to set a negative step value in this plugin to change from clockwise to counter-clockwise. To avoid all that hassle I'd select each piece of text manually unless the number of annotations is really large.

Install by going to MoI's appdata folder.

On Windows you can find the Moi appdata folder by typing Win+R to bring up the Windows "Run" dialog and then type in:
%AppData%\Moi\

On Mac from a Finder window, go to the menu and pick Go > "Go to folder" and type in:
~/Library/Application Support/Moi/

You should see the folders “commands” and "startup". Put numberSequence.htm and numberSequence.js in commands.

To set up a shortcut key go to Options > Shortcut Keys and type in numberSequence as the command name.

- Peer

Attachments:
numberSequence.zip


From: bemfarmer
3 Mar   [#6]
The MoI TEXT command can be used to add a number to the Dial, say number = 60. This is a TEXT 60, but a numerical value of a FOR Loop index would be the initial term in a new script, (incremented).

To add a TEXT 60 with the MoI TEXT command, (without user entry), I altered 2 lines of the Text.htm file, and commented out the normal default of text 'MoI'

code:
			function Initialize()
			{

// Brian's Test Code, 2 lines of code added to MoI TEXT command .htm file, and one line of code deleted, as a test.
				var i = 60;
				var InitText = i.toString();

//				var InitText = 'MoI';  //This is the original TEXT command line, commented out as a test.<<<<<<<<<
			
				try { InitText = moi.command.getOption( 'Text.htmDefaultText' ); }
				catch(e) { }
				
				text.value = InitText;
				
				if ( bold.value )
					text.style.fontWeight = 'bold';
					
				if ( italic.value )
					text.style.fontStyle = 'italic';
			}



Saved the altered Text.htm and Text.js files as TextRadial01, and added to the add-on scripts commands in MoI Appdata.
Running the altered script converts numerical index (i) to a text number (60 in the test case.)
(The altered code is just a temporary learning device, to learn how to turn 60 numeric into 60 text. I guess it is ASCII?, and is to be discarded.)

The MoI Text command can be used to add the initial Number to the 12 O'Clock position, and determine the desired Text factory defaults, for Font, Style, Size, Solid vs Surface, Centered, etc.

So a script could be written with a For loop increment from 1 to 60, with repetitive calls to the Text Factory, with the desired values of the previous sentence, and the 59 rotations mentioned previously.

- Brian
It is basic coding, but I find it hard, as an amateur programmer.
From: bemfarmer
4 Mar   [#7]
I am unsure, but suspect that substantial amounts of Text command code would need to be reproduced, to generate all 60 number characters. ???

- Brian
From: bemfarmer
4 Mar   [#8]
Create new script, DialTextGenerator, using most of the TextCommand code.

Feed script DialTextGenerator the "default" string '1 2 3 4 5 ... 58 59 60' , and save the result as an object list.

Then use the object list in a For loop to place the individual Text geometric entities that are in the objectlist.

- Brian

To center each entity at 12 o'clock??.
From: bemfarmer
4 Mar   [#9]
Run Text factory multiple times, using Text command support functions as needed, centering each text entity of one number, at 12 o'clock. Use .Calculate, to create objectlist for each individual number geometric entity, and append to all_numbers objectlist.
Then apply For loop to all_numbers objectlist, to rotate each geometric entity by the appropriate angle around the large circle. Update each placement, to add number geometric entity to geometry database.
-Brian

Spellchecker keeps changing what I type :-)
From: bemfarmer
4 Mar   [#10]
Create a rough draft of Dial layout, using big circle/ 60 sided polygon, with little tangent circles, centered at each vertex, (or centered at midpoint of each side of polygons.)

Decide on Size of numbers, center, font, etc.

-Brian
From: BurrMan
4 Mar   [#11] In reply to [#1]

This isn't “scripting” it with some type of an Array increment pattern, but i would probably just move towards “flow” for this.

UnwrapCurve your arc
Array extent count your dash
Type out text
Flow to arc

[Edit] Haven't tested yet. You may have to do some type of 360 incremental rotation on the text, so it remains vertically aligned as it rotates around the arc. I think there is a plugin that can do this as a pre flow op on typed text.


From: bemfarmer
4 Mar   [#12] In reply to [#11]
I agree that Flow is worth a try.
I came across a similar Rhino "flow" example during google searches.
There might be distortion issues?, and alignment/spacing issues?, and need to get the base line length right.

MoI Text command can easily generate the string of number geometric objects, ( 1 2 3 ... 60 ), to use flow with. (If spacings will work)

- Brian
From: danperk (SBEECH)
4 Mar   [#13]
I agree Flow would be a good approach, I haven't tried Elephant so I don't know if the Flow command can be used with it.

I set the numbers in Illustrator Tabs using unwrapped circle.


Image Attachments:
Flow_Cir.gif 


From: bemfarmer
4 Mar   [#14] In reply to [#13]
This looks excellent.

I wonder if there is any tiny distortion in the numbers?

- Brian
From: danperk (SBEECH)
4 Mar   [#15] In reply to [#14]
"I wonder if there is any tiny distortion in the numbers?"

Not if you check Rigid in the Flow command. In this case even without using Rigid the distortion is minor.
From: Barry-H
5 Mar   [#16]
Hi,
flow works ok in nodeditor.
Cheers
Barry



Updated:
Tidied up into a Macro allowing text rotation and easier to understand.

Update 2
New Nod File Clock Dial 2m
Modified again to speedup dial rotation.

Attachments:
Clock Dial 2m.nod

Image Attachments:
Screenshot (793).png 


From: wisty
5 Mar   [#17] In reply to [#16]
Thank you guys - most impressive response and (very) helpful. Suspect I am going to have to spend some time climbing a very steep learning curve!
This software is awesome in its power, but as Frenchy says you do need daily training!!
In particular thank you Barry for the .nod file. It looks like it does what I want - just have to work out what all the knobs and sliders do !!
Regards
From: wayne hill (WAYNEHILL5202)
5 Mar   [#18] In reply to [#16]
Hi Barry,


Excellent work on the node editor! Can the node be modified for text rotation? I made this perpetual calendar. The Cad/Cam software being used was difficult to get it right.

Thank you,

Wayne



From: Barry-H
5 Mar   [#19] In reply to [#18]
Hi Wayne,
see update have tidied up the nod into a Macro so text & dial rotation for alignment are adjustable.
Cheers
Barry
From: BurrMan
5 Mar   [#20] In reply to [#18]
Nice result Wayne! Really like your design.

Show messages:  1-20  21-23