Notifications
Clear all

[Closed] keyboard value imput during script running

I want to get the value from the keyboard after pressing enter during script running! The script has no window!

I know about entering a value in maxscript listener:

v = getKBValue prompt:"Enter object count:"
 if classOf v != integer then
   print "Value entered must be an integer"
 else print v

but how to use it when you work inside max viewport, an object is selected and operate with it – and at a moment you need to give a value from keyboard?

I will appreciate very much your support!

17 Replies

It may call an input field when typing first digit-and after hitting enter-a variable would get the value! I have the idea, but no clue how to achieve that!

heeeey, please! still no idea? PLEASE HELP! I need it very much!

help yourself. try to better explain what you want… do you want to interrupt your code, wait for user’s keyboard input, and continue the code after that?

maybe it’s what you want:


(
	answer
	do
	(
		format "today is %
" ((dotnetclass "DateTime").Today.ToString "D")
		v = getKBChar prompt:"is it true?(Y/N)"
		answer = if stricmp v #y == 0 then format "
good! have a nice day!
" else
		(
			format "
try again...
"
			undefined 
		)
	)
	while answer == undefined 
	ok
)


Thank you, Denis! Sorry for the bad explanation!
Unfortunately it doesn’t work!

	fn mouseCapture msg ir obj faceNum shift ctrl alt =
	(
		if msg == #freeMove then
		(
				myObj.pos = mapScreenToCP mouse.pos
				myObj.pos.z = zzz
				myObj.dir = [0,0,1]

				if keyboard.shiftpressed then
					print "shift pressed"
				return #continue	  
	   )
   )  

The above script is working fine at me! It’s printing shift pressed while I move mouse inside viewport! But if I use this one:

	fn mouseCapture msg ir obj faceNum shift ctrl alt =
	(
		if msg == #freeMove then
		(
				myObj.pos = mapScreenToCP mouse.pos
				myObj.pos.z = zzz
				myObj.dir = [0,0,1]

		v = getKBChar prompt:"is it true?(Y/N)"
		answer = if stricmp v #y == 0 then format "
good! have a nice day!
" else
		(
			format "
try again...
"
			undefined 
		)
				return #continue	  
	   )
   )  

then my script stops at all!

	fn mouseCapture msg ir obj faceNum shift ctrl alt =
 	(
 		if msg == #freeMove then
 		(
 				myObj.pos = mapScreenToCP mouse.pos
 				myObj.dir = [0,0,1]
				distance = getKBChar prompt:"put distance"
 				myObj.pos.y =  myObj.pos.y+distance
 				return #continue	  
 		 )
 	)  

I want to put the distance on which the object should move after pressing enter!

as i understood you want to make a cloning tool that works the same as Revit… but you don’t have enough skills for that. to make this tool is not easy at all. you have to know many things.
how can i tell you just an ending of a story if you don’t know the whole story.
try to go this way:

make mouse track function

check that one of modifier keys pressed (ALT for example)

if so, popup modal dialog that has only one control – spinner

if Esc or Return pressed close dialog and continue tracking


after that we will continue

I’ve done it allready

Take a look here please:

http://artrender.info/tmpmike/clonetool/

Page 1 / 2