Lisp for T+G Boards (modifying existing lisp required)

Lisp for T+G Boards (modifying existing lisp required)

paul9ZMBV
Advocate Advocate
819 Views
10 Replies
Message 1 of 11

Lisp for T+G Boards (modifying existing lisp required)

paul9ZMBV
Advocate
Advocate

Hi

I have a lisp that someone was kind enough to do where it plots tounge and grooved boards

 

I could ideally do with it being modified slightly

 

I have attached a sample drawing as to what I want to achieve

 

Basically I need it to be able to ask if a bevel is required or not and whether a tongue is required on the ends or not

 

So I have the options to draw as per the options on the left hand side of the attached (I have the option currently to draw as per the right hand side)

 

I have attached the current lisp below

 

This would be much appreciated

0 Likes
820 Views
10 Replies
Replies (10)
Message 2 of 11

paul9ZMBV
Advocate
Advocate
(defun c:t_g_board (/ total_width_dim _redraw total_width boards_number tongue_thickness tongue_setback tongue_length tongue_overlap insertion_point
              board_thickness boards_gap_chamfer one_board_width board_start_geom_list board_end_geom_list vertices_list
           )
(setq total_width_dim (car (entsel "\nPick dimension for total width: "))
 _redraw (redraw total_width_dim 3)
 total_width (cdr (assoc 42 (entget total_width_dim)))
          boards_number (getint "\nEnter number of boards: ")
          board_thickness (getreal "\nEnter board_thickness: ")           ; 22
          tongue_thickness (getreal "\nEnter tongue thickness: ")   ;   6
          tongue_setback (getreal "\nEnter tongue setback: ")           ;   8
          tongue_length (getreal "\nEnter tongue_length: ")           ; 12
          boards_gap_chamfer (getreal "\nEnter boards_gap_chamfer: ")           ;   3
          insertion_point (getpoint "\nPick insertion point: ")
insertion_point_list '((0 0))
tongue_overlap (- tongue_length boards_gap_chamfer)
one_board_width (/ (- total_width (* boards_gap_chamfer (1- boards_number))) boards_number)
board_start_geom_list (list (list (list one_board_width (+ (- board_thickness) tongue_setback))   ; 1
    (list one_board_width (+ (- board_thickness) boards_gap_chamfer))       ;   2
    (list (- one_board_width boards_gap_chamfer) (- board_thickness))   ;   3
    (list boards_gap_chamfer (- board_thickness))                           ;       4
    (list 0 (+ (- board_thickness) boards_gap_chamfer))             ;   5
    (list 0 (+ (- board_thickness) tongue_setback))             ;   6
    (list (- tongue_length) (+ (- board_thickness) tongue_setback))     ;   7
    (list (- tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   8
    (list 0 (+ (- board_thickness) tongue_setback tongue_thickness))            ;   9
    (list 0 0)  ;   10
    (list one_board_width 0)    ;   11
    (list one_board_width (+ (- board_thickness) tongue_setback tongue_thickness))  ;   12
    )
    (list (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback tongue_thickness)) ;   1
    (list (- one_board_width tongue_overlap boards_gap_chamfer) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   2
    (list (- one_board_width tongue_overlap boards_gap_chamfer) (+ (- board_thickness) tongue_setback)) ;   3
    (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback))    ;   4
    )
    )
    board_end_geom_list (append (car board_start_geom_list)
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))) ;   13
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback)))  ;   14
    )
    )
(repeat (1- boards_number) (setq insertion_point_list (append insertion_point_list (list (mapcar '+ (last insertion_point_list) (list (+ one_board_width boards_gap_chamfer) 0))))))  (foreach insertion (vl-remove (last insertion_point_list) insertion_point_list)
(foreach pline board_start_geom_list
(vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point insertion vertex))
pline
)
)
)
)
)
)
vertices_list
)
)
)
)
(vlax-put (vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point
(last insertion_point_list)
vertex
)
)
board_end_geom_list
)
)
)
)
)
)
vertices_list
)
)
'closed
1
)
(redraw total_width_dim 4)
(princ)
)
0 Likes
Message 3 of 11

Sea-Haven
Mentor
Mentor

Have a look at this can be used as a front end when doing multiple value inputs, note returns string values but use atof etc to convet to real or atoi for integer.

 

Example code at top of code. Can be used in any code. Replaces this and can set default values.

 

boards_number (getint "\nEnter number of boards: ")
          board_thickness (getreal "\nEnter board_thickness: ")           ; 22
          tongue_thickness (getreal "\nEnter tongue thickness: ")   ;   6
          tongue_setback (getreal "\nEnter tongue setback: ")           ;   8
          tongue_length (getreal "\nEnter tongue_length: ")           ; 12
          boards_gap_chamfer (getreal "\nEnter boards_gap_chamfer: ")           ;   3

 

 

 

