GeoStrat - 3D models generator for geological stratigraphy

Sondaggi e rilievo GeoStrat is a program developed by the need to create a three-dimensional solid model starting from the topographic and geognostic surveys an area in order to generate the geological cross-sections at any point of the terrain being studied. Written in Visual Basic© and AutoLISP©, the program relies on csv files previously created or manipulated in Excel© containing the topographic survey, the coordinatesof the survey and the results (columns) of the geognostic surveys themselves. We have deliberately chosen to use a csv file because the output of the survey instruments is not homogeneous, it changes according to the manufacturer, and the files used to read the points were always different, thus exploiting the potential of the spreadsheet it is easier to standardize the data. Once the file has been prepared with the starting data, the resulting csv file is fed to AutoCAD©, where the points returned by the topographic survey and the columns relative to the actual geognostic surveys are inserted into the graphic environment.

Sondaggi
Sondaggi
At this point the program asks the user for the degree of precision he wants for the final solid and through interpolation calculates the vertices of the triangles constituting the surfaces that separate the different geognostic layers. Each layer is put on a specific layer for the type of material and with the vertices we construct a mesh made up of 3DFace elements. Through a function in AutoLISP©, the 3D solids of the various layers are generated and these can be managed through all the boolean operations of AutoCAD© to obtain the Stratigraphic Sections.

Following the AutoLISP code for the generation of solids.

; Face2Vol.lsp creates 3DSolids from 3DFaces
; R.D.Ramirez - GTA Srl; AutoCAD 2010

; **********************************************************************************************************
(defun 3DPROC (/ CNT ACT_ELE SELSET ACT_ELIST P1 P2 P3 GES_VOLUME)
  ; global SAVE_CNT Z_MIN Z_MAX
  (setq selset (ssget "_p" '((0 . "3DFACE")))) ; select 3dfaces only
  (setq CNT 0)
  (repeat (sslength selset)
    (setq act_ele (ssname selset cnt))	
    (command "_chprop" act_ele "" "_co" "2" "")	
    (setq act_elist (entget act_ele))		
    (setq
      	P1 (trans (cdr (assoc 10 act_elist)) 0 1)
	    	P2 (trans (cdr (assoc 11 act_elist)) 0 1)
    		P3 (trans (cdr (assoc 12 act_elist)) 0 1)
    ) ; setq


    (command "_pline"
	     (list (car P1) (cadr P1) Z_MIN)
	     (list (car P2) (cadr P2) Z_MIN)
	     (list (car P3) (cadr P3) Z_MIN)
	     "_c"
    )					; command
    (command "_extrude" (entlast) "" Z_MAX)   
    (command "_slice" (entlast) "" "_3p" P1 P2 P3 (list (car P1) (cadr P1) Z_SEL)) ; Z_MAX ... upper level of extrusion; Z_MIN ... lower level of extrusion

    (if (> cnt 0) (command "_union" ges_volume (entlast) "")) ; union extruded triangles
    (command "_chprop" act_ele "" "_la" PROC_LAYER "") ; move processed triangles to layer "proc"
    (setq ges_volume (entlast))
    (setq save_cnt (1+ save_cnt))

    (if	(= save_cnt 5000)
      (progn
	(command "_qsave")
	(setq save_cnt 0)
       )
    )	
    (setq cnt (1+ cnt))
  ) ; repeat
) ; EODEFUN 3DPROC
; **********************************************************************************************************

; main

(prompt "face2vol ver. 3.5 R.Marschallinger 2009 (AutoCAD 2010)\n")
(prompt "for performance, set shademode to 2D")
(command "_osnap" "_none")
(setvar "delobj" 1)
(setvar "cmdecho" 0)
(setvar "solidhist" 0)

(setq
  save_cnt 0
  Z_SEL 0.0
  Z_MIN 0.0
  Z_MAX 0.0
  Z_ADD 0.001 
)

(alert "Input lower and upper levels (z) of solid model to be created")
(setq z_min (- (getreal "\nZ min: ") Z_ADD))
(setq z_max (+ (getreal "\nZ max: ") Z_ADD))

(initget "U D u d")
(setq TYP (strcase (getkword "\t\t extrude solid upward or downward [U D] : ")))
(if (= TYP "U") (setq Z_SEL Z_MAX) (setq Z_SEL Z_MIN)) 

(initget "R r I i")
(setq TYP (strcase (getkword "\t\t regular or irregular arrangement of input 3Dfaces [R I] : ")))

(setq prefix (getstring "\nLayer prefix: "))

(setq z_max (- z_max z_min))

(setq 3D_LAYER (strcat prefix "_3DSOLID"))
(setq PROC_LAYER (strcat prefix "_PROC"))

(command "_elev" "0.0" "0.0")
(command "_layer" "_n" PROC_LAYER "_f" PROC_LAYER "_m" 3D_LAYER "_co" "1" 3D_LAYER "")

(if (= TYP "R") ; regular grid ...
  (progn
    	(command "_plan" "")
    	(alert "pick lower left corner")
	(setq lowleft (getpoint "\nlower left corner"))
	(alert "pick upper right corner")
	(setq upright (getpoint "\nupper right corner"))

	(setq num_slices (getint "\nnumber of columns : "))
	(setq col_width (abs (/ (- (car lowleft) (car upright)) num_slices)))

	(setq X_LOW (car lowleft) X_HIGH (+ X_LOW col_width) Y_LOW (cadr lowleft) Y_HIGH (cadr upright))

	; aggregate 3DFACES columnwise
	(repeat	num_slices
  		(setq	selset (ssget "_c" (list X_LOW Y_LOW)(list X_HIGH Y_HIGH)'((0 . "3DFACE")))) 
  		(3DPROC)
  		(setq X_LOW X_HIGH X_HIGH (+ X_HIGH COL_WIDTH)) 
	) ; repeat

	(setq selset (ssget "_c" LOWLEFT UPRIGHT '((0 . "3DSOLID")))) 
	(command "_union" selset "")
  ) ; progn
) ; if

(if (= TYP "I")
	(progn
	  	(INITGET "Y y N n")
	  	(setq HIDETYPE (strcase (getstring "freeze layer with processed triangles [y n] ? ")))
	  	(if (= HIDETYPE "N") (command "_layer" "_th" PROC_LAYER ""))
			(prompt "\nselect 3Dfaces [all select modes]")
			(command "_select" pause)
			(setq selset (ssget "_p"  '((0 . "3DFACE")))) 
	  		(3DPROC)
	) ; progn
) ; if