Notifications
Clear all

[Closed] Scripted Modifier and Node it is attached to?

I’ve a scripted modifier which I wish to effect the material of the object I’ve it attached to.

Is there and easy way to see what max node a scripted modifier is attached to?

I have it store it during an ‘on create’ event, but if you instance the object with the mod, the modifier on the instance has the orginial value.

Thanks

3 Replies

Hi,

I’ve also had this problem, and I’ve finally came up with the follwing solution. It’s not perfect, but works well enough for my purposes. What I’m doing is adding a function to the plugin that returns an array of the nodes the instance of the plugin is attached to (it has to be an array since the same instance of the modifier might be assigned to several nodes).

Here’s a sample code:




-- Get Owners
-- by Ofer Zelichover (C) 2007
-- This code demonstrates how to get the nodes with an
-- instance of a scripted modifier attached to them.

plugin modifier ownersDemo
	name:"Owners Demo"
	classID:#(0x14e65e22, 0x20c6d530)
	version:1
(
	-- This is the function that gets the array of nodes.
	-- It can be called from within the scripted modifier
	-- by using this.getOwners() or from other maxscript 
	-- scopes by calling it as a method of the modifier.
	-- (Both methods are demostrated below).
	fn getOwners =
	(
		for o in refs.dependents this where isValidNode o collect o
	)

	-- Just a standard param block.
	parameters params rollout:roll
	(
		param1 type:#float default:0.
	)

	-- And a sample rollout
	rollout roll "Parameters"
	(
		spinner spParam1 "demo value:"
		button bnOwners "Who am I attached to?"
		-- This is how you would use the function from within
		-- the modifier
		on bnOwners pressed do print (this.getOwners())
	)

)


-- And an example of how to use it generally:
b = box()
addModifier b (ownersDemo())
print (b.ownersDemo.getOwners())


hOpes this helps,
o

SWEET… that is EXACTLY what I was looking for…

Thanks a bunch!

I know I’m nitpicking here, but for completeness sake change this line:

param1 type:#float default:0

to:

param1 type:#float default:0 [b]ui:spParam1[/b]

to “bind” the spinner to the parameter

Cheers
Martijn