TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: RolandOrzabal on September 03, 2012, 03:57:28 AM

Title: Display the last inputed value for Mline
Post by: RolandOrzabal on September 03, 2012, 03:57:28 AM
A friend of mine ask if it is possible to input first the Mline scale before proceeding with the MLINE command :

so i thought it would be like this

Code: [Select]
(setq UserScale (getreal "\nEnter Mline Width:  "))
(command "._mline" "j" "z" "scale" UserScale "style" "Standard")


it is working but my concern is if i want to run again the routine, i want the last inputed value to show. The user can press enter to accept the default or enter a new value.

I've heard of rtos to convert the number into a string but don't know how to apply it here
Title: Re: Display the last inputed value for Mline
Post by: irneb on September 03, 2012, 05:27:56 AM
Something like this
Code - Auto/Visual Lisp: [Select]
  1. (setq *UserScale* 1.0)
  2. (defun c:MLTest (/ UserScale)
  3.   (or (and (setq UserScale (getreal (strcat "\nEnter MLine width <" (rtos *UserScale*) ">: ")))
  4.            (setq *UserScale* UserScale))
  5.       (setq UserScale *UserScale*))
  6.   (command ...); Condinued
  7.   (princ))
Title: Re: Display the last inputed value for Mline
Post by: Lee Mac on September 03, 2012, 07:32:37 AM
In addition to Irneb's example, perhaps this will help you NOD:

http://lee-mac.com/promptwithdefault.html (http://lee-mac.com/promptwithdefault.html)
Title: Re: Display the last inputed value for Mline
Post by: Tharwat on September 03, 2012, 07:51:43 AM
Another ...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test nil
  2.   (setq wids (if wids widths 1.0 ))
  3.   (if (progn (initget 6)
  4.              (setq widths (cond ((getreal (strcat "\n Specify Mline scale <" (rtos wids 2 2) ">:")))
  5.                                 (T wids)
  6.                           )
  7.              )
  8.              (setq wids widths)
  9.       )
  10.     (command "._mline" "j" "z" "scale" (rtos wids 2 2) "style" "Standard")
  11.   )
  12.   (princ)
  13. )
Title: Re: Display the last inputed value for Mline
Post by: Lee Mac on September 03, 2012, 07:58:52 AM
Only one global variable is required...

Code - Auto/Visual Lisp: [Select]
  1. (initget 6)
  2. (setq *scale*
  3.     (cond
  4.         (   (getdist (strcat "\nSpecify MLine Scale <" (rtos (cond (*scale*) ((setq *scale* 1.0)))) ">: ")))
  5.         (   *scale*   )
  6.     )
  7. )
Title: Re: Display the last inputed value for Mline
Post by: RolandOrzabal on September 08, 2012, 04:04:14 AM
Thanks for ALL the help Lee, Tharwat irneb
it worked liked a charm!

thanks again