Hello,
I’ve spent the last two hours becoming more frustrated with this…
I read a string in from a INI file and it looks like this:
'C:\Temp\Junk\08 Folder\Whatever.3dm'
The \0 is causing so much trouble because I can’t figure out how to get Python to not treat it special - and secondly, convince Rhino to open the file. Mostly the second part. The script also has to deal with folders that start with 01 through 99 so I can’t just hack something together for this special case.
The code below is the closest that I have got - the os module knows it exists but the “open command” completely freaks out.
Can someone offer a suggestion on the proper way to deal with this?
import rhinoscriptsyntax as rs
import os
# This string comes from a INI file - I can't just put an "r" in front of it
A = 'C:\Temp\Junk\08 Folder\Whatever.3dm'
print(A)
A = A.replace('\0', '/0')
A = A.replace('\\', '/')
print(A)
# Python thinks this is OK
print(os.path.exists(A))
result = rs.Command(f'_-Open {A} _Enter')
print(result)
The Rhino result for this looks like:
Command: _-Open
Name of the file to open ( UpdatePromptUpdateBlocks=Yes Browse ): C:/Temp/Junk/08
File C:/Temp/Junk/08.3dm not found, unable to open
2 posts - 2 participants