Author Topic: Need lisp for calculating explosive loading in boreholes  (Read 1055 times)

0 Members and 1 Guest are viewing this topic.

nekonihonjin

  • Newt
  • Posts: 103
Need lisp for calculating explosive loading in boreholes
« on: September 04, 2022, 02:41:54 AM »
I call upon the ancient gods of lisp,
I would like to automate an activity that I often do in my job, it consists in calculating the amount of explosive that a ring of drill holes must have to perform the blasting in an optimal way.
but to be honest it is a far cry from the little or nothing I know about lisp

So I'm hoping that one of the masters will find the challenge interesting.


The most useful and repeated task would be to find the point on a line where the two adjacent lines are a set distance apart.
something like this:
https://autocadtips1.com/2017/03/13/lisp-version-of-closest-distance-between-two-objects/
but instead of finding the point where the distance is minimun, find the distance set in a variable.
all the info is in the DWG.






« Last Edit: September 04, 2022, 11:12:12 AM by nekonihonjin »

nekonihonjin

  • Newt
  • Posts: 103
Re: Need lisp for calculating explosive loading in boreholes
« Reply #1 on: September 04, 2022, 05:43:18 PM »
A starting point could be, given 3 polylines, with a common vertex, find the point at which a line perpendicular to the one in the middle and crossing it, would touch at its ends those on the sides, since it has a predetermined length.


BIGAL

  • Swamp Rat
  • Posts: 1416
  • 40 + years of using Autocad
Re: Need lisp for calculating explosive loading in boreholes
« Reply #2 on: September 04, 2022, 09:26:49 PM »
The line is a known length so get the answer in one go, just go back to Trig for a triangle O/H = sin(ang) , A/H =cos(ang), O/A = tan(ang). Unfortunately you need the aTan answer, look up help re Tan and Atan in lisp.

Just think 1/2 angle of the 2 lines.

A man who never made a mistake never made anything

nekonihonjin

  • Newt
  • Posts: 103
Re: Need lisp for calculating explosive loading in boreholes
« Reply #3 on: September 04, 2022, 10:16:28 PM »
The line is a known length so get the answer in one go, just go back to Trig for a triangle O/H = sin(ang) , A/H =cos(ang), O/A = tan(ang). Unfortunately you need the aTan answer, look up help re Tan and Atan in lisp.

Just think 1/2 angle of the 2 lines.

Bigal thanks for the response, forgot to mention the side lines are not always equidistant from the center. and the small line not always will be centered in the middle line.





gonna read what you recomended.

BIGAL

  • Swamp Rat
  • Posts: 1416
  • 40 + years of using Autocad
Re: Need lisp for calculating explosive loading in boreholes
« Reply #4 on: September 06, 2022, 09:26:14 PM »
So long as you have 2 line angles that your comparing, does not matter if 2 3 or 4+ lines. May need to repeat to find the closest answer.
A man who never made a mistake never made anything

nekonihonjin

  • Newt
  • Posts: 103
Re: Need lisp for calculating explosive loading in boreholes
« Reply #5 on: September 07, 2022, 01:37:28 AM »
I was able to get it, I'm sure it's not the most elegant or simple way, but it gets the job done. it just needs a loop with the same spacing, to apply it to each line, around the section.

Code: [Select]
(defun VxGetInters (Fst Nxt Mde / IntLst PntLst)
(setq IntLst (vlax-invoke Fst "IntersectWith" Nxt Mde))
(cond
(IntLst
(repeat (/ (length IntLst) 3)
(setq PntLst (cons
(list
(car IntLst)
(cadr IntLst)
(caddr IntLst)
)
PntLst
)
IntLst (cdddr IntLst)
)
)
(reverse PntLst)
)
(T nil)
)
)



(defun c:cargar ( / lineamedia linea2 linea3 lineader lineaizq fline midptder pt1 pt2 bordo l1endpt pdist )
(setvar "UserI1" (getvar "OSMode"))
(setvar 'osmode 0)
(setq bordo (getreal "\nBurden-spacing: "))
(setq lineamedia (entsel "\nSelect line to charge"))
(setq lineader (car (entsel "\nSelect right line")))
(setq lineaizq (car (entsel "\nSelect left line")))
(command "_copy" lineamedia "" "0,0" "0,0")
(setq linea2 (entlast))
    (setq linea2v (vlax-ename->vla-object linea2)
          startpt (vlax-curve-getStartPoint linea2v))

(command "_rotate" linea2 "" startpt 90)
    (setq lineaderv (vlax-ename->vla-object lineader)
           midptder (vlax-curve-getPointAtDist lineaderv 1.0 )) 
(command "_move" linea2 "" startpt midptder)

(setq linea2v (vlax-ename->vla-object linea2))
(setq lineaizqv (vlax-ename->vla-object lineaizq))
    (setq intpts (VxGetInters linea2v lineaizqv acExtendNone))
    (mapcar '(lambda (l) (if (MeIsPointOnObjects l linea2v lineaizqv) (vlax-invoke (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) 'AddPoint l ) ) ) intpts );

(setq pt1 (cdr (assoc 10 (entget (entlast)))));get coord
(command "_erase" (entlast) "");erase point
(command "_pline" midptder pt1 "")
(setq linea3 (entlast))
(setq linea3v (vlax-ename->vla-object linea3))
(setq dist (Vla-Get-Length linea3v))
(setq dist2 (/ bordo dist))
(setq pdist (vlax-curve-getPointAtDist lineaderv dist2 ))
(command "_move" linea2 "" midptder pdist)
(setq lineamedia2 (car lineamedia))
(setq lineamediav (vlax-ename->vla-object lineamedia2))
    (setq intpts (VxGetInters linea2v lineamediav acExtendNone))
    (mapcar '(lambda (l) (if (MeIsPointOnObjects l linea2v lineamediav) (vlax-invoke (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) 'AddPoint l ) ) ) intpts );
(setq pt2er (entlast))
(setq pt2 (cdr (assoc 10 (entget (entlast)))));get coord
(setq l1endpt (vlax-curve-getEndPoint lineamediav))
(command "_pline" pt2 l1endpt "")
(setq fline (entlast))
(command "_pedit" fline "_W" 0.2 "")
(command "_erase" linea2 linea3 pt2er "")



(setvar "OSMode" (getvar "UserI1"))

(princ)
)



(defun MeIsPointOnObjects (Pnt Fob Nob) (and (vlax-curve-getParamAtPoint Fob Pnt) (vlax-curve-getParamAtPoint Nob Pnt) ) )