Deleting All visualizations meeting a Specific Condition

How to remove all visualizations meeting one criteria ?
Deleting Visualizations may be very useful in many situations. One example is, if we want to remove all Line Charts (may be I am not interested in trends at the moment). This is how it can be achieved -
from Spotfire.Dxp.Application.Visuals import *
for p in Document.Pages:
for v in p.Visuals:
if str(v.TypeId) == "TypeIdentifier:Spotfire.LineChart": # Criteria
print v.Title
p.Visuals.Remove(v)
In case you want to keep it restricted to currently active page only,code is more simple -
from Spotfire.Dxp.Application.Visuals import *
for v in Document.ActivePageReference.Visuals:
if str(v.TypeId) == "TypeIdentifier:Spotfire.LineChart": # Criteria
print v.Title
Document.ActivePageReference.Visuals.Remove(v)
Share: