Set ALL Filled Regions to Invisible Lines

In Revit, I have a script I use to change the line type of all filled regions to Invisible Line, using the Plissken package.
It worked perfectly for projects in Revit 2021 but in Revit 2022, it seems to break no matter what I change the input values to. Is there another package that will fix this (or another solution)? I am relatively new to Dynamo and need this to work for all versions of Revit.

Thanks! See pictures attached.

What does the error say? You should just need to remove the spaces.

It says the formatting is wrong (must be name:…", and when I remove spaces, it still shows the same error…

Removing the space is the first step, but the input name also can’t be a class name. You need to change it to something else like FilledRegion, filledRegions, or Filled_Regions for example.

This is odd, because it works perfectly in R21.

Whenever I try FilledRegion, it gives me the same error. filledRegion, filledRegions and Filled_Regions no longer produce an error, but nothing happens to the filled region borders…

That’s because these changes were made in R22. It removes confusion and saves class names specifically for classes. FilledRegion is still a class. That’s my fault.

Can you show us what your graph is doing now that the inputs are working?

It shows nothing wrong, but nothing happens (I’m pretty new to Dynamo so not sure if this is what you wanted to see).

Copy the contents of the custom node and use that in your graph instead. That way it shows the errors or warnings that you’re getting. And make sure you have all the node preview bubbles pinned so we can see the data as well.

If I understand correctly, like this?

Side note, I tried to ‘Save As’ the edited custom node to keep it separate (as to not mess up my R21 one), but it inserts the edited one into both. Hopefully it applies to both versions once fixed…

Correct. Now you just need to connect the inputs so that it will run.

The new requirements still work for previous versions so there’s no harm there.

Sorry, what is connected improperly? Or do you mean connect the existing script to this “expanded” custom node?

Correct. Instead of feeding your data into the custom node where the internal warnings won’t show, we can pull out the “guts” of the node and run everything in the main graph so that all the warnings are visible.

Assuming I’ve set this up right, I get no errors, but nothing happens… Still works for older versions when changing to FilledRegions (2020) and Filled Regions (2021). R22 just yields nothing…

The “==” node won’t compare elements like that. It’s fine for strings, integers, etc, but with elements it’ll just return everything as false. You can either turn the element into something that “==” can compare, e.g. use String.FromObject or get the element IDs, or you can use a different comparison node, such as List.Equals with the inputs set to L1@. Though this has been the case in older versions of Revit/Dynamo too, so I’m not sure how you got a result out of 2020 and 2021.

I agree it is odd, especially since I can see the list of filled regions there too… Would you be able to show me an example that fits this scenario?

Dumb question maybe, but have you confirmed you have the correct line style selected and that the lines definitely aren’t updating?

As for comparing the filled regions, just add an Element.Id node between the elements and the inputs of the == node.

Yep, definitely the right line type. Is there something wrong with the y input for the == node? Or the final outputs?

My bad, I thought the == node was comparing the two FilledRegion lists but it’s actually just checking for nulls. The Element.Id node isn’t actually necessary in that case, but it doesn’t hurt either.

Can you post the python code for us to look at? Please be sure to use the Preformatted Text option (</>) when sharing code.

##Written By Thed Hogan

import clr
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System import *

#The inputs to this node will be stored as a list in the IN variables.
doc =  DocumentManager.Instance.CurrentDBDocument
app =  DocumentManager.Instance.CurrentUIApplication.Application
#These are my inputs for the Node
filledRegion = IN[0]
toggle = IN[1]
gStyle = IN[2]

#Declared Variables
output = list()
startPoint = list()
endPoint = list()
existingLines = list()
profiles = list()
filledRegionCount = 0

collector = FilteredElementCollector(doc).WherePasses(ElementOwnerViewFilter(doc.ActiveView.Id)).OfClass(CurveElement)

for element in filledRegion:
	filledRegionCount = filledRegionCount + 1
	notProfile = True
	idSub = 1
	while notProfile:
		if doc.GetElement(Autodesk.Revit.DB.ElementId(element.Id - idSub)).ToString() == "Autodesk.Revit.DB.Sketch":
			profiles.append(doc.GetElement(Autodesk.Revit.DB.ElementId(element.Id - idSub)))
			notProfile = False
			idSub = idSub + 1
			if idSub > 1000:
				notProfile = False
#Collect existing <sketch> lines in the view, the toggle can reset the collection
if toggle == True:
    for detailLine in collector:
        if detailLine.get_Parameter(BuiltInParameter.ELEM_CATEGORY_PARAM).AsValueString() == "<Sketch>":
#Check each filled region
for i in range(0, filledRegionCount):
	#Set currentRegion:
	currentRegion = profiles[i].Profile.get_Item(0)
	changeRegion = False
	#Find the Curves of Each Filled Region, using start and end points of existing lines in the <sketch> Category of the current view
	#Compare the lines current linestyle to the given linestyle and determine if a change needs to happen
	for curve in currentRegion:
		if curve.GetEndPoint(0).ToString() in startPoint and curve.GetEndPoint(1).ToString() == endPoint[startPoint.index(curve.GetEndPoint(0).ToString())]:
			#The Method .get_Parameter() was depricated after Revit 2015
				if gStyle[0].Name != existingLines[startPoint.index(curve.GetEndPoint(0).ToString())].get_Parameter('Subcategory').AsValueString():
					changeRegion = True
			#If the above fails, it means this is is being run in Revit 2016 or later, so we will use .LookupParameter() instead, the try/except allows us to avoid having to perform a Revit version check for a relatively minor change
				if gStyle[0].Name.ToString() != existingLines[startPoint.index(curve.GetEndPoint(0).ToString())].LookupParameter('Subcategory').AsValueString():
					changeRegion = True
	#If one or more Lines in the border are not the same as the given linestyle, begin a transaction to change that filled region
	#This transaction must be nested inside of an if statement, to prevent it from running indefinitely and crashing the file while Dynamo is set to Automatic
	if changeRegion == True:
	#Send back the list of Filled Regions

#Assign your output to the OUT variable.
OUT = output