Author Topic: Rebar Lisp  (Read 6586 times)

0 Members and 1 Guest are viewing this topic.

AfricaAD

  • Guest
Rebar Lisp
« on: August 30, 2005, 01:04:27 PM »
Is there any way I can simplify this lisp? The variables are repetitive but I would like to keep the individual commands.

I do have a pull-down & toolbar for this as well. I would also like to add a dialogue box to it in the future.

Get complete lisp here: Rebar_v1.0

Bah! Lisp is too long.  :(

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Rebar Lisp
« Reply #1 on: August 30, 2005, 01:12:00 PM »
Do you want to have that other post nuked?

PS: You can delete your own posts, but I've no problem doing it for you.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AfricaAD

  • Guest
Rebar Lisp
« Reply #2 on: August 30, 2005, 01:25:30 PM »
I think it is gone.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Rebar Lisp
« Reply #3 on: August 30, 2005, 01:26:44 PM »
But not forgotten, I can bring it back if you wish.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Rebar Lisp
« Reply #4 on: August 30, 2005, 03:31:01 PM »
Take a look at this approach.
This is an example only & needs more error checking and does not
address metric.

I reduced the number of key strokes by using a get key routine.
At the command line enter rb the space bar then press a key L, D or H
You are the prompted for the size. Here you could also allow the letter M
to switch to metric.

Better yet would be a dialog box. :)

Code: [Select]
;;  enter rb and spacebar or enter to run
(defun C:RB (/ otm llyr plw ansx dia dod fr)
  (setq otm (getvar "orthomode"))
  (setq llyr (getvar "clayer"))
  (setq plw (getvar "plinewid"))
  (setq ansx (get_key "LDH" "Press key [L D or H] Line, Donut or Hook? : "))
  (if (not ansx)
    (exit) ; user quit
  )
  (initget 7)
  (setq dia (getdist "\nEnter rebar size : "))
  ;;  need size error checking


  (setvar "clayer" "0")
  (command "orthomode" "1")
  (cond
    ((= ansx "L")
     (command "plinewid" dia)
     (command "pline")
     (while (> (getvar "cmdactive") 0) (command pause))
    )

    ((= ansx "D")
     (setq did (getvar "donutid"))
     (setq dod (getvar "donutod"))
     (command "donut" "0" dia)
     (while (> (getvar "cmdactive") 0) (command pause))
     (setvar "donutid" did)
     (setvar "donutod" dod)
    )

    ((= ansx "H")
     (command "plinewid" dia)
     (command "pline")
     (while (> (getvar "cmdactive") 0) (command pause))
     (setq fr (getvar "filletrad"))
     (setvar "filletrad" (* dia 2))
     (command "fillet" "p" "last")
     (command "filletrad" fr)

    )

  ) ; end cond stmt


  (setvar "clayer" llyr)
  (setvar "plinewid" plw)
  (command "orthomode" otm)
  (princ)
)
(prompt "\nEnter rb and spacebar or enter to run.")
(princ)
;;--------------------------------------------------------



;;  get a key press, return only if matches filter
;;  return nil if Enter is pressed
(defun get_key (keys msg / key KeyCode Lp)
  (setq keys (append (vl-string->list (strcase keys))
                         (vl-string->list (strcase keys t))
                 )
  )
  (setq Lp t)
  (while Lp ; Main Loop
    (prompt (strcat "\n" msg))
    (setq Key nil)
    (while (= Key nil) ; Loop here until a key is pressed
      (setq Key (grread nil 2)) ; get a key press
    )
    ;; Process the key press
    (if (= (car key) 2) ; Skip if not a KeyPress
      (progn
        (setq KeyCode (cadr Key)) ; Set ASCII Key Code

        (cond
          ((= KeyCode 13) ; ENTER key pressed
           (setq KeyCode nil
                 Lp nil) ; Exit Loop
          )

          ((member KeyCode keys) ; got a hit
           (setq Lp nil) ; Exit Loop
          )
        ) ; end cond stmt
      ) ; progn
    ) ; Endif
  ) ;End While
  (if keyCode
    (strcase (chr keyCode))
  )
) ; end defun
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.

AfricaAD

  • Guest
Rebar Lisp
« Reply #5 on: August 30, 2005, 04:35:07 PM »
MP:
No worries, the code is pretty repetitive.  :roll:  

CAB:
This approach is alot cleaner & better than mine.  :P
This is a good start, thanks!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Rebar Lisp
« Reply #6 on: August 30, 2005, 04:43:05 PM »
You're welcome.
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.