Hi there,
The layouts probably get sorted based on when they were created. I haven’t worked with Civil3D files in combination with dynamo, so I can’t help you with how you should sort the layouts. However I would like to give you some advice. That node on the top isn’t very parametric, you could replace it with something like this:
So it seems like the problem is on the original node’s end since it is not ordering the data in the order of the sheets. Without changing that directly, I would look to use regex and vary my approach depending on how exactly your sheet format scales. Here is a solution for your specific example. Instead of simply appending to the “result” list variable in each step, it will probably be better to create a sublist for each type, sort each sublist, and then combine them all into the final result at the end. But this should get you started with python:
import re
#start with:
sheets = ['1F', '2F', '3F', '4F', 'GF', 'RF']
result = []
#reference only#
#final sheets should be:
final_sheets = ['GF', '1F', '2F', '3F', '4F', 'RF']
#so ordering of sheets should be this and then with numerical prefix
order = ['GF', 'F', 'RF']
#reference only#
#Identify sheets with the letters 'GF' and adds to result
#regex that looks for the string 'GF'
pattern = '(GF)'
for sheet in sheets:
if re.search(pattern, sheet):
result.append(sheet)
else:
pass
#Identify sheets with a number prefix and then 'F' letter and adds to result
#regex that looks for the string 'F' with a numeric prefix
pattern = '\d+[F]'
#
for sheet in sheets:
if re.search(pattern, sheet):
result.append(sheet)
else:
pass
#Identify sheets with the letters 'RF' and adds to result
#regex that looks for the string 'RF'
pattern = '(RF)'
for sheet in sheets:
if re.search(pattern, sheet):
result.append(sheet)
else:
pass
print(result)
It appears that there isn’t a clear way to extract the layouts in the same order as they appear in Civil 3D. I spent some time finding and extracting the paperspace block items that represent the layouts, but they sort alphabetically too. I then took a look at the paperspace block parameters, but didn’t see anything that indicated a position relative to the other blocks/layouts. All that to say, I think we’re only going to get layouts sorted alphabetically…but I’m still a novice, so I could be wrong.
Nothing is sorted in AutoCAD, everything is done in the UI there.
Layouts have a taborder property so it is possible to sort, but you need to get the Layout object, not the blockreference.
Edit: there is no taborder node in the Civil3DToolkit, you might do something in Python or wait a while. Soon I will release a package with new nodes, with these it is possible to get the layouts sorted by taborder:
Yes - you will need to upgrade to a later version of Civil 3D, as per the compatibility note in the release notes here: Releases · mzjensen/Camber · GitHub.
FWIW I would jump straight to 2022.1.1 if you can; no valid reason not to really.