Notifications
Clear all

[Closed] converting to point3 array

I’ve been struggling with my first script. Using filterstring I was able to extract just this data from a txt file(quotes seem to be impossible to filter). Now I’m trying to convert this to a point3 array with the z coordinate being 0. Any help would be greatly appreciated.

#(““0″”, “”-0.919″”)
#(“”-2.76″”, “”-0.919″”)
#(“”-2.76″”, “”-0.341″”)
#(“”-2.865″”, “”-0.341″”)
#(“”-2.916″”, “”-0.3″”)
#(“”-2.916″”, ““0.166″”)
#(””-2.87″”, ““0.207″”)
#(””-2.87″”, ““1.302″”)
#(””-2.694″”, ““1.302″”)
#(””-2.694″”, ““0.207″”)
#(””-2.587″”, ““0″”)

4 Replies

There seems to be something wrong with your output, the doubled quotes to be exact; but provided they’re single ones and you have collected all these arrays in another one, try this:


arrays = #(#("0","-0.919"),#("-2.76","-0.919")) -- the result of your previous process
arrayOfPoint3s = for i in arrays collect Point3 (i[1] as float) (i[2] as float) 0

Still, if you’re reading it from file, readValue might be a better option by using which you could avoid the filterString altogether.

Thank you for the reply. The values are in quotes for all the txt files I need to import. Each coordinate line starts with <vertex so I had to use filterstring, don’t really know how to use readValue for that.

Ok, then it makes sense; so just add ” (escaped quote) to the filterstring tokens to get rid of those quotes and there should be no problem.

That did the trick, those double quotes were the source of all my problems.
Thank you!