Jump to content

Trouble getting user input within a command


Recommended Posts

Posted

What would be a better way of doing this. This does not seem to work. I am trying to pause in order to have the user input the scale for the hatching, because it will be different dpending on the scale of the drawing. Obviously "cloud" is a variable assigned to a previously created object. Any help is appreciated.

 

Thanks in advance.

 

(command "-bhatch" "a" "a" "y" "" "p" "ansi31" (princ "\nWhat scale: ") pause "0" "s" cloud "" "")

 

:Edit - It works fine without the princ command (just the pause), but then other users wont know what to input. I am trying to find a way to easily prompt the user for the scale.

Posted

Here's two options:

 

(princ "\nWhat scale: ")
(command "-bhatch" "a" "a" "y" "" "p" "ansi31" pause "0" "s" cloud "" "")

OR

(if (setq scale (getreal "\nWhat scale: "))
 (command "-bhatch" "a" "a" "y" "" "p" "ansi31" scale "0" "s" cloud "" ""))

Posted

Your problem, I think, is that the (princ) function is returning a value, whatever the value happens to be. That value is fed to the command line as input, which isn't recognized as valid.

Posted

Even one more way...

 

(vl-cmdf "._bhatch" "_A" "_A" "_Y" "" "_P" "_ANSI31" (getreal "\nEnter Scale: ") 0.0 "_S" cloud "" "")

Posted

Thanks, that works great! That is exactly what I was looking for.

Guest
This topic is now closed to further replies.
×
×
  • Create New...