Delete all "Detail Lines" with a specific "Line Style" parameter" - How?


#1

Hello All,

This is my second script, so go easy on me. I need to delete all “Detail Lines” with a specific “Line Style” parameter".

 

For my case, the “Line Style” parameter value = “Construction”.

I installed the Eraser package, and it works great to remove all “Detail Lines” in the array, but I am trying to figure out how to edit the array to only delete the “Detail Lines” with the
"Line Style" of “Construction”.

https://dl.dropboxusercontent.com/u/107160035/dynamo2.JPG

Thank you for any guidence.

 

Daniel

 


Hide all lines of a specific line style / texts of a specific text type
#2

Here’s how you could do it. Basically it’s just a matter of filtering.
delete by linestyle


#3

Daniel,

You were close, or rather on a good path. Here’s how i solved this:

 

Capture

Explanation:

You had a good idea to collect all lines using the Category OST_Lines and then query them for Line Style parameter. What that returns however, is an ElementId object. That’s an Id of a Line Style type that was assigned to the given Detail Line. Now in order to filter out just the ones with a Line Style called (named) “Construction” or in my example 1-Dash you need a few things. First I used a custom Python node to get the Line Style itself and then then queried it for an Id. I am using an archi-lab ElementId node here since it returns an ElementId object instead of integer object like the standard Element.Id node does in Dynamo. Objective is to use that style Id and compare it to one that we got returned from Element.GetParameterValueByName node (remember I said it returns an ElementId so its important that we have two matching data types if we want to compare them. you cannot compare an integer to ElementId object). Then I am using Equals node to create a list of True/False values that tell me which lines have the desired line style. Use List.FilterByBooleanMask to get only lines that have desired style assigned and then just delete it. I am again using a custom node from archi-lab package.

You can get the archi-lab package from the package manager and for that one custom node, the code is below. I will eventually make that into a custom node and add to archi-lab package so check back in the near future.

#Copyright(c) 2015, Konrad Sobon # @arch_laboratory, http://archi-lab.net

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

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

name = IN[0]

lineStyles = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Lines)
lStyle = []
try:
lStyle.append(next(i.LineStyle for i in lineStyles if name==i.LineStyle.Name))
except StopIteration:
pass

OUT = lStyle[0]

 


#4

Andreas, nice one! SteamNodes, Clockwork and archi-lab showcasing the power of custom nodes. :slight_smile:


#5
#Copyright(c) 2015, Konrad Sobon # @arch_laboratory, http://archi-lab.net

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

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

name = IN[0]

lineStyles = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Lines)
lStyle = []
try:
lStyle.append(next(i.LineStyle for i in lineStyles if name==i.LineStyle.Name))
except StopIteration:
pass

OUT = lStyle[0]


Here’s a small modification and an extra filter to get only Detail Lines.

Capture