Jump to content
Developer Wiki and Function Reference Links ×

rotate hexagon symbols randomly - is there a script?


Recommended Posts

I have a range of symbols which are all hexagons of the same size (image). The contents differ, in this case being gradients, but they could be full of circles of different diameters representing plants (image). I want to rotate the hexagon symbols randomly.

is this possible with vectorscript? Has anyone does anything similar? And would there may a way of having rule control on which faces can touch others?

FWIW the project these are coming out of will have circa 400 hexagons.

Edited by nig
Link to comment

Very possible

This script will look for all the symbols named 'HEX' and rotate them around the insertion point of each symbol either 0,1,2,3,4 or 5 * 60 degrees.

I'll attach an example file.

hth

mk

Procedure RandomRotate;

{Badly scripted by Michael Klaers}

{April, 2014}

{? 2014, Small Group, Inc - Michael Klaers michaelk@verysmallgroup.com}

{Licensed under the GNU Lesser General Public License}

{Gets all the symbols named 'HEX' and rotates them by random (0-5) multiples of 60 degrees}

VAR

SymbolHandle : Handle; {Handle to Symbol}

RandomNum : Integer;

xLoc, yLoc : Real;

PROCEDURE SpinBySixty(SymbolHandle:HANDLE);

BEGIN

RandomNum := (((Random *10) / 2) DIV 1);

GetSymLoc(SymbolHandle, xLoc, yLoc);

HRotate(SymbolHandle, xLoc, yLoc, (RandomNum * 60) );

END;

BEGIN

ForEachObject(SpinBySixty, ((S='HEX')));

END;

RUN(RandomRotate);

Link to comment

Hi Michael, Not so badly scripted - amazing, works very nicely and solves a big problem for me.

I've enclosed my test file which has basic plant icons inside the hexagon symbol- the only problem I had was that I had to move the symbol insertion point to the centre of the symbol - before they were rotating off-centre.

How I intend to use is this is guidance for the planting team - there's no money available for field supervision, and the planters won't be trained gardeners, so this way a semi-random planting scheme can be very explicitly laid out with minimal notes. Will probably GPS hexagon centres to assist setout.

Link to comment

I wrote it while I was supposed to be doing something else :)

If I had another 15 minutes I would have had it get the name of a selected symbol and use the center of the object rather than the insertion point.

Looks like you have it figured out, but let me know if you need more help. I enjoy procrastination.

mk

Link to comment
And would there may a way of having rule control on which faces can touch others?

You could also load all of these symbols in an array and try to randomize them more according to your criteria.

If with faces you mean segments (green touching red ) that would be harder as a script can't "see" how a gradient changes

Link to comment

Procrastination time....

I intend to arrange the plants within the shape so that e.g. wetter tolerant plants are along say one face,, while say the opposite face was more drier tolerant species. Can the plugin be made so that wet faces don't end up adjacent to dry faces? I'm not sure if this is possible logically, let alone programmatically!

The colour coded example shows this type of relationship, eg red is dry, blue is wet.

The other mod would be a dropdown / or ability to select a new symbol name - possible or not?

Edited by nig
Link to comment
What do you mean by 'load all of these symbols in an array'? Do you mean programmatically or in a physical array on the screen?

Programmatically. Afterwards you can choose to change rotation and position of some elements or just reprint the whole array physically.

Procrastination time....

I intend to arrange the plants within the shape so that e.g. wetter tolerant plants are along say one face,, while say the opposite face was more drier tolerant species. Can the plugin be made so that wet faces don't end up adjacent to dry faces? I'm not sure if this is possible logically, let alone programmatically!

Simply put you could create a structure array holding the handle, insertion point ,type and an array of handle of each adjacent for each hexagon.( multidimensional array if you want to work with rows and columns)

From this point you can do some calculations on the order of elements and shift some based on your criteria.

Most of it will work out but you'll stumble on impossible combinations.

If 2 objects are adjacent its easy to rotate the 2nd one until it fits, but if that 2nd one has in total 6 around it you'll have make some choices..

Programmaticly you could manually assign a "degree ?" to a type of plant" (easy way) or you could work with subsymbols defining these

The other mod would be a dropdown / or ability to select a new symbol name - possible or not?

Not sure what you would like here, change all the symbols or just one ?

Edited by hippothamus
Link to comment
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...