Hi,
I am trying to automate this workflow: https://www.youtube.com/watch?v=_bbMv5uXUCM
I am using a script which exports height curves as dwg and orthophoto as jpg from ArcGIS. These two the can be intersected to make a detailed surface with high quality satellite texture on it.
This can be done within SketchUp already, but it is not accurate enough for this purpose.
I have made the first part that gets the image into SketchUp, asks for dimensions and extrudes it, but I am having trouble understanding how to get the FromContoursTool to work.
This is the first part:
# First we pull in the standard API hooks.
require 'sketchup.rb'
# A new menu item is added to SketchUp.
UI.menu("Extensions").add_item("GIS til SketchUp") {
UI.messagebox("Let's go!")
# A box asking for the dimensions of the data area.
results = inputbox(["Length ", "Width; "], ["?", "?"], ["", ""], "Dimensioner på udtræk")
# Width and length are converted to integers.
length = results[0].to_i
width = results[1].to_i
# A box asks for an image location. The image is exploded.
chosen_image = UI.openpanel("Open Image File", "c;/", "Image Files|*.jpg;*.png;||")
model = Sketchup.active_model
image = model.active_entities.add_image(chosen_image, ORIGIN, length, width)
entities = image.explode
# A face is drawn.
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [length, 0, 0]
pts[2] = [length, width, 0]
pts[3] = [0, width, 0]
# The face is extruded to a volume.
face = entities.add_face(pts)
status = face.pushpull(100, true)
}
This is the second part:
# A new menu item is added to SketchUp.
UI.menu("Extensions").add_item("Contours") {
UI.messagebox("Let's Go")
# First we pull in the standard API hooks.
require 'sketchup.rb'
require 'extensions.rb'
Sketchup;;require 'su_sandbox/GeometryHelpers'
model = Sketchup.active_model # Sketchup active model
se = model.active_entities # Sketchup Active Entities. Allows working inside a component.
ss = model.selection # Model selection, if it exists
if ss.length == 0 then ss = se end # otherwise use the whole model.
# edges = [] # create empty array
# se.each do |e|
# if e.is_a? Sketchup;;Edge # if e is a sketchup edge
# edges << e # add to e
# ss.add e # add e to selection
# end
# end
Sketchup.active_model.select_tool FromContoursTool
}
Any help would be appreciated - I'm finding it challenging finding documentation on what I'm trying to do. Or if there is a good post already that I have overlooked, please point me in the right direction.
All the best,
Nicholas