Excel Roundtrip – Fill Patterns, Line Styles etc. - Continued

Hi Konrad.
I hope all is well with you.
Just checking the old post regarding the renaming of Line Styles, File Patterns, and I have been trying to achieve that for more than a year, as I am not on this full time, and I need help again.

I have loaded the routine I made based on the old post, as well as a Revit Project to help things out.
I am not using the renaming through Excel and I do not think this has any impact on the issue I am having.

To conclude, there is something not quite working once I connect the data into the last Python node, that should rename the Line Styles as per your post. Could you please help me out with that?

Here are a few images related to this post:

Dynamo Version
2480

Revit Version

Dynamo Routine

Dynamo Routine Applied

Python Script 1 - 3

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

Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

Import DocumentManager and TrasactionManager

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

from System.Collections.Generic import *

Import RevitAPI

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

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

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

GraphicsStyleType.Projection =
for i in IN[0]:
GraphicsStyleType.Projection.append(UnwrapElement(i))
values = IN[1]

TransactionManager.Instance.EnsureInTransaction(doc)
for i, j in zip(GraphicsStyleType.Projection, values):
i.Name = j
TransactionManager.Instance.TransactionTaskDone()

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

Python Script 2

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

Import ToDSType(bool) extension method

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

Import DocumentManager and TrasactionManager

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

from System.Collections.Generic import *

Import RevitAPI

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

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

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

GraphicsStyleType =
for i in IN[0]:
GraphicsStyleType.append(UnwrapElement(i))
values = IN[1]

TransactionManager.Instance.EnsureInTransaction(doc)
for i, j in zip(GraphicsStyleType, values):
i.Name = j
TransactionManager.Instance.TransactionTaskDone()

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

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

Import ToDSType(bool) extension method

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

Import DocumentManager and TrasactionManager

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

from System.Collections.Generic import *

Import RevitAPI

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

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

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

graphStyle =
for i in IN[0]:
graphStyle.append(UnwrapElement(i))
values = IN[1]

TransactionManager.Instance.EnsureInTransaction(doc)
for i, j in zip(graphStyle, values):
i.Name = j
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = graphStyle
PM_Line Styles Rename.dyn (38.7 KB)

Hi,

Did you also try with the Element.SetName node from Clockwork package ?

Hi Alban,

Thank you for your suggestion. I have linked the data to the Element.SetName node, and unfortunately, that did not work. Please, image attached.

Hi,

The API doesn’t seem to allow renamming of GraphicStyle.

The Python Script error is pretty explicit :
Exception: This element does not support assignment of a user-specified name.

1 Like

Hi Alban,

Thank you for your feedback. However @Konrad_K_Sobon manages to rename GraphicsStyle using Excel. So, I believe it should be possible to rename them if the Python script is fixed.

The topic you are referring is about the renaming of Fillpaterns and the API allows to rename FillPatterns.
I suggest you look in the API what is possible.

Hi Alban,
I understand what you are saying, but the title includes Line Style, what gives an understanding that it is possible. I do not know how to get into the API side of Revit.
I was just trying to use info from an API post and interpret it into Python, which I do not know, to try to obtain information and it is, for me at the moment, another world of its own. Thanks for the support and suggestions anyway.