21 Mar 2018

Event monitor for the Viewer

In order to understand what is going on inside the Viewer it can be useful to see the events that are firing at certain points.

Philippe already has a nice and polished solution for this implemented inside an Extension. However, I thought the below quick and dirty solution could be useful as well since it could be even used with the Viewer on the various Autodesk storage websites like A360 as described in this article - see above image.

function subscribeToAllEvents (viewer) {
    for (var key in Autodesk.Viewing) {
        if (key.endsWith("_EVENT")) {
            (function(eventName) {
               viewer.addEventListener(
                    Autodesk.Viewing[eventName],
                    function (event) {
                        console.log(eventName, event);
                    }
                ); 
            })(key);
        }
    }
}

 

Related Article

Posted By

Adam Nagy

Follow @AdamTheNagy Adam Nagy joined Autodesk back in 2005 and has been providing programming support, consulting, training and evangelism to external developers. He started his career in Budapest, then worked in Prague for 3 years and now lives in South England, UK. At the moment focusing on Inventor and Fusion 360, plus cloud and mobile related technologies. Adam has a degree in Software Engineering and has...