(setq boards_number (atoi (nth 0 ans))  ; 8
    board_thickness (atof (nth 1 ans))  ; 22
    tongue_thickness (atof (nth 2 ans)) ; 6
    tongue_setback (atof (nth 3 ans))   ; 8
    tongue_length (atof (nth 4 ans))    ; 12
    boards_gap_chamfer (atof (nth 5 ans))  ; 3
)

 

 

0 Likes
Message 4 of 11

paul9ZMBV
Advocate
Advocate

This sounds amazing it would good if someone would be so kind as to incorporate this into this into a complete working lisp, im quite new to this and this is beyond my skills currently.

0 Likes
Message 5 of 11

Sea-Haven
Mentor
Mentor

Ok part 2. I posted already what to do once you fill in values. Have a go at using it.

 

 

SeaHaven_0-1737448507461.png

 

 

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" 
  "Enter number of boards: "  5 4 "10"
  "Enter board_thickness: " 5 4 "22"
  "Enter tongue thickness: " 5 4 "6"
  "Enter tongue setback: " 5 4 "8"
  "Enter tongue_length: " 5 4 "12"
  "Enter boards_gap_chamfer: " 5 4 "3"
  )
)
)

 

0 Likes
Message 6 of 11

paul9ZMBV
Advocate
Advocate

sorry a little confused could this be added to the lisp below please so its a complete working lisp

but i like the look of it a lot

Thanks

 

(defun c:t_g_board (total_width_dim _redraw total_width boards_number tongue_thickness tongue_setback tongue_length tongue_overlap insertion_point
              board_thickness boards_gap_chamfer one_board_width board_start_geom_list board_end_geom_list vertices_list
           )
(setq total_width_dim (car (entsel "\nPick dimension for total width: "))
 _redraw (redraw total_width_dim 3)
 total_width (cdr (assoc 42 (entget total_width_dim)))
          boards_number (getint "\nEnter number of boards: ")
          board_thickness (getreal "\nEnter board_thickness: ")           ; 22
          tongue_thickness (getreal "\nEnter tongue thickness: ")   ;   6
          tongue_setback (getreal "\nEnter tongue setback: ")           ;   8
          tongue_length (getreal "\nEnter tongue_length: ")           ; 12
          boards_gap_chamfer (getreal "\nEnter boards_gap_chamfer: ")           ;   3
          insertion_point (getpoint "\nPick insertion point: ")
insertion_point_list '((0 0))
tongue_overlap (tongue_length boards_gap_chamfer)
one_board_width ((total_width (boards_gap_chamfer (1- boards_number))) boards_number)
board_start_geom_list (list (list (list one_board_width ((board_thickness) tongue_setback))   ; 1
    (list one_board_width ((board_thickness) boards_gap_chamfer))       ;   2
    (list (one_board_width boards_gap_chamfer) (board_thickness))   ;   3
    (list boards_gap_chamfer (board_thickness))                           ;       4
    (list 0 ((board_thickness) boards_gap_chamfer))             ;   5
    (list 0 ((board_thickness) tongue_setback))             ;   6
    (list (tongue_length) ((board_thickness) tongue_setback))     ;   7
    (list (tongue_length) ((board_thickness) tongue_setback tongue_thickness))    ;   8
    (list 0 ((board_thickness) tongue_setback tongue_thickness))            ;   9
    (list 0 0)  ;   10
    (list one_board_width 0)    ;   11
    (list one_board_width ((board_thickness) tongue_setback tongue_thickness))  ;   12
    )
    (list (list (one_board_width tongue_overlap) ((board_thickness) tongue_setback tongue_thickness)) ;   1
    (list (one_board_width tongue_overlap boards_gap_chamfer) ((board_thickness) tongue_setback tongue_thickness))    ;   2
    (list (one_board_width tongue_overlap boards_gap_chamfer) ((board_thickness) tongue_setback)) ;   3
    (list (one_board_width tongue_overlap) ((board_thickness) tongue_setback))    ;   4
    )
    )
    board_end_geom_list (append (car board_start_geom_list)
    (list (list (one_board_width tongue_length) ((board_thickness) tongue_setback tongue_thickness))) ;   13
    (list (list (one_board_width tongue_length) ((board_thickness) tongue_setback)))  ;   14
    )
    )
(repeat (1- boards_number) (setq insertion_point_list (append insertion_point_list (list (mapcar '+ (last insertion_point_list) (list (one_board_width boards_gap_chamfer) 0))))))  (foreach insertion (vl-remove (last insertion_point_list) insertion_point_list)
(foreach pline board_start_geom_list
(vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point insertion vertex))
pline
)
)
)
)
)
)
vertices_list
)
)
)
)
(vlax-put (vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point
(last insertion_point_list)
vertex
)
)
board_end_geom_list
)
)
)
)
)
)
vertices_list
)
)
'closed
1
)
(redraw total_width_dim 4)
(princ)
)
0 Likes
Message 7 of 11

