Select to view content in your preferred language

# Pass forward the exact number of faces after split in z/x

3594
6
06-04-2015 05:50 AM
Occasional Contributor

I need some help, I thought this would be straight forward 😉

I need to know how to pass the number of the faces after a split in the z and x direction. What my end goal should be is to create a recursion that will change the split distance until the number of faces equals a value. I want a grid of 9 faces (to make the test simple) and then I will need it to calculate the split size from that information.

So in case geometry.nFaces or split.total == 9 : do something else : go back and modify the split value + 1 or so.

If I try to print what is going on I can see that if I use nFaces I will get printed 1 nine times. If I use split.total I will get 3 nine times. How can I call the actual face number sum 9? If I report on this I wil get N = 9, Sum 27, Avg = 3.

I must forget something here!

Start-->

split(x) { scope.sx / 3 : split(z) {scope.sz / 3 : splitZ(split.total) }*}*

#split(z) { scope.sz / 8 : splitZ(split.total) }*

splitZ(N)-->

#case Z == 1 : color(1,0,0) else : color(1,0,1)

#case split.total == 2 : print(true) else : print(false)

print(N)

report("Grid", N)

#case Z == 7 : color (1,0,0) else :  color (1,1,0)

6 Replies
by Anonymous User
Not applicable

Kenneth,

Draw a picture you should. Illuminated your intentions will become. A photo you can take of this drawing. Posted here it should become.

Chris

Occasional Contributor

Ok, I go to my hardcore plan….

This actually the end result, but created manually. I will in this case try to place 80 points in a grid. In this rule I can manually change the split size to match 80 points. But if I would like 70, I should manually change the split size again. Not very parametric.

So I thought going the other way around, and automatically calculate the split size, from the number of points I would like.

My thought is to create a recursion that changes the split size when the number of points is not equal my selected amount, causing the points  to stand closer or further apart, and for that I guess I need to know when I’m hitting 80 points. Makes sense, or is there a more eatable solution ?

by Anonymous User
Not applicable

Ok, if I make like Yoda, I should expect a padawan thrown in there.

What's the goal of the points thingy?

by Anonymous User
Not applicable

Write a python script that changes the rule attributes and runs the rule over and over. Write the total points and attribute values into the reports for the model. Keep doing this until you get what you want. Keep changing the values and running until you get many attribute settings that get the right result. Make a fitness test for these and compare these against each other to get the best fit. You can make the first genetic solver for CE. Read here:

by Anonymous User
Not applicable

Do the results have to be in a grid as you show? Your grid is really just rows. There is a "noAdjust" parameter for the split operation if you need to split into a grid which lines up in both x and z directions. If the grid is not necessary, there might be other recursion options.

Regular Contributor

Hi Kenneth

Hehe, Chris was my Padavan .. hehe.. Hope he turns to the dark side too .. 😉

There is no way in CGA to get the information of how many shapes a split will produce 'before' you actually do the split. That is a well-known limitation of CGA.

E.g. if you have a zig-zagged shape and you cut off the 'spikes', CGA cannot 'foresee' the result. You only know if once the split was actually done.

Cheers,

Matt

Matthias Buehler

-------------------------------------

Garsdale Design Limited

www.garsdaledesign.co.uk