Display Message on Viewport (toggle)

Hello, I have a small macro and would like to have some text displayed on the viewport when I activate it, I've tried the code from this page:

https://forums.cgsociety.org/t/draw-a-text-in-corner-of-the-viewport/163...

but I get an error Exception message: "registerRedrawViewsCallback() expected function, got: undefined."

My macro is the following:

macroScript LockSnapScale
category:"# sampei"
buttonText: "Lock,Snap,Scale"
toolTip:"Lock,Snap,Scale"

(
actionMan.executeAction 0 "59231" -- Selection: Selection Lock Toggle
actionMan.executeAction 0 "40072" -- Snaps: Snaps Toggle
actionMan.executeAction 0 "40223" -- Snaps: Percent Snap Toggle
macros.run "Tools" "Non_Uniform_Scale"
toolMode.selectionCenter()
)

Comments

Comment viewing options

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

You are a legend! I've been

You are a legend! I've been wanting something like this for years. Thank you so much for making this, I've sent a donation to your paypal. I think you could sell it, I've shown it to some colleagues and they all agree that it's hugely useful, I am calling it "Selection Atom" since it gravitates over the cursor. I've also made a logo, it really deserves it :D
Very happy, thanks again :)

https://i.imgur.com/4KMkLlj (full resolution)
https://imgur.com/NitlvQ3 (24 pixel bmp icon)
https://imgur.com/m2r5rJU (24 pixel bmp icon alpha)

miauu's picture

.

Thank you for the donation.
The logo/icon is sweet. :)

miauu's picture

.

(
	global GW_displayText
	try(unregisterRedrawViewsCallback GW_displayText)catch()
	fn GW_displayText =
	(
		wPos = 40 -- horizontal position max = gw.getWinSizeX() 0 is left
		hPos = 40 -- vertical position max = gw.getWinSizeY() . 0 is lower left
		gw.htext [wPos,hPos,0] "Potatoes" color:red
 
		gw.updateScreen() 
	)
	registerRedrawViewsCallback GW_displayText
)
sampei's picture

thanks so much Miauu, that

thanks so much Miauu, that works! would it be difficult to make a toggle for the text to appear and disappear? Right now once it is activated, the text just stays on the viewport permanently, ideally it would disappear when I run the script for a second time...

Comment viewing options

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