Get Line Style by Name / Archi-lab

Hello,

Does anyone know why the “Get Line Style by Name” Node is not working?

1 Like

Hi Jan,
Use the other node get all line styles then connect Element.Name node to get names of the line styles then filter the one which you need.

1 Like

works for me

Are you using German language Revit?

This seems like it could possibly be a similar issue to the following post; this is where a custom node has been setup with the English name of parameters/etc. Then when it tries to find these within revit it cannot because they are named as your local translation of that parameter within your revit setup.

1 Like

Use this script from Archi-Lab (I think). Then just use “Get Item at Index” for the line style you want.
@Konrad_K_Sobon is right though. Your way should work. But as a work around, try this… (What @Kulkul said)

I tried it in the English version also, but it is not working…

An other solution I found was to get to the GraphicStyle via ID to Element also from the Archilab Package.

Yeah but then you would need to know the exact id

…and those can change frequently in a workshared project.

1 Like

Thanks for your reply…

I can find find the ID in LookUp… but anyway I know it’s not the smartest solution

Any other ideas

jckh

As far as I can see these are the only two options.

Hello Jan,

I am currently using Revit 2015 with the same version of Dynamo you have and I am receiving the same error. The node works correctly when I used Revit 2017. The error comes from line 31: cat = Category.GetCategory(doc, BuiltInCategory.OST_Lines). I am pretty new Dynamo and just started my python and API learning so I don’t know exactly how to fix it for 2015. I am currently searching and testing. If someone that is more familiar with python and API can help that would be greatly appreciated. Otherwise I will do my best to fix the issue and post here if I find one.

-just located
Changes in the 2016 API: (copy and pasted from page)

Category API additions

The new static methods:
•Category.GetCategory(Document, ElementId)
•Category.GetCategory(Document, BuildInCategory)

act as a shortcut to lookup and return a Category object.

Now I just need to figure out how to use the old lookup system

1 Like

Hi,
use this code instead:

#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

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

doc = DocumentManager.Instance.CurrentDBDocument

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

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

try:
	errorReport = None
	cat = doc.Settings.Categories.get_Item(
      BuiltInCategory.OST_Lines )
	gs = cat.GetGraphicsStyle(GraphicsStyleType.Projection)
	gsCat = gs.GraphicsStyleCategory.SubCategories
	dataOut = [i.GetGraphicsStyle(GraphicsStyleType.Projection) for i in gsCat]
except:
	# if error accurs anywhere in the process catch it
	import traceback
	errorReport = traceback.format_exc()

#Assign your output to the OUT variable
if errorReport == None:
	OUT = dataOut
else:
	OUT = errorReport

Tomasz,

Thanks very much for providing this. I have attempted to copy and past your code and I am receiving Null as the output. I will attempt to retype the code. Thanks again for discovering the fix much faster then I have. After a retyped it by hand I am now receiving this:

1 Like

First code lists all line styles.
Here’s another “Line Styles By Name”:

#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

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

doc = DocumentManager.Instance.CurrentDBDocument

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

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

name = IN[0]

try:
	errorReport = None
	cat = doc.Settings.Categories.get_Item(
      BuiltInCategory.OST_Lines )
	gs = cat.GetGraphicsStyle(GraphicsStyleType.Projection)
	gsCat = gs.GraphicsStyleCategory.SubCategories
	lineStyles = [i.GetGraphicsStyle(GraphicsStyleType.Projection) for i in gsCat]
	
	lStyle = []
	try:
		lStyle.append(next(i for i in lineStyles if name==i.Name))
	except StopIteration:
		pass
	
	if len(lStyle) != 0:
		dataOut = lStyle[0]
	else:
		message = "No Line Style with specified \nname could be found."
		dataOut = '\n'.join('{:^35}'.format(s) for s in message.split('\n'))
except:
	# if error accurs anywhere in the process catch it
	import traceback
	errorReport = traceback.format_exc()

#Assign your output to the OUT variable
if errorReport == None:
	OUT = dataOut
else:
	OUT = errorReport
3 Likes

Faster again! I just located difference between what you sent and what Konrad wrote. Thanks again! It worked well!

While I am here I will share what I used this for: The issue I have with Copy Monitor on Grid Lines are it doesn’t track additional grid lines and the process of renaming them is usually a chore because of the duplicate name error. I created this DYN to rename the grid lines based on the linked file and then called out all new grids with a specifically styled line. I am a bit new to Dynamo so the script maybe inefficient but I learn a bit by making it. Thanks for all the help.

CopyMonitorRenameandCallout2015A.dyn (38.2 KB)

I may be missing something but the code Tomasz provided and the Archi-lab node “Get Line Style by Name” is not working for me either. Same error message as above: AttributeError: ‘NoneType’ object has no attribute “Name”.

The funny thing is that the node worked on the first time. Using RVT2017 and latest Dynamo.

Rarus,

The current “Get Line Style by Name” node by Archi-lab works for 2016 and 2017. There was a change in the API from 2015 to 2016, which is why I was having issues because I was using 2015. Therefore if you are using 2017 it is best to just use the Archi Lab node.

1 Like

Hi,
Bringing this one back to life.

I have gotten the following request:

  1. Draw detail lines in the center location of all walls in the project.
  2. Have separate line types for each wall type.

Progress:

  1. I have a script that creates line types matching the name of all the wall types.
  2. I have a script that creates the lines, but all lines comes out in the default “Thin Line” type.
  3. I can’t figure out how to change the line types. I was hoping to use the node “Get Line Style by Name”, but it only seems to work for one type at a time, not multiple types.

I’ve attached a snapshot of my script.
get%20line%20style%20by%20name

I also had this problem u have to set the: Get Line Style by name to level 1 so it detects all the selected graphic style’s correctly.
image