Basic city builder tool

Anonymous

Basic city builder tool

Anonymous
Not applicable

Using Python i'm looking to create a tool which extrudes the polyPlanes faces with "Keeping Faces Together" off to allow pavements between the buildings. I would like to be able to add  random height to the buildings. I'm very new to building scripts but not to Maya it's self, if someone could help point me in the right direction or know of a more efficient way to create this would be appreciated!

 

Thanks

Niall

0 Likes
Reply
Accepted solutions (1)
1,068 Views
7 Replies
Replies (7)

contact
Contributor
Contributor
Accepted solution

Hi!

This is written in MEL, but you can easily translate it to Python if you need.
You need to select the faces of the plane that you want to extrude before running it.

// 1: Extude the faces to form the base of the building
polyExtrudeFacet -keepFacesTogether 0 -localScale 0.7 0.7 0.7; // replace "0.7" with preferred building-to-street-width ratio
// 2: Extrude the building bases to form the roofs, but don't move them yet
polyExtrudeFacet -keepFacesTogether 0 -localScale 1.0 1.0 1.0; // reduce "1.0" if you want buildings to taper at the top
// 3: Move each building roof by a random amount
$faces = `ls -selection -flatten`;
for ($f in $faces) {
    $height = rand(1,2); // replace "1" and "2" with minimum building height and maximum building height
    move -r 0 $height 0 $f;
}

Hope it helps.

Anonymous
Not applicable

Wow! I'll give this a go later and translate it. Thanks a lot!

0 Likes

Anonymous
Not applicable

Translated to Python and it worked like a charm, thanks!

0 Likes

contact
Contributor
Contributor

Glad I could help.

For completeness, maybe you could share the Python version as well for other people looking for similar scripts.

0 Likes

Anonymous
Not applicable
Of course! It's slightly different in the sense that it creates the plane for you but yes, here it is. Thanks again. import maya.cmds as mc cmds.polyPlane( n='plg', w=10, h=10 ) cmds.polyExtrudeFacet( 'plg.f[0:99]', kft=False, ltz=2, ls=(.5, .5, 0), lt=(0., 0., 0.) ) cmds.polyExtrudeFacet( 'plg.f[0:99]', kft=False, ltz=2, lt=(0., 0., 2.) )
0 Likes

Anonymous
Not applicable
Can't seem to edit my comment to add this file so here it is.
0 Likes

Anonymous
Not applicable
import maya.cmds as mc cmds.polyPlane( n='plg', w=10, h=10 ) cmds.polyExtrudeFacet( 'plg.f[0:99]', kft=False, ltz=2, ls=(.5, .5, 0), lt=(0., 0., 0.) ) cmds.polyExtrudeFacet( 'plg.f[0:99]', kft=False, ltz=2, lt=(0., 0., 2.) )
0 Likes