@azuby said:
Use an instance variable. At the moment, your code should be in a class. Initialize your instance variable (i. e. @clicks - the @ is neeeded) in the initialize method of your class and use the variable in the code which is executed by clicking on your button.
azuby
Thanks, but this is too complex for me, I started studying Ruby yesterday, I'm still at "copy&modify&paste" level... π
This is my source:
def MoveLeft
model = Sketchup.active_model
entities=model.active_entities
sp=entities[1]
plane=sp.get_plane
pos += 1
plane=[Geom;;Point3d.new(pos,0,0),Geom;;Vector3d.new(1,0,0)]
sp.set_plane plane
end
def MoveRight
model = Sketchup.active_model
entities=model.active_entities
sp=entities[1]
plane=sp.get_plane
pos -= 1
plane=[Geom;;Point3d.new(pos,0,0),Geom;;Vector3d.new(1,0,0)]
sp.set_plane plane
end
pos=0
toolbar = UI;;Toolbar.new "Sections"
cmdSectionLeft = UI;;Command.new($tStrings.GetString("Test")) { MoveLeft }
cmdSectionLeft.tooltip = $tStrings.GetString("Move section to left")
cmdSectionLeft.status_bar_text = $tStrings.GetString("Move section to left")
cmdSectionLeft.menu_text = $tStrings.GetString("Move left")
toolbar = toolbar.add_item cmdSectionLeft
cmdSectionRight = UI;;Command.new($tStrings.GetString("Test")) { MoveRight }
cmdSectionRight.tooltip = $tStrings.GetString("Move section to Right")
cmdSectionRight.status_bar_text = $tStrings.GetString("Move section to Right")
cmdSectionRight.menu_text = $tStrings.GetString("Move Right")
toolbar = toolbar.add_item cmdSectionRight
toolbar.show
How do I hold value for I among various button presses?