Help Retrieving Object Styles Line Patterns

Does anyone know if it is possible to retrieve the line patterns of Imported Object Styles. See image below. I have the start of a graph that will retrieve the subcategories of the Imported Object Styles, but the subcategories are retrieved as strings. That is making it difficult to attempt to retrieve any additional information. I am at a loss as to what direction to go from here. If anyone could offer any guidance I would certainly appreciate it. Thank you.

Hi @jmmiller

Are you looking for this?

1 Like

Yes @Kulkul that’s what I am after. Ideally I would like to be able to retrieve all the line patterns that are found under Imported Objects. The end goal is being able to filter out the used line patterns and purge just the unused line patterns.

Take a look at this discussions

1 Like

Than you @Kulkul for pointing me to two great threads. I actually referenced both of those threads when creating a model clean up graph. I actually use @Konrad_K_Sobon method for deleting imported line patterns. see image and attached file. The issue I am having is being able to filter out the currently used imported line styles. The current method removes them all, whether they are used or not.

ModelCleanUp.dyn (49.7 KB)

1 Like

@Kulkul - Would you be willing to share your python script? I still have not been able to find a solution to this issue. Thank you.

I was able to ultimately find a solution to my issue. Thank you @Kulkul for you assistance. I was able to generate the below code to produce the information I needed.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
cat = UnwrapElement(IN[0])
subcat = cat.SubCategories

listNames = []
listPattern = []
patname = []
listout = []
listpatid = []

for i in subcat:
	name = i.Name
	listNames.append(name)
	id = i.GetLinePatternId(GraphicsStyleType.Projection)
	pat = LinePatternElement.GetLinePattern(doc,id)
	listPattern.append(pat)
	listpatid.append(id)
	try:
		patname.append(pat.Name)
	except:
		patname.append("Solid")
		
	style = i.GetGraphicsStyle(GraphicsStyleType.Projection)
	listout.append(style)


OUT = listout, listNames, listPattern, patname, listpatid
3 Likes