Created
July 30, 2015 20:56
-
-
Save petfactory/1035e5c720be380fc5d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.core as pm | |
import math | |
w = 200 | |
h = 200 | |
rw = 50 | |
rh = 50 | |
num_rect_width = float(w)/rw | |
num_rect_height = float(h)/rh | |
# if the remainder is 0 we have an even count | |
if num_rect_width % 1 == 0: | |
count_x = int(num_rect_width) | |
else: | |
count_x = int(math.floor(num_rect_width) + 2) | |
# if the remainder is 0 we have an even count | |
if num_rect_height % 1 == 0: | |
count_y = int(num_rect_height) | |
else: | |
count_y = int(math.floor(num_rect_height) + 2) | |
#print('num x: {0}\nnum y: {1}'.format(num_rect_width, num_rect_height)) | |
#print('count x: {0}\ncount y: {1}'.format(count_x, count_y)) | |
# loop throughr rows and col | |
for row in range(count_y): | |
for col in range(count_x): | |
x1 = col * rw | |
x2 = x1 + rw | |
y1 = row * rh | |
y2 = y1 + rh | |
#print('row: {0} col: {1}'.format(row, col)) | |
#print(x1, x2, y1, y2) | |
pos_list = [ (x1, y1), | |
(x2, y1), | |
(x2, y2), | |
(x1, y2) | |
] | |
# add a z componenmt to the pos list | |
crv_pos_list = [ (p[0], p[1], 0) for p in pos_list ] | |
crv_pos_list.append(crv_pos_list[0]) | |
# build the crv | |
pm.curve(d=1, p=crv_pos_list, name='row_{0}_col_{1}'.format(row, col)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment