Batch Create Snapshots from Infraworks 360 Bookmarks using Javascript

Using a few lines of Javascript code you can automate the process of creating snapshots for each bookmark in your model.

To run the code simply open the SCRIPTING editor and copy/paste the code below into the main window then click the START SCRIPT button and the code will iterate through the bookmarks of the current model and create a snapshot for each one. You can modify the length, width and location of the snapshot by modifying the variables in the code below. The snapshots that are created have the same name as their corresponding bookmarks.


// Some global vars…
var doc = app.ActiveDocument(); // the Active Document
var bmList = app.ActiveDocument().Bookmarks; // a variable to hold the list of bookmarks
var imgWidth = 1920; // snapshot width in pixels. change to your preference
var imgHeight = 1080; // snapshot height in pixels. change to your preference

// Loop through the bookmarks within the model
for (var i=0; i<bmList.length; i++) {
    var bm = bmList[i]; // list of bookmarks
    var strFilePath = “E:\temp\”; // Change this path to where you want your snapshots saved
    var bName = (bm.name); //gets the bookmark name
    var bmName = (bm.name+”.jpg”); // appends .JPG to the bookmark name
    strFilePath = strFilePath + bmName; // concatenate the string of the path (from above) and the bookmark name with .JPG
    CreateBookmarkSnapshot (bName, strFilePath); // pass the bookmark’s name and concatenated file path/name to the CreateBookmarkSnapshot function
}

// Create a snapshot of the active bookmark
function CreateBookmarkSnapshot (strBookMarkName, strJPGPath) {
    doc.MoveToBookmark(strBookMarkName); // activate the bookmark
    app.CreateSnapshot(strJPGPath, imgWidth, imgHeight); // create the snapshot using the defined path/name and width & height variables
}


And there you have it. A short, simple script to automate the sometimes tedious process of creating snapshots from multiple bookmarks.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s