New here to Dynamo/Revit and could use some help figuring out how we can get Dynamo to help fill out some sheet numbering parameters we have in Revit so that it matches the ordering in the project browser. We have our Sheet lists grouped and sorted using a 3 parameters in the project browser.
“SHEETS-PRIMARY SORTING” , “SHEETS-SECONDARY SORTING” for grouping and then sorted by the “Sheet Number” .
Once grouped and sorted properly would then like to have Dynamo fill in 3 parameter fields on the sheet properties. “Sheet Count” and “Current Sheet No.” should match and “Total Sheets” should be the total number of sheets in the project.
Any help or guidance provided will be much appreciated, I’ve gotten somewhat close but can never get the order to match the project browser order. Let me know if other information could be helpful.
Use the GroupByKey function to sort your lists based on your PRIMARY and SECONDARY sorting values. Then the rest is just list management.
You’ll have to run the script every time you add or remove a sheet to keep the values accurate. This is not a self-updating script.
Pay attention to the use of levels in the nodes, if you aren’t already familiar with them. I used them as a shortcut for managing sublists.
EDIT: Forgot to upload a screenshot of my project browser for reference.
Thank you, the sheet sorting has got me very close close with just one group’s keys are out of order, and the SetParameterByName is now giving me an error
So hoping you can help solve this, if you can see from the 1st circled object the Keys at the Secondary Sorting are out of order causing the sheet listed LS1.00 to be located at the bottom rather than at the top of its primary sorting(the red arrow in the screenshot).
Lastly the SetParameterByName is giving me an error of “Warning: Element.SetParameterByName expects argument type(s) (Element, string, var), but was called with (string, string, string).” after adding the “Sheet Number” sorting at the end of the Sorting section. If i skip the Sheet Number sorting the SetParameterByName does not error out, but the ordering is way off.
I misread your original post, I apologize, looks like you want the total number of sheets for the whole project, not per section. I revised it as below.
Did a test with randomizing the order of sheets created, looks like the “group by key” node doesn’t automatically sort when grouping, so that’s where you’re seeing the ordering issue. You’ll have to use “sort by key” in conjunction with the grouping at every stage in order to achieve what you want. The code is a bit convoluted, but it should work for now. Could probably be made more elegant but I’d need to have a deeper understanding of the final intent behind the parameters.
Not sure why you’re getting the input error for the set parameter value node. I’d check the input type for the custom sheet parameters, though it seems like you’re already aware as you’ve specified string vs number inputs in your code so I’m not sure what could be wrong.
I think the renumbering portion of the workspace is fine and working it’s just a matter of getting the order correct before sending it to renumber. Final intent would be to have a solution that can be run against a project and renumber all sheets in the project in the same order they show in the project browser. In the example we have been working with the the goal would be to have them all number in order of the project browser order, then properly count and update the fields. This is a small project and could probably just manually renumber as needed, but we have much larger projects where we have to add/remove drawings at times and the task of manually updating all the page counts is time consuming. I have tested the renumber on a larger project with many more sheets and it had similar results not being able to sort the “SECONDARY SORTING” , so i think that is where the issue or ordering is an issue. I did a small test to sort secondary(#1 in screenshot) with Sort Natural option. Looking at the list it places them in the proper order but once i pass it through it gets out of order again, so i must be linking it incorrectly.
I have set it up with “sort by key” as you laid out but ended with same result as i had before there is still the one sheet “LS1.00 - LSS SITE PLAN” which ends up last under the “3) SHEETS AND SECTIONS” when it should show up first. This is a small project for us, i tried the renumber on a larger project that showed same issue where it is unable to sort the “SECONDARY SORTING” in order. as you can see in #2 in the screenshot the order goes 2,3,1 instead of 1,2,3, and does not seem to sort properly under “sort by key” (#3 in screenshot). The LSS SITE PLAN should end up as sheet 12
Thank you for you help…much appreciated
Im stuck,… i can get it sorted it seems at the second project browser level but how do i pass this through so that i can sort by sheet number
After a lot of trial and error this is what ended up working…maybe it can help someone else
What node did you use for the " [&] list.groupbykey" ?
Sincere regards from Sweden
Ampersand package - version 2017.2.2 is what i am using