Set linestyle to <Invisible>

Hi

I would like to set the line style of some filled regions to ‘Invisible’. I’ve used various nodes to get the document’s line styles but ‘Invisible’ is not included. I’m guessing that this is because it is some sort of in-built special line style.

Any ideas how I can access it?

  1. Correct name is ‘Invisible line’
  2. ‘Invisible line’ is not really a ‘Line Style’ but ‘Override Style’.
    I think both of above or one of them cause it.
    You can use Element.OverrideInView instead.

Yes sorry, I meant ‘Invisible line’.

So how do you create or retrieve the override style for ‘Invisible line’? It is not contained in Line Patterns…

Connect “True” to ‘hide’

1 Like

This should work.

@Hyunu_Kim Connecting True to Hide results in the entire filled region being hidden. I only want to set the sketch lines to invisible.

@SeanP Thanks. So Invisible is a GraphicStyle?! Looks like the Archilab node is using a different method instead of the FilteredElementCollector, hence why it is different.

With the invisible graphic style, I then needed to set the filled region perimeter. Filled regions don’t have a Line Style parameter so needed to use a different method. The Plissken package had this python code which works:

##Written By Thed Hogan

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

clr.AddReference('System')
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
		else:
			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>":
        	startPoint.append(detailLine.GeometryCurve.GetEndPoint(0).ToString())
        	endPoint.append(detailLine.GeometryCurve.GetEndPoint(1).ToString())
        	existingLines.append(detailLine)
#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
			try:
				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
			except:
				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:
		TransactionManager.Instance.EnsureInTransaction(doc)
		UnwrapElement(filledRegion[i]).SetLineStyleId(ElementId(gStyle[0].Id))
		TransactionManager.Instance.TransactionTaskDone()
	#Send back the list of Filled Regions
	output.append(filledRegion[i])

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

2 Likes

Hello …another way without python…

1 Like

Ha, I am so conditioned at this point I jump to Python first almost without thinking. This is a good catch!

2 Likes

hehe :wink: you old python shark ;)…