Message 1 of 8
Uncle Max' Oddities
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Community,
I have found an odd effect in Maxscript:
I have scripted a simple function that re-sets the first vertex of a closed shape to the middle of the spline.
If the function is called outside of a rollout it works very well.
But if it is called inside of rollout by an event handler (on test_button pressed do...) the function is not executed anymore.
For having a look at this phenomenon please do the following:
Create a closed spline. If you want to, you can mark the beginning with a point-helper with a pathconstraint as position controller.
Select the closed spline.
Then start the core-function, to see that function itselve works:
Now you probably see that the start point jumps each time the function is called.
So far so good.
Now, please start the bound-in-function:
Run the script and press the button ("Move First-Point"). You probably see the spline to be copied (which is intended). But you do not see the start-point moved.
I have implemented the copy-function, to see the phenomenon. There must be done something with the spline after the reset of the startpoint. When you comment-out the copy-code it works as intended.
The conclusion: The combination of a scope within a rollout-event (button pressed) and something done to the spline after the reset-first-point-function causes max to ignore splineops.makefirst within the function call.
Does anybody have a clue, why this occurs? Does anybody have a solution or a workaround? I am working on this for days to find a solution...
Kind regards
Arnim
I have found an odd effect in Maxscript:
I have scripted a simple function that re-sets the first vertex of a closed shape to the middle of the spline.
If the function is called outside of a rollout it works very well.
But if it is called inside of rollout by an event handler (on test_button pressed do...) the function is not executed anymore.
For having a look at this phenomenon please do the following:
Create a closed spline. If you want to, you can mark the beginning with a point-helper with a pathconstraint as position controller.
Select the closed spline.
Then start the core-function, to see that function itselve works:
clearspline = $
function set_start_fn clearspline_var: =
(
max modify mode
select clearspline_var
subObjectLevel = 1
--if set_start_at == undefined then set_start_at = 1
set_start_at = (numknots clearspline_var) / 2 as integer
setknotselection clearspline_var 1 #(set_start_at)
-- clearspline_var.makefirst 1 53
splineOps.makeFirst clearspline_var
updateshape clearspline_var
subObjectLevel = 0
updateshape clearspline_var
) -- function set_start_fn clearspline_var: =
set_start_fn clearspline_var: clearspline
Now you probably see that the start point jumps each time the function is called.
So far so good.
Now, please start the bound-in-function:
clearspline = $
function set_start_fn clearspline_var: =
(
max modify mode
select clearspline_var
subObjectLevel = 1
--if set_start_at == undefined then set_start_at = 1
set_start_at = (numknots clearspline_var) / 2 as integer
setknotselection clearspline_var 1 #(set_start_at)
-- clearspline_var.makefirst 1 53
splineOps.makeFirst clearspline_var
updateshape clearspline_var
subObjectLevel = 0
updateshape clearspline_var
) -- function set_start_fn clearspline_var: =
rollout test_roll "Test"
(
button test_but "Move First-Point"
on test_but pressed do
(
clearspline = $
max create mode
set_start_fn clearspline_var: clearspline
updateshape clearspline
--/*
maxops.clonenodes $ newnodes: ©node
copynode .name = "Copy-Spline EX"
in coordsys world move copynode
-- */
) -- on toll_but pressed do
) -- rollout toll_roll "Test"
createdialog test_roll
/*
maxops.clonenodes $ newnodes: ©node
copynode .name = "Copy-Spline EX"
in coordsys world move copynode
segment_laengen = getseglengths clearspline 1 cum: false byVertex:false
print segment_laengen
*/
Run the script and press the button ("Move First-Point"). You probably see the spline to be copied (which is intended). But you do not see the start-point moved.
I have implemented the copy-function, to see the phenomenon. There must be done something with the spline after the reset of the startpoint. When you comment-out the copy-code it works as intended.
The conclusion: The combination of a scope within a rollout-event (button pressed) and something done to the spline after the reset-first-point-function causes max to ignore splineops.makefirst within the function call.
Does anybody have a clue, why this occurs? Does anybody have a solution or a workaround? I am working on this for days to find a solution...
Kind regards
Arnim