Purge Line Patterns

Purge Line Patterns

Dale.Bartlett
Collaborator Collaborator
599 Views
4 Replies
Message 1 of 5

Purge Line Patterns

Dale.Bartlett
Collaborator
Collaborator

I can return all Line Patterns and IDs with:

FilteredElementCollector collector = newFilteredElementCollector(doc);

IList<Element> elems = collector.OfClass(typeof(LinePatternElement)).ToElements();

then process elems to select ones to purge, and add to:

IList <ElementId> idsToDelete = newList<ElementId>();

then delete by element iD:

tr.Start();
// all at once

// doc.Delete(idsToDelete);

// or

foreach (ElementId eid in idsToDelete)
{
 doc.Delete(eid);
}

tr.Commit();

 

However the elements (Line Patterns) are not being deleted from the document. Any thoughts? Thanks, Dale




______________
Yes, I'm Satoshi.
0 Likes
600 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Did you try to make a collection of linepatterns like

 

doc.LinePatterns()

 

and delete each element in the collection like :

 

foreach (LinePatternElement line in doc.LinePatterns())
{
     doc.Delete(line.Id);
}

0 Likes
Message 3 of 5

Dale.Bartlett
Collaborator
Collaborator

Thanks for the reply.

There is no definition for doc.LinePatterns...

Dale




______________
Yes, I'm Satoshi.
0 Likes
Message 4 of 5

Anonymous
Not applicable
You are right, excuse me. I've made an extension for it. Looking at the code I'm doing the same a you. I make a collection of LinePatternElements. And looping through this collection I delete them.

FilteredElementCollector(doc).WherePasses(new ElementClassFilter(typeof(LinePatternElement))).OfType<LinePatternElement>().ToList();
0 Likes
Message 5 of 5

Dale.Bartlett
Collaborator
Collaborator

Thanks Remy,

There have been some other published macros using similar code that presumably work. I haven't tested my code in multiple files, so possibly there is something in the file itself. Dale




______________
Yes, I'm Satoshi.
0 Likes