hey there,
I have a tool which deletes fill patterns in a family. Up till Revit 2014 it worked, but now in 2015 it doesn't anymore.
It looks like the standard Fill Patterns like Solid fill, Vertical, Diagonal up, Crosshatch ect. can't be deleted anymore??
With RevitLookup I concluded that all 'standard' fill patterns have an ElementId which consists of less digits then 'user fill patterns'.
So I've made the workaround like below, but this will only bypass them. Does anybody know how I can delete these standard fill patterns in a family ?
public static void RemoveFillPatterns(Document doc)
{
List<FillPatternElement> fillp = new FilteredElementCollector(doc).WherePasses(new ElementClassFilter(typeof(FillPatternElement))).OfType<FillPatternElement>().ToList();
foreach (FillPatternElement HatchPattern in fillp)
{
try
{
if (HatchPattern.Id.ToString().Length > 5) doc.Delete(HatchPattern.Id);
}
catch (Exception ex)
{
// apperently a standard fill pattern which can't be deleted in 2015
MessageBox.Show(ex.Message);
}
}
}
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Yes, apparently that is normal.
Don't worry about the language, it is fine!
Best regards,
Jeremy
Eek, I am finding that it is working to well - all of the patterns except the Solid Fill ones are being deleted even if they are used in some regions.
Is there a way to filter out the ones that are being used in Regions?
Thanks
Hello,
Is there already some sort of workaround for the solid fill deleting issue?
I now have a project with like 100 solid fills and would like to purge these. Dynamo couldn't delete them either...
Tried hatchkit as well without any results.
Anybody solved this?
@kyeungнаписал (-а):Hello,
Is there already some sort of workaround for the solid fill deleting issue?
I now have a project with like 100 solid fills and would like to purge these. Dynamo couldn't delete them either...
Tried hatchkit as well without any results.
Anybody solved this?
Yes. Yesterday there was a similar task - I solved the problem in 5 minutes))
So, there is a file in which 30 solid hatches with the names "Сплошная заливка1", "Сплошная заливка2", etc. ("Solid Fill") Revit does not allow them to be deleted. So what do you need? That's right - they need to be changed first! It takes two transactions (maybe one - I did not try) - in the first one I change the fill pattern, and in the second I delete the element by the id. To replace the fill pattern, I took the first one that I found that is not solid - "Кирпич (Brick)".
using System; using System.Linq; using System.Windows; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; namespace Reinforcement { [Transaction(TransactionMode.Manual)] public class TestCommand : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var doc = commandData.Application.ActiveUIDocument.Document; var fpe = new FilteredElementCollector(doc).OfClass(typeof(FillPatternElement)).Cast<FillPatternElement>().ToList(); var f = fpe.First(fp => fp.Name.Equals("Кирпич")).GetFillPattern(); foreach (FillPatternElement element in fpe) { try { var elId = ElementId.InvalidElementId; using (Transaction tr = new Transaction(doc, "TEST")) { tr.Start(); if (element.Name.Contains("Сплошная заливка") && !element.Name.Equals("Сплошная заливка")) { element.SetFillPattern(f); elId = element.Id; } tr.Commit(); } if(elId != ElementId.InvalidElementId) using (Transaction tr = new Transaction(doc, "TEST")) { tr.Start(); doc.Delete(elId); tr.Commit(); } } catch (Exception exception) { MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); } } return Result.Succeeded; } } }
Profit