Get Detail Line Line Pattern

Hi all,

I am trying to get the the Line Pattern set to a Line in the Line Styles menu (sorry for the confusion). The Line Pattern set to Detail Lines. I found the API link below and wrote this simple code but I just get null as the return. Any ideas? I am guessing I do not have the right API section.

http://www.revitapidocs.com/2018/230a23fa-45d0-d698-2e2d-61d2ecfad0a6.htm

import clr
import math

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

EleId = UnwrapElement(IN[0])
element = []
	
for i in EleId:
	
	LinePatternElement.GetLinePattern(doc,i.Id)
	OUT = element.append(i)

Thanks,
Steven

This will be of interest for you: LinePatternElement names

1 Like

Unfortunately that is not have C# solutions work, you need to create the entire solution in C# and compile the project in order to create the node. More info can be found in the Dynamo Primer:
http://dynamoprimer.com/en/10_Packages/10-5_Zero-Touch.html

2 Likes

Oke Thanks. Going to study on that to see how far i can come. I will take my time :slight_smile:

Thanks for the link @Jonathan.Olesen,

Unfortunately I was unsuccessful at putting something together. In the Link you provided Gopinath says there is no way to get the Line Pattern (back in 2014). I have culled through the API and Have not found anything else other than what I posted above. Unless anyone else has an Idea I think we will just have to wait for Autodesk to add something.

@Steven its possible, you have to get the graphics style element from the curve using the LineStyle property. With the GraphicsStyle, get the category and type properties, and use those with the GetLinePatternId method

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

doc = DocumentManager.Instance.CurrentDBDocument

curves = IN[0]
if not isinstance(curves,list):
	curves = [curves]
patterns = []
for curve in curves:
	curve = UnwrapElement(curve)
	gscat = curve.LineStyle.GraphicsStyleCategory
	gstype = curve.LineStyle.GraphicsStyleType
	patterns.append(doc.GetElement(gscat.GetLinePatternId(gstype)))

OUT = patterns

PS it appears solid returns null

4 Likes

Just a follow-up on the “Solid”. :slight_smile:

The “solid” is special and is not really a line pattern (even tough it looks that way). It can however be set using:
“ProjectionLinePatternId” of the “OverrideGraphicSettings” of a category the Id of the Solid “pattern” is: -3000010

It is stated under “Remarks” here:
http://www.revitapidocs.com/2015/e52c87b7-4544-372f-70a6-00188f6fd252.htm

5 Likes