The headless API is intended to represent interactive CAD tasks in program code. This means that we basically have no user interface to interact with. We describe our intentions with code, line by line. This has a lot of advantages, but there are also difficulties we have to deal with. Especially tasks where we normally select geometry with the cursor, is not practicable. In this cases we would have to know where the exact position of geometry is found in the global coordinate system. This is hardly possible.
📝 Note: To use this method, you need to add the BuerliGeometry component to your application and set selection property true. Otherwise the selection of geometry won't work.
The selectGeometry method allows you to filter the types of graphic that are selectable. There's another optional parameter to define how many selections can be made before continuing with executing code. By default one selection is needed.
Here is a code snippet how to use the selectGeometry method.
The return value contains a lot of information about the made selection. If you want to continue with the graphic id of the selected graphic, e.g. to add a chamfer or use it as a reference, you will find the id in the "graphicId" property. In the following code snippet, the made selection will be used in the chamfer method.
There are also use cases where selections are not desired, because we don't want to let the user select anything. In this case there's another method called findGeometry. Within a part we can look for a specific type of graphic at a specific global position. The following code snippet shows an example where we want to find some planes at two different positions.
If the positions are correct it will return an array containing the two graphic ids of the found planes. We can use this ids for further operations.
See the selection in action in the next video.
You can find the whole example in our public application buerli-examples