How to identify the features of face

Hello everyone!
I’ve written a simple web viewer and I want to be able to analyze the type of face (plane, cylinder, cone, etc.) when a face is selected, I’ve got the properties of the face in the code, but I don’t know what to do next, if I’m going in the right direction.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Click Face Example</title>
        #viewer {
            width: 100%;
            height: 100vh;
            position: relative;
            outline: none;
<div id="viewer"></div>
<script type="module">
    import * as Communicator from "./js/hoops/hoops-web-viewer.mjs";

    const hwv = new Communicator.WebViewer({
        containerId: "viewer",
        enginePath: "/js/hoops",
        endpointUri: "/data/microengine.scs",

        selectionArray: selectionFunc,

    function selectionFunc(selections) {
        if (selections.length > 0) {
            for (const selectionEvent of selections) {
                const selection = selectionEvent.getSelection();
                const nodeId = selection.getNodeId();
                if (selection.isFaceSelection()) {
                    const face = selection.getFaceEntity();
                    const entityId = face.getCadFaceIndex();
                    console.log('Face Id', entityId)

                    hwv.model.getNodeProperties(nodeId).then((nodeProperties) => {
                        console.log('Node Properties', nodeProperties)

                    hwv.model.getFaceAttributes(nodeId,entityId).then((Attributes) => {
                        Attributes.attributes.forEach((item) => {
                            console.log('Face Attribute', item)
                }else if (selection.isLineSelection()) {
                    const edge = selection.getLineEntity();
                    console.log('edge id', edge.getLineId())


My mother tongue is not English, I hope my expression is clear enough.

Hi @kabochow !

You are on the right track! You just need to call type() on the result from getFaceProperty.

Here’s a simple demo I quickly put together to demonstrate this:

I am not checking against all possible types in this demo, but you can find them all listed here: FaceType — HOOPS Communicator Documentation

Let me know if this isn’t clear or if you have any other issues.



Thank you beau
The examples you provided are very helpful to me. In addition to identifying the types of individual surfaces, I would also like to be able to recognize the shapes of combinations of surfaces, such as square holes, countersunk holes, keyway holes, conical holes, straight slots, T-slots, etc. This would allow me to apply it to my CNC machining automatic quoting feature.
The following is an example diagram in sequence:

Does HOOPS Communicator have methods for this? Can you provide some suggestions?

I’m trying to get the surface area of the face but getFaceProperty can’t get the surface area, is there any other way to get the surface area?

Hi @kabochow ,

Unfortunately, the level of feature recognition you are describing is not provided with the HOOPS Communicator SDK.

Regarding getting the surface area of a face with Communicator, it looks like @tino was able to to provide some guidance in this post. I would just add that you may also be able to calculate it if you are using HOOPS Exchange (which is part of HOOPS Web Platform). In this case, you’d be working with an additional API and need to link your Communicator and Exchange data.

1 Like