hi there,
for a running project in our office, where we need to make a surface drainage plan for a large area with lots of constraints, we are now using sketchup instead of our normal cad solution what is good in many ways because, for example, there are already lots of plugins that help for example colorize the slope and altitude etcâŚ
but one thing was missing, a dynamic âheight tagâ for all vertices
so i have, with the help of chat gpt, made a small ruby script that implements a overlay, which once activated, looks for all active entities in the context and then iterates through all vertices and draws on screen the height of each individual vert over model 0.00 âŚ
so far so good - but the plugin is pretty heavy on the performance.
so i am wondering if it can be optimised or fi there is a better way to accomplish this goalâŚ
before messing with my own code, i was trying to play with the height by datum plugin but there is a problem that the text tags loose interactivity when they are not in the same context as the âentitiesâ plus some other problems like not being able to automaticly âtagâ all vertices at once etcâŚ
also i was looking into tak2hatas really great draw slope on faceâŚ
its great, performs great, does what is needed, but - there are also 2 features missing for making it perfect âŚ
1 - select if both height and slope should be drawn, or only slope,
2 - slope in % not as fractal
anyway - i would be super happy if someone could help me develope this plugin to have better performance and maybe even bring it so far as to being able to publish it in the extension store for free
i think the idea is quite handy for landscaping + there are several featues that could be incrementally added âŚ
here is my script for you to play with
class HeightOverlay < Sketchup::Overlay
def initialize
description = âdraw height over model zero zero on screen as overlay for each vertice in the active model contextâ
super(âunique_identifier_for_your_overlayâ, âdyn. height tags for verticesâ, description: description)
@height_cache = {} # Cache initialisieren
end
def draw(view)
model = Sketchup.active_model
active_entities = model.active_entities
active_entities.grep(Sketchup::Edge).each do |edge|
edge.vertices.each do |vertex|
unless @height_cache[vertex]
height = vertex.position.z.to_l.to_s
@height_cache[vertex] = height
end
screen_pos = view.screen_coords(vertex.position)
draw_text_with_size(view, screen_pos, @height_cache[vertex], size: 16)
end
end
end
private
def draw_text_with_size(view, position, text, size: 14)
view.draw_text(position, text, size: size)
end
class ExampleAppObserver < Sketchup::AppObserver
def expectsStartupModelNotifications
true
end
def register_overlay(model)
overlay = HeightOverlay.new
model.overlays.add(overlay)
end
alias_method :onNewModel, :register_overlay
alias_method :onOpenModel, :register_overlay
end
observer = ExampleAppObserver.new
Sketchup.add_observer(observer)
end