FloatScript by maxscript

FloatScript by maxscript

Anonymous
Not applicable
1,752 Views
3 Replies
Message 1 of 4

FloatScript by maxscript

Anonymous
Not applicable

Hi,

Im trying to setup a script wich will create a float_script controller for object rotation, but I have some problem with addTarget option. So I have a cylinder wich will have the script on x rotation, and I have a point helper wich is path_constrainted to a line, what I need is to addTarget of the percent of that point helper, my code look like this :

                    fs = float_script ()
                    o.rotation.controller.X_Rotation.controller = fs
                    fs.addTarget "Percent" mainCnt.position.controller.Percent

 

When I evaluate this script it throws me a error:
Runtime error: IScriptCtrl::AddTarget - Target needs to be object or subAnim, got: 0.0

Anyone can help?

0 Likes
Accepted solutions (1)
1,753 Views
3 Replies
Replies (3)
Message 2 of 4

istan
Advisor
Advisor

if you evaluate this line:

 

 

 

mainCnt.position.controller.Percent

 

 

 

what is it reporting ?

 

Did you find this example in the doc ?

obj1 = Teapot ()--Create a teapot
-->$Teapot:Teapot001 @ [0.000000,0.000000,0.000000]
obj2 = instance obj1--Create an instance
-->$Teapot:Teapot002 @ [0.000000,0.000000,0.000000]
obj2.pos = [-100,0,0]--Place the instance 100 units along -X
-->[-100,0,0]
obj3 = Box pos:[100,0,0]--Create abox 100 units long X
--> $Box:Box001 @ [100.000000,0.000000,0.000000]
ctrl = float_script()--Create aFloat Script Controller
-->Controller:Float_Script
obj3.height.controller = ctrl--Assign Controller to Height of Box
-->Controller:Float_Script
ctrl.addTarget "myTeapot" obj1[4]--Add Target Var. with Teapot Obj.
-->true
ctrl.setExpression "myTeapot.Radius"--Set Height to Teapot Radius
-->true
ctrl.getTarget "myTeapot"--Get the Target Track as SubAnim value
-->SubAnim:Object__Teapot
ctrl.getTarget "myTeapot" asObject:true--Get as Object
-->Teapot
ctrl.PrintDetails()--Print the controller details
-->"** Script Control Details **
-->* Description:
-->(null)
-->* Expression:
-->myTeapot.Radius
-->* Variables
-->Members: 5
-->01) T, Constant = 16000.0
-->02) S, Constant = 3.33333
-->03) F, Constant = 100.0
-->04) NT, Constant = 1.0
-->05) myTeapot, Track: $Teapot001.'Object (Teapot)', tick offset = 0
-->"
 
0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks for reply, I've seen this before, but mayby Im wrong. In float_script window there is a four buttons =
Assing Constant
Assing Controller

Assign Track

Assign Node

What I need is Track, but when I try:
$.rotation.controller.X_Rotation.controller.addTrack it throws me a error "unknow property". Manually I can assign the percent of Point on path_constraint by clicking AssignTrack, but how to do it in maxscript?

0 Likes
Message 4 of 4

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

check the mxs help for right syntax:

 

delete objects
with redraw off
(
	s = point name:#source wirecolor:orange axistripod:on box:on
	t = dummy name:#target
	c = circle radius:100 
	pc = t.position.controller = path_constraint path:c 

	ps = s.rotation.controller.z_rotation.controller = float_script()
	ps.addtarget "Percent" pc[#percent]
	ps.setexpression "(Percent*0.01) * (2*PI)"
)

 

 

AddTarget requires a subAnim (not a controller, not a Value)

 

0 Likes