How to toggle cutting plane visibility and toggle cutting plane section?

How to toggle cutting plane visibility and toggle cutting plane section?
6

Hey @619944680 –

I think for the visibility you can try:

const cuttingManager = hwv.cuttingManager;
    const cuttingSection = cuttingManager.getCuttingSection(0);
    cuttingSection.setOpacity(0);
    cuttingSection.setOpacity(1);

@guido Probably would be more helpful for the cutting plane section bit though. :slight_smile:

@guido Hi,guido.
I would like to ask how to toggle cutting plane visibility and toggle cutting plane section as in the official example?

I think for the cutting section you don’t want to mess with the opacity but instead activate and deactivate it:
https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Communicator.CuttingSection.html#Communicator.CuttingSection.deactivate

@guido Hi,guido
I asked you about the cutting last time,But I think activate and deactivate cannot meet the demand.

Actually, I want to achieve these two button functions like the official example through JS code, rather than clicking on the button.
1697179758094
6

I see the titles of these two buttons are “Cutting Plane Visibility Toggle” and “Cutting Plane Section Toggle”.
So I would like to ask how the functions of these two buttons can be implemented through JS code?
Looking forward to your reply.
Thanks.

Unfortunately this functionality has not a simple one-line equivalent as the cutting/sectioning functionality is controlled via the UI classes. My suggestion would be to look through the typescript source code of the UI to understand how this functionality is exactly implemented.

The UI code can be found in the package in the web_viewer/typescript/ui folder. In there you should search for toggleReferenceGeometry and toggleCuttingMode which corresponds to the two buttons you mentioned.

I use toggleReferenceGeometry and toggleCuttingMode,But in my code, the console reported an error.

I have looked at the error code, which is shown in the following figure. May I ask what may be the cause? Did I accidentally make changes to certain parts of the code?


Hi,
those functions you mentioned are really internal to the cutting plane UI code and are not necessarily meant to be called from your code. Having said that, you would have to do something like this to call them from the UI object:

ui._cuttingPlaneController.toggleReferenceGeometry()

My suggestions would be to take the UI code as an example to write your own functionality on top of the cutting/sectioning functionality of the core HC api.

2 Likes