Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Animating Text Strings

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
330 Views, 2 Replies

Animating Text Strings

I need to read a spreadsheet and animate text values based on data parsed from the string.  I can do the text parsing part.  Years ago, I animated text values in MaxScript with a funky work-around involving inserting a small program an object somewhere and having the frame number set to a variable and that somehow changes the text string to the variable that another running maxscript program was executing that pasred the string and defined the text string to a variable that was used in the weird frame, something, something.....  It was awhile ago and I'd have to restore the archived job and dig through the process to figure out what the heck I did.  It worked but was really odd and tricky to implement.  But I had text in temperature and pressure sensors changing to reflect a spreadsheets value for those items at the appropriate frame.

 

I'm hoping that something has been done to MAX since then to make all this easier, Like allow MaxScript to access a text object's value and replace it for a given frame.

 

If anyone has any new information in this area....much appreciated.

Thanks.

Buck Wyckoff

BSDI

2 REPLIES 2
Message 2 of 3
Swordslayer
in reply to: Anonymous

If all you need is a viewport playback/screengrab and you have the values saved in a plain text file, this will work:

 

(
	local txt = selection[1] -- currently selected object is the Text Node

	if isKindOf txt.baseObject Text do
	(
		local textScript = scale_script()
		textScript.addObject #txt (NodeTransformMonitor node:txt)
		textScript.script = "if NOT isKindOf ::textValBuffer Array do\n(\n" +
			"\ttextValBuffer = #();\n" +
			"\tlocal file = openFile \"C:\\\\TEMP\\\\test.txt\";\n" + -- path to the file
			"\twhile NOT EOF file do append textValBuffer (readLine file);\n" +
			"\tclose file;\n);\n\n" +
			"if F >= 0 AND F < textValBuffer.count do\n" +
			"\ttxt.baseObject.text = textValBuffer[int(F+1)];\n[1,1,1]"

		txt.scale.controller = textScript
	)
)

 

 

it would on the other hand crash when rendering a sequence (all the rendertime meshes have been already evaluated), so for that you'd have to export it as an obj sequence first:

 

(
	local obj = selection[1]
	local outputFolder = "C:\\TEMP\\test\\"
	local settingsSet = false

	if doesFileExist outputFolder do
	(
		for i = 0 to 6 do
		(
			local filename = outputFolder + obj.name + formattedPrint i format:".3i" + ".obj"
			sliderTime = i

			if NOT settingsSet then
			(
				exportFile filename selectedOnly:true
				settingsSet = true
			)
			else exportFile filename #noPrompt selectedOnly:true
		)
	)
)

 

 

and load it via objLoader.

Message 3 of 3
Anonymous
in reply to: Swordslayer

Thanks.

I'll have to chew on this for a while.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report