At Autodesk University last week, Scott Kent and I both presented classes where we featured the ability to randomize the appearance of assets in Infrastructure Modeler.
We both introduced the idea of randomizing some mock up data mostly for demo purposes (it's hard to get redistribution rights for really good looking models), but it turns out that I've had several questions from folks on how to do this. Many people are turning to data sources like Open Street Map* or building footprint layers from local governments to have a context within which they will create their detailed project scenes. But they find that they don't know how to introduce some visual complexity that adds richness to that background data.
Using JavaScript and Style Rules, it's possible to randomize data in several different ways. Here are a couple of use cases:
- Random roof slopes
- Random building facades
- Random roof materials
- Random building heights
- Random tree heights
- ... and many more
I'll address the first three items here.
Random roof slopes
Did you know that in the Configure Dialog, nearly every field there can be populated with any of the following:
- fixed values (1, SomeName,...)
- FDO expressions (ROOF_HEIGHT *3.25, NAME + " " + ALT_NAME)
- JavaScript
- Attributes (NAME, DESCRIPTION, ALTERNATE_NAME)
The JavaScript route is what I often use to randomize roof slopes.
In the Roof Slope text field on a vector buildings import, type in the following:
Math.random()*35.0

Push OK and refresh when you have finished your other configurations... what do you see?
That's a quick and dirty mechanism that does produce some undesireable results. It's odd to see a gigantic airport or warehouse building with a 35 degree pitch, but then visit DIA...
I'm hoping you can see how this might also be useful to do things like randomize the heights of trees!
Using JavaScript for the whole import
Here's a secret. Underneath the covers, we are using JavaScript to drive much of the import process. So why not give our users access to that? We do.
In the Configure Dialog, after you have configured all the easy stuff, switch to the Script tab:

You'll see many of your configuration changes presented to you in script. Here you have the option to edit that script!
Note: Once you Edit the script, you will no longer be able to change the configuration on the other tabs unless you Revert.
If you dare, click the Edit button (you can always Revert, so it's hard to do harm).

The script should become editable. I then add a few lines such as this:
switch (SOURCE.FeatId % 3) {
case 0: BUILDINGS.ROOF_MATERIAL = "Roadways:Mat_MV_Diamond02";
break;
case 1: BUILDINGS.ROOF_MATERIAL = "Roofing:Shingles_Composite_Grey";
break;
default: BUILDINGS.ROOF_MATERIAL = "Roofing:Wood_Tile";
}
Note that the materials for the roofs come from the names of styles in the Style Palette. I insert the text so that I see this:

Then I push "OK & Refresh" and see what happens. If the import appears to do nothing, then I can check the Log window to see if there are any reported JavaScript errors.
TIP: When you're typing in the Script window, there is some help. Try typing the letter B then press CTRL+Space. See what happens.
Using the Style Rules
To style buildings with random facades, we don't even force you to use any scripting. You can use a really simple style rule to add a good amount of variety to your buildings. Here's what you do:
- Open the Style Rules window
- Click on the Buildings tab (if it's not already highlighted)
- Add a style rule using the green plus (+) sign and give it a name
- Open the style rule and add a couple of styles
- Then expand the window to the right a little bit... and enter some numbers into the Probability column; the numbers represent how often you want each facade to appear
- Accept the changes by clicking OK
- Press the green Refresh button on the lower right of the Style Rules interface to execute the rules
- See what happens!

Here's an example of these techniques applied to a model I created for AU. I hope this tip helped!

* One of the biggest missed opportunities in the crowdsourced geodata movement is that the OSM folks didn't think to have data collectors at least approximate the number of floors of assets like buildings. That would have made it 100x more useful for folks like Infrastructure Modeler users.