Forge APS Viewer – Revit颜色方案 – 如何从2D查看器获取房间颜色

huangapple go评论88阅读模式
英文:

Forge APS Viewer - Revit Color Scheme - How to get room color from 2D Viewer

问题

我们正在尝试从在2D查看器中查看的图纸中检索房间颜色(基于Revit颜色方案中的视图):

颜色方案在Revit中

出于此目的,我检索了所有的房间并获取了它们的材料:

const tree = model.getInstanceTree();
const frags = model.getFragmentList();

const getRoomsId = new Promise((resolve, reject) => {
	obj.model.search('Rooms', function (dbIds) {
		dbIds.some(dbId => {
			if (tree.getNodeName(dbId) === 'Rooms') {
				resolve(dbId)
				return true
			}
		})
	})
})

getRoomsId.then(function (roomsId) {
	tree.enumNodeChildren(roomsId,
	  function (childId) {
		tree.enumNodeFragments(childId, function (fragid) {
			const material = frags.getMaterial(fragid);
			console.log('Room: ', childId, ' / ', tree.getNodeName(childId), ' Fragment: ', fragid, ' Material: ', material.uuid)
		})
	   }
	)
})

不幸的是,正如下面的日志所示,它们似乎都具有相同的材料,因此我不知道颜色是从哪里来的:

根据日志,tree.enumNodeChildren(childId) 没有检索到任何东西,所以我想知道它是否以某种方式使用叠加来显示颜色。

非常感谢任何帮助。

英文:

We are trying to retrieve the Room colors (based on Views with Revit Color Scheme) from Sheets viewed in the 2D Viewer:

Forge APS Viewer – Revit颜色方案 – 如何从2D查看器获取房间颜色

Color Scheme in Revit

Forge APS Viewer – Revit颜色方案 – 如何从2D查看器获取房间颜色

For this purpose I retrieve all the rooms and get their materials:

const tree = model.getInstanceTree();
const frags = model.getFragmentList();

const getRoomsId = new Promise((resolve, reject) => {
	obj.model.search('Rooms', function (dbIds) {
		dbIds.some(dbId => {
			if (tree.getNodeName(dbId) === 'Rooms') {
				resolve(dbId)
				return true
			}
		})
	})
})

getRoomsId.then(function (roomsId) {
	tree.enumNodeChildren(roomsId,
	  function (childId) {
		tree.enumNodeFragments(childId, function (fragid) {
			const material = frags.getMaterial(fragid);
			console.log('Room: ', childId, ' / ', tree.getNodeName(childId), ' Fragment: ', fragid, ' Material: ', material.uuid)
		})
	   }
	)
})

Unfortunately they all seem to have the same material as shown in the log below, so I have no idea where the colors are coming from:

Forge APS Viewer – Revit颜色方案 – 如何从2D查看器获取房间颜色

tree.enumNodeChildren(childId)

doesn't retrieve anything so I wonder if somehow it is using an overlay to display the colors.

Any help is very much appreciated.

答案1

得分: 1

替代使用材质,2D查看器使用顶点颜色。

const mesh = frags.getVizmesh(fragId);
const vbr = new Autodesk.Viewing.Private.VertexBufferReader(mesh.geometry, viewer.impl.use2dInstancing);

var vertexCount = vbr.vcount;

for (var i = 0; i < vertexCount; i++) {
    // Each vertex knows its related dbId
    var dbId = vbr.getDbIdAt(i);
    // sign extend the upper byte to get back negative numbers (since per-vertex ids are clamped from 32 bit to 24 bit)
    dbId = dbId << 8 >> 8;
    var color = vbr.getColorAt(i)
    color = color >>> 0     // Signed to Unsigned 32
    color &= 0x00FFFFFF     // Getting rid of opacity
}

注意:颜色存储为GBR而不是RGB。

英文:

Instead of using Material the 2D Viewer uses Vertex colors.

    const mesh = frags.getVizmesh(fragId);
    const vbr = new Autodesk.Viewing.Private.VertexBufferReader(mesh.geometry, viewer.impl.use2dInstancing);

    var vertexCount = vbr.vcount;

    for (var i = 0; i &lt; vertexCount; i++) {
        // Each vertex knows its related dbId
        var dbId = vbr.getDbIdAt(i);
        // sign extend the upper byte to get back negative numbers (since per-vertex ids are clamped from 32 bit to 24 bit)
        dbId = dbId &lt;&lt; 8 &gt;&gt; 8;
        var color = vbr.getColorAt(i)
        color = color &gt;&gt;&gt; 0     // Signed to Unsigned 32
        color &amp;= 0x00FFFFFF     // Getting rid of opacity
    }

Note: The color is stored as GBR instead of RGB

huangapple
  • 本文由 发表于 2023年7月13日 14:41:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76676566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定