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">
<head>
    <meta charset="UTF-8">
    <title>Click Face Example</title>
    <style>
        #viewer {
            width: 100%;
            height: 100vh;
            position: relative;
            outline: none;
        }
    </style>
</head>
&lt;body&gt;
<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",
    });

    hwv.setCallbacks({
        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())
                }
            }
        }
    }

    hwv.start();
</script>
</body>
</html>

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

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: https://3dsandbox.techsoft3d.com/?snippet=8KB0g5yAkyoWH8KIWrMzUo

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.

Thanks!

2 Likes

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

Hi there,

According to the the 2024.4.0 release notes, the Communicator.SubentityProperties is now deprecated (and hidden).
The API to compensate for this deprecation is not documented yet (as far as I know) and It seams this API is far from compensate the deprecation (only Utils.isFace, Utils.isPlaneElement, Utils.isLineElement and a few more).

We’ve migrated to the version 2024.4.0 and as far as we tried the subentity properties object (origin, radius, normal, …) is always null (it looks props are not available anymore) and we can get the type of the face.

@beau.trifiro
Could you please explain how to do the simple demo you’ve made now the SubentityProperties are deprecated?
(And how to extract the subentity properties)

Thank!

Hi @aloys, I’ve created a feature request to undeprecate and unhide Communicator.SubentityProperties. I’ve reached out to the engineering team to see if there is anything missing from our documentation that would enable the capability in this demo and will follow up here if so. I apologize for the inconvenience this change has caused. If you are an existing partner with a support account, please create a feature request as well: https://support.techsoft3d.com/ (or you can let me know your organization so I can create one for you).

Hi @beau.trifiro,

Thanks!