Notifications
Clear all

[Closed] max script | change text shape using external array txt

Hi all, somebody can help me?
I would like change text shape dynamically using a external txt file.
If I have 3 text shape objects in the scene, and my external array in .txt have a code like this:
var text = [“dog”, “cat”, “mouse”];
text shape1 object change to dog
text shape2 object to cat
text shape3 object to mouse

I know the idea but how do this in max script?
Can I set the an instance or use the original instance to set new shape name

I found this on the internet
<text>.text String default: “3ds MaxText”
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-6CB41D09-0586-43DF-821A-93EBEE01DD9D.htm,topicNumber=d30e310760

:banghead:

3 Replies

I think just set the object name with your predefined array
for ex: $shape1.name = text[1]

If you use the OpenFile function and then ReadDelimitedString, you can store the values (“dog” etc) in the text file simply as strings separated by a comma (or, actually, whatever you like – readDelimitedString allows you to choose what is being used to separate values). You read each one in turn, and can assign them to a variable. At that point, what you actually do with them is up to you!

Just remember to always close your files in Maxscript, and if your script crashes halfway through running with the file open, run a gc() command in the listener to clear Max’s memory of having opened it. This makes sure it’s editable again.

Thanks DanGrover and batigolnguyen for starting point.
Let me try some attempts with your tips and after that I post again
Thanks very much
Regards, Fernando.