this question is kinda complex, so bear with me. basically, im trying to make my script generate a square city by creating a building, then moving it along the x axis. once the building is in place, i want the script to call a function that places n number of building along the y axis. then it would repeat this n times to get a square city.
here is the section of the code that involves the city generation:
############################################
#CITY STUFF
############################################
###########city
#generates buildings along x axis
def city():
global height
global T_width
global depth
global T_buildnum
global EVENT_NOEVENT,EVENT_DRAW,EVENT_EXIT, EVENT_CITY
for n in range(T_buildnum.val):
Building(T_height.val, T_width.val, T_depth.val)
sel = Blender.Object.GetSelected()
for obj in sel:
objlocx = obj.LocX
objlocx = (n * T_width.val) + (T_width.val * n)
obj.LocX = objlocx
City2()
#adds randomness
r = whrandom.random()
if r < 0.7:
r = r + 1
objsizex = obj.SizeX
objsizex = objsizex * r
obj.SizeX = objsizex
#adds randomness
r_2 = whrandom.random()
if r_2 < 0.7:
r_2 = r_2 + 1
objsizez = obj.SizeZ
objsizez = objsizez * r_2
obj.SizeZ = objsizez
#adds randomness
r_3 = whrandom.random()
if r_3 < 0.7:
r_3 = r_3 + 1
objsizey = obj.SizeY
objsizey = objsizey * r_3
obj.SizeY = objsizey
###############################################################
def City2():
global height
global T_width
global depth
global T_buildnum
global EVENT_NOEVENT,EVENT_DRAW,EVENT_EXIT, EVENT_CITY
global objlocx
print('hello')
for n in range(T_buildnum.val):
Building(T_height.val, T_width.val, T_depth.val)
#adds randomness
r = whrandom.random()
if r < 0.7:
r = r + 1
sel = Blender.Object.GetSelected()
print(sel)
for obj in sel:
objlocy = obj.LocY
objlocy = (n * T_depth.val) + (T_depth.val * n)
obj.LocY = objlocy
objsizex = obj.SizeX
objsizex = objsizex * r
obj.SizeX = objsizex
print(r)
#adds randomness
r_2 = whrandom.random()
if r_2 < 0.7:
r_2 = r_2 + 1
objsizez = obj.SizeZ
objsizez = objsizez * r_2
obj.SizeZ = objsizez
print(r_2)
#adds randomness
r_3 = whrandom.random()
if r_3 < 0.7:
r_3 = r_3 + 1
objsizey = obj.SizeY
objsizey = objsizey * r_3
obj.SizeY = objsizey
the function city creates buildings along the x axis, and the function city2() creates buildings along the y axis. T_buildnum is the number of buildings, set by the user in a GUI button
how and where can i make it so that city() calls city2() each time it loops?
thanks for the help, but im still having the same problem. i can get both functions to work, but the y-axis buildings are only generated from the first x-axis building. (confused? i mean all the y axis buildings are bunching up, they’re not spreading out according to the location of the x axis building)
any other ideas?
thanks
then its your code, if i wasn’t busy i’d go through it and i probably will when i get sick of BlODEd so if noone’s helped you by tomorrow then i’ll go through it. sound good?
hey everyone starts somewhere. its probablyt your values for distance moved, check those first cause if it is buildign them jsut too close together increase your build distance.