Hmm interesting.
So it appears that ta solid is not a pattern, and therefore not a patternelement, which is what that node is expecting.
I can see that the solid line pattern is ElementId(-3000010)
But that the Python for that node doesn’t look like it wants an element ID as its input.
Soo… That would be the road i would go down, would be to alter the Python in that node to accept an ID.
ooorrr what might be easier is making a linestyle that is so close to Solid that it could substitue it.
(This isn’t a healthy solution but oh well…)
My code below makes a new Linestyle as well, but aseperate the pattern, its just something i was slapping together. but you don’t need that so you can take it away
Can i just stress, that this is not a smart solutuion… but is ia “A” solutiuon
Line pattern of the above snip (Obvjously make your dashes just HUGE!)
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
version = int(app.VersionNumber)
clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import System
from System.Collections.Generic import *
# Determine the display units based on the Revit version
if version < 2021:
UIunit = doc.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits
else:
UIunit = doc.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId()
# Inputs
patternName = IN[0] # Name of the line pattern
types = IN[1] # List of segment types (Dash, Space, Dot)
values = IN[2] # List of segment values
lstSegments = List[LinePatternSegment]() # List to store line pattern segments
line_color = IN[3] # RGB values for line color (magenta)
line_weight = IN[4] # Line weight value
subcategory_name = IN[5] # Name of the new subcategory
# Convert RGB values to a Color object
line_color = DB.Color(line_color[0], line_color[1], line_color[2])
# Create line pattern segments based on the input types and values
for type, value in zip(types, values):
if type == "Dash":
lstSegments.Add(LinePatternSegment(LinePatternSegmentType.Dash, UnitUtils.ConvertToInternalUnits(value, UIunit)))
elif type == "Space":
lstSegments.Add(LinePatternSegment(LinePatternSegmentType.Space, UnitUtils.ConvertToInternalUnits(value, UIunit)))
elif type == "Dot":
lstSegments.Add(LinePatternSegment(LinePatternSegmentType.Dot, 0))
# Create a new line pattern
linePattern = LinePattern(patternName)
linePattern.SetSegments(lstSegments)
# Create a line pattern element in the document
TransactionManager.Instance.EnsureInTransaction(doc)
linePatternElement = LinePatternElement.Create(doc, linePattern)
# Create a new subcategory for the line style
cat = doc.Settings.Categories
lineCat = DB.Category.GetCategory(doc, DB.BuiltInCategory.OST_Lines)
lineStyle = doc.Settings.Categories.NewSubcategory(lineCat, subcategory_name)
lineStyle.LineColor = line_color
lineStyle.SetLineWeight(line_weight, DB.GraphicsStyleType.Projection)
# Commit the transaction
TransactionManager.Instance.TransactionTaskDone()
# Outputs
OUT = linePatternElement, lineStyle