Notifications
Clear all

[Closed] efficient Viewport drawing methods

Hello everybody

I got today another one small exercise for that who would like explain to me what I am doing wrong that my script is slow again [font=Wingdings]J[/font] This Is just a test for gw. command and should have draw vertex number for selected spline on screen. Yes I know it is exactly same how SHOW VERTEX NUMBERS in line but the point is why my screen draw is not so smooth and fast. Is it because I do something generally wrong or because I can’t have better feedback from gw. command when I am updating whole screen? Thanks for your explanation and suggestion how it write better.

 
global DrawTest
unregisterRedrawViewsCallback DrawTest
fn DrawTest = 
(
gw.setTransform(Matrix3 1)
local p3TextPos = [0,0,0]
SplineSet = $
if (selection.count == 1) and ((isKindof SplineSet splineshape == true) or (isKindOf SplineSet line == true)) do
(
for i = 1 to numKnots SplineSet do
(
	KnotPosition = getKnotPoint SplineSet 1 i 
	p3TextPos =gw.wTransPoint KnotPosition
	--print p3TextPos
	KnotNumber = i as string
	--Print KnotNumber
	gw.wText p3TextPos KnotNumber color:yellow
)
)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
registerRedrawViewsCallback DrawTest

Don’t forget take this for unregister

 
unregisterRedrawViewsCallback DrawTest
4 Replies

I am not sure what your situation is …I have tried your script 。The number on the screen flashed over and over.
And My suggestion is:Maybe play around with a scripted manipulator is a good idear.

Yeap that’s the point . The numbers in my script are flashed but when you try switch on SHOW VERTEX NUMBERS direct from max they are nice and smooth. So Do you think is nothing wrong with my script it is just how this gw command works and if i want make my print on screen smooth i must use for that scripted manipulator :\ Hmm i read about this but i was hoping it must be way how make it better with gw either. But thanks for your reply.

 PEN

This is just the way GW works. You can’t get it smooth.

Well ,Why the numbers flash out?
I think this because max has to rebuild/recreate the text number each time redraw callback function is being called.
So , the idear is if we can store the text number somewhere , things may go smoother.For example ,store a text number spline/mesh somewhere , show it when you need show it.I don’t think splines or meshes tend to flash out:P
This idear comes with another 2 problems sometime(maybe always with mxs). Text number spline/mesh need to be kicked out of your selectable possibility,Then a selection change callback is needed.And you may want it face to the screen. Figure out the transform matrix in a script controller and update it with redraw callback.