Hello to everyone,
Is it possible to extract a structured list of layers (including sublayers) from a Rhino file to an Excel list? It could be very handy, when working on projects of massive architectural scale. Also, would it be possible to have the process reversed, starting from an excel list, then generating an automatic list of layers?
Hello to everyone,
I have a script that does layer name export to .CSV if that helps. I have not written the opposite to import though - although it shouldn’t be too hard to do, it would just depend on how the lines are structured vis-a-vis sublayers (i.e. separator).
ExportLayerNamesCSV.py (418 Bytes)
Thank you! I am going to try it immediately and come back to your shortly.
It does work well (sub-layers seem to be separated by a double colon : on a generic file. Thank you.
In the specific file I have to manage, however, layers are actually in Chinese. Is this the reason why I am getting the following error?
Yeah, probably because I didn’t make any provisions for non-ascii characters. I tried fixing that, try re-downloading from the original link above…
Thank you! I have just tried it and this is what now I get:
OK, I don’t know if the lines of code I added work for Chinese characters, it’s intended for extended ascii characters like letters with accents… Can you post a file with one or two layers so I can see what it returns?
Of course, thanks. I have just created a blank file, with the name “default” translated in Chinese. The outcome is pretty much the sameChinese Layers - Test 01.3dm (45.7 KB)
Does the following work any better?
ExportLayerNamesCSV_Ex.py (453 Bytes)
Unfortunately I get the same error (from the same upload file).
Hmm, that’s odd, I don’t get any errors when I run it on your file and I get this .csv as a result…
test1.csv (11 Bytes)
However, if I open it in Notepad, I see this:
But in Excel I get this:
I guess I don’t understand any of this encoding stuff…
Edit - in Excel if I import the file via the Data menu instead of just opening it directly, I get this:
Partially I now get similar results. I can open the csv correctly in Notepad and Notepad++ and I can see all the layers in order (with sublayers). However, when importing the csv in Excel from the DATA menu, I have to specify the character set and, trying different Chinese sets, the writing doesn’t look correct. Which was did you choose? Was it automatic? I guess we are nearly there!
After all this work it could be nice to see it incorporated it as a standard feature in Rhino, if other users feel the need as well. Reversing the process would also be fantastic!
Yes, I just went to the Data menu, chose “From Text/CSV”
browsed to the .csv file then specified comma as the delimiter
then hit the “Load” button at the bottom.
I don’t know why it adds the column heading in this case, but I am not an Excel expert.
All working! so the secret was to select none.
Great, thanks very much!
One more thing…If you create sublayers, is there any reason why the csv output has two colons created ( :: ) and, as consequence, in Excel I get an empty columns in the list, instead of adjacent columns? Thanks
Two colons is the Rhino standard format for the layer-sublayer separator. When you have a sublayer, Rhino outputs this automatically as part of the layer name. It could be changed by programming an extra line in the script to replace them with some other character/sequence.
When you import data in Excel, it sees the colons and somehow sets that up as a proposed separator. That’s why I had to manually choose ‘comma’ as the separator above.
If you do change the sublayer separator output to something else, if you want to re-import your list, you would also need a custom conversion back to the double colon format to get the sublayers back.
Thanks, all clear.