PDA

View Full Version : PolyLine update problem.


doffer
02-28-2006, 08:16 AM
Hey there.
First post from me :)

I have a problem with a script I'm making.
I need some lines to be drawn on my screen. Much like the lines in "Show Safe Frames".
For that I use gw.wPolyLine, like in the Maxscript help file.

The problem is though, that everytime my screen updates, the lines disappear.
Is there any way that I can keep my lines drawn, even when the screen updates, and only go away whenever my script is closed down?

Here is my script. I know it's not good. I'm not a programmer :D

--Define some variables.
v_width = gw.GetWinSizeX()

v_height = gw.GetWinSizeY()

vp1 = v_width/3

vp2 = vp1 + vp1

hp1 = v_height/3

hp2 = hp1 + hp1

--Turn on safe frames.

displaySafeFrames = true

--Color the lines red

gw.setColor #line red

--Draw the vertical lines.

gw.wPolyline #([vp1,0,0], [vp1,v_width,0]) true

gw.wPolyline #([vp2,0,0], [vp2,v_width,0]) true

--Draw the horizontal lines.

gw.wPolyline #([0,hp1,0], [v_width,hp1,0]) true

gw.wPolyline #([0,hp2,0], [v_width,hp2,0]) true



-- Update viewportet

gw.enlargeUpdateRect #whole

gw.updateScreen()







Anyways... Hope you get my question and have an answer.
If polylines isn't the best solution, please say so.
The same goes for the whole script. If something is done wrong, feel free to say it ;)

Best regards...
Doffer :shrug:

FaceMn
02-28-2006, 02:12 PM
Yep, the easiest solution here is to wrap your code into a function and then pass it like this:

fn draw_safeframes = (
-- gw code here
)

-- Register the function
registerRedrawViewsCallback draw_safeframes


-- Unregister the function
unRegisterRedrawViewsCallback draw_safeframes

doffer
03-07-2006, 07:57 AM
Hey FaceMn.

Sorry for the slow replying.
I've tried what you say, but it doesn't seem to work out.
If you would try to look at my code again, and see if I'm doing anything wrong.


fn draw_lines =

(

--Lav variabler

v_width = gw.GetWinSizeX()

v_height = gw.GetWinSizeY()

vp1 = v_width/3

vp2 = vp1 + vp1

hp1 = v_height/3

hp2 = hp1 + hp1

--slå Show Safe Frames til, når scriptet køres.

displaySafeFrames = true

--farv linierne røde

gw.setColor #line red

--PolyLine forklaring.

--gw.wPolyline#(*nederste*[x,y,z], *øverste*[x,y,z]),true

--Tegn de vandrette

gw.wPolyline #([vp1,0,0], [vp1,v_height,0]) true

gw.wPolyline #([vp2,0,0], [vp2,v_height,0]) true

--tegn de lodrette

gw.wPolyline #([0,hp1,0], [v_width,hp1,0]) true

gw.wPolyline #([0,hp2,0], [v_width,hp2,0]) true



-- Update viewportet

gw.enlargeUpdateRect #whole

gw.updateScreen()



)



-- Register the function

registerRedrawViewsCallback draw_lines

-- Unregister the function

unRegisterRedrawViewsCallback draw_lines


Don't mind the comments. They're danish :D

CGTalk Moderation
03-07-2006, 07:57 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.