Sea-Haven
Mentor
Mentor

Your lucky in a good mood and had time. Look at how code is used for future programs with lots of value entries. The Multi getvals.lsp needs to be saved in a support path or edit the (load "c:\\yourdirectorypath\\Multi getvals.lsp")

 

(defun c:t_g_board (/ total_width_dim _redraw total_width boards_number tongue_thickness tongue_setback tongue_length tongue_overlap insertion_point
              board_thickness boards_gap_chamfer one_board_width board_start_geom_list board_end_geom_list vertices_list
           )
(setq total_width_dim (car (entsel "\nPick dimension for total width: "))
 _redraw (redraw total_width_dim 3)
 total_width (cdr (assoc 42 (entget total_width_dim)))
)

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" 
  "Enter number of boards: "  5 4 "10"
  "Enter board_thickness: " 5 4 "22"
  "Enter tongue thickness: " 5 4 "6"
  "Enter tongue setback: " 5 4 "8"
  "Enter tongue_length: " 5 4 "12"
  "Enter boards_gap_chamfer: " 5 4 "3"
  )
)
)
		  
(setq boards_number (atoi (nth 0 ans))
    board_thickness (atof (nth 1 ans))
    tongue_thickness (atof (nth 2 ans))
    tongue_setback (atof (nth 3 ans))
    tongue_length (atof (nth 4 ans))
    boards_gap_chamfer (atof (nth 5 ans))
)
	  
(setq insertion_point (getpoint "\nPick insertion point: ")
insertion_point_list '((0 0))
tongue_overlap (- tongue_length boards_gap_chamfer)
one_board_width (/ (- total_width (* boards_gap_chamfer (1- boards_number))) boards_number)
board_start_geom_list (list (list (list one_board_width (+ (- board_thickness) tongue_setback))   ; 1
    (list one_board_width (+ (- board_thickness) boards_gap_chamfer))       ;   2
    (list (- one_board_width boards_gap_chamfer) (- board_thickness))   ;   3
    (list boards_gap_chamfer (- board_thickness))                           ;       4
    (list 0 (+ (- board_thickness) boards_gap_chamfer))             ;   5
    (list 0 (+ (- board_thickness) tongue_setback))             ;   6
    (list (- tongue_length) (+ (- board_thickness) tongue_setback))     ;   7
    (list (- tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   8
    (list 0 (+ (- board_thickness) tongue_setback tongue_thickness))            ;   9
    (list 0 0)  ;   10
    (list one_board_width 0)    ;   11
    (list one_board_width (+ (- board_thickness) tongue_setback tongue_thickness))  ;   12
    )
    (list (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback tongue_thickness)) ;   1
    (list (- one_board_width tongue_overlap boards_gap_chamfer) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   2
    (list (- one_board_width tongue_overlap boards_gap_chamfer) (+ (- board_thickness) tongue_setback)) ;   3
    (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback))    ;   4
    )
    )
    board_end_geom_list (append (car board_start_geom_list)
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))) ;   13
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback)))  ;   14
    )
    )
(repeat (1- boards_number) (setq insertion_point_list (append insertion_point_list (list (mapcar '+ (last insertion_point_list) (list (+ one_board_width boards_gap_chamfer) 0))))))  (foreach insertion (vl-remove (last insertion_point_list) insertion_point_list)
(foreach pline board_start_geom_list
(vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point insertion vertex))
pline
)
)
)
)
)
)
vertices_list
)
)
)
)
(vlax-put (vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point
(last insertion_point_list)
vertex
)
)
board_end_geom_list
)
)
)
)
)
)
vertices_list
)
)
'closed
1
)
(redraw total_width_dim 4)
(princ)
)
(c:t_g_board)

 

Pretty cool answer

SeaHaven_0-1737450175056.png

 

0 Likes
Message 8 of 11

paul9ZMBV
Advocate
Advocate

Hi Sea-Haven

 

Thanks so much for that its very much appreciated and works seamlessly 

 

The only thing that i need changed to make it perfect is that if i don't want a bevel it doesn't work ie i enter 0 value for the bevel

 

In an ideal world i could do with a separate input for the bevel and a separate input for the gap between (and if the bevel input was 0 it would just draw as square edged rather than a bevel)

 

I fully understand if you don't have the time for this

 

What you have done is greatly appreciated.

 

0 Likes
Message 9 of 11

paul9ZMBV
Advocate
Advocate

