[Closed] weird path constraint problem
Hi Guys,
I’m having a weird problem with the following script. What it does is it adds a path constraint to the selected object and then appends a new path to it.
Everything works fine when you run it, however if I save the file and re-open it, the second path has been removed.
Here’s the code…
(-- Start Script
local var1 = $Line01
local var2 = $Line02
MyController = $.position.controller = Path_Constraint()
MyController.path = var1
MyController.percent = 50
MyController.follow = true
deleteKeys $.position.controller #allKeys
$.position.controller.appendTarget var2 50.0
)[color=#008000][size=2][color=#fffffe]-- End Script
[/size][/color][/color]
Create two lines (must be named line01 and line02). Then create an object, select it and run the script. It will create a path constraint with the two lines. See how it works, save it and reopen it…Line02 will not be in the path constraint list anymore. I have no-idea why this is happening and suspect it’s something quite simple which i might have overlooked.
Thanks for taking a look.
-sheefy
Looks like assigning to the .path property screws the ParamBlock of the constraint. After that, even removing and adding new paths via the UI does not fix it – it will always save the first one. Remember, the original Path Controller had only one path and the .path property was used to get and set it. It was left there for backwards compatibility, but it looks like using the property interferes with the new functionality of the Path Constraint (support for multiple paths). Of course, I might be wrong, but it appears to be the cause.
Use .appendTarget method each time you add a path.
(
local var1 = $Line01
local var2 = $Line02
$.position.controller = Path_Constraint()
$.position.controller.percent = 50
$.position.controller.follow = true
deleteKeys $.position.controller #allKeys
$.position.controller.appendTarget var1 50.0
$.position.controller.appendTarget var2 50.0
)
Just thought I should post another thank you. This thread just saved me a huge headache as I had a scene that was created with a script that used the .path property. After trying to do some tweaks by hand this morning, then saving the scene and reopening all of the tweaks were gone. Drove me crazy until I ran a search and found this thread, now I at least know why it was happening and was able to update the script to use .addTarget instead of .path
Thanks!!