Revit Duplicating 1000s of Line Styles

python
dynamo
revit

#1

Hi guys, I’ve spent a while lurking in this forum but this is my first post here! Hopefully it goes ok - I ran a search but haven’t found a solution to this specific problem so here goes:

We’re having problems with Revit 2015 duplicating line styles. This is similar to other problems I’ve read about where Site Designer duplicates line styles (with the prefix ‘SW’). This problem seems to have been fixed in Revit 2017.

The duplicate linestyles can be found in:
Visibility Graphics > Model Categories > Detail Items

Our Revit has chosen a few linestyles to replicate thousands of times. In practice, our model works fine until someone has to enter a View Template, Visibility Graphics or the Object Styles menu. I’ve read Revit 2017 lets you batch-delete object subcategories, but we can’t do this in 2015 so I’m looking for an automated solution instead of hitting delete thousands of times.

The linestyles which are being duplicated are: PTE Hidden 1, PTE Hidden 5, PTE Hidden 6, PTE Hidden 7, PTE Solid 6, PTE Solid 7 (seems to be random, there are about 40 line styles which have the PTE suffix but only a few are getting replicated).

I’ve tried deleting these line styles using PythonRevitShell, SharpDevelop and Dynamo. I’ve consulted the following:

This says a similar problem is caused by Site Designer, gives links to two forum discussions below:

http://forums.autodesk.com/t5/revit-architecture-forum/linestyles-duplicating/td-p/5426100
(I’ve tried this Python Script in RevitPythonShell: it ran but didn’t help)

http://forums.autodesk.com/t5/revit-architecture-forum/can-t-delete-multiple-linestyles/td-p/5622246
(Tried this script too, no luck)

I tried the below Dynamo Workflow to highlight the linetypes, get their object ID, used Manage > Select by ID in Revit and delete. This approach makes Revit thinks for a long while, seemes to delete them from the Dynamo lists… but if I open the View Template they’re all still there (even after purging the file).

Below is a shot of the Python Script used:

I found a post on Konrad Sobon’s site, in the comments (August 15 2015 at 3:13am) he suggests a couple of workflows to delete line styles (rather than line patterns): http://archi-lab.net/delete-imported-line-patterns-using-dynamo/

Tried these, didn’t have any luck, first graph:

Second graph:

And the custom Python node used in the second graph:

Not to give up too easily, I turned to SharpDevelop using this script from BoostYourBIM:

Which threw up some kind of API error:

I would be incredibly grateful if someone could suggest a way to delete our 1000s of rogue linestyles!

Thanks for reading! (And sorry for all the links / images!).

Ollie


#2

I think the reason that all the solutions you mentioned don’t work is that they are all made to delete subcategories of Lines and not of DetailItems. You could give this a try:

the code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

lines=doc.Settings.Categories.get_Item(BuiltInCategory.OST_DetailComponents)
subcats=lines.SubCategories

OUT = subcats, [x.Name for x in subcats]

#3

Hi T_Pover, thanks for the response! I’ve set up the graph but my version of the archi-lab package doesn’t contain the delete elements node. What version are you using?


#4

Hi @oliver.green

What version of dynamo and archi-lab your using?


#5

I’ve got Archi-lab version 2016.5.27
Alternatively you could try one of these 2 nodes from springnodes or steamnodes:


#6

Hi KulKul - I’m using Dynamo 1.2 and have downloaded the Archi-lab package 2016.5.27 which T_Pover is using which does contain the delete elements node. I’ve run the graph and it seems to have completely deleted the top list (seems successful so far, deleted 26 line types)

However - we somehow still have the 10000 line types :confused:


#7

@T_Pover could it possibly be because this line:
_lines=doc.Settings.Categories.get_Item(BuiltInCategory.OST_DetailComponents)
seems to get detail components, but not detail items? I’m not sure if there’s a practical distinction between the two API-wise.

Thanks a lot for your previous answers, I’m pretty desparate to get this file back in working order!


#8

If you are after the line style types then you need to swap OST_DetailComponents with OST_Lines.


#9

As far as I know OST_DetailComponents are Detail Items in the Revit API. I don’t know if the lines could somehow be of another BuiltInCategory if they are not specified under the Lines category.
If you could share the model maybe I’d be able to find something.


#10

Hi Brendan,

the specific items I want to delete are found under:
Visibility Graphics > Model Categories > Detail Items

I’m not great at this, but I’m guessing line style types would be under:
Visibility Graphics > Model Categories > Lines ?

@T_Pover Thanks for the offer: I’ll take a look to see how to clean / upload the model. Would really appreciate if you were able to take a look! :grin:


#12

If you are saying these are appearing after using the site tool then it would seem that these lines are specified within the family objects associated. So as a quick check it may be worth while looking into these manually as a check(see up to 5 max) then if yes and they are not important you will have to perform a delete from the family.


#13

@T_Pover

I’ve cleaned the model which can be downloaded from here:

https://drive.google.com/open?id=0B9QvkL9zFMurZVJLLTY3QnMwX3c

It contains nothing except some model text and 1000s of line styles. Note: Opening visibility graphics or view template causes your computer to think for about 10 minutes. If anyone can solve this then I owe then I’m paying for drinks all weekend!


#14

Hi Brendan - I’ve deleted everything out of this model (all geometry, families, templates etc and purged the model) and the linetypes still persist somehow. That’s leading me to think that they’re being caused by something other than families.


#15

@oliver.green Could you please drop your rvt file. Which contains all the detail lines. So that we can have closer look and provide you possible solution. It will also help others who is trying to help you and avoid waste of time. Thanks :slight_smile:


#16

@Kulkul I’ve shared a Google Drive link to the .rvt in post #13 - does that work? is there a better way to share? :slight_smile:


#17

@oliver.green Sorry i didn’t see that. Are you looking to delete line styles which are not in used?


#18

@Kulkul No worries, there’s a few specific linetypes which have replicated themselves into over 10000 individual linetypes. There are no lines drawn in the model I’ve uploaded, just loads of line types (which cannot be purged). They’re under View Template > Model Categories > Detail Items and they begin with the prefix “PTE”

My guess is I’d need to use code to interact with the API and force Revit to delete these line types, but I’m new to the API and have no idea how to do that :neutral_face:


#19

@oliver.green No worries! Give me sometime.


#20

Amazing, thanks so much for looking!


#21

@oliver.green I can’t see any view templates in your model?