Export creates ":" symbol in the path name - can't save file. Screenshot included

I’m trying to export all the layers in separate files using the attached script.
For some reason it adds “::” character in the file name. Windows can’t save file with “:” in the filename.
I think the problem is strLayer. Can I replace it somehow?
Can anyone please help me?
Thanks!

Str

Rhino_Export_By_Layers.rvb (1.3 KB)

Script:
Rhino_Export_By_Layers.rvb (1.3 KB)

Hi Yuri, did you write that script yourself? Just put in an extra replace function to convert the : into some other valid character in the strLayer variable before passing that one on to the strFile variable.
The reason the : appears is that the names of sublayers just are strings with a “parent::child::grandchild” format.

Wim, thank you.
I didn’t write it - I found it online.
Can you please help me with the replace function? I know next to nothing about the scripting.

Something like this should work - I haven’t tested it though…

ExportLayerObjects-Mod.rvb (1.3 KB)

–Mitch

Thanks a lot!
Works great.

HI,

although the problem is solved in the script already, the problem comes from the fact that when Rhino creates layer names it uses a ‘:’ to separate layers and sublayers, so the layer name ends up as comething “layer01:sublayer:finallayer”. So when you convert the layer name to a file name you get problems with the colons in the filename. A simple replace function to trap for colons and spaces usually sorts it out…

fname = str.encode(curlayer) +".dxf"
fname = fname.replace(" ", "")
fname = fname.replace(":", "-")

Hope that helps.

cheers
Peter

Actually, Rhino uses a double colon :: to separate layer/sublayers…

Layername::SubLayer::SubSubLayer

–Mitch