- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
On family document, I deleted unused materials and saved it through api . But family file size did not reduce as I expected. I tried it by manulal like attached files and result was the same.
Can I reduce the file size somehow? Actually, the number of materials are 100 and file size is over 2MB.
Here is my source code and please find attached file.
protected void DeleteUnusedMaterials()
{
Document doc = sData.FamilyDocument;
List<ElementId> MaterialIds = new List<ElementId>();
FilteredElementCollector materialCollector = new FilteredElementCollector(doc);
ICollection<Element> materials = materialCollector.OfClass(typeof(Material)).ToElements();
foreach (Element m in materials)
{
if (m.Name.Contains("ShIP_base"))
{
MaterialIds.Add(m.Id);
}
}
using (Transaction t = new Transaction(doc, "Delete unused materials"))
{
t.Start();
foreach (var id in MaterialIds)
{
doc.Delete(id);
}
t.Commit();
}
}
Solved! Go to Solution.