I drew a rectangle and attached dimension and then pasted this in the console:
# This is an example of a DimensionObserver
class MyDimensionObserver < Sketchup::DimensionObserver
def onTextChanged(dimension)
puts “onTextChanged: #{dimension}, new_text= #{dimension.text}”
end
end
# Attach the observer. (Assumes there is a dimension in the model root.)
dim = Sketchup.active_model.entities.grep(Sketchup::Dimension).first
dim.add_observer(MyDimensionObserver.new)
(taken from the documentation)
Now I change the rectangle, the dimension’s text is updated, but the observer is not called (I don’t see a message in the console). Can you help me understand why?