Notifications
Clear all

[Closed] Adding Expression or Script Controller

I understand how to assign controllers, obj.pos.controller = float_script()
What I don’t understand is how to add the expression or script… specifically creating vector variables in an expression controller. I found the IExprCtrl in the help but don’t know the first step…

I’d like to create a unique material for each of a selection of objects and add unique expression controllers to various properties of each material.

Here is what I have started.

Happy Fathers day (at least in the U.S.)

obs = selection
for i = 1 to obs.count do 
(
	obs[i].material = StandardMaterial()
	obs[i].material.name = ("Hex_" + formattedPrint i format:"04u")
	
	fe = Point3_Expression()
	
	obs[i].material.diffuse.controller = fe
	
	fe.addVectorTarget "p1Pos" obs[i].position.controller
	fe.addVectorTarget "p2Pos" $Point01.position.controller
	fe.SetExpression "[(length(p1Pos - p2Pos)/1000)), (length(p1Pos - p2Pos)/1000)), (length(p1Pos - p2Pos)/1000))]"
)
2 Replies

Hi jonahhawk,

You are probably getting an error because you have too many closing brackets in your expression:

Martijn

Dank je wel Martijn.

That’s what I get for scripting at 1:00 AM on a Saturday night.