本文介绍了Autodesk Forge Viewer:viewer.setThemingColor是否可以在转换后的DWG文件上使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

viewer.setThemingColor对我来说可以很好地将revit中的颜色更改为svf文件

viewer.setThemingColor works fine for me to change the color of something in a revit to svf file

但是当我尝试将其用于从DWG到SVF的转换时,它什么也没做.

but when i try and use it for a DWG to SVF conversion it does nothing.

oViewer.setThemingColor(1604, new THREE.Vector4(0, 1, 1,1));

请注意,我假设的一件事是,鼠标单击以进行选择的dbId与我需要用于setThemingColor的dbId相同.

Note one thing I am assuming is that the dbId that the mouse click does for seletion is the same dbId I need to use for setThemingColor

任何指针都会有所帮助.

Any pointers would be helpful.

推荐答案

这应该有效...您确定要传递正确的dbId吗?实际上,它对我有效.

That should work... Are you sure about you are passing a correct dbId? In fact it works on my side.

您可以尝试我的查看器游乐场.可能是您的模型有一个特定的问题,在这种情况下,您可以与我们分享该设计.如果需要,可以私下进行.

You can give it a try on my viewer playground. It could be that there is an issue specific to your model, in which case you could share that design with us. Privately if needed.

这是我的测试代码:

AutodeskNamespace("Autodesk.ADN.Viewing.Extension");

Autodesk.ADN.Viewing.Extension.Basic = function (viewer, options) {

  Autodesk.Viewing.Extension.call(this, viewer, options);

  var _this = this;

  _this.load = function () {

    viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, function(e){

      if(e.dbIdArray.length) {
        var dbId = e.dbIdArray[0];
        console.log('DbId: ' + dbId);
        viewer.setThemingColor(dbId, new THREE.Vector4(0, 1, 1,1));
      }
    })

    return true;
  };

  _this.unload = function () {

    return true;
  };
};

Autodesk.ADN.Viewing.Extension.Basic.prototype =
  Object.create(Autodesk.Viewing.Extension.prototype);

Autodesk.ADN.Viewing.Extension.Basic.prototype.constructor =
  Autodesk.ADN.Viewing.Extension.Basic;

Autodesk.Viewing.theExtensionManager.registerExtension(
  "Autodesk.ADN.Viewing.Extension.Basic",
  Autodesk.ADN.Viewing.Extension.Basic);

这篇关于Autodesk Forge Viewer:viewer.setThemingColor是否可以在转换后的DWG文件上使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!