need lisp for optimize explosive charge on boreholes

need lisp for optimize explosive charge on boreholes

hmsanchez
Explorer Explorer
572 Views
3 Replies
Message 1 of 4

need lisp for optimize explosive charge on boreholes

hmsanchez
Explorer
Explorer

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.need lisp 01.jpgneed lisp 02.jpg

0 Likes
573 Views
3 Replies
Replies (3)
Message 2 of 4

hak_vz
Advisor
Advisor

I have some experience with blasting predominantly in surface exploitation of aggregate materials. I have created some scripts for creating blasting borehole charge distribution for blasting on quarry slopes. Main charge is mostly ANFO and charge calculations are made using Langefors.

If we presume that you have charge length calculated for each individual blasthole then task is simple. To avoid picking each individual blasthole I would use following algorithm.

a) select all blastholes and sort them in cw or ccw direction  with ucs temporarily set on leftmost or rightmost blasthole.

b Test drawing direction of each blasthole so that end of it is placed in central intersection point where all blasthole lines intersect and flip direction if created not according to this rule.

c) Length of the each charge and stem to be created can then be collected either in an loop,  from a list of charge and stem lengths or read from outer file where in single line we have c and s value.

 

Which option would best suite to you?

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 4

hmsanchez
Explorer
Explorer

Hi Miljenko, good to know you're familiar with the subject.

I do not have charge calculated, that's what I want the lisp to perfom, at least the length of column charged of each borehole, later on I can export a table and use those lengths to calculate the ammount of explosive required.

 

Usually I have to calculate this by hand, using the criteria provided in the DWG that I attached. What I'm asking for is a lisp to automate the calculation, so it will place on every borehole the required length.

 

it'll be good to start from the center upper hole and from there either clockwise or counter clockwise, by choice.

 

I allready have a lisp to make the ring and another to collect lenghts, number the holes and insert a table with number, lenght and the total m.

 

here they are:

 

(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:generabl ( / snam jnam sobj jobj sobj2 jobj2 intpts pt1 pt2 pivot len)
(setq snam (car (entsel "\nPick ore area: "))) ;select the bigger polygon
(setq snam2 (car (entsel "\nPick starting level section: "))) ;select smaller polygon

(setq pivot (getpoint "\nIndicate pivot point: "))
(setvar "UserI1" (getvar "OSMode"))
(setvar 'osmode 0)
(setq offdist (getreal "\nSpacing for boreholes: "))
(setq sobj (vlax-ename->vla-object snam));polygon big
(setq sobj2 (vlax-ename->vla-object snam2));polygon small


(vlax-invoke (vlax-ename->vla-object (car (entsel "\nSelect starting line: "))) 'offset offdist)

 

(setq jnam (entlast)) ;select the line
(setq MyPline (vlax-ename->vla-object jnam)
endpt (vlax-curve-getEndPoint MyPline))

(command "_scale" jnam "" end "1.01")

(setq MyPline (vlax-ename->vla-object jnam)
startpt (vlax-curve-getStartPoint MyPline))

(command "_scale" jnam "" startpt "10")

(setq jobj (vlax-ename->vla-object jnam))

(setq len 15)
(while (> len 6)
(progn


(setq intpts (VxGetInters sobj jobj acExtendNone))

(mapcar '(lambda (l) (if (MeIsPointOnObjects l sobj jobj) (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) jnam "");erase point and line
(command "_pline" pivot pt1 "")

(setq line3 (entlast))
(setq jobj2 (vlax-ename->vla-object (entlast))) ;

(setq intpts (VxGetInters sobj2 jobj2 acExtendNone))

(mapcar '(lambda (l) (if (MeIsPointOnObjects l sobj2 jobj2) (vlax-invoke (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) 'AddPoint l ) ) ) intpts );

(setq pt2 (cdr (assoc 10 (entget (entlast)))));get coord
(command "_erase" (entlast) line3 "");erase point and line
(command "_pline" pt2 pt1 "")
(setq joff (vlax-ename->vla-object (entlast)))
(vla-Offset joff offdist)

(setq jnam (entlast)) ;select the line


(setq MyPline (vlax-ename->vla-object (entlast))
startpt (vlax-curve-getStartPoint MyPline))

(command "_scale" jnam "" startpt "3")


(setq jobj (vlax-ename->vla-object (entlast)))


(setq len (vla-get-length jobj))

);progn
);while

(command "_erase" (entlast) "");erase last line


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


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

 

 

 

 

--pick polys to make length table:

 

 

; http://www.theswamp.org/index.php?topic=57753.0
; simple table example lines to table
l By AlanH Aug 2022

(defun c:boreholetable ( / )
(defun rtd (a)
(/ (* a 180.0) pi)
)

(defun pl-table ( / ss sp curspace tableobj k totlen x len ang rownum)
(setq ss (ssget (list (cons 0 "LWPOLYLINE"))))


(setq y -1)
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss (setq y (1+ y)))))
(setq pto (vlax-curve-getendpoint obj))
(command "_text" pto "0.5" "" (+ y 1))
)


(setq sp (vlax-3d-point (getpoint "\nPick point to insert table ")))

(Setq curspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(setq tableobj (vla-addtable curspace sp 2 3 1 25))
(vla-settext tableobj 0 0 "Boreholes")
(vla-settext tableobj 1 0 "No.")
(vla-settext tableobj 1 1 "Length m")
(vla-settext tableobj 1 2 "Angle")

(setq k 0 totlen 0.0)
(setq x -1)
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss (setq x (1+ x)))))
(setq totlen (+ totlen (vlax-get obj 'Length)))
(setq len (rtos (vlax-get obj 'Length) 2 1))
(setq ang (rtd (angle (vlax-curve-getstartPoint obj)(vlax-curve-getEndPoint obj))))

(if (> ang 270.0)
(setq ang (rtos (+ -360 ang) 2 0))
( if (> ang 90.0)
(setq ang (rtos (- 180 ang) 2 0))
(setq ang (rtos ang 2 0))
)
)

(setq tableobj (vlax-ename->vla-object (entlast)))
(setq rownum (vla-get-rows tableobj))
(vla-InsertRows tableobj rownum (vla-GetRowHeight tableobj (- rownum 1)) 1)
(vla-settext tableobj rownum 0 (rtos (setq K (1+ k)) 2 0))
(vla-settext tableobj rownum 1 len)
(vla-settext tableobj rownum 2 ang)
)

(setq tableobj (vlax-ename->vla-object (entlast)))
(setq rownum (vla-get-rows tableobj))
(vla-InsertRows tableobj rownum (vla-GetRowHeight tableobj (- rownum 1)) 1)
(vla-settext tableobj rownum 0 "Total")
(vla-settext tableobj rownum 1 (rtos totlen 2 1))

(vla-ScaleEntity tableobj sp "0.08")

 

(princ)
)
(pl-table)
)

 

 

0 Likes
Message 4 of 4

memarzan
Community Visitor
Community Visitor

lsp COMMAND?

 

0 Likes