Maxscript-Load Animation with a Spinner

Hi everyone,

I’m trying to load an animation with one Spinner attribute that I have, so I wrote the code for it and works good.

There is a problem though, that when I animate the Spinner nothing happens in viewport, only it works when I change the spinner value myself (I mean using mouse and changing the value). The Spinner gets updated as timeslider moves, but nothing happens in viewport.

Here is the code:

animTriggerAT = attributes animTrigger(
	
	parameters triggerParams rollout:triggerRoll(
		refObjList type:#MaxObjectTab tabSize:0 tabSizeVariable:true
		trgObjList type:#MaxObjectTab tabSize:0 tabSizeVariable:true
		rootObjList type:#MaxObjectTab tabSize:0 tabSizeVariable:true
		triggerSpinnerSp type:#integer animatable:true ui:triggerSpinner
		
	)

	rollout triggerRoll "Drone Trigger" width:162 height:300(
		spinner triggerSpinner "Trigger" range:[0,200,0] type:#integer width:128 height:16
		
		fn calcTM val = (
			for i = 1 to trgObjList.count do(
				with animate off(
					if refObjList[i].node.parent != undefined then(
						trgObjList[i].node.transform = (at time val (refObjList[i].node.transform * inverse refObjList[i].node.parent.transform * refObjList[i].node.parent.transform)) * rootObjList[1].node.transform
					)else(
						trgObjList[i].node.transform = (at time val (refObjList[i].node.transform))	* rootObjList[1].node.transform
					)
				)
			)
		)
		
		on triggerSpinner changed val do(
			calcTM val 
		)
	)
)

custattributes.add $CTRL_Drone.modifiers[1] animTriggerAT

I’d be appreciated if you can see what’s wrong, and feedback me.

Thanks,
Ehsan

Consider any of the following methods:

redrawViews()

Causes the 3ds Max viewports to be immediately redrawn in an optimal way, such that only those parts of the view that have changed are redrawn. This is different from forcing a redraw with the max view redraw command or one of the following methods which redraw the entire scene in all views.

completeRedraw()
forceCompleteRedraw [ doDisabled:<boolean> ]

Calling this method will cause all the viewports to be completely redrawn. This method literally forces everything (every object, every screen rectangle, every view) to be marked invalid and then the whole scene is regenerated. The individual object pipeline caches are not flushed, however. This routine is guaranteed to be slow. If the optional doDisabled: boolean argument for ForceCompleteRedraw is true, disabled viewports will also be redrawn.

setNeedsRedraw complete:<bool>

Sets an internal MAXScript flag that viewports need to be redrawn before MAXScript returns. This is equivalent to a delayed redrawViews().
If complete: is true, a flag is set that a complete viewport redraw is needed. This is equivalent to a delayed completeRedraw().

Thanks but none, worked!

So I decided to run the core code into a Script Controller and reference my data from the Attribute Holder. It worked well.