I want to view the dwg file in HOOPS_Communicator with a black background, the font display is the same color as autocad, and the font is white. How to achieve this? In other words, the viewing effect is consistent with Autocad.
The SheetManager class has the method setSheetColors which makes it possible to set colors for the background, the sheet itself and the sheet shadow color.
As for the text nodes, that can be set using the function setNodesColors. Admittedly however, there is not a streamlined way to identify the text nodes and change the color. This would have to be a feature request.
Hello, do you have any good ideas? Is there any way to quickly find the font color in the drawing and change black to white? Can you briefly describe the specific logic?
There is unfortunately no reliable way to identify text in the converted DWG file in the webviewer currently, as text is also rendered as mesh geometry and has no specific attributes attached to it. I agree with my colleague that support for this would be a feature request.
As previously mentioned, the text does not have an identifier to enable filtering only text.
That said, it’s possible to walk the entire tree and retrieve ALL the nodes for a given color, let’s say black. Here’s a quick code snippet to do that:
var blackArray = [];
async function walkNodes(nodeId) {
var children = hwv.model.getNodeChildren(nodeId);
for (var i = 0; i < children.length; i++) {
if (hwv.model.getNodeType(children[i]) == 3) {
var color = await hwv.model.getNodesEffectiveFaceColor([children[i]]);
if (color[0].r == 0 && color[0].g == 0 && color[0].b == 0) {
blackArray.push(children[i]);
}
}
await walkNodes(children[i]);
}
}
async function walkAllNodes() {
var rootId = hwv.model.getAbsoluteRootNode();
await walkNodes(rootId);
console.log("All nodes have been processed.");
}
walkAllNodes()
.then(() => {
console.log("Done processing all nodes.");
})
.catch((error) => {
console.error("An error occurred:", error);
});
You can then set the desired new color for the nodes in blackArray.