Notifications
Clear all

[Closed] Maxscript Scripted Modifier Update

Hello Everyone,

I have been trying to create a scripted modifier. All works fine. The only thing is I want to display the current Z position of the object in the modifier. This will require me to update the modifier everytime the object updates. Can someone please guide me on how to update a modifier on the movement of its base object?

sample code:


plugin modifier accessBaseObject
	name:"Access Details" classID:#(0x260e697e, 0x64b63822) replaceUI:true version:1
(
	parameters main rollout:params
	(
		enterValue type:#float animatable:true ui:spnEnterValue default:0.0
		on spnEnterValue set val do (print $.name)
	)
	rollout params "Modifier Parameters"
	(
		spinner spnEnterValue "Enter Value : "
	)
	
	on update do
	(
		print ($CAMERA.pos.Z)
	)
)

Thanks in advance,
Videep

7 Replies

you have to make a dependency with this object. a possible solution as to add new parameter in your modifier param block of type #maxobject, and set it to NodeTransformMonitor of a monitoring object (it’s a camera in you case)

1 Reply
(@videep)
Joined: 10 months ago

Posts: 0

I tried to do the same, but how to monitor the transform change?. Here’s the code:


plugin modifier accessBaseObject
	name:"Access Details" classID:#(0x260e697e, 0x64b63822) replaceUI:true version:1
(
	parameters main rollout:params
	(
		spnEnterValue type:#float animatable:true ui:spnEnterValue default:0.0
		camNode type:#node subAnim:true ui:pckButton
		watchNode type:#maxObject subAnim:true ui:watchThis
		
		on spnEnterValue set val do (print $.name)
	)
	rollout params "Modifier Parameters"
	(
		spinner spnEnterValue "Enter Value : "
		pickbutton pckButton "Select Node : "
		button watchThis "Watch Object"
		
		on pckButton picked obj do(print obj.name; camNode = obj; print camNode.name)
		
		on watchThis pressed do
		(
			watchNode = NodeTransformMonitor node:camNode forwardTransformChangeMsgs:true;
		)
	)
	
	on update do
	(
		print (camNode);
	)
)

Thank You for your quick response. I feel I am not able to get the maxscript document for this…Can you please help me further?

Thanks in advance,
Videep

plugin modifier NMonitor
	name:"Node Monitor" 
	classID:#(0x899e697e, 0x64b63822)
(
	fn setMonitoring = 
	(
		if isvalidnode this.mnode do
		(
			this.zmonitor.controller.addnode "mnode" this.mnode
			this.zmonitor.controller.setexpression "if isvalidnode mnode then mnode.pos.z else 0"
		)
	)
	parameters params rollout:params
	(
		mnode type:#node ui:ui_mnode
		on mnode set val do setMonitoring()
		zmonitor type:#float ui:ui_zmonitor 
	)
	rollout params "Parameters"
	(
		pickbutton ui_mnode "NONE" autoDisplay:on width:140
		spinner ui_zmonitor "Z Position" type:#worldunits fieldwidth:60 
	)
	on create do
	(
		zmonitor.controller = float_script()
	)
)

delete objects
t = box name:"target" pos:[30,0,0] wirecolor:green
s = box name:"source" pos:[0,0,0] wirecolor:orange isselected:on
	
addmodifier s (NMonitor mnode:t)

if you want to be safe and avoid possible circular dependency use #maxObject and NodeTransformMonitor for a target (monitoring) node.

There are another ways how to do similar monitoring, but this one is what i usually use in simple situations

Is there any way to monitor UVW mapping and topology changes in stack under scripted modifier?
Or maybe just recalculate modifier BEFORE every viewport redraw?
I tried setting up global event handlers, but this works slowly and uneven somehow, so I’m looking for better solution.
Thanks in advance.

2 Replies
(@vjapi)
Joined: 10 months ago

Posts: 0

I don’t know in scripted modifiers but in regular c++ plugins you can trust on Eval function

(@denist)
Joined: 10 months ago

Posts: 0

what type is your scripted modifier?

simpleMeshMod gets all mesh related change notifications

My modifier deals with an UVW mapping, it extends UVW_Mapping_Paste