How do i create a line with pre specified number of verts and then do something?

so i belive what i am trying to do is very siple.
lets say i want to create a line with 3 points and after i click the right mouse button to stop the creation it will messagebox = "aaa"

but.. if i try to do something like this:

StartObjectCreation Line
messagebox "aaa"

the "aaa" will show on the first click not after i right click

if i try some mouse tool it will kind of abort the mousetool

i tryed lots of callbacks without any luck

so.. theres any way to do it?

Comments

Comment viewing options

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

oops...

Sorry, my bad, I write this by memory, here is correct one:

tool makeLine numPoints:5 -- limit clicks to 4
(
	local sp = splineShape()
	fn fn_addKnot = (addKnot sp 1 #corner #line worldPoint)
 
	on mousePoint clickNo do (
		case clickNo of (
			1: (addnewSpline sp; fn_addKnot())
			default: (fn_addKnot(); updateShape sp)
		)
	)
)
startTool makeLine prompt:"Click 4 times to create line"

Also dunno why if numPoints is 4 it end of 3 clicks,
but if click and drag i end with 4 knots.
So i set numPoints to 5 to can click w/o dragging.

my recent MAXScripts RSS (archive here)

Anubis's picture

maybe mouse tool is not so

maybe mouse tool is not so bad too

tool makeLine numPoints:4 -- limit clicks to 4
(
	local sp = splineShape()
	addnewSpline sp
 
	on mousePoint clickNo do (
		if clickNo <= 4 do
			addKnot sp 1 #corner #line worldPoint
		if clickNo == 4 do updateShape sp
	)
)
startTool makeLine prompt:"Click 4 times to create line"

my recent MAXScripts RSS (archive here)

mjbg's picture

Thank you Anubis but for some

Thank you Anubis
but for some reason i cannot run your code
it says:

-- Error occurred in anonymous codeblock; filename: C:\_Neo3d\_ Scripts Neo3d\Scripts temp\; position: 92; line: 4
-- Syntax error: at name, expected tool clause: 
--  In line: 	addnewSpline s
mjbg's picture

i found some way using

i found some way using RegisterRedrawViewsCallback
just in case

fn teste = 
(
	try
	(
	aa = numknots $
	if aa == 4 do 
		(
		messagebox "aaa"
		stopCreating()
		unRegisterRedrawViewsCallback teste
		)
	)
	catch()
)
clearSelection()
RegisterRedrawViewsCallback teste
StartObjectCreation Line

Comment viewing options

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