[Closed] Scripted Modifier Events
I have made a script that is a Modifier.
So, for example, there’s the event that triggers when
the modifier is opened:
on theModRollout open do …
Now, the question is, does anyone know what event
is triggered by the deletion of the modifier?
I would like to execute a routine when the modifier is
removed from the node…
Thanks.
*Edit:
The last post has a better explanation (and latest progress updated)
Check out the Scripted Plug-in Clauses topic in the online reference. The events for scripted plugins are listed near the bottom of that document.
Martijn
I have, but failed to use them…
For example:
plugin modifier theMod
name:"theModName"
classID:#(0x710269ad, 0x7ecb8bad) -- <-- I don't know what this is, or what values to use
version:1
(
parameters main rollout:theRollout
(
myParam1 type:#float ui:spn1
myParam2 type:#float ui:spn2
)
rollout theRollout "Rollout Name"
(
spinner spn1 "Spinner 1" --- etc.
spinner spn2 "Spinner 2" --- etc.
)
)
Where should I put the clause? I would just like to execute, for example: messageBox “Test”
Ah, also something else… My parameters (myParam1, myParam2) are animatable, but when I alter them in the track editor, it doesn’t update the node values (height, for example). The spinner does update, but not the node’s height. How could I fix this?
Thanks!
These can be put anywhere inside the plugin’s scope (read: between the opening and closing brackets of the plugin) :
plugin modifier theMod
name:"theModName"
classID:#(0x710269ad, 0x7ecb8bad) -- <-- I don't know what this is, or what values to use
version:1
(
parameters main rollout:theRollout
(
myParam1 type:#float ui:spn1
myParam2 type:#float ui:spn2
)
rollout theRollout "Rollout Name"
(
spinner spn1 "Spinner 1" --- etc.
spinner spn2 "Spinner 2" --- etc.
)
[b]on ... do
(
...
)[/b]
)
From the online ref:
The classID property retrieves the internal 3ds Max Class ID of the
MAXWrapper classes and objects. The value returned is an array containing
two numbers, PartA and PartB of the 3ds Max internal class ID.
For a MAXWrapper object, the value returned is the Class ID of the class
the object is an instance of.
You can use the genClassID function to generate a unique Class ID for your plugin.
Each parameter has an event on param set val … which you can use to respond to changes. Since the script doesn’t know what each parameter represents or does, you will need to use these events and tell the script what to do when the parameter changes.
Hope this helps,
Martijn
Okay… “on delete do …” in that exact place I had already tried, but it didn’t work… I’ll try again, maybe I did something wrong…
About the class# I didn’t know, thanks for explaining that!
And I have made a function already “on myParam1 set val do …”, it works normally by setting values in the normal UI, but when I set the value via track editor, the spinner value updates, but it doesn’t reflect on the object in the scene. The way I found around it was setting up a “on param get val do”, but it generates a HUGE overhead, sometimes even crashing Max… So I’m sure that isn’t the correct way, lol…
Are you sure it didn’t work? Here’s some info about the event from the docs:
on deleted do …
Called whenever the scripted plug-in object is finally deleted. This may not occur immediately, such as when a scene node containing a scripted base object is deleted, since the object is held onto by the undo stack in case the node delete is undone by the user. The delete may occur when the undo stack is cleared, such file new or reset.
The spinners are already bound to the params (myParam1 type:#float ui:spn1) so any changes made to the param should update the ui and visa versa. So you don’t need the on myParam1 set val do … event to update the ui. What do you mean by “but it doesn’t reflect on the object in the scene.” ?
Martijn
About the “on deleted”… Yes, I read that… But there is no other way then to make any action happen at the exact moment that the modifier is deleted from the object? I guess it’ll have to be done via plugin?
And about the value in the Track Editor, what I mean is… I have my main camera and two other cameras (left & right). One of my spinners makes the distance between the cameras increase or decrease. If I animate this value, the cameras move accordingly, that works fine. But if I make any changes to the animation in the Track View it screws it all up.
Please… does anyone know how to do this?
Bobo maybe?
Once again I’ll explain…
plugin modifier MyTestMod
name:"My Test Mod"
classID:#(0x1409034d, 0x27d2e578)
version:1
(
parameters main rollout:MTM
(
myParam1 type:#float ui:spn01
myParam2 type:#float ui:spn02
on myParam1 set val do
(
$.height = val
)
on myParam2 set val do
(
$.length = val
)
)
rollout MTM "My Test Mod"
(
spinner spn01 "Height"
spinner spn02 "Length"
)
)
So it animates fine, if I open the Curve Editor, I can change the animation curve and it works fine and changes the spinner value accordingly… The node’s height/length values animate as well, but the changes I make in the Curve Editor do NOT change the node’s properties animation, altough the spinner’s value displays the value it should be at…
*Edit:
I think I found out a way: Wire Parameters. I’ll test this and update here my progress.
So this is the way I managed to solve this… Using Wire Parameters
For example:
paramWire.connect2way $.modifiers[#My_Test_Mod][#myParam1] $.baseObject[#Height] "Height" "myParam1"
Include this code in a clause. In that manner you have the parameters linked and you don’t even need to use the “on myParam1 set val do”.
I hope this can be helpful to someone
Hi Celarien,
What is the reason you are using a scripted modifier for this?
Have you ever heard of the plugin XIDMary ?
I have developed a Stereo Camera which makes XIDMary unnecessary, as well fixed certain issues which were incorrect in XIDMary, such as camera roll and render size (via skew)
Edit:
By the way, you wouldn’t happen to know how to restrict it to only showing in the Modifier list if the superclassof $ is camera?
I mean, it works as is, and won’t allow to create on any other object type, but it would be better if it wouldn’t even show if not camera…
I’ve built a similar script a while ago using custom attributes. My script created two cameras (L/R) that were controlled by a dummy object. The dummy object contained the custom attributes to control eye separation, lens size etc. And, like you said, frustrum correction was applied so both camera’s had the exact same (skewed) frustrum.
Will the modifier you’re writing be applied to both camera’s? Or a control object? I’m just curious how you’re tackling this.
Cheers,
Martijn