ScriptSpot

Forum topic · General Scripting

How to stop drawing lines drawn using gw.Polyline

By vishangshah · 2016-09-27

Description

Hello,

I am drawing some visualization lines using gw.Polyline in maxscript.
How can I toggle visibility of those Polylines?

Even if it means clearing out everything and redrawing them, its fine.
I tried gw.clearscreen but didn't seem to work.

Thanks in advance

Comments (6)

vishangshah · 2016-10-02

Thanks for reply.
Below is the code I am using from maxscript help page.


unregisterRedrawViewsCallback GW_displayObjectNames
fn GW_displayObjectNames =
(
  gw.setTransform (matrix3 1)
  for o in objects where not o.isHiddenInVpt do
    gw.text o.pos (o as string) color:yellow
  gw.enlargeUpdateRect #whole  
)
registerRedrawViewsCallback GW_displayObjectNames

I tried to run unregisterRedrawViewsCallback "functionname".
But that didn't help. Even resetting doesn't disable it.
Only restarting works or deleting scene object (which will result in an error due to registered calls).

.

miauu · 2016-10-02

This works:


(
	global GW_displayObjectNames
	unregisterRedrawViewsCallback GW_displayObjectNames
	fn GW_displayObjectNames =
	(
	  gw.setTransform (matrix3 1)
	  for o in objects where not o.isHiddenInVpt do
		gw.text o.pos (o as string) color:yellow
	  gw.enlargeUpdateRect #whole  
	)
	registerRedrawViewsCallback GW_displayObjectNames
)
--	"to stop the drawing uncomment and execute next line only"
-- unregisterRedrawViewsCallback GW_displayObjectNames

fajar · 2016-09-30

if drawing line must be registered then stop drawing must be unregistered those function ..

let say you have


fn drawLine =
(
-- draw some line here
)
---to draw in screen you must use 

RegisterRedrawViewsCallback drawLine 

to stop it you must use


unRegisterRedrawViewsCallback drawLine 

.

miauu · 2016-09-30

To be sure that the drawLine will be unregistered correctly declare it as a global variable first.

.

miauu · 2016-09-28

Post your code.

`

pixamoon · 2016-09-28

is it with registerRedrawViewsCallback ?