Set solid line pattern in overrides

Hi,
I am trying to set a line pattern to solid in overrides for a filter I am applying using dynamo…
and before you ask why not leave it without overrides and that the deafult line is solid - in the views I am applying the filter to the deafult line is not solid so that doesnt work…

I found out that solid isnt really a line pattern thats why it cannot be chosen with a standard line pattern node…
found this method, but I do not understand how I can use that part of the code to get the element id of the solid line pattern - I think if I have the id I can select the solid line pattern using element name by id and then feed that into the graphics override node - is that possible?

any help is appreciated

You’ll have to show us what you have so far.

2 Likes

just filtering the views where I want to apply the filter, and for the overrides its feeding the projectionlinepattern from line patterns node but there you cannot select a solid line… so no idea how to feed solid line pattern into the overrides

Try not putting anything at all, or “null”

I did - that leaves the lines in filter as -no override- but in these views the deafult line is set to some dashed line so this does not work - the lines are not solid as I need them to be…

so still need to figure out how to feed solid pattern into the overrides…

dont understand why the solid line would be different from the rest and could not be selected in line patterns node… doesnt make much sense to me

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 :wink:

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

this works great!

I am very much a noob into dynamo itself not to mention to editing the python of the nodes.
For my purposes this works just fine so thank you very much !