Author Topic: how do i keep this loaded.  (Read 5051 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
how do i keep this loaded.
« on: March 26, 2004, 07:58:49 AM »
I have a lisp which lets me draw circuit lines.

I've changed the code to allow me to input the drawing scale so that it sizes the circuit lines according to the drawing scale.

but each time i run the routine it asks me to input the scale, is there a way in which i can make it default to the last scale used, rather than having to input each time.

Code: [Select]
(initget (+ 1 2 4))
     (setq #d (getint "\nDrawing Scale: "))
   (setq #dist (* #D 5.75 )
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
how do i keep this loaded.
« Reply #1 on: March 26, 2004, 08:14:14 AM »
You could make the variable global and test for it's existence in the program.

Code: [Select]

(if (not #d)
  (progn
    (initget (+ 1 2 4))
    (setq #d (getint "\nDrawing Scale: "))
    (setq #dist (* #D 5.75))
  )
  ;else
 (setq #dist (* #D 5.75))
)
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
how do i keep this loaded.
« Reply #2 on: March 26, 2004, 10:54:00 AM »
Cheers mate.

you are a star.  Works great.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

DEVITG

  • Bull Frog
  • Posts: 479
how do i keep this loaded.
« Reply #3 on: March 26, 2004, 05:21:15 PM »
It works great, but , could be possible to use userrx to store the last scale used , does not matter if the lisp is unloaded or not???
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

hudster

  • Gator
  • Posts: 2848
how do i keep this loaded.
« Reply #4 on: March 26, 2004, 05:49:56 PM »
I'm already using userr1 to store the scale for insertion of a few blocks.

would i be able to change this to show userr1 = #d?

This would be a lot better, as it would exclude the possibility of a typo.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
how do i keep this loaded.
« Reply #5 on: March 26, 2004, 05:52:29 PM »
If you are going to store a bunch of var's, wht not store them in a file then read them in when you start the program.
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
how do i keep this loaded.
« Reply #6 on: March 27, 2004, 04:32:02 AM »
the userr1 variable was set up by someone else in my company, and it's already stored in a file so that it is loaded with each drawing.
if it enter (getvar userr1), it returns the drawing scale.

So can i take it by that, I can use it in the lisp routine?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
how do i keep this loaded.
« Reply #7 on: March 27, 2004, 07:33:45 AM »
>I can use it in the lisp routine?
sure.
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
how do i keep this loaded.
« Reply #8 on: March 27, 2004, 10:51:03 PM »
Don't forget there are 4 other userr# variables. Just use one of them.

hendie

  • Guest
how do i keep this loaded.
« Reply #9 on: March 29, 2004, 02:44:49 AM »
there's also SETCFG & GETCFG which can be useful

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
how do i keep this loaded.
« Reply #10 on: March 29, 2004, 08:10:34 AM »
You can also use SETENV and GETENV
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
how do i keep this loaded.
« Reply #11 on: March 29, 2004, 01:35:25 PM »
XData? LData? Dictionaries? Registry?

Don't forget a USERIx can hold up to 4 decimals ..

*ok, so I like to overdo it .. so what?!*

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
how do i keep this loaded.
« Reply #12 on: March 29, 2004, 04:00:21 PM »
To fill a global variable full of values I like to use an association list.

Code: [Select]
(defun var-store (var value)
  (cond ((and value) (cons var value))))
(defun test (lst)
  (cond
    ((>= (length lst) 2)
     ;; if there are atleast two left in the list
     (setq a (cons (var-store (car lst) (cadr lst)) a))
     ;; construct a list
     (test (cdr (cdr lst)))))
  a
  ;; Return the list
 )


Use it like this:
(reverse (test '(test1 1 test2 2 test3 3 test4 4)))
-> ((TEST1 . 1) (TEST2 . 2) (TEST3 . 3) (TEST4 . 4))

But if you cant create the variables at run-time or ask the user I sudgest a file, regristry, or x/l data. I would try to stay away form the Users variables.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org