Jump to content

Autolisp to make holes


Impala62

Recommended Posts

Hi all,

 

I detail in 2D structural steel.

I am looking for a lisp that will create holes with option of offset guage line hole dia number of holes etc.

 

Is there anything out there or close to this?

 

Bill

Link to comment
Share on other sites

This is a quick program. I had a better one when I detailed structural steel a couple of years ago. There is no error trapping and it can be improved. It should help you get started.

 

Brian

 

(defun c:holes ( / rows cols rowd rowv rowh hole )
 (setq rows (getint "\nEnter the number of rows (---) <1>: ")
       cols (getint "\nEnter the number of columns (|||) <1>: ")
       rowd (getdist (strcat "\nBeam guage <" (itoa 3) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (itoa 3) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (itoa 4) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
 )
 (if (= rows nil)(setq rows 1))
 (if (= cols nil)(setq cols 1))
 (if (= rowd nil)(setq rowd 3))
 (if (= rowh nil)(setq rowh 4))
 (if (= rowv nil)(setq rowv 3))
 (if (= hole nil)(setq hole 0.8125))
 (setq ins (getpoint "\nSelect insertion point: "))
 (repeat cols
   (setq lstpnt (polar ins (* pi 1.5) rowd))
   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   (repeat (1- rows)
     (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   )
   (setq ins (polar ins 0 rowh))    
 )
 (princ)
)

Link to comment
Share on other sites

Thank you for the code.

 

Got it to work nicely.

Now, how can I add an offset for edge distance of steel to center of first column/row hole/s?

 

Bill

Link to comment
Share on other sites

Thank you for the code.

 

Got it to work nicely.

Now, how can I add an offset for edge distance of steel to center of first column/row hole/s?

 

Bill

(defun c:holes ( / rows cols rowd rowv rowh hole )
 (setq rows (getint "\nEnter the number of rows (---) <1>: ")
       cols (getint "\nEnter the number of columns (|||) <1>: ")
       rowd (getdist (strcat "\nBeam guage <" (itoa 3) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (itoa 3) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (itoa 4) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
 )
 (if (= rows nil)(setq rows 1))
 (if (= cols nil)(setq cols 1))
 (if (= rowd nil)(setq rowd 3))
 (if (= rowh nil)(setq rowh 4))
 (if (= rowv nil)(setq rowv 3))
 (if (= hole nil)(setq hole 0.8125))
 (setq ins (getpoint "\nSelect insertion point: "))
[color=red][/color] 
[color=lime]  ' Add this[/color]
[color=red]  (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))[/color]

 (repeat cols
   (setq lstpnt (polar ins (* pi 1.5) rowd))
   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   (repeat (1- rows)
     (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   )
   (setq ins (polar ins 0 rowh))    
 )
 (princ)
)

I think this might work. If it's not quite what you want send me a cad file of what you want and I will see what I can do.

 

Brian

Link to comment
Share on other sites

Thanks Brian,

 

I found it not to work, yet.

 

What I want to be able to do is once all the input is done the last thing I need is an input of offset dist. from insertion point.

 

Bill Sceltema

Link to comment
Share on other sites

Thanks brian....Hope you don't mind if I grab a copy..

nice..simple..routine..:)

No problems. I hope it helps.

 

 

Here is a modified version that draws end connections. I have a mutch more complete detailing program but I usually charge for that. (Sorry!)

 

Brian

(defun c:holes_center ( / rows cols rowd rowv rowh hole )
 (setq rows (getint "\nEnter the number of rows (---) <1>: ")
       cols (getint "\nEnter the number of columns (|||) <1>: ")
       rowd (getdist (strcat "\nBeam guage <" (rtos 3) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 3) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (rtos 4) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
 )
 (if (= rows nil)(setq rows 1))
 (if (= cols nil)(setq cols 1))
 (if (= rowd nil)(setq rowd 3))
 (if (= rowh nil)(setq rowh 4))
 (if (= rowv nil)(setq rowv 3))
 (if (= hole nil)(setq hole 0.8125))
 (setq ins (getpoint "\nSelect insertion point: "))
 (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
 (repeat cols
   (setq lstpnt (polar ins (* pi 1.5) rowd))
   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   (repeat (1- rows)
     (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   )
   (setq ins (polar ins 0 rowh))    
 )
 (princ)
)

(defun c:holes_end ( / dir rows rowd rowh rowv rowo hole )
 (initget 0 "Left Right")
 (setq dir  (getkword "\nEnd of beam (Left/Right) <L>: ")
       rows (getint "\nEnter the number of rows (---) <1>: ")
       rowd (getdist (strcat "\nBeam guage <" (rtos 3) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 3) ">: "))
       rowo (getdist (strcat "\nEndge offset <" (rtos 1.5) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
 )
 (if (= dir  nil)(setq dir "Left"))
 (if (= rows nil)(setq rows 1))
 (if (= rowd nil)(setq rowd 3))
 (if (= rowh nil)(setq rowh 4))
 (if (= rowv nil)(setq rowv 3))
 (if (= rowo nil)(setq rowo 1.5))
 (if (= hole nil)(setq hole 0.8125))
 (setq ins (getpoint "\nSelect insertion point: "))
 (if (= dir "Left")
   (progn
     (setq ins (polar ins 0 rowo)
           lstpnt (polar ins (* pi 1.5) rowd)
     )
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     (repeat (1- rows)
       (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
       (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     )
   )
   (progn
     (setq ins (polar ins pi rowo)
           lstpnt (polar ins (* pi 1.5) rowd)
     )
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     (repeat (1- rows)
       (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
       (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     )
   )
 )
 (princ)
)

Beam.jpg

Link to comment
Share on other sites

Thank you for the code,

I tried to add the column function as well to holes_end but I know I am missing something. Bold blue is my added code.

 

Am I close?

 

(defun c:holes_center ( / rows cols rowd rowv rowh hole )
 (setq rows (getint "\nEnter the number of rows (---) <1>: ")
       cols (getint "\nEnter the number of columns (|||) <1>: ")
       rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 30) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (rtos 4) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
 )
 (if (= rows nil)(setq rows 1))
 (if (= cols nil)(setq cols 1))
 (if (= rowd nil)(setq rowd 30))
 (if (= rowh nil)(setq rowh 4))
 (if (= rowv nil)(setq rowv 30))
 (if (= hole nil)(setq hole 17.5))
 (setq ins (getpoint "\nSelect insertion point: "))
 (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
 (repeat cols
   (setq lstpnt (polar ins (* pi 1.5) rowd))
   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   (repeat (1- rows)
     (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   )
   (setq ins (polar ins 0 rowh))    
 )
 (princ)
)

(defun c:holes_end ( / dir rows [color=magenta][b]cols[/b][/color] rowd rowh rowv rowo hole )
 (initget 0 "Left Right")
 (setq dir  (getkword "\nEnd of beam (Left/Right) <L>: ")
       rows (getint "\nEnter the number of rows (---) <1>: ")

[color=magenta][b]        cols (getint "\nEnter the number of columns (|||) <1>: ")[/b][/color]

       rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 30) ">: "))
       rowo (getdist (strcat "\nEndge offset <" (rtos 30) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
 )
 (if (= dir  nil)(setq dir "Left"))
 (if (= rows nil)(setq rows 1))

[b][color=magenta]  (if (= cols nil)(setq cols 1))[/color][/b]

 (if (= rowd nil)(setq rowd 30))
 (if (= rowh nil)(setq rowh 4))
 (if (= rowv nil)(setq rowv 30))
 (if (= rowo nil)(setq rowo 30))
 (if (= hole nil)(setq hole 17.5))
 (setq ins (getpoint "\nSelect insertion point: "))



[color=magenta][b]  (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))[/b][/color]
[b][color=magenta]  (repeat cols[/color][/b]
[b][color=magenta]    (setq lstpnt (polar ins (* pi 1.5) rowd))[/color][/b]
[b][color=magenta]    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))[/color][/b]



 (if (= dir "Left")
   (progn
     (setq ins (polar ins 0 rowo)
           lstpnt (polar ins (* pi 1.5) rowd)
     )
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     (repeat (1- rows)
       (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
       (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     )
   )
   (progn
     (setq ins (polar ins pi rowo)
           lstpnt (polar ins (* pi 1.5) rowd)
     )
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     (repeat (1- rows)
       (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
       (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
     )
   )
 )
 (princ)
)

 

Edited by SLW210
Link to comment
Share on other sites

Try this.

Brian

(defun c:holes_end ( / cols dir rows rowd rowh rowv rowo hole )
 (initget 0 "Left Right")
 (setq dir  (getkword "\nEnd of beam (Left/Right) <L>: ")
       rows (getint "\nEnter the number of rows (---) <1>: ")
       cols (getint "\nEnter the number of columns (|||) <1>: ")
       rowd (getdist (strcat "\nBeam guage <" (rtos 3) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 3) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (rtos 3) ">: "))
       rowo (getdist (strcat "\nEndge offset <" (rtos 1.5) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
 )
 (if (= dir  nil)(setq dir "Left"))
 (if (= rows nil)(setq rows 1))
 (if (= cols nil)(setq cols 1))
 (if (= rowd nil)(setq rowd 3))
 (if (= rowh nil)(setq rowh 3))
 (if (= rowv nil)(setq rowv 3))
 (if (= rowo nil)(setq rowo 1.5))
 (if (= hole nil)(setq hole 0.8125))
 (setq ins (getpoint "\nSelect insertion point: "))
 (if (= dir "Left")
   (progn
     (setq ins (polar ins 0 rowo))
     (repeat cols
       (setq lstpnt (polar ins (* pi 1.5) rowd))
       (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
       (repeat (1- rows)
         (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
         (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
       )
       (setq ins (polar ins 0 rowh))
     )
   )
   (progn
     (setq ins (polar ins pi rowo))
     (repeat cols
       (setq lstpnt (polar ins (* pi 1.5) rowd))
       (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
       (repeat (1- rows)
         (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
         (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
       )
       (setq ins (polar ins pi rowh))
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

Thanks Brian,

 

It works great.

 

One last request. And I understand if you say no, you've helped out alot here.

 

What if I wanted to instead have user input for columns they had the optionof ofset a series of columns.

 

I work alot with Steel angle and there are many times there is a run of holes along the length.

 

So a user would choose 1 or 2 rows, beam guage, hole dia., but is triggered to ask for 1st offset, 2nd offset, 3rd offset

 

Thanks again.

 

Bill

Link to comment
Share on other sites

  • 1 month later...

I am attempting to add a line to your code to see if I understand the language any better.

 

I would like to incorporate this code into another lisp routine , but thought I would start by trying to add a simple line to your code.

 

Added code in bold.

 

(defun c:hol ( / rows cols rowd rowv rowh hole )

 
[b]    (setq ins (getpoint "\nInsertion Point"))
  (setq len1 (getpoint "\nLength of Line"))[/b]

(setq rows (getint "\nEnter the number of rows (---) <2>: ")
       cols (getint "\nEnter the number of columns (|||) <3>: ")
       rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 50) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (rtos 50) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
 )

 (if (= rows nil)(setq rows 2))
 (if (= cols nil)(setq cols 3))
 (if (= rowd nil)(setq rowd 25))
 (if (= rowh nil)(setq rowh 50))
 (if (= rowv nil)(setq rowv 25))
 (if (= hole nil)(setq hole 17.5))

[b]   (setq ins (getpoint "\nSelect insertion point: "))
 (setq pt02 (polar ins (dtr 90.0)  len1 )) [/b]

 (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
 (repeat cols
   (setq lstpnt (polar ins (* pi 1.5) rowd))

[b] (command "line" ins pt02 "") [/b]

   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   (repeat (1- rows)
     (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
     (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   )
   (setq ins (polar ins 0 rowh))    
 )
 (princ)
)

(defun dtr (x) 
(* pi (/ x 180.0))
) 
Link to comment
Share on other sites

  • 3 years later...

Mr Brian,

 

 

I have read your post that lisp for holes. I hope you only solve my problem. I want draw some circles (holes) on a line ( gauge line) on different distances. I wrote lisp for that by using your "holes Lisp". but i could not write correct. Plz rectify my lisp or give new for me. plz.........my id is ramesh22338@yahoo.com

 

My Lisp code :

 

(defun c:hh ( / rows cols rowd rowv rowh rowo hole )

(setq

cols (getint "\nEnter the number of columns (|||) : ")

rowd (getdist (strcat "\nGauge Line : "))

rowo (getdist (strcat "\n1st Hole: "))

rowh (getdist (strcat "\n2nd Hole / center : "))

rowb (getdist (strcat "\n3rd Hole / center : "))

 

hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))

)

(if (= rows nil)(setq rows 0))

(if (= cols nil)(setq cols 1))

(if (= rowd nil)(setq rowd 3))

(if (= rowh nil)(setq rowh 1))

(if (= rowb nil)(setq rowb 1))

(if (= rowo nil)(setq rowo 25))

(if (= hole nil)(setq hole 17.5))

(setq ins (getpoint "\nSelect insertion point: "))

(setq ins (polar ins 0 rowo))

(repeat cols

 

(setq lstpnt (polar ins (* pi 1.5) rowd))

(entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))

 

(repeat (1- rows)

(setq lstpntt (polar lstpnt (* pi 1.5) rowh))

(entmake (list (cons 0 "circle")(cons 10 2ndpnt)(cons 40 (/ hole 2.0))))

 

(setq lstpnt (polar 2ndpnt (* pi 1.5) rowb))

(entmake (list (cons 0 "circle")(cons 10 3rdpnt)(cons 40 (/ hole 2.0))))

)

(setq ins (polar ins 0 rowh))

)

(princ)

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