Reputation: 59
I need to put some code in a MaxScript that will take data from parts of a .txt (or maybe CSV) file and use it to name exported objects etc.
So far iv'e only been using listener to work out scripts and so this is beyond me right now.
Any help appreciated, thanks!
Upvotes: 2
Views: 2348
Reputation: 367
This is because in your export line you have adata between double quotes which instead of using your variable use the string value "adata". Try using this snippet instead
assetPath = PathConfig.AppendPath maxfilepath "Assets"
fileName = (adata as string) + "_123"
fullPath = PathConfig.AppendPath assetPath fileName
exportFile fullPath #noPrompt selectedOnly:true using:ExporterPlugin.classes[14]
Note: The "as string" and the bracket might not be necessary on the second line if your variable is already a string.
Upvotes: 0
Reputation: 59
So I have got this far:
adata = (dotnetClass "System.IO.File").ReadAllLines "Job_Log.csv"
print adata
exportFile ((maxfilepath + "\Assets\" ) + "adata" + "_123") #noPrompt selectedOnly:true using:ExporterPlugin.classes[14]
It exports to the correct path and the second line prints the data/name in the .csv file ok, but I cant get that value to be the name it exports as.
It just comes out as "adata_123.obj" instead
Any Ideas?
Upvotes: 0
Reputation: 749
Here is a nice short example of opening and parsing a csv file: https://forums.autodesk.com/t5/3ds-max-programming/need-maxscript-help-reading-values-from-a-csv/td-p/4823113
Upvotes: 1
Reputation: 367
I would suggest to take a look at FileStream. You should be able to open and read your file using it :)
Upvotes: 0