Author Topic: Display the last inputed value for Mline  (Read 2053 times)

0 Members and 1 Guest are viewing this topic.

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Display the last inputed value for Mline
« 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
« Last Edit: September 22, 2012, 12:05:37 AM by NOD684 »
"memories fade but the scars still linger"

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Display the last inputed value for Mline
« Reply #1 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))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Display the last inputed value for Mline
« Reply #2 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

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Display the last inputed value for Mline
« Reply #3 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. )

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Display the last inputed value for Mline
« Reply #4 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. )

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Re: Display the last inputed value for Mline
« Reply #5 on: September 08, 2012, 04:04:14 AM »
Thanks for ALL the help Lee, Tharwat irneb
it worked liked a charm!

thanks again
"memories fade but the scars still linger"