Author Topic: Remember last inputed offset distance  (Read 1942 times)

0 Members and 1 Guest are viewing this topic.

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Remember last inputed offset distance
« on: October 29, 2012, 05:18:03 AM »
Hi to all, need a little help here...am new to lisp and i want the routine to remember the last inputed offset distance if the user runs the command again. My code keeps on resetting it to 1


Code: [Select]
(defun c:offset+ () (c:off+))
(defun c:off+ (/  *error* ent dist kwrd ofside dist1)
;; 24 october 2012 nod684

(defun  *error* (msg)
(command "._undo" "_end")
(setvar 'osmode osm)
(setvar 'cmdecho cmd1)
)

(command "._undo" "_begin")
(setq cmd1 (getvar 'cmdecho))
(setvar 'cmdecho 0)
(setq osm (getvar 'osmode))
(setvar 'osmode 923)
(prompt "\nSelect Object to Offset:   ")
(while (not ent)
(setq ent (ssget "_+.:S:L" '((0 . "*LINE,CIRCLE,ELLIPSE"))))
)
(initget (+ 1 2 4 64))
(setq dist (if dist dist1 1.0 ))
  (if
              (setq dist1 (cond ((getdist (strcat "\n Specify Offset Distance <" (rtos dist 2 2) ">: ")))
                                (T dist)
                          )
             )
             (setq dist dist1)

(while (= ofside nil)
(setq ofside (getpoint "\nSide to offset on: "))
)
  (initget (+ 2 4) "Yes No")
  (setq kwrd (getkword "\nDelete source object? [Yes/No] <Yes>:  "))
  (if (/= kwrd "No")
    (setq kwrd "Yes")
  )
   (command "offset" "erase" "no" dist ent ofside "")
   
  (if (eq kwrd "Yes")
    (command "erase" ent "")
  )
  (*error* "")
  (princ "\nDone!")
(princ))
"memories fade but the scars still linger"

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Remember last inputed offset distance
« Reply #1 on: October 29, 2012, 05:44:55 AM »
Have you looked into the sysvar OFFSETDIST?  -David
R12 Dos - A2K

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Re: Remember last inputed offset distance
« Reply #2 on: October 29, 2012, 05:57:36 AM »
Have you looked into the sysvar OFFSETDIST?  -David

thanks a lot!! i'll check on that :)
"memories fade but the scars still linger"

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Re: Remember last inputed offset distance
« Reply #3 on: October 29, 2012, 06:02:28 AM »
Thanks a lot David! it's just what i need....working as i want it to be now :)
thanks again!
"memories fade but the scars still linger"

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Remember last inputed offset distance
« Reply #4 on: October 29, 2012, 08:57:11 AM »
Glad it worked for you.  -David
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Re: Remember last inputed offset distance
« Reply #6 on: October 29, 2012, 11:04:08 PM »
Thanks again David and thanks for the info CAB
"memories fade but the scars still linger"

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Remember last inputed offset distance
« Reply #7 on: October 30, 2012, 07:20:49 AM »
The following tutorial may also be of interest since you are looking to remember the last entered input:

http://lee-mac.com/promptwithdefault.html

RolandOrzabal

  • Newt
  • Posts: 86
  • "memories fade but the scars still linger"
Re: Remember last inputed offset distance
« Reply #8 on: October 31, 2012, 04:40:17 AM »
The following tutorial may also be of interest since you are looking to remember the last entered input:

http://lee-mac.com/promptwithdefault.html


Thanks Lee!
"memories fade but the scars still linger"