how can I create a folder to export different type of files in rhino python.
right at the start of the script I want to pront the user to select a location and create a folder, that folder will then be used to save the files the script will export.
it will be 2 .csv files and 1 .dwg file
I tried using rs.savefilename but that creates a file, not a folder.
at the moment I’m exporting just by using:
with open(“filename” + ‘.csv’,“w”) as f:
f.writelines(make_csv(matrix))
but this just exports the file in the same place I have the script saved.
To create a directory with Python, use os.mkdir
To save there, use os.path.join this will combine the directory name and the filename to an absolute path.
import os
import os.path
dir = r"C:\temp"
if not os.path.exists(dir):
os.mkdir(dir)
with open(os.path.join(dir, "filename"+'.csv'), "w") as f:
f.writelines(make_csv(matrix))