This seems to have slipped off the radar.
I don’t think this is a write permissions issue (though you may have seen that while attempting to write to a macOS system protected path)…
First off, I think your path needs to be somewhere you are absolutely sure that you have write permissions to. I used
/Users/dan/Desktop to test this.
Next, I think you also need to make sure that the Python component’s points input needs to be set to “List Access.” I commented out some of the middle section of code and constructed a proper path that worked to write these to my desktop.
Thirdly, you need to stringify (
pt.X (etc) point accessors to write them to the file.
import Grasshopper as gh
import Rhino as rc
ghenv.Component.Name = "Pointexporter"
ghenv.Component.NickName = "PtExp"
ghenv.Component.Description = "exports a list of points into a .txt file"
# file = os.path.dirname(os.path.realpath(filePath))
if "." not in extension: extension = "." + extension
#if os.path.exists(file) == False: # Test if file already exists; if it doesn't, proceed
# file = fileName + extension # Set file name and extension
#if os.path.exists(file) == True: # If it does exists, follow the next steps
# file_count = len([f for f in os.walk(".").next() if f[-4:] == extension]) # Find #all files with the same extension
# file = fileName + "_" + str(file_count) + extension # Add the number to the new file #name as a differentiator
path = os.path.join(filePath, fileName + extension)
# points input needs to be set to List Access
file = open(path, "w")
for pt in points:
file.write(`pt.X` + ", " + `pt.Y` + ", " + `pt.Z` + "\n")
msg = "Set 'save' to True."
Attached is a somewhat patched version of your pointExporter-v2.gh (11.7 KB) file with some minor tweaks to get it to work.
Probably too little too late, but just in case someone experiences a similar issue in GhPython in Grasshopper for Mac.