One of the most basic questions that we receive is, "How many assets are in my model?"
It turns out that there is no easy way to get this information from the user interface, but it's a pretty simple task with a JavaScript.
Here's what you do:
1. Open Infrastructure Modeler and load a model of choice
2. Select Window-->Scripting Window and
3. Paste the following code snippet into the window:
(Note that some browsers copy out hidden characters that won't run in Infrastructure Modeler. It may help to paste this to a simple text editor first.)
// Autodesk Infrastructure Modeler 2012 JavaScript example
// Name: Count All Model Assets
var tcount = 0;
var db = app.ActiveModelDb;
print();
print("Counting all assets in model");
print("----------------------------");
//Loop through the tables
for (i = 0; i < db.TableCount; i++){
//This line skips some internal tables that don't need to be counted
if (db.TableNames[i].slice(0,4) != "__jo"){
//Sum the number of records in each relevant table
count = db.Table(i).QueryRowCount();
if (count > 0){
print(" "+ db.TableNames[i] + " " + count);
tcount += count;
}
}
}
print();
print("Total selected: " + tcount);
print();
4. Click Start Script
5. You should see some output like this:
