gw.text problem

hello

I tried to modify a Paul Bertino script to show name and poistion of selected objects.
I works but I can't do a script to remove it (need to reboot max).
I don't really understand maxscript help "register" and "unregister" ??

If somebody can help :-)
----------------------------------------------
(
unRegisterRedrawViewsCallback showObjectNames

fn showObjectNames=
(
gw.setTransform(Matrix3 1)
for o in selection do
(

gw.text (o.pos+[0,0,0]) ("< "+o.name+" >") color:yellow

gw.text (o.pos+[0,0,-3]) (o.pos.x as string ) color:yellow

gw.text (o.pos+[0,0,-6]) (o.pos.y as string ) color:yellow

gw.text (o.pos+[0,0,-9]) (o.pos.z as string ) color:yellow
)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
registerRedrawViewsCallback showObjectNames
showObjectNames()
)

Comments

Comment viewing options

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

well, I solved my problem

well, I solved my problem :
use one time it show test, second time it hide...

thanks for unvolontary help of andrei kletskov (111) - http://andklv.narod.ru -- andklv@mail.ru :-))

--------------------------
fn showObjectNames=
(
gw.setTransform(Matrix3 1)

a=3
esp= -3

for o in selection do
(

gw.text (o.pos) (" "+o.name+"") color:yellow

)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)

if rvcb == undefined then
(
global global_count = 0
fn rvcb = showObjectNames()
registerRedrawViewsCallback rvcb
countme()
)
else
(
unRegisterRedrawViewsCallback rvcb
rvcb = undefined
b = box2 5 15 100 37
gw.clearScreen b
gw.updateScreen()
)
-----------------------

titane357's picture

not solved. I tried all I

not solved.
I tried all I can imagine, I need to reboot max to remove text....

Anubis's picture

Make 2 events, button

Make 2 events, button pressed for example, to reg/unreg callbacks. For example:

on btn_show pressed do
(
	registerRedrawViewsCallback showObjectNames
	showObjectNames()
)
on btn_hidde pressed do
	unRegisterRedrawViewsCallback showObjectNames

my recent MAXScripts RSS (archive here)

titane357's picture

I'd prefer to do two

I'd prefer to do two separate .mcr
I tried "unRegisterRedrawViewsCallback showObjectNames" anubis but without any result (my fault)

I have another question : how can I show Angleaxis x,y,and z values ? and not values : rotation.x (= 0.000882 like)

------------------------------
(
unRegisterRedrawViewsCallback showObjectNames
fn showObjectNames=
(
gw.setTransform(Matrix3 1)
a=3
esp= -3
for o in selection do
(
gw.text (o.pos+[a,0,1]) ("< "+o.name+" >") color:yellow
gw.text (o.pos+[a,0,esp*1]) (o.pos.x as string + " | "+ o.pos.y as string + " | "+ o.pos.z as string ) color:yellow
--gw.text (o.pos+[a,0,esp*1]) (o.rotation.Euler_X as string + " | "+ o.rotation.Euler_y as string + " | "+ rotation.Euler_z as string ) color:white
gw.text (o.pos+[a,0,esp*2]) (((o.scale.x)*100.0) as string + " | "+ ((o.scale.y)*100.0) as string + " | "+ (((o.scale.z)*100.0) as string) ) color:yellow
)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
registerRedrawViewsCallback showObjectNames
showObjectNames()
)
-------------------------------------------

real08121985's picture

"unRegisterRedrawViewsCallbac

"unRegisterRedrawViewsCallback showObjectNames" hides the text
(removes the callback of the function on each viewport redraw = unregisters callback)
"registerRedrawViewsCallback showObjectNames" shows the text
(enables/adds the callback of the function on each viewport redraw = registers callback)

in your script you first perform a hide and afterwards a show, so the result is the text will be shown :)

titane357's picture

hello "Real08121985" thanks

hello "Real08121985"
thanks for precision.
this script was the one to show the text.
But I can't manage to hide the text, even with an another script with "unRegisterRedrawViewsCallback showObjectNames" at the end... :-(((
Strangely max do not show Objects coordinates anymore (??)

Comment viewing options

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