Thanks for the help, I think that is what I need. For those interested, here is a link to a very simple example of using Ruby and WebDialogs: http://sketchupapi.blogspot.com/2008/02/sharing-data-between-sketchup-ruby-and.html
Latest posts made by jrstoup
-
RE: A Question on Making a GUI
-
A Question on Making a GUI
I have been working with ruby and SU for a bit now and have created a simple plugin for creating a 1 meter square grid of variable size along each axis. The interface for this is very simple as it just pops a dialog box requesting the desired size of the grid. What I would like to do is make a more complex GUI for handling additional variables as well as managing preexisting grids.
To do this, will I have to manage everything through he existing UI class or is there another way of doing this? I read somewhere a reference to creating custom html pages but was unsure if that was meant solely for displaying data. Can I create my own custom dialog box? If so, how?
-
How can I create a 1 meter square plane in Ruby?
This seems like it should be fairly trivial, but for the life of me I can't find the answer I'm looking for so I'm counting on you guys to come through for me. Here is my problem, I want to create a plane that is exactly 1 meter square as in this example:
pt1 = [0,0,0] pt2 = [val,0,0] pt3 = [val,val,0] pt4 = [0,val,0] my_face = entities.add_face [pt1, pt2, pt3, pt4]
I need to figure out the relationship between the unit system sketchup uses and meters. Does anyone have a clue as to how I can do this?
-
RE: Ruby Scripting Question - Defining Functions
I tried using your function and sadly, regards of which menu item I select ("Some_Method 1", "Some_Method 2" or "Some_Method 3") it always says "You chose 3". Any ideas why I am only getting the final index of the loop?
-
RE: Can Plugins Create Key Bindings?
Here is what I eventually figured out. You can create a ruby script, add it to the plugins menu and then create a shortcut that references that script. However, to create the shortcut you have to go into the menu Window > Preferences > Shortcuts, search for the script and then add it that way.
So to recap, yes it is possible to bind scripts to keys, however you can't do it with another script. Adding shortcuts can only be done by the user it seems. So now you know.
-
Ruby Scripting Question - Defining Functions
I am trying to streamline my code by putting my function calls into a loop. So far, I have been unsuccessful. Anyone care to give me a clue as to why?
#What I have UI.menu("PlugIns").add_item("Method 1") {method1} UI.menu("PlugIns").add_item("Method 2") {method2} UI.menu("PlugIns").add_item("Method 3") {method3} def method1 derp = "derp1" end def method2 derp = "derp2" end def method3 derp = "derp3" end
The above code creates three menu items called "Method 1", "Method 2" and "Method 3". Those entries call the corresponding methods created below them. What I would like to do is put all of that into a loop so I can create as many entries and methods as I want. Here is my rough attempt at that:
#What I want max = 3 for n in 1..max switchStr = "" UI.menu("PlugIns").add_item("Method " + n.to_s) { switchStr = "method" + n.to_s eval switchStr } def switchStr derp = "derp" + n.to_s end end
Now, unfortunately the above code doesn't work. I am currently looking through the Ruby documentation to determine what exactly it is that I need (a proc perhaps?) however I thought I would take a shortcut and ask you. So, what am I doing wrong here? I feel like this should be simple and I'm just missing something. Thoughts?
-
Can Plugins Create Key Bindings?
I looked in the SketchUp documentation and I can't find what I'm looking for so I thought I would come here.
What I want to do is bind a custom ruby script to a specific key. For example, I want to bind the F8 key so that when it is pressed a window comes up and says "Congrats, you pressed F8!". Is this possible? If so, what is the API call?
Thanks.