ScriptSpot

Forum topic · General Scripting

Help: registerRedrawViewsCallback + mouse tool

By mjbg · 2012-01-03

Description

so.. viewport isnt updating when i use this 2 commands together..
why?

here is one sample code


fn aaa = 
(
	unregisterRedrawViewsCallback aaa
	test = text size:100 kerning:0 leading:0 isSelected:on text:"test"
	starttool foo
)


tool foo
(
on mousePoint clickno do #stop
on freeMove do $.pos = worldPoint
)

registerRedrawViewsCallback aaa

the script is clearly working. But for some reason i cannot see where i place the text in this example.

note that the code is only to emulate the error i'm getting.. i know doesnt make sence to register the callback only to unregister it..

i've tried using redrawViews(), completeRedraw(), forceCompleteRedraw.. with no luck

Comments (7)

mjbg · 2012-01-03

hey Anubis.. i dont understand what you are saying.. lol
i think im not very clear.... les see if i can clarify this with the same example

if i do simply this (below), the mouse tool will work properly and i will see the text moving until i place it


tool foo
(
on mousePoint clickno do #stop
on freeMove do $.pos = worldPoint
)

test = text size:100 kerning:0 leading:0 isSelected:on text:"test"
starttool foo

but if i do the "starttool foo" inside one registerRedrawViewsCallback function (op example) it will not work.. but i am doing the exact same thing.. except one is triggered by some event etc..

mjbg · 2012-01-03

only updating the original example:


fn aaa = 
(
if objects.count == 5 do
   (
   unregisterRedrawViewsCallback aaa
   test = text size:100 kerning:0 leading:0 isSelected:on text:"test"
   starttool foo
   )
)
 
 
tool foo
(
on mousePoint clickno do #stop
on freeMove do $.pos = worldPoint
)
 
registerRedrawViewsCallback aaa

so i want the starttool foo to be executed when the objects.count == 5

tested it

Anubis · 2012-01-04

Ok, i tested this and now i see.
Something weird going on with the Text object.
Looks like Max bug.

mjbg · 2012-01-04

it looks like it "freezes" the max viewport when a new object is created by some function called by the callback

anyway.. nothing to do with the mouse tool as i thought
i just find it weird that none of the redraw commands work.

thanks for the efort

where is the event?

Anubis · 2012-01-03

except one is triggered by some event etc...

and where is your event which will trigger the callback? this is what i mean ;)

something like this: fn aaa

mjbg · 2012-01-03

something like this:


fn aaa = 
(
if objects.count == 5 do -- event
   (
   unregisterRedrawViewsCallback aaa
   test = text size:100 kerning:0 leading:0 isSelected:on text:"test"
   starttool foo
   )
)
 
 
tool foo
(
on mousePoint clickno do #stop
on freeMove do $.pos = worldPoint
)
 
registerRedrawViewsCallback aaa

should work like this:
i run the script in one empty scene
then i start creating objects.. when i try to create the 5th object it runs the tool foo..

the script works like it should.. but i cannot see the text placemant like when i can see if i run the tool foo "outside" of the callback..

redraw needs scene changes

Anubis · 2012-01-03

your tool not do anything that needs redraw,
so the callback not fired

(
global cbfn_aaa
unregisterRedrawViewsCallback cbfn_aaa

fn cbfn_aaa = 
(
	test = text size:100 kerning:0 leading:0 isSelected:on text:"test"
	starttool foo
	unregisterRedrawViewsCallback cbfn_aaa
)

tool foo
(
	on mousePoint clickno do (
		$.pos = worldPoint
		#stop
	)
	--on freeMove do $.pos = worldPoint
)
 
registerRedrawViewsCallback cbfn_aaa
Dummy() -- do something that needs redraw
)