Recognising Sketchup
-
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
-
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 visibleThis 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 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
-
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.
-
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
Advertisement