Hello,
After a period of break I resume my learning in Ruby.
I am currently working with observers to perform some actions after importing a new entity to the SketchUp entity collection.
I want to transmit the “number” variable present in the “Test_A” module to the “Observer” class.
How can I do this?
module Plugin
class Observateur < Sketchup::EntitiesObserver
def onElementAdded(entities, entity)
if entity.class == Sketchup::ComponentInstance
p "NAME = #{entity.definition.name} = #{number}"
end
entities.remove_observer(self)
end
end
module Teste_A
def self.add_observateur()
Sketchup.active_model.entities.add_observer(Observateur.new() )
end
def self.import_01
number = "01"
add_observateur()
end
import_01
end
end
Thank you in advance for your help.