Removing objects in dash_vtk

Hello!

Please tell me how to correctly delete objects from dash_vtk.View, for example:

@app.callback(
        [Output("vtk-view", "children"), Output("add-btn", "n_clicks")],
    [Input("vtk-view", "clickInfo"), Input("vtk-view", "children"), Input("check_mode", "value"), Input("keyboard", "keydown"), Input("vtk-view", "hoverInfo"), Input("add-btn", "n_clicks")],
)
def change_view(clickData, Data, check_mode, event, hoverData, pushButton):
    if pushButton != 0:
        nameObj = clickData['representationId']
        state = getStateObj(Data, nameObj)
        xLength = state['xLength']
        yLength = state['yLength']
        zLength = state['zLength']
        center = state['center']
        ObjId = 'box-' + str(checkIdObj(Data, nameObj) + 1)
        new_box = dash_vtk.GeometryRepresentation([rect3d(xLength, yLength, zLength, center)], id=ObjId)
        Data.append(new_box)
        return Data, 0
    if clickData and check_mode == 'Delete':
        nameObj = clickData['representationId']
        i = findObj(Data, nameObj)
        if i:
            Data.__delitem__(i)
            return Data, 0

Here the ‘findObj’ function finds an object with the given id in the children data from ‘dash_vtk.View’. Then I delete by this index the element of the ‘Data’ list (it’s children from ‘dash_vtk.View’).
The problem is that after that the objects are really removed from the scene, but the scene itself is broken - rotation, zoom, artifacts appear. When rotating the graph, everything jumps in different directions.
What can be the problem, maybe after this action it is necessary to reconfigure the parameter ‘interactorSettings’ in ‘dash_vtk.View’, or?

Thank you in advance for your help!

1 Like