Create Keys for Keyschedule via CSV


Hello,

How can i separete my list? so that each parameter get filled correctly

so for Code and discription.

KR

Andreas

The trick here is that you need to have at least one value to start with, and then you just duplicate that value and change the parameter value of that item.

You could also programatticaly add that row as well.
https://www.revitapidocs.com/2022/e14a7a0f-0a5c-c010-7cc2-a83cb1a9da8c.htm

1 Like

CreateScheduleViaCSV.dyn (13.7 KB)


Thank you! I have still errors…

do i realy call parameters here or the “first” value
i have 2 “key ProjectParameters”

import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
view = UnwrapElement(IN[0])
out = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

elems = FilteredElementCollector(doc,sched.Id).ToElements()

for i in IN[1]:
	new = ElementTransformUnils.CopyElement(doc,elems[0].Id,XYZ(0,0,0))
	elem = doc.GetItem(new[0])
	elem.LookupParameter("Key Name").Set(i[0][0])
	elem.LookupParameter("Raumnutzungscode").Set(i[0])
	elem.LookupParameter("Nutzungsartbezeichnung").Set(i[1])
	out.append(elem)
TransactionManager.Instance.TransactionTaskDone()

OUT = out

or is this the way:
2021-12-09_14h36_18

RK

Andreas

I don’t think this is the correct index.

1 Like

2021-12-09_14h37_33
thats the startpoint in the csv

Then just use [0], I was using nested lists in my example that is why the double [0][0].

2021-12-09_14h39_21
it says it should not have a negativ value, the collection is out of range

In your schedule, which one is the “Key Name” or the default Revit column?
SInce you are only using 2 columns, I think you need to remove the Key Name line and just use the other two columns.

for i in IN[1]:
	new = ElementTransformUnils.CopyElement(doc,elems[0].Id,XYZ(0,0,0))
	elem = doc.GetElement(new[0])
	elem.LookupParameter("Raumnutzungscode").Set(i[0])
	elem.LookupParameter("Nutzungsartbezeichnung").Set(i[1])
	out.append(elem)
1 Like

2021-12-09_14h41_56
Raumnutzungscode in Revit

I think it is still the index is not correct

2021-12-09_14h45_32

Is that at least 1 row in the schedule already? If not, the above code will not work.

i already updated it as you discriped before
Raumnutzungscode and Nutzungsartbezeichnung are my project Parameters

the start with the first line “050100” and “Bildungsraum” (my first values)

is my imput correct

there is no first raw just the parameternames

error remains out of range
2021-12-09_14h39_21

Thank you!
i think the problem is i dived the values by “semicolon”
How can i deal with that
2021-12-09_15h05_00

because “,” is already in use

Use a Split node and break them into two values which should help.

Again, you will need to make sure there is at least one, even if empty, row that is in the key schedule to begin with or this code will not work.


so it something but it did not take the values from the list
it seems to be it took just the numbers an filled it :frowning:

1 Like

You need to split the values like I showed. Right now it is geting the “0” and the “5” or “7” from the first [0] and second [1] characters of your overall string.

1 Like

Well it worked! for any reason Codeblock did not work, so i used stringNote!

1 Like