英文:
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:
Color Scheme in Revit
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:
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 < 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
}
Note: The color is stored as GBR instead of RGB
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论