compas-dev / compas

Core packages of the COMPAS framework.
https://compas.dev/compas/
MIT License
311 stars 106 forks source link

`compas_rhino.utilities.delete_layers` deletes whole tree when given dict as input. #710

Open tetov opened 3 years ago

tetov commented 3 years ago

Describe the bug

Unexpected behavior when using a dict as parameter for compas_rhino.utilities.delete_layer.

(I might be misunderstanding though, let me know if so and I can probably updated docstring)

To Reproduce

Environment

Rhino Python Editor

Sample script

from compas_rhino.utilities import create_layers, delete_layers
layers = {'COMPAS': {'layers': {'Datastructures': {'layers': {'Mesh': {}, 'Network': {}}}}}, "SAPMOC": {}}
create_layers(layers)
delete_layers({'COMPAS': {'layers': {'Datastructures': {'layers': {'Network': {}}}}}})

Result

image

Expected result

image

Other environment details

Desktop (please complete the following information):

tomvanmele commented 3 years ago

perhaps we should provide the option to delete "endpoints" only?

tetov commented 3 years ago

Maybe, but that can be done with "COMPAS::Datastructures::Network".. I think just making sure that the more specific the input is, the more specific the action is. If the dict given contains sublayers down to an endpoint only the endpoint is removed. If it stops before then the last points tree is removed.