Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I bulk Create Parameters in Key Schedules

8 REPLIES 8
Reply
Message 1 of 9
Bishesh.M
1864 Views, 8 Replies

How do I bulk Create Parameters in Key Schedules

I’m trying to import parameter names from excel and create multiple key schedule parameters at once in Revit using dynamo. I've used the Parameters.CreateProjectParameter and Parameters.CreateSharedParameters node, but the parameters created by these nodes doesn't show up in the list of Key Schedule Parameters or Fields. Please let me know if there are any nodes in dynamo that creates key schedule parameters or any other methods to create multiple key schedule parameters at once.

 

Thanks,
Bishesh

8 REPLIES 8
Message 2 of 9
Yien_Chao
in reply to: Bishesh.M

you will have more answers on the Dynamobim forum.

Message 3 of 9
Bishesh.M
in reply to: Yien_Chao

I've posted it there last week. Still waiting for a solution.

Message 4 of 9
SteveDFThorne
in reply to: Bishesh.M

I was looking to do this very same thing last week and found out that you cannot currently create proper project /shared parameters from Dynamo because the Revit API doesn't support this. I have come to the conclusion that the best way to move forward would be to create the parameters manually and then use this method: https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/screencast/Main/Details/90c... to populate. 

Message 5 of 9
a.koltakovADRC7
in reply to: Bishesh.M

With Dynamo Python:

 

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

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

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

# Assign input to the IN variables.
keySchedule = UnwrapElement(IN[0]) #Input - Node Views with your Schedule
keyCount = IN[1]
newKeys = []

# Start the Transaction
TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument)

for i in xrange(keyCount):

    # Create before list of keys in key schedule.
    scheduleBefore = FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument, keySchedule.Id).ToElementIds()

    # Add new key to key schedule.
    schedule = keySchedule.GetTableData().GetSectionData(SectionType.Body)
    schedule.InsertRow(schedule.FirstRowNumber + 1)

    # Create after list of keys in key schedule.
    scheduleAfter = FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument, keySchedule.Id).ToElementIds()

    # Identify new key by comparing before and after lists.
    newRow = list(set(scheduleAfter) - set(scheduleBefore))[0]
    newKeys.append(DocumentManager.Instance.CurrentDBDocument.GetElement(newRow))

# End the Transaction
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable
OUT = newKeys

 

After you can use Element.SetParameterByName for add parameter name and value.

 

Message 6 of 9
Bishesh.M
in reply to: a.koltakovADRC7

Thanks for your response. I was out of office for a while so just got a chance to try out your python code. It gave me the (given) number of rows in my key schedule. What I am looking for is to find a way to add key parameters that are the "Columns" in a key schedule. Please let me know if you have a code that can add key parameters.

Message 7 of 9
Bishesh.M
in reply to: SteveDFThorne

That's exactly what I've found and I've also been following the same process as you've described. But I'm looking forward to either the developers to add this feature to the API or someone else to figure out another way.

Message 8 of 9
a.koltakovADRC7
in reply to: Bishesh.M

Each row in a Key Schedule is an Element that contains a set of Parameters. Parameters represent each column of the schedule.

We can collect all "rows" (elements) just by doing this:

elements = FilteredElementCollector(doc, viewSchedule.Id).ToElements()

Then we can query each element that is being returns for parameters:

params = []
for i in elements:
    params.append(i.Parameters)

Once you have the parameters you can just write values to them and they will appear in a schedule.

But not all parameters are representing a field in the key schedule, though. But that can be easily filtered out by checking the parameter's definition name toward scheduleable fields.

Maybe the Revit API SDK team can include some of the code in the schedule samples, before a more intrincit method for reaching this goal being created.

Message 9 of 9

Was there any update on this. I have been searching the internet for a solution to add custom parameters to a key schedule then link to excel. I do not want to manually add fields every time a new column is added to the excel sheet, I just it to happen auto behind the scenes. Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community