Using observer results
-
I have finally found out how to use the selection observer to get the data I need to manipulate my javascript arrays:
but I've got stuck on how to transfer the data to actually do the manipulation (Clicking on an entity in the SU display spins the tumbler to show its name in the focus stripe). Here's the rough-in code.
class MySelectionObserver < Sketchup;;SelectionObserver def onSelectionBulkChange(selection) #### SHOULD BE RUBY FUNCTION TO SEND TO JAVASCRIPT ????? a = 0 entities = Sketchup.active_model.active_entities entities.each do |entity| if entity.class == Sketchup;;Group || entity.class == Sketchup;;ComponentInstance if selection[0] == entity puts a #cmd = "receiveSelected('#{a}');" #@dlg.execute_script (cmd) end # if class end # if selected a = a+1 end # loop end # def end # class def chrisglasierScenes Sketchup.active_model.selection.add_observer(MySelectionObserver.new) .... onto dialog and callbacks
All help well appreciated as usual.
Thanks
Chris
-
Sorry to bump this but I really would like to know whether or not it is possible to call a javascript function in a web dialog by clicking on an SU component linked to a selection observer?
Any leads on how to go about this would be welcomed.
Thanks
Chris
-
OK I've done it using a two step sequence: $global variable to capture the observer selection; "Synchro" button in web dialog to spin the component list. If anyone knows how to cut out the Synchro bit that would be a real improvement.
Chris
-
Sorry Chris, I would love to help. I have never used web dialogs - however!, I have bought me a nice Javascript book and I am going through it. I only in chapter 2, so I have not got to the point where I can do anything, but maybe in a few days or weeks I'll know better how to get SU and JS to talk freely back and forth.
I can say that I don't like JS nearly as much as Ruby though.
Chris
Advertisement