@AndersDeleuran It appears that the list of GUIDS in addedIDsJson is from an earlier execution of the code. Initially upon loading the GH document, it would be empty, so no deletions would occur during the opening execution. That would leave 2 copies - the original and those created by the script. Subsequently, each time the Python script is run manually from GH, the objects created by the previous execution are deleted, then a new set of objects is created. Once again, that leaves 2 sets of objects - the original and those created by the latest execution.
I have included some debug Print statements to produce the output below. Taking as an example the large foreground surface, before opening the GH document, Rhino shows that its GUID is 1f6c8615-889a-4564-a365-066738691888. The GUID remains in the model, never being deleted by the script.
In the output from the second execution below, you will see that addedIDsJson and hence brpID for the deletion use the values stored in addedIDs from the first execution.
It appears that the delete could occur just before the add. I think the delete should use brp instead of brpID. The delete might have to be done after the add if it will cause the geometry to no longer be available for the add. I am having trouble finding the correct syntax for the object reference to be used in the delete command. In the course of trying different syntax, I have reintroduced rhinoscriptsyntax.
Output from the first manual execution of the Python script:
('addedIDsJson: ', '[
β6b9483e6-0558-44ca-aebd-181878a12482β, βd1c9d2a7-6e4c-4bd2-838e-2d3b41f9d5a5β,
βe0b70e43-d29c-46ec-967c-01ac3e3c9811β, β6e2e8a5d-6e60-42a8-8e59-ef8214de65cbβ,
β033a5da4-39bf-4ce8-b993-61dd5af7188bβ,
β879ea363-7192-49c2-bf1d-0f97730a0143β
]')
('brpID: ', β6b9483e6-0558-44ca-aebd-181878a12482β)
('brpID: ', βd1c9d2a7-6e4c-4bd2-838e-2d3b41f9d5a5β)
('brpID: ', βe0b70e43-d29c-46ec-967c-01ac3e3c9811β)
('brpID: ', β6e2e8a5d-6e60-42a8-8e59-ef8214de65cbβ)
('brpID: ', β033a5da4-39bf-4ce8-b993-61dd5af7188bβ)
('brpID: ', β879ea363-7192-49c2-bf1d-0f97730a0143β)
('addedIDs: ', [
β51d0478b-8350-4c49-8e29-d973f2bf51b5β,
β01a7017f-a3fe-4e35-860f-1717b5b6853cβ,
βa8f346c6-15a2-460e-b096-b8b4f9b8df67β,
β8546f59d-5c6c-4a32-b821-8391de545cf8β,
βdf06194f-ca7a-415e-a673-07122567fa44β,
β9440a22b-f46f-4c2c-b76f-631d7e2474fbβ])
Output from the second manual execution of the Python script:
('addedIDsJson: ', '[
β51d0478b-8350-4c49-8e29-d973f2bf51b5β,
β01a7017f-a3fe-4e35-860f-1717b5b6853cβ,
βa8f346c6-15a2-460e-b096-b8b4f9b8df67β,
β8546f59d-5c6c-4a32-b821-8391de545cf8β,
βdf06194f-ca7a-415e-a673-07122567fa44β,
β9440a22b-f46f-4c2c-b76f-631d7e2474fbβ
]')
('brpID: ', β51d0478b-8350-4c49-8e29-d973f2bf51b5β)
('brpID: ', β01a7017f-a3fe-4e35-860f-1717b5b6853cβ)
('brpID: ', βa8f346c6-15a2-460e-b096-b8b4f9b8df67β)
('brpID: ', β8546f59d-5c6c-4a32-b821-8391de545cf8β)
('brpID: ', βdf06194f-ca7a-415e-a673-07122567fa44β)
('brpID: ', β9440a22b-f46f-4c2c-b76f-631d7e2474fbβ)
('addedIDs: ', [
β5160a732-6527-4324-ba3c-44a1964ed01dβ, β3cec5ad9-6d2a-4af1-93ec-e3998b7d3fb0β,
β7ee9db7e-80a5-4423-b496-a7415b3c8f95β, β973cb7c3-7d0f-438e-83be-c4627cdbd58cβ, βf45f5ea5-5b5d-4281-8db9-d8b8ec837406β,
β2d8aebce-f0dc-40f0-a612-3270aa597bf5β
])
Regards, Garry.
GUID.3dm (7.8 MB)
251102_BakeSetIsocurveDensity_03.gh (10.9 KB)