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