[python] scripting Snapshots command issue

Hi @dale

There seems to be an issue (may as well be designed this way) with the -snapshot command when used in a script:

If you create a couple of snapshots manually, then run the script below to create several snapshots.
Then comment out the creation part and uncomment the deletion part and run again:

import rhinoscriptsyntax as rs
import scriptcontext as sc



# Create snapshots
list_of_snapshot_names = ["ALA","BALA","NICA"]
for name in list_of_snapshot_names:
    rs.Command("-Snapshots Save {0} _Cancel".format(name))
#
"""
# Deleting all snapshots
list_of_snapshots = sc.doc.Snapshots.Names
for name in list_of_snapshots:
    print name
    rs.Command("-Snapshots Delete {0} _Cancel".format(name))
"""

Apparently you cannot delete snapshots that were created manually.
The script identifies them, prints their names but doesn’t delete them.

This seems to work:

import rhinoscriptsyntax as rs
import scriptcontext as sc

list_of_snapshot_names = ["ALA","BALA","NICA"]
for name in list_of_snapshot_names:
    rs.Command("-Snapshots Save {0} _Enter".format(name), False)

print sc.doc.Snapshots.Names.Length
    
for name in list_of_snapshot_names:
    rs.Command("-Snapshots Delete {0} _Enter".format(name), False)

print sc.doc.Snapshots.Names.Length

– Dale

It doesn’t work here.

Wait, you missed the point that my deletion part doesn’t try to delete only the names in the list above. It tries to delete all names taken from the list of snapshots in the document.

In the example you post above, as much as I understand it, you are trying to delete the names only from the list_of_snapshot_names

The issue I’m trying to point out is that this scripted command doesn’t delete snapshots created manually.