The following Ruby script was developed as a Google Sketchup Pluggin to automate the 3D plotting of exploration drill hole results from data contained in a text only data file. Note: there is strong probability the script will require company/site specific modification to match the format of drill hole information posted in news releases. #----------------------------------------------------------------------------- # Name : extrud_selected_faces_along_normal # Author : # Date : 2008.10.10 # Description : Plot Exploration geology drill hole assay results (metres) in 3D (Google Sketchup) # Menu Item : # Usage : # Type : tool # #-------- Example Data File -------------------------------------------------------------------------------------------------------------------- # # Drill Elev Grid Grid Dip Azimth Section Section Length : From To Core True Core True Weighted # # Hole North East (Geo) North East : Length Width Length Width Average # # [m] [m] [m] [m] [m] [m] : [m] [m] [m] [m] [ft] [ft] Ni[%] # # # Source: Sedar 2008.02.20 updated 2008.09.16 # LN07-65 0.0 3112.13 1859.37 -52.34 300.12 3624.86 54.19 106.99 # : 41.60 52.98 11.38 9.32 37.34 30.58 0.350 # : 50.00 52.00 2.00 1.64 6.56 5.38 0.477 #----------------------------------------------------------------------------------------------------------------------------------------------- # # Notes: # Sketchup's base unit system is inches (ie: line ([0,0], [1,0]) draws a 1 inch line along X-axis). # Dimensions then use a multiplier to convert the base unit values (ie: the above line would be 2.54 cm or 0.0254m) # To accurately convert, use Sketchup's Ruby API Numberic methods, such as value.m (eg: line ([0.m,0,m],[1.m,0.m] for a 1 metre line) require 'sketchup.rb' # Constants # Grade multiplier used for cylinders representing assayed data GRADE_DIA_SCALE = 5.0 # Position in Array in which Drill Hole information is stored DRILLHOLE = 0 ELEVATION = 1 GRID_N = 2 GRID_E = 3 DIP = 4 AZIMUTH = 5 LENGTH = 8 # Position in Array in which Assay Core results are stored CORE_FROM = 1 CORE_LENGTH = 3 CORE_GRADE = 7 # ----------------------------------------------------------------------------- def explorationDrillHoles # - Initialize # Start entity creation. model = Sketchup.active_model model.start_operation "Input Drill Holes" entities = model.active_entities # display ruby panel for messages Sketchup.send_action "showRubyPanel:" # Program Variable Declaration fDIP = 0.0 fAZIMUTH = 0.0 pt1=[0,0,0] pt2=[10,10,10] vec = pt2.vector_to pt1 b_rgb = 0 # Blue g_rgb = 0 # Green r_rgb = 0 # Red aveGrade = 0.0 # ----------------------------------------------------------------------------- # - Load data from file filename = get_filename if filename == nil then # exit if cancel was choosen return end # PushPull will create voids if two objects are on the same plane (or errors if incorrectly defined). # To avoid this situation where two grade results are at the same depth, incrementally increase each # depth grade report by miniscule amount (1/10 mm or 0.004 in) to avoid complicated coding. # [Note: 0.001 inch is the smallest value permitted in Sketchup] dInc = 0.0000 IO.foreach(filename ){ |line| # Format input line = line.strip # remove leading and trailing whitespace line = line.tr('\t', ' ') # replace all tabs with spaces line = line.squeeze(" ") # remove all multiple spaces # Ignore if line starts with a "#" (35) or is empty if not line[0].eql?(35) || line.strip.empty? # Split line using default space deliminator arr = line.split if arr[0].eql?':' then # Process Drill Hole Grade Results dInc += 0.0001 # Increment CORE_FROM depth value pt2 = [ pt1[0] + (arr[CORE_FROM].to_f + dInc).m * Math.cos(fDIP.degrees) * Math.sin(fAZIMUTH.degrees), pt1[1] + (arr[CORE_FROM].to_f + dInc).m * Math.cos(fDIP.degrees) * Math.cos(fAZIMUTH.degrees), pt1[2] + (arr[CORE_FROM].to_f + dInc).m * Math.sin(fDIP.degrees) ] circleO = entities.add_circle pt2, vec, (arr[CORE_GRADE].to_f.m * GRADE_DIA_SCALE) # circleO.hidden = true aveGrade = arr[CORE_GRADE].to_f case aveGrade when 0.0..0.499 r_rgb = 0 g_rgb = (254*aveGrade/0.5).to_i b_rgb = 254 when 0.5..0.9999 r_rgb = 0 g_rgb = 254 b_rgb = 254 - (254*(aveGrade-0.5)/0.5).to_i when 1.0..1.4999 r_rgb = (254*(aveGrade-1.0)/0.5).to_i g_rgb = 254 b_rgb = 0 when 1.5..1.9999 r_rgb = 254 g_rgb = 254 - (254*(aveGrade-1.5)/0.5).to_i b_rgb = 0 else r_rgb = 254 g_rgb = 0 b_rgb = 0 end baseO = entities.add_face circleO baseO.material = Sketchup::Color.new(r_rgb,g_rgb,b_rgb) # Colour of extrusion baseO.pushpull arr[CORE_LENGTH].to_f.m else # Define drill hole (length and orientation) dInc = 0.0000 # Reset depth increment used by PushPull print "Processing Drill ", arr[DRILLHOLE],"\n" fDIP = Float(arr[DIP]) fAZIMUTH = Float(arr[AZIMUTH]) pt1 = [ Float(arr[GRID_E]).m, Float(arr[GRID_N]).m, Float(arr[ELEVATION]).m ] pt2 = [ pt1[0] + Float(arr[LENGTH]).m * Math.cos(fDIP.degrees) * Math.sin(fAZIMUTH.degrees), pt1[1] + Float(arr[LENGTH]).m * Math.cos(fDIP.degrees) * Math.cos(fAZIMUTH.degrees), pt1[2] + Float(arr[LENGTH]).m * Math.sin(fDIP.degrees) ] vec = pt1.vector_to pt2 model.active_layer = Sketchup.active_model.layers.add(arr[DRILLHOLE]) hole = model.entities.add_line(pt1, pt2) # hole.material = Sketchup::Color.new(180,0,0) # Colour end end } end # ------ Get Filename -------------- def get_filename model = Sketchup.active_model model_filename = File.basename(model.path) if model_filename != "" model_name = model_filename.split(".")[0] model_name += ".x" else model_name = "Untitled.x" end my_str = UI.openpanel("Geology Drill Hole DataFile", "", model_name) end # This will add an item called "Import Drill Holes" to the Plugins menu. # First check to see if we have already loaded this file so that we only add the item to the menu once if( not file_loaded?("ExplorationDrillHole.rb") ) add_separator_to_menu("Plugins") UI.menu("Plugins").add_item("Import Drill Holes") {explorationDrillHoles} end # ----------------------------------------------------------------------------- file_loaded("ExplorationDrillHole.rb") |