Purge Unused Images
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I can't correctly purge unsed images.
I'd like to got the same result as the tool called "Manage Images"
When I want to purge, for example : TextNotes, I can use this method (founded in BuildingCoder thx) :
I collect all TextNotes type
I collect all TextNote instances, and for each instance I remove the ID of the Type in my Collection of TextNotes Type.
FilteredElementCollector collector = new FilteredElementCollector(BIM_Extracteur._doc);
//all textNotesTypes
ICollection<ElementId> textNotesTypes = collector.OfClass(typeof(TextNoteType)).ToElementIds().ToList();
//all TextNotes Instances
FilteredElementCollector textNotes = new FilteredElementCollector(BIM_Extracteur._doc).OfClass(typeof(TextNote));
foreach( TextNote textNote in textNotes )
{
bool removed = textNotesTypes.Remove(textNote.TextNoteType.Id);
}But, with Images, it is more difficult and strange look :
For imagesType, it works fine :the command is :
ICollection<ElementId> ImagesTypes = collector.OfClass(typeof(ImageType)).ToElementIds().ToList();
But, for Images Instance, there is no Image type because image instance is typeof Element.
If I use this :
FilteredElementCollector ImagesCollector = new FilteredElementCollector(BIM_Extracteur._doc); ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_RasterImages); ICollection<Element> images= collector.WherePasses(filter).ToElements();
The result is ImageType only
and when I use this :
ICollection<Element> images = new FilteredElementCollector(BIM_Extracteur._doc).OfCategory(BuiltInCategory.OST_RasterImages).ToElements();
Result is ImageType and Element for OST_RasterImage why?
And, if I got an image also used in Image parameter of my objets, that mean, I have to make a new filter to get all elements in all categories where image parameter containing my ImageType id?
Not sure to be very clear......sorry
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107