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

    Recognising Sketchup

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 668 Views 3 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 am trying to get a web dialog to recognise it has been opened by a sketchup plugin. Is there some standard Ruby like window.opener in Javascript. (The html file in the web dialog can be opened and used with other applications provided the Sketchup switch = 0).

      Any guidance gratefully received ... 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
      • R Offline
        RickW
        last edited by

        Sorry, I'm not sure what you are trying to do.

        @dialog = UI.webDialog.new
        @dialog.show()
        @dialog.visible? # returns true if the dialog is visible

        This will tell ruby that the dialog is open, but I don't think that's what you were asking. What do you need to accomplish?

        EDIT: After a few more readings, I think I may have figured it out 😄 You could use @dialog.execute_script(javascript_goes_here) that could set a js variable to say the html was opened from SketchUp.

        RickW
        [www.smustard.com](http://www.smustard.com)

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

          @rickw said:

          EDIT: After a few more readings, I think I may have figured it out 😄 You could use @dialog.execute_script(javascript_goes_here) that could set a js variable to say the html was opened from SketchUp.

          Many thanks ... apologises for the many readings!

          I tried a function call as shown here:

          #Ruby
          
          @dlg = UI;;WebDialog.new("Nameset", false,"",300, 205,0,0,false)
                	     
          	subDir = "D;/Nameset3/"
          	fileName = "Nameset3 machine.htm"
          	
          @dlg.set_file File.join(File.dirname(__FILE__), subDir+fileName)
          	
          @dlg.execute_script("startSketchup()") 
          
          //javascript
          
          function startSketchup(){
          sketchup=1
          productsRun()}    //picks up and positions skp components 
          

          The dlg.execute_script works fine from the Ruby console but not directly. Obviously I am missing something - but what?? I tried a add_action_callback but that causes much aggro with non-Sketchup use, and I quickly gave up trying to get one to work.

          Further advice much appreciated.

          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
          • C Offline
            CPhillips
            last edited by

            This is kinda a hack, but in javascript window.external will throw a "not implimented" exception under Sketchup but not under IE or Firefox.

            You could catch that exception and set a flag.

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

              Thanks for the responses. I have persevered with the dialog.execute_script because this seems right and proper, but I think at least for the moment I have to fall back on the exception business - probably try ... catch rather than window.external as I use that a lot during development stages.

              Thanks again.

              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
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement