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.
It can solve problem when drawings_mode is “3D” with setNodesColors and getNodeEffectiveLineColor, but when this mode is “2D” and viewing dwg with sheet, both getNodeEffectiveFaceColor and setNodesColors are invalid. And I found part of nodes are PMI type, but I set PMI color also invalid.
How to change nodes color and PMI color when the drawings_mode setting as “3D”?
Using HotelFloorPlan drawing (2D) that is part of the quickstart module, I’m able to use both getNodeEffectiveFaceColor and setNodesColors. Worth pointing out is that in my example, I only created an array for nodes with a black color. The method getNodeEffectiveFaceColor takes a node id and a face id. And setNodesColor takes a color map and not an array.
Maybe if you could share snippets of our code or even the drawing file, this would make it easier to diagnose the issue.