[Closed] Unknown system exception
Hi.
I’ve done a function that attach 2 point helpers to the end points of a line using a script controller. This is the function:
fn attachShapeToPoints P1 P2 =
(
ss = SplineShape Pos:P1.pos
addNewSpline ss
addknot ss 1 #corner #line P1.pos
addknot ss 1 #corner #line P2.pos
updateShape ss
local ctrlSource = \
"if (isValidNode target) and (isValidNode owner) then
" +
" target.pos * ( inverse owner.transform)
" +
"else [0,0,0]"
animateVertex ss #all
local ctrlP1 = Point3_Script()
ctrlP1.addNode "target" P1
ctrlP1.addNode "owner" ss
ctrlP1.script = ctrlSource
ctrlP1.update()
ss[4][8][2].controller = ctrlP1
local ctrlP2 = Point3_Script()
ctrlP2.addNode "target" P2
ctrlP2.addNode "owner" ss
ctrlP2.script = ctrlSource
ctrlP2.update()
ss[4][8][5].controller = ctrlP2
OK
)
What it does is set the shape points to animatable and then assign the script controller to them so they keep attached to the point helpers.
It works fine if for example I call the function in the listener (or a new script document):
pt1 = Point pos: [-50,0,50]
pt2 = Point pos: [50,0,-50]
attachShapeToPoints pt1 pt2
But if I do the same in the “pressed” event handler of a button, it throws an unknown system exception in the line:
ss[4][8][2].controller = ctrlP1
This is the test code:
rollout roTest "Test"
(
button btnCreateShape "Create shape"
on btnCreateShape pressed do
(
pt1 = Point pos: [-50,0,50]
pt2 = Point pos: [50,0,-50]
attachShapeToPoints pt1 pt2
)
)
createDialog roTest
I have no idea what’s going on there. Does anybody knows what could be causing that?.
Thank you.
Hi HalfVector,
I get the same error as you… don’t ask why it works, but I’ve tried assigning first a point3_list controller to each spline__Vertex and then replace it for your Point3_Script controller and seems to be working fine
...
ss[4][8][2].controller = Point3_List()
ss[4][8][2].controller = ctrlP1
...
ss[4][8][5].controller = Point3_List()
ss[4][8][5].controller = ctrlP2
Hope it helps,
Hey Diego, gracias. That’s really weird!.
If anybody has an explanation for this one…
Thanks.
I posted in here a while back about this the only way I found was to assign keys to the tracks and then replaced them with the point3 script controllers.
animateVertex sx #all
addnewkey sx[4][8][2].controller currenttime
addnewkey sx[4][8][5].controller currenttime
then
[size=1]sx[4][8][2].controller = Point3_Script ()
sx[4][8][5].controller = Point3_Script ()
Dan
[/size]