Notifications
Clear all

[Closed] Update Text

LoneRobot…thats hilarious…took me a second to get the joke. Now where did i put that coffee…

Thanks for the replies…
Yeh its checking to see if a folder exists which is how i want it.
There are no strange characters in the text file.
It doesnt break at a specific point and if you restart the script from where it broke it will do that name fine.
I think the renderer is crashing it halts at the render line, I read in the manual that you should change text using a controller else the renderer crashes, not really sure how to do that… any ideas?

the example should be fine, actually – that warning is only when you’re trying to render an animation (which is not really appropriate in this case as you’re reading lines from a text file – you’d have to set the animation range to match the number of lines in that file first, etc.)

That said – an example of how to change text, using a controller, is in the topic Bobo mentioned near the top of this thread

 JHN

*proest

-Johan

that warning is only when you’re trying to render an animation

Dont really understand what you mean by that… I am rendering an animation for each line of text in a text file.

As I said i have read that section of the manual but its not clear to me, I do only have 3 days experience with maxscript 🙁

I’ll elaborate

The example given in the MaxScript documentation – and which includes the warning that you should use a controller – is for when rendering an actual animation range through the standard 3ds Max render scene dialog/etc. The same as you would render any specific animation.

When going with the script I posted earlier, you’re not really rendering an ‘animation’ – you’re rendering one single frame each time, and saving that out. The difference to us humans is pretty vague, but as far as 3ds Max is concerned, there’s a whole world of difference.

For example, you can’t create/delete objects when rendering an animation in 3ds Max, as 3ds Max ‘caches’ some of the information about the scene when rendering an animation, and it doesn’t pick up on these node changes. But you’re absolutely free to render one single frame, after which max clears that cache, then create/delete the object(s), then render one single frame again, etc.

You could use the controller form… then it’d look something like this:


rollout roll_test "test" (
	local obj_text, obj_cam, f_in, f_out
	pickbutton pick_txt "pick text object"
	button btn_selinfile "select input file"
	button btn_doit "do it"

	on pick_txt picked obj do ( obj_text = obj )
	on btn_selinfile pressed do ( f_in = getOpenFilename() )
	on btn_doit pressed do (
		local f = openFile f_in mode:"r"
		persistent global textLines
		textLines = #()
		while (not (eof f)) do (
			append textLines (readline f)
		)
		close f

		animationRange = (interval 1 textLines.count)
		sc = (obj_text.kerning.controller = float_script())
		sc.addNode "textObject" obj_text
		sc.script = "
			if (textLines != undefined) then (
				try ( textObject.text = textLines[(currentTime as integer / ticksPerFrame)] )
				catch ( textObject.text = \"-- error --\" )
			)
			else ( \"-- textLines missing --\")
			1.0"
	)
)
createDialog roll_test

Note that you no longer pick a camera or the output filename – you would just render whatever viewport / camera view you would like, to whatever filename you would like, through the Render Scene Dialog.

The meat of the script is that it…

  1. reads all lines from the text file into an persistent array (saves with the .max scene file)
  2. changes the scene’s animation range to range from 1 to the number of lines read
  3. sets up a controller on the text object’s ‘kerning’ value (making the presumption you don’t use that) that…
  4. changes the text of the text object to the Nth string in the aforementioned array, where N depends on the current frame

You can scrub the viewport and see the effect – same should happen when rendering (make sure you render the active time segment – if you render outside of the valid range of lines, the text will read “– error –”)

Ah ok I guess I will stick with what I’ve got as im not clued up on maxscript enough to do anything more advanced… the script I have works it just needs some user interaction when the error occurs, not too much of a big deal.
Thanks for the advice, i appreciate it.

Page 2 / 2