If you are managing a Revit project chances are that you have to deal with some consultants working in AutoCAD platform. It’s not an ideal situation. If I had to compare it to something it would be that awful roommate you had in college that just would never keep the place clean. This is how it is with AutoCAD – Revit situation. You want to do everything you can to keep that CAD trash out of your Revit model. So you drill your team on importance of cleaning the CAD files of all layers and purging it nicely and of course NEVER IMPORT, if anything link that beast in. Even though, someone will always import some CAD in and with it comes the trash: LINE PATTERNS:
Yes, this is annoying to say the least, especially if you have roughly 8585 of those! This is insane!
Here’s how to get rid of ones that are named in a way that my gut feeling tells me come from AutoCAD – IMPORT – Xref – …. yes I can see you from a mile away!
First let’s get all Line Patterns using Element Types and All Elements of Type. Once you have all of them you can see their name with Element.Name node.
Next step is to filter line patterns that we think came from AutoCAD. We are looking for any line pattern that has IMPORT in its name. Here’s how:
String.Contains node will return a boolean True or False if word IMPORT is contained in a line pattern name. We can next use that to filter element list like so:
You can see that using List.FilterByBoolMask will return only desired elements. Also, a quick glance at List. Count reveals that our filtered list contains “only” 8543 elements from the original 8585. Now let’s get them deleted from the model. Since Dynamo currently doesn’t have a delete elements node (and rightfully so, its a bit scary to throw one in for every beginner user) i created my own. Here’s code for the Python node that will do the Deleting:
Here’s what you will get when you run it:
Now I am just going to re-run my definition and pull off a Watch component from All Elements of Type node to see what I am left with after the deletion process:
Yes, this looks a lot better now. I only have 42 line patterns left in the project. Congratulations, you have just taken out AutoCAD trash!