import maya.cmds as cmds import random #will need this to generate random buildings #User control parameters #---------------------------------------------------------------------------------------------------------------------------------------# #city name #terrain type (hilly/flat) #layout (regular/irregular grid or circular) #city spread area #number of blocks per dimension #number of buildings per block #width of road #gap between buildings #width of pavement #green coverage #city centre percentage #---------------------------------------------------------------------------------------------------------------------------------------# def createCityGUI(): #create GU for the user to select the parameters cityWindow = cmds.window (title = "City Generator 1.0", wh(400, 500), s=True) cmds.columnLayout (adjustableColumn=True, rowSpacing=5, cw=100, cal='left') cmds.showWindow(cityWindow) def deleteCity(): cmds.select(all=True) cmds.deleteCity() def createCity(): #fetch the control parameters from the createCityGUI and generate the city deleteCity() #delete the existing city before creating a new one #fetch the control parameters: __name = cmds.textFieldGrip('cityName', query=True, text=True) #do the same for the amount, gap, roadWidth, paveWidth, districtSize and citySpread makeCity('city', __amount, __gap, 5, roadWidth, __paveWidth, __districtSize, __citySpread) #----------------------------------------the main program starts with the following function--------------------------------------------# if __name__ == "__main__": createCityGUI()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question