Notifications
Clear all

[Closed] Scripted Plugin, Spinners, and Auto Key

Hi. I consider myself to be a noob as far as maxscript goes. I did a couple of scripts for my 3d artist at my studio, but maxscript docs still confuse me.

Here’s what I’m doing. I’m writing a scripted Helper plugin (at least thats what the docs call it) that extends the Dummy class.

I create the parameters, and a rollout with spinners. What I’m trying to achieve is to be able to animate the Spinners, so they move the objects created in the Tool Create method.

It all seems to work, however when I do so and take a look at the Track View, I see that the spinners have keyframes, but since my 3d artist is using Auto Key a lot, the objects that get moved with the spinners also get the keyframes.

I removed the leyframes from the objects to see if the spinners will still move them, but they don’t, eventhough the spinners still have keyframes.

What am I missing here? It’s probably some “on” event. At this point I’m only using “on changed”. Even if that’s it, I still have a problem of “additional keyframes”.

Thank you for your time guys. Below you will find a sample code that behaves exactly as I described.

Everything up to THIS point is the most important for me and I could really use some help. Anhything that follows is just me being curious. So…

  1. Is it possible to “cast” the properties of the object created in the Tool Create into my own rollout?
  2. How can I make it so that no matter which object of the ones created in the Tool Crearte gets selected I will always see my rollout (in the modify panel of course)?
  3. How can I make it so that if one of the created objects gets deleted, all of them will be deleated as well?

Sample code.
Once you Evaluate it, it will appear in the Helpers section of the Create tab under Standard category.


plugin Helper TestHelper
	name:"Example" ;
	classID:#(0x2f560483, 0x589c0d0a);
	category:"Standard";
	extends:dummy;
	replaceUI:true
	invisible:false

(

	local thisObj, gBox
	
	tool create 
	( 

		on mousePoint click do 
		(
			
			thisObj = $;
			gBox = Box();
			delegate.boxsize = [10,10,10];
			
			gBox.parent = thisObj;
			#stop;
		)
	) 
	
	parameters pParams rollout:params

	(
		XPos type:#float animatable:true ui:XPos default:0.0
	)
		
	rollout params "Simple Camera Rig"
	(
		Spinner XPos "X:" range:[-1e9, 1e9, 0]
		
		on XPos changed val do 		(	in coordsys parent gBox.pos = [val,0,0]	)
	)
)


Thanks in advance.

3 Replies

I tried to loose the “on change” event on the spinner and link the spinner controller to the controller for the box position, but I couldn’t make it work as well. Some error “undefined”. Maybe I’m approaching the problem from the wrong angle. Guys… Please. Help.

Even if I’d make the controller to link properly then it still wouldn’t serve my needs, because the keyframes would be created on the objects that get moved with the spinner. What I want to achieve is to have the keyframes only on the spinner.

Guys. Help. Thanks.

You are trying to create something like a “System” plugin (like Biped, Sunlight System etc.) where one object controls all others. This will be tricky because you want the animation of the box to be stored in the dummy.

It is easy to avoid the setting of the keyframes on the box – just set the animation context to off inside the handler.

on XPos changed val do ( with animate off in coordsys parent gBox.pos = [val,0,0] )

But this does not solve the problem with having the box moved when the helper’s track is changing. Even worse, even if you could get the Helper to move the Box all the time, since a Helper plugin is not renderable, chances are that at render time anything that Helper does via scripts won’t apply to any rendering objects like the box because the renderer ignores helpers unless another object DEPENDS on them (e.g. is Parented to the Dummy or has a Script Controller referencing the Dummy).

I would suggest using Script Controllers to create the dependency, where the Position of the Box has a Script Controller referencing the track in the Helper. If the Position Script is the only controller (no List controller to accommodate user animation), then the side effect will be no keys on the Box when the AutoKey is on.

Thanks for the reply. I finally solved this using paramWire and a few constrains. Any idea on how to create a “system” plugin? That’s essentially what I’m doing. Probably just a difference in the declarations at the top, but if you’ve done something like this before it would be a huge help.

Also… any ideas on the other issues? 1) 2) and 3)?

Thanks.