@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)