sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Using observer results

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 1.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • chrisglasierC Offline
      chrisglasier
      last edited by

      I have finally found out how to use the selection observer to get the data I need to manipulate my javascript arrays:

      Observer transfer problem.png

      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

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • chrisglasierC Offline
        chrisglasier
        last edited by

        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

        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

        1 Reply Last reply Reply Quote 0
        • chrisglasierC Offline
          chrisglasier
          last edited by

          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.

          sceneComponentTumble.png

          Chris

          With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            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

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement