Notifications
Clear all

[Closed] Script on an object to modify it's self?

What’s the best way to have a script that’s attached to an object in some way to be able to modify that object? I have a little rig I’m trying to make and I want to make it as few objects as I can cause there’s going to be a lot of them in a scene. I need to modify the positions of the verts of a spline based on the transform of another object. I was hoping to be able to put the script ON the spline somehow, and have it execute every frame to reposition the verts. But if I add it as a list controller or as part of the transform controller, I get an illegal self reference. I’ve tried to add script controllers to other spots like the render thickness, but they don’t seem to evaluate. I have it working perfectly with the script on an intermediate object. But I’d rather not have that extra object if I don’t have to. Was just talking with a co-worker who said. “How good would a script modifier be?” Is it possible? Is there already such a thing? A modifier that you can put a script into that you can modify that object with it?

Cheers,

Cg.

4 Replies

I can think of a few different things to try.

Use AnimateVertex to add a controller to the vertex.
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-E75D8D72-53D4-4306-BD8C-25D7363A7050.htm,topicNumber=d30e612686

Use a change hadler on the target object. http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-513285B3-DBF6-471E-B587-B5BE14D4D875.htm,topicNumber=d30e705402

Simplist method is to just add a Spline IK modifier. Create Controls and just link the control for that vertex to your target.

I guess you can do something with a custom attribute as well, but I would try those other methods first.

Hi thanks for your reply. I think the animate vert and the spline IK ways would be much more cumbersome than what I already have. But I’m keen to know more about how you think I could use a callback or a custom attribute. I’ve used both quite a bit in the past, but am unsure as to how either would apply in this case. Could you elaborate a little please?

Cheers,
Cg.

animated verticies is probably the right solution for you.
after we have subanims for verts we can apply a controller to animate them.
it might be script controller, expression controller, or wire controller.
i prefer wire:


delete objects
(
	radius = 20
	a = converttosplineshape (circle name:"body" radius:radius wirecolor:yellow)
	d = dummy name:"target" boxsize:[10,10,10] isselected:on
	d.parent = a
	animatevertex a #all
	c = a.baseobject[#master]
	p = d.pos.controller

	c[2].controller = Point3_XYZ()
	paramWire.connect p[3] c[2][1] ("Z_Position+" + radius as string)
	c[5].controller = Point3_XYZ()
	paramWire.connect p[3] c[5][2] ("Z_Position+" + radius as string)
	c[8].controller = Point3_XYZ()
	paramWire.connect p[3] c[8][1] ("-Z_Position-" + radius as string)
	c[11].controller = Point3_XYZ()
	paramWire.connect p[3] c[11][2] ("-Z_Position-" + radius as string)
)

I managed to get it working by putting the script on the rotation controller of the driver object.