Rename grid object

Hi,
Im trying to rename a grid object with the command SetParameterByName. When I create a grid object as an output from a python script and use this as an input to a second python script it works. But when I use the same code in the first Python script it gives an error that a grid object doesnt have the SetParameterByName method. Does anyone have an idea why this is happening/ how it can be solved in one python code block? underneath the working and failing codes printscreen + copied code.


Version:0.9 StartHTML:00000097 EndHTML:00009232 StartFragment:00000199 EndFragment:00009194
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk

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

clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)

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

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

doc = DocumentManager.Instance.CurrentDBDocument
R1=0 #richting numerieke assen
A1=IN[0] #aantal grids nummeriek
A2=IN[1] #aantal grids letters
if IN[2] == True: #boolean voor richting numerieke assen (rechts naar links of links naar rechts)
R1 = -1
else:
R1 = 1
A3=IN[3]*R1 #Array afstanden nummeriek
A4 = IN[4] #Array afstanden letters
T1=A3 #Translate afstanden nummeriek
T2=A4 #Translate afstanden letters

#Punten numerieke assen
P1 = Point.ByCoordinates(0,0,0) #punt 1
P2 = Point.ByCoordinates(0,20000,0) #punt 1
P3 = Point.ByCoordinates(A2,0,0) #punt 3
Lijst1 = [] #Lijst met grid array numeriek
Lijst2 = [] #Lijst met grid array letters
Lijst3 = [] #Lijst met gridobjects
#numerieke assen genereren
L1 = Line.ByStartPointEndPoint(P1, P2) #curve voor 1e numerieke grid
L2 = L1.ToRevitType() #vertaling 1e curve voor 1e numerieke grid naar Revit
V1 = Vector.ByTwoPoints(P1, P3) #vector tbv kopieren numerieke assen

TransactionManager.Instance.EnsureInTransaction(doc)
Lijst3.append(Autodesk.Revit.DB.Grid.Create(doc, L2))

for _ in range(A1):
L3=Geometry.Translate(L1,V1,T1) #curve voor nummerieke as x
P4= L3.StartPoint#startpunt nummerieke as x
L4=L3.ToRevitType() #nummerieke as x naar Revit
T1+=A3 #Translate afstand tot volgende gridline
G2 = Autodesk.Revit.DB.Grid.Create(doc, L4) #Gridline x
Lijst1.append(G2) #Gridline x toevoegen aan lijst

TransactionManager.Instance.TransactionTaskDone()

# letter assen
P5 = Point.ByCoordinates(0,1,0)
L5 = Line.ByStartPointEndPoint(P1, P4) #curve voor 1e numerieke grid
L6 = L5.ToRevitType()
V2 = Vector.ByTwoPoints(P1, P5) #vector tbv kopieren letter assen

TransactionManager.Instance.EnsureInTransaction(doc)
G3 = Autodesk.Revit.DB.Grid.Create(doc, L6)
for _ in range(A2):
L7=Geometry.Translate(L5,V2,T1) #curve voor nummerieke as x
L8=L7.ToRevitType() #nummerieke as x naar Revit
T2+=A4 #Translate afstand tot volgende gridline
G4 = Autodesk.Revit.DB.Grid.Create(doc, L8) #Gridline x
Lijst2.append(G2) #Gridline x toevoegen aan lijst

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = Lijst3[0].SetParameterByName("Name","test")

Hi @wouter.hilhorst

Try the below code in your last line. See if that helps.

OUT=[ele.LookupParameter("Name").Set("Test") for ele in Lijst3]

1 Like

Thanks! I was just watching a YouTube video about this. It works better when it directly communicates with the API.