Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Purge Line Patterns

4 REPLIES 4
Reply
Message 1 of 5
Dale.Bartlett
403 Views, 4 Replies

Purge Line Patterns

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.
4 REPLIES 4
Message 2 of 5

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);
}

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 3 of 5

Thanks for the reply.

There is no definition for doc.LinePatterns...

Dale




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

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();
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 5 of 5

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community