Hi there,
when I use rs.DeleteObjects() to remove geometry from the scene, hidden objects are not deleted.
The documentation doesn’t say anything about the visiblity state.
please see my script to demonstrate this effect:
- Expected behaviour is that all objects are deleted, regardless of their visibility state.
- Actual behavior is that after running command ‘Show’ the hidden objects appear not to be deleted
best regards,
TIm
import rhinoscriptsyntax as rs
import random
data = [
{"x": 49.0678524495116, "y": 7.919379520865089, "z": 0},
{"x": 25.56026082842878, "y": 14.915053467815836, "z": 0},
{"x": 47.2731842519928, "y": 0.5888198323628968, "z": 0},
{"x": 5.856550407038497, "y": 31.827319204399195, "z": 0},
{"x": 1.7161146209003997, "y": 42.56881702080915, "z": 0},
{"x": 44.82476328457838, "y": 9.42424800111748, "z": 0},
{"x": 0.9370494436862387, "y": 28.9739049613968, "z": 0},
{"x": 16.39590751331968, "y": 14.23797380815779, "z": 0},
{"x": 7.113163914331578, "y": 5.346340324542603, "z": 0},
{"x": 1.2861890038707524, "y": 41.609614712757576, "z": 0},
{"x": 22.49536389779682, "y": 23.631381955753366, "z": 0},
{"x": 47.776179654336445, "y": 29.71259777000657, "z": 0},
{"x": 1.8519621153271493, "y": 9.07692372387341, "z": 0},
{"x": 10.271044565689097, "y": 8.25626816004248, "z": 0},
{"x": 6.7040562191802096, "y": 8.472688462636057, "z": 0},
{"x": 17.246187233196025, "y": 18.267583908935908, "z": 0},
{"x": 12.632308225756445, "y": 12.544157463464739, "z": 0},
{"x": 33.34157205412152, "y": 30.847526081157856, "z": 0},
{"x": 22.593954020732493, "y": 23.45088802015678, "z": 0},
{"x": 36.07346915168073, "y": 14.43192379491769, "z": 0}
]
def main():
# create empty document
rs.DocumentModified(False)
rs.Command("-New None", False)
rs.EnableRedraw(False)
# generate points from list
pts = []
for i, entry in enumerate(data):
pt = rs.AddPoint(entry['x'], entry['y'], entry['z'])
pts.append(pt)
# randomly hide some points
for pt in pts:
hide = random.choice([True, False])
if hide:
rs.HideObject(pt)
# delete all points
rs.DeleteObjects(pts)
# THIS COMMAND IS NORMALLY RUN BY THE USER VIA THE COMMAND BAR
# EXPECTED: nothing is shown, because all points were deleted
# ACTUAL: hidden points were not deleted
rs.Command('Show', False)
rs.EnableRedraw(True)
if __name__ == '__main__':
main()
1 post - 1 participant