i have managed to add the gap input and chamfer input separately and set variables, (board_gap and board_chamfer)

 

I just need help making the t+g boards draw with the separate variables

 

for example if the board_chamfer is 0 it draws the t+g boards with square edges

 

(defun c:t_g_board (/ total_width_dim _redraw total_width boards_number tongue_thickness tongue_setback tongue_length tongue_overlap insertion_point
              board_thickness boards_gap_chamfer one_board_width board_start_geom_list board_end_geom_list vertices_list
           )
(setq total_width_dim (car (entsel "\nPick dimension for total width: "))
 _redraw (redraw total_width_dim 3)
 total_width (cdr (assoc 42 (entget total_width_dim)))
)
 
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" 
  "Enter number of boards: "  5 4 "10"
  "Enter board_thickness: " 5 4 "22"
  "Enter tongue thickness: " 5 4 "6"
  "Enter tongue setback: " 5 4 "8"
  "Enter tongue_length: " 5 4 "12"
  "Enter boards_gap: " 5 4 "3"
  "Enter board_chamfer: " 5 4 "3"
  )
)
)
  
(setq boards_number (atoi (nth 0 ans))
    board_thickness (atof (nth 1 ans))
    tongue_thickness (atof (nth 2 ans))
    tongue_setback (atof (nth 3 ans))
    tongue_length (atof (nth 4 ans))
    boards_gap (atof (nth 5 ans))
    board_chamfer (atof (nth 6 ans))
)
  
(setq insertion_point (getpoint "\nPick insertion point: ")
insertion_point_list '((0 0))
tongue_overlap (- tongue_length boards_gap_chamfer)
one_board_width (/ (- total_width (* boards_gap_chamfer (1- boards_number))) boards_number)
board_start_geom_list (list (list (list one_board_width (+ (- board_thickness) tongue_setback))   ; 1
    (list one_board_width (+ (- board_thickness) boards_gap_chamfer))       ;   2
    (list (- one_board_width boards_gap_chamfer) (- board_thickness))   ;   3
    (list boards_gap_chamfer (- board_thickness))                           ;       4
    (list 0 (+ (- board_thickness) boards_gap_chamfer))             ;   5
    (list 0 (+ (- board_thickness) tongue_setback))             ;   6
    (list (- tongue_length) (+ (- board_thickness) tongue_setback))     ;   7
    (list (- tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   8
    (list 0 (+ (- board_thickness) tongue_setback tongue_thickness))            ;   9
    (list 0 0)  ;   10
    (list one_board_width 0)    ;   11
    (list one_board_width (+ (- board_thickness) tongue_setback tongue_thickness))  ;   12
    )
    (list (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback tongue_thickness)) ;   1
    (list (- one_board_width tongue_overlap boards_gap_chamfer) (+ (- board_thickness) tongue_setback tongue_thickness))    ;   2
    (list (- one_board_width tongue_overlap boards_gap_chamfer) (+ (- board_thickness) tongue_setback)) ;   3
    (list (- one_board_width tongue_overlap) (+ (- board_thickness) tongue_setback))    ;   4
    )
    )
    board_end_geom_list (append (car board_start_geom_list)
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback tongue_thickness))) ;   13
    (list (list (+ one_board_width tongue_length) (+ (- board_thickness) tongue_setback)))  ;   14
    )
    )
(repeat (1- boards_number) (setq insertion_point_list (append insertion_point_list (list (mapcar '+ (last insertion_point_list) (list (+ one_board_width boards_gap_chamfer) 0))))))  (foreach insertion (vl-remove (last insertion_point_list) insertion_point_list)
(foreach pline board_start_geom_list
(vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point insertion vertex))
pline
)
)
)
)
)
)
vertices_list
)
)
)
)
(vlax-put (vla-addlightweightpolyline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble
(cons 1 (length (setq vertices_list
(apply 'append
(mapcar '(lambda (vertex) (mapcar '+ insertion_point
(last insertion_point_list)
vertex
)
)
board_end_geom_list
)
)
)
)
)
)
vertices_list
)
)
'closed
1
)
(redraw total_width_dim 4)
(princ)
)
(c:t_g_board)
0 Likes
Message 10 of 11

komondormrex
Mentor
Mentor

@paul9ZMBV 

someone, eh) you've gotta be kidding)

@Sea-Haven 

Alan, nothing personal, but for me you really act like a certain sausage seller with this multi... of yours)

komondormrex_0-1737557773239.gif

 

0 Likes
Message 11 of 11

paul9ZMBV
Advocate
Advocate

thanks @komondormex

 

No offence intended I couldn't remember who done the t+g lisp originally

 

The lisp you show in the video is perfect any chance of the coding please, it would be very much appreciated

0 Likes