Batch Create Snapshots from InfraWorks using JavaScript - Part I

Batch Create Snapshots from InfraWorks using JavaScript - Part I

Did you know you can automate workflows in InfraWorks using JavaScript? It's true!!

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 loop through the bookmarks of the current model and create a snapshot for each one. You can modify the length, width and location of the snapshots by modifying the variables in the code below. The snapshots that are created have the same?name?as their corresponding?bookmarks.

// Some global variables...
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 = "C:\\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
}        

Curious to learn more?

Connect with me or subscribe to the Built Different newsletter for more insights on leveraging automation in AEC. You can also book some time with me to discuss how Autodesk Construction Cloud can help your team streamline your workflows and unlock the full potential of your project data.

要查看或添加评论,请登录

Matt Wunch的更多文章

  • InfraWorks and JavaScript - Part II

    InfraWorks and JavaScript - Part II

    In a previous article I showed you how you can automate the process of creating snapshots for each bookmark in your…

  • The Multitasking Mirage: Why Doing It All At Once Means Doing It All Worse (and Draining Your Brain)

    The Multitasking Mirage: Why Doing It All At Once Means Doing It All Worse (and Draining Your Brain)

    I used to think I was great at multitasking. I would be in a meeting listening to the conversations and sending emails…

  • Please don’t 'Like' or ‘Share’ this post!

    Please don’t 'Like' or ‘Share’ this post!

    Infinite scrolling. It's a simple concept, but it has a profound impact on our lives.

  • The Power of Structure: Unlocking Your Potential Through Daily Routines and Technology

    The Power of Structure: Unlocking Your Potential Through Daily Routines and Technology

    I'm a big fan of having structured, daily routines, and when those routines are disrupted I find myself feeling less…

    1 条评论
  • Sabbatical Edition

    Sabbatical Edition

    Where have I been? So, it's been a while since I've posted a new edition of Built Different, and for good reason: I've…

  • What Drives You?

    What Drives You?

    Have you ever wondered why some employees go above and beyond while others simply clock in and clock out? The answer…

    1 条评论
  • Autodesk Reality Capture Solutions

    Autodesk Reality Capture Solutions

    Introduction You know the importance of having reliable and up-to-date information about your projects. Whether you are…

  • Digital Transformation

    Digital Transformation

    Let's talk about Digital Transformation and why the traditional approach of AEC & D&M firms – delivering projects on…

  • The Future is Generation Z

    The Future is Generation Z

    The AEC (Architecture, Engineering, Construction) and D&M (Design & Manufacturing) industries are on the precipice of a…

    3 条评论
  • Beyond the Grind

    Beyond the Grind

    For far too long, the AEC & D&M industries have glorified "the grind." Long hours, constant stress, and sacrificing…

    1 条评论

社区洞察

其他会员也浏览了