Message 1 of 2
Problem with inserting script into float_script controller.
Not applicable
04-18-2012
01:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys,
So I'm learning MaxScript and everything was going well until I hit a snag. I'm writing a script that automatically adds a point helper to a spline and inserts a script into the .percent property that derives the point's position on the path from the number in it's name. The ultimate objective is to drive many points along the same path with a single control. Everything works well except when I try to enter the script into the point which gives me "can't convert float" error. If I were to insert the code manually the point does exactly what I need, but if I try to do it via script it blows up. Any thoughts? Maybe one of you old hands can take a look and see if there is something obvious in my code that can resolve this?
Much thanks. Marcin
So I'm learning MaxScript and everything was going well until I hit a snag. I'm writing a script that automatically adds a point helper to a spline and inserts a script into the .percent property that derives the point's position on the path from the number in it's name. The ultimate objective is to drive many points along the same path with a single control. Everything works well except when I try to enter the script into the point which gives me "can't convert float" error. If I were to insert the code manually the point does exactly what I need, but if I try to do it via script it blows up. Any thoughts? Maybe one of you old hands can take a look and see if there is something obvious in my code that can resolve this?
Much thanks. Marcin
SplineName = $.name as string + "_Anchor_"
Point name:SplineName
Temp = getnodebyname SplineName
Temp.pos.controller = position_list ()
Temp.pos.controller.Available.controller = Path_Constraint ()
Temp.pos.controller.'Path Constraint'.path = $
n = EmptyModifier ()
addmodifier $ n
$.modifiers.name = "PathControl"
att_PathControl=attributes PathControl (
parameters par_PathControl rollout:rol_PathControl (
Offset type:#float UI:spn_Offset
Spacing type:#float UI:spn_Spacing
)
rollout rol_PathControl "Path Control" (
spinner spn_Offset "Offset:" type:#float
spinner spn_Spacing "Spacing:" type:#float
)
)
custAttributes.add n att_PathControl
Temp.pos.controller.'Path Constraint'.Percent.controller = float_script()
Temp.pos.controller.'Path Constraint'.Percent.controller.AddTarget "Offset" $.PathControl.PathControl
Temp.pos.controller.'Path Constraint'.Percent.controller.AddTarget "Spacing" $.PathControl.PathControl
Temp.pos.controller.'Path Constraint'.Percent.controller.AddNode "SelfNode" Temp
Temp.pos.controller.'Path Constraint'.Percent.controller.script = "Temp = (filterstring SelfNode.name \"" + Temp.name + "\")\nY = Temp as float\nY = Y * Spacing\nY = Y + Offset\nY=Y/100\n"