Jump to content

Lisp routine for Rebar Layout


guyzen2004

Recommended Posts

Is there a possibility of creating a lisp routine of making horizontal and vertical lines on a certain structure (say a slab) by just giving the horizontal and vertical distances respectively of the lines. And also the distance of the first and last line from the structure so that it may appear that you are drawing reinforcing bars on a given structure.

Link to comment
Share on other sites

Guest Alan Cullen

I would have to agree with Paul. You can write a lisp, but without thinking too hard about that, you could have problems writting the lisp to cover all the different situations.

 

Whereas, by using commands such as ARRAY, OFFSET, DIVIDE, MEASURE and others, you could achieve the result you want just as easily.

Link to comment
Share on other sites

You can play with this old routine.

;;; FUNCTION    ArrayPick.lsp
;;;  Variation of the Array command, user picks the direction and distance 
;;;  to fill, then enters or picks the object offset distance
;;;  Offset direction angle is 0, 90, 180, or 270 deg only
;;; 
;;; ARGUMENTS 
;;; none 
;;; 
;;; USAGE 
;;;  aPick
;;; 
;;; PLATFORMS 
;;; 2000+ 
;;; 
;;; AUTHOR 
;;; Copyright© 2004 Charles Alan Butler 
;;; ab2draft@TampaBay.rr.com 
;;; 
;;; VERSION 
;;; 1.0 Oct. 01, 2004 
;;;
;;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL* 
;;; PURPOSES AND ONLY IF YOU RETAIN 
;;; THIS HEADER COMPLETE AND UNALTERED 
;;; you must contact me if you want to use it commercially 
;;;  

(DEFUN c:apick (/ p1 p2 ss dist inc step)
 (setq usercmd (getvar "CMDECHO"))
 (setvar "CMDECHO" 0)
 (setq useros (getvar "osmode"))
 (setvar "osmode" 175)
 (prompt "\nSelect objects to offset.")
 (if (setq ss (ssget))
   (progn    
     (if (setq p1 (getpoint "\n*-*  Pick Starting point  *-*"))
       (if (setq p2 (getpoint p1 "\n*-*  Pick End point  *-*"))
         (progn
           (setq step (getdist "\nEnter offset distance. [ENTER=24] "))
           (setq step (cond (step) (24)))
           (setq dist (distance p1 p2)
                 ang  (angle p1 p2)
                 inc  (1+(fix (/ dist step)))
           )
           (cond 
             ((and (>= ang 0.785) (<= ang 2.36)); array up
              (command "_.array" ss "" "R" inc "" step)
             )
             ((and (> ang 2.36) (< ang 3.9)); array left
              (command "_.array" ss "" "R" "" inc (- step))
             )
             ((and (>= ang 3.9) (<= ang 5.5)); array down
              (command "_.array" ss "" "R" inc "" (- step))
             )
             (T  ; array right
              (command "_.array" ss "" "R" "" inc step)
             )
           ) ; end cond stmt
         ) ; end progn
       ) ; endif
     ) ; endif
   ) ; end progn
 ) ; endif
 ;;==========  Exit Sequence  ============ 
 (setvar "osmode" useros)
 (setvar "CMDECHO" usercmd)
 (princ)
) ; end defun
(prompt "\nArray Pick Loaded. Enter aPick to run.")
(princ)

Link to comment
Share on other sites

Hey Cab,

Thank you for your lisp routine. I really appreciate it. Though simple but helps a lot in my drawing. I hope you have this kind of lisp for irregularly shaped figures.

Link to comment
Share on other sites

Thanks.

 

That lisp works with any shaped object(s) that the array command works with. The limitation is that it arrays in the 0 & 180 or 90 & 270 direction only.

 

I have another I use if the offset direction is not one of those.

 

If that is not what you were refering to by "irregularly shaped figures" please explain further.

;;; TrussOffsetUCS.lsp 
;;; 
;;; Author: Copyright© 2005 Charles Alan Butler 
;;; Version:  1.0 May 01, 2005
;;; Purpose: offset objects user offset distance to fill selected area
;;;          Modified version of TrussOffset.lsp to use UCS
;;;          Will work with any objects
;;; 
;;; [Prompts]
;;; Select objects
;;; Enter or select offset distance
;;; Pick start & end point of array distance, these picks establish 
;;;  direction and total distance, not start & end points.
;;;
(defun c:trussoucs (/ *error* p1 p2 ss dist num tmp)
 ;;; error function & Routine Exit 
(defun *error* (msg)
 (if
   (not
     (member
       msg
       '("console break" "Function cancelled" "quit / exit abort" "")
     )
   )
    (princ (strcat "\nError: " msg))
 ) ; if 
 (setvar "osmode" useros)
 (setvar "CMDECHO" usercmd)
 (princ)
) ; 
;end error function 
 (setq usercmd (getvar "CMDECHO"))
 (setvar "CMDECHO" 0)
 (setq useros (getvar "osmode"))
 (setvar "orthomode" 1)

 (prompt "\nSelect objects to offset")
 (setq ss (ssget))
 (if ss
   (progn
     (if (null to_step); global var
       (setq to_step 24)
       (setq to_step (abs to_step))
     )
     (setq tmp (getdist (strcat "\nEnter or pick offset amount. <"(rtos to_step) "> ")))
     (if tmp
       (setq to_step tmp)
     )
     (setq p1 (getpoint "Pick Starting point"))
     (if p1
       (progn
         (setq p2 (getpoint p1 "Pick End point and the axix of offset"))
         (if p2
           (progn
             (setq dist (distance p1 p2)
                   num  (fix (1+(/ dist to_step)))
                   ang  (angle p1 p2)
             )
             (if (or (equal ang pi 0.2)
                     (equal ang (* pi 1.5) 0.2)
                 )
               (setq to_step (- to_step)); reverse the direction
             )
             (setvar "osmode" 0)
             (cond
               ((or (equal ang 0 0.2) ; Horrizontal
                    (equal ang pi 0.2)
                )
                (command "_.array" ss "" "R" "" num to_step)
               )
               ((or (equal ang (/ pi 2) 0.2) ; Vertical
                    (equal ang (* pi 1.5) 0.2)
                )
                (command "_.array" ss "" "R" num "" to_step)
                
               )
               (t
                 (alert "Under condtruction")
                 (setq p3 (polar p1 (+ (angle p1 p2) (/ pi 2)) 50))
                 (command "._ucs" "N" "3" p1 p2 p3) ; origin x y
                 (command "_.array" ss "" "R" "" num to_step)
                 (command "_ucs" "P")
               )

             ) ; end cond stmt
           ) ; end progn
         ) ; endif
       ) ; end progn
     ) ; endif
   ) ; end progn
 ) ; endif
;;;==========  Exit Sequence  ============ 
 (*ERROR* "")
 (princ); Exit quietly
) ; end defun
(prompt "\nOffset Object Loaded. Enter OOS to run.")
(princ)

Link to comment
Share on other sites

  • 2 years later...
  • 3 years later...

Hi Cab ,

I have your old code - Rebar .

;;  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

can you add the offset for rebar (concrete cover) . Ex : 10 , 15 , 20 , 25 mm ......

THANKS YOU !

Link to comment
Share on other sites

  • 5 years later...

hello .

i am new at this forum 

can you help me to write lisp  .

thanks for all worthily efforts 

abdulellah.alattab@gmail.com 

 

hook.JPG

Edited by Abdulellah
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...