Closed Nesciosquid closed 9 years ago
Hey, sorry not to get to this sooner. I spun up a Windows VM to check this out and couldn't duplicate the problems you had right away. However, I don't think I've used SolidPython in Windows for more than a year, and I'm not at all certain there's no problem. Could you upload the code you were trying to run?
You might check out SolidPython/solid/examples/basic_scad_include.py
. I had no problems running that one either with Git Bash or the normal Windows command prompt. Let me know if that works for you and that might help track things down.
I notice in the last screenshot you attach that the directory you're using contains a non-Ascii ankh character ("SCAD
Let me know how things go, and thanks for checking out SolidPython.
Here's a .rar archive of some example code that shows the difference in behavior when you specify the path in different ways.
That non-ASCII ankh is the result of the mangling, not the cause. :)
https://www.dropbox.com/s/g1i8yk6s8qm5hte/solidpython_issue_34_example.rar?dl=0
Found it. SolidPython generates a Python code string to wrap around any imported SCAD code, and it evals that generated string. The backslash-delimited Windows paths were getting interpolated with only a single backslash character, leading to the problems you saw. I escaped the backslashes one more level before the eval and everything seems to be working smoothly now. Thanks for bringing that one up.
Awesome!
Thanks for getting to this so quickly.
I'm making some tools for my PhD research that use your library, and it's awesome to know you care about maintaining it!
-Aaron Heuckroth
On May 10, 2015, at 2:52 PM, Evan Jones notifications@github.com wrote:
Found it. SolidPython generates a Python code string to wrap around any imported SCAD code, and it evals that generated string. The backslash-delimited Windows paths were getting interpolated with only a single backslash character, leading to the problems you saw. I escaped the backslashes one more level before the eval and everything seems to be working smoothly now. Thanks for bringing that one up.
— Reply to this email directly or view it on GitHub.
Glad to know SolidPython is helping you get stuff done! Best of luck,
Evan
On May 10, 2015, at 7:02 PM, Aaron Heuckroth notifications@github.com wrote:
Awesome!
Thanks for getting to this so quickly.
I'm making some tools for my PhD research that use your library, and it's awesome to know you care about maintaining it!
-Aaron Heuckroth
On May 10, 2015, at 2:52 PM, Evan Jones notifications@github.com wrote:
Found it. SolidPython generates a Python code string to wrap around any imported SCAD code, and it evals that generated string. The backslash-delimited Windows paths were getting interpolated with only a single backslash character, leading to the problems you saw. I escaped the backslashes one more level before the eval and everything seems to be working smoothly now. Thanks for bringing that one up.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub https://github.com/SolidCode/SolidPython/issues/34#issuecomment-100681843.
I'm trying to employ the
use()
function to grab SCAD files out of a subdirectory of the folder I'm running my SolidPython scripts from.Regardless of whether I use relative or absolute paths, using the
os.path
functions to specify the target file results in a ValueError from_get_include_path()
.The only way I was able to get this to work was by avoiding
os.path
altogether and specifying relative paths as strings using forward slashes, or creating an absolute path withos.path.abspath
and usingstring.replace("\\", "/")
, both of which are pretty gross.This only happens with folder or file names beginning in letters that correspond to backslash ASCII codes -- having a folder named "features" breaks it, but "deatures" works just fine. This is definitely some kind of backslash escape problem, similar to http://stackoverflow.com/questions/11815881/windows-filename-gets-mangled.
Am I doing something stupid, or is there some kind of wonky behavior going on?
I've also included a screenshot of what the OpenSCAD file looks like if I modify
_get_include_path
to returnos.path.abspath(include_file_path)
instead. Notice that the seconduse
statement has a mangled path -- maybe there's something weird happening when writing the include/use line into the actual SCAD document?I'm on Win7, running Python 3.4, installed by cloning the git repo and running setup.py.