首页 > Windows开发 > 详细

View and Data API Tips: Hide elements in viewer completely

时间:2016-01-22 00:08:47      阅读:245      评论:0      收藏:0      [点我收藏+]

By Daniel Du

With View and Data API, you can hide some elements in viewer by calling “viewer.hide(dbIds)”, when the elements are hided, it actually make it transparent with a shallow mark to it, or make it ghosted. It is a nice feature as user probably need to know the existence of these elements even they are hided.  But you may want to hide elements completely instead of ghosting some times. Here are a code snippet you can use if you want to hide some elements totally.

    Autodesk.Viewing.Viewer3D.prototype.turnOff = function(dbIds){

        var node ;

        if (Array.isArray(dbIds)) {
            for (var i = 0; i < dbIds.length; i++) {
                var id = dbIds[i];

                node = viewer.model.getData(). instanceTree.dbIdToNode[id];

            }
            
        }
        else
        {
            node = viewer.model.getData(). instanceTree.dbIdToNode[dbIds];
         
        }

        //hide the node completedly
        viewer.impl.visibilityManager.setNodeOff(node, true);
        
      
    };

    Autodesk.Viewing.Viewer3D.prototype.turnOn = function(dbIds) {

        var node ;

       if (Array.isArray(dbIds)) {
            for (var i = 0; i < dbIds.length; i++) {
                var id = dbIds[i];

                node = viewer.model.getData(). 
instanceTree.dbIdToNode[id]; } } else { node = viewer.model.getData().instanceTree.dbIdToNode[dbIds]; } //show the node viewer.impl.visibilityManager.setNodeOff(node, false); };

 

The usage is very simple, just call “viewer.turnOff(arrayOfDbIds)” or “viewer.turnOf(arrayOfDbIds)”. Hope it helps.

View and Data API Tips: Hide elements in viewer completely

原文:http://www.cnblogs.com/junqilian/p/5149807.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!