Notifications
Clear all

[Closed] TextPlus animation not works as expected

here is a “PRO” version – keeps #tracking controller animatable

delete objects

t = textplus dir:-y_axis isselected:on
	
c = t.tracking.controller = float_list()
f = c.available.controller = linear_float()

s = c.available.controller = float_script()
c.active = 1
s.addnode "self" t
s.addconstant "list" #("A:","B:","C:","D:","E:","F:") 
s.setexpression \
@"
	text = formattedPrint (int T) format:#'06X'
	if not self.isselected do self.setPlaintextString (list[mod F 6 + 1] + text)
	0
"

I disabled the setting text when the node is selected… it’s just to prevent continuous updating the modifier panel

1 Reply
(@domos)
Joined: 10 months ago

Posts: 0

And no more errors
Yeah, now “isselected” makes good sense

Same runtime error.
Open tracking/script controller (window) to get it.

Thank you, Denis,

I modified your code to this:

(
	delete objects

	tp1 = textPlus size:25 pos:[0,0,0]
	tp2 = textPlus size:25 pos:[0,50,0]
	
	textObjsArr = #(tp1, tp2)
	
	strArr = #(#("Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday", "Saturday", "Sunday"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
		
	animationRange = (interval 0 12)
	
	slidertime = 0
	for i = 1 to textObjsArr.count where isValidNode textObjsArr[i] do
	(
		t = textObjsArr[i]
		c = t.tracking.controller = float_list()
		f = c.available.controller = linear_float()
		s = c.available.controller = float_script()
		c.active = 1
		s.addnode "self" t
		s.addconstant "list" strArr[i] 
		s.setexpression \
		@"
			cnt = list.count
			if not self.isselected do self.setPlaintextString (list[mod F cnt + 1])
			0
		"
	)
)

It works in one direction only. When I move the time slider from left to right the proper month and day is shown. When I move the time slider from right to left – the wrong month and day is shown. For example, moving the slider:
frame 1 -> Jan
frame 2 -> Feb
frame 3 -> Mar
frame 4 -> Apr
frame 3 -> Maj instead of Mar
frame 2 -> Apr instead of Feb
frame 1 -> Mar instead of Jan

When I use this:

(
	delete objects

	tp1 = textPlus size:25 pos:[0,0,0]
	tp2 = textPlus size:25 pos:[0,50,0]
	
	textObjsArr = #(tp1, tp2)
	
	strArr = #(#("Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday", "Saturday", "Sunday"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
		
	animationRange = (interval 1 12)
	
	slidertime = 1
	for i = 1 to textObjsArr.count where isValidNode textObjsArr[i] do
	(
		t = textObjsArr[i]
		c = t.tracking.controller = float_list()
		f = c.available.controller = linear_float()
		s = c.available.controller = float_script()
		c.active = 1
		s.addnode "self" t
		s.addconstant "list" strArr[i] 
		s.setexpression \
		@"
			cnt = list.count
			if not self.isselected do self.setPlaintextString (list[mod F cnt + 1])
			0
		"
	)
)

Animation is from frames 1 to 12. The frame 1 never shows the correct month/day. And the same problem when slider is moved from right to left exist.

I tried to assign the flaotList to other animatable controllers(not TextPlus.tracking) but the result is the same.

When Text objects are used the problem with the wrong month/day not exist no matter how I move the animation slider. For example this code shows proper month/day no matter that the animation starts from frame 3.

(
	tp1 = text pos:[0,0,0]
	tp2 = text pos:[0,50,0]
	
	textObjsArr = #(tp1, tp2)
	
	strArr = #(#("Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday", "Saturday", "Sunday","Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
		
	animationRange = (interval 3 12)
	
	slidertime = 3
	for i = 1 to textObjsArr.count where isValidNode textObjsArr[i] do
	(
		t = textObjsArr[i]
		theCtrl = float_script()
		theCtrl.addNode "TheText" t
		theCtrl.addConstant "strArr" strArr[i] 
		theCtrl.SetExpression "if F != 0.0 then TheText.text  = strArr[F]\n0"
		t.kerning.controller = theCtrl
	)	
)
delete objects
(
	t = textplus name:#test dir:-y_axis isselected:on
	s = t.tracking.controller = float_script()
	s.addnode "self" t
	strs = #(#("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))

	animationrange = interval 1 12.9	
	s.addconstant "list" strs[1] 
	s.setexpression "tx = list[int F]; self.setPlaintextString tx; self.getPlaintextString &_tx; format \"% #% = %\\n\" F tx _tx;\n 0"
)

i see the issue now… but as you can see text matches frames (see print)…
we have to force somehow mesh update…

After you “Set Value as Text” everything works as expected. But I don’t see a way to do it with a script yet (excluding direct access to the UI)

after updating 3ds max to 2020.2 we have SetValueAsText in MaxScript. but … it doesn’t work for me. Always returns FALSE with any options. If anyone has time or an emergency, welcome to the game … I pass.

BTW 2020.3 update is available but I have not tried it.

Yes, the text matches the frames, but the mesh is not updated properly.

In the TextPlus’s method that builds the object, the string to display is acquired and shape buffers are built from that before the tracking value (or any other value) is acquired. Changing the text in the controller doesn’t affect the current object currently being built. Without some changes in the code (acquire animated values before acquiring the string), what you are trying to do will simply not work.

Larry Minton

1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

for some it would sound like a death sentence, but for me only as a challenge…

here is another version:

delete objects
(
	t = textplus name:#test dir:-y_axis isselected:on
	c = t.scale.controller = scale_list()
	s = c.available.controller = scale_script()
	c.active = 1
	
	s.addnode "self" t
	strs = #(#("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))

	animationrange = interval 1 12.8	
	s.addconstant "list" strs[1] 
	s.setexpression "tx = list[int F]; if modPanel.getCurrentObject() != self do self.setPlaintextString tx;  \n [1,1,1]"
)

edited … hmm… scale doesn’t work. but I’m not used to giving up…

Isn’t that same for Max Text, and you say it is working – in all cases?
I was testing codes in 2021 and performance of Text Plus was terrible but it would update when selected (when going backward). Or when having Debug window open.

I think it’s clear that tracking or leading controllers are used as a “backdoor entry” here.

Also, I think 1st example of using leading controller for this way I get from official docs or tutorials, not sure tough.

I mean it is not that “it will simply not work”.

1 Reply
(@miauu)
Joined: 10 months ago

Posts: 0

My previous post quoted Larry Minton – the creator of Maxscript. This is his answer in the thread that I posted in the 3ds Max Beta team forum.

Page 2 / 3