ERROR LOOPPING CONTINUOSLY CANNOT CALL FUNCTION JUST ONCE

I WANT TO REFRESH FORM DEPENDING ON SELECTING OBJECTS(COULD BE SINGLE OBJECTS AS WELL AS GROUPS) THIS SCRIPT http://www.scriptspot.com/forums/3ds-max/general-scripting/how-to-enable... IS GIVING ERROR WHEN WORKING WITH GROUPS, THAT IS WHY I WANT TO USE TIMER

timer clock "testClock" interval:1000 --tick once a second

on clock tick do
(

fresh_obj_selection=selection as array

if cur_obj_selection!=fresh_obj_selection

then
(
print("output::"+(fresh_obj_selection as string))
print("output::"+(cur_obj_selection as string))
cur_obj_selection=fresh_obj_selection

)

)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
artrender.info's picture

SOLVED

THANK YOU!

function check_selection = (
this_sel_count = (selection as array).count
updatefunction()
)

...................

on my_rollout open do check_selection()

artrender.info's picture

STILL NOT WORKING

THX FOR QUICK ANSWER! MY GOAL IS TO CALL FUNCTION ONLY WHEN I SELECT OTHER OBJECTS

-------------BEFORE ROLLOUT I USE-------------------------

cur_obj_selection = selection as array

------------------AFTER ROLLOUT -----------------------------

--I WANT TO CHECK, IS SELECTION CHANGED OR NOT, IF YES THEN PRINT
--I DON'T KNOW WHY BUT IT'S PRINTING CONTINUOUSLY IF EVEN I DON'T SELECT ANYTHING --ELSE, JUST ONE OBJECT SELECTED

timer clock "testClock" interval:1000 --tick once a second

on clock tick do
(

--fresh_obj_selection=selection as array
fresh_obj_selection = for i in selection where not isGroupHead i collect i

if cur_obj_selection!=fresh_obj_selection

then
(
print("output::"+(fresh_obj_selection as string))
print("output::"+(cur_obj_selection as string))
--print cur_obj_selection[1]
--print fresh_obj_selection[1]
cur_obj_selection=fresh_obj_selection

)

)

Anubis's picture

no need UPPER case typing!

You cannot compare arrays directly like a1 != a2.
You should compare all elements stored inside.
And to track SELECTION CHANGED via Timer, hmm...
probably (close enough, but not precise):

on clock tick do
(
	if selection.count != lastSelCount do
	(
		lastSelCount = selection.count
		print selection
	)
)

Better is to follow Branko advice and use callbacks.

my recent MAXScripts RSS (archive here)

barigazy's picture

i suggest you to read this

i suggest you to read this topic from mxs help about
General Event Callback Mechanism.
On this forum you can find some examples

http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/index.htm...

bga

artrender.info's picture

TRIED THIS AND IS STILL NOT WORKING

ITS STILL LOOPING, AND IT'S PRINTING EVERY SECOND
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"
"output::#()"

timer clock "testClock" interval:1000 --tick once a second

on clock tick do
(

--fresh_obj_selection=selection as array
fresh_obj_selection = for i in selection where not isGroupHead o collect o

if cur_obj_selection!=fresh_obj_selection

then
(
print("output::"+(fresh_obj_selection as string))
print("output::"+(cur_obj_selection as string))
--print cur_obj_selection[1]
--print fresh_obj_selection[1]
cur_obj_selection=fresh_obj_selection

)

)

barigazy's picture

Sorry. I correct for-loop.

Sorry. I correct for-loop. Look the first code (for o in selection ...)

bga

barigazy's picture

...

Try to isolate group helper object

fresh_obj_selection = for o in selection where not isGroupHead o collect o
-- or
if isGoupMember selection[1] do ...

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.