Hey guys, new to Rhino, and running into an issue straight away, been playing around for a while but jsut can;'t seem to get around it,
I need to do a batch script to convert a set of files,
i have got the folder indexed, I can get all the filenames etc, thats all fine, (I’m familiar with python)
however when I try to open the file through script Rhino always prompts me whether I want to save, and there is something about UpdatePromtUpdateBox etc. which means my file never loads (and even if it would, it does this for every file requiring manual clicking,
I also found a ready made batch convert but it does the same thing.
anyways the most basic thing to test seemed to be this:
so I seem to have got everything working, except for filenames that include spaces…
any idea on how to handle those? otherwise I got it to do pretty much everything I want
Passing a path in the Rhino commandline will work fine without double quotes, except when there is a space character in the path eg: D:\test\test file with spaces.stl
Passing that as a string without double quotes will make Rhino catch the space as an enter and you will end up with Rhino not being able to make sense of the input.
So to circumvent that you can define a command string in python with single quotes and inside it, put the path in double quotes, making sure Rhino will interpret the part in between double quotes as a single entity input.
If you are referring to the .format statement, the braces represent substitution items. When it is executed, the braces are replaced by what is inside the parentheses using the appropriate formatting. Example:
item=1.0
print "The value of my item is {}".format(item)
>>> 'The value of my item is 1.0'
Pretty much anything can be substituted in, numbers, strings, etc. You can have any number of braces in a format statement, they are executed in order:
a=3
b="eggs"
c=2
d="spam"
print "I had {} {} and {} slices of {} for breakfast this morning".format(a,b,c,d)
>>>'I had 3 eggs and 2 slices of spam for breakfast this morning'
Format statements are very powerful and allow you to easily set up strings using your variables for printing and sending to the command line.
Nope the curly braces … rs.Command(’_-Open {} _Enter’.format(path))
My real question that I was gonna hold off asking until I did my 'forum due diligence" is when I try to open a file when there already is stuff loaded I keep getting a get a save changes dialog box
i’m facing a similar problem with a file path at present.
Only difference being that i’m passing the file name with the absolute path as a variable.
So i have my variable “fpath” and following is a result when i print the fpath variable:
E:\Folder\New - File.stp
But when i use the open file command in Rhino, it can’t find the file due to the white spaces in the filename.
Following is the command i’ve tried:
rs.Command(’_-Open fpath _Enter’)
What do i need to modify in the Open File command?