Web console - Sketchup interface
-
There must be some kind of interface between the ruby scripting and SketchUP, beside the web console or the ruby console. Lets say you want to make a plugin that when the user is over a face it changes color and when he is gone form the face, it returns to the default color. Writing it in the web console alone will not let you try it since it goes through the code only once and you don't get a chance to go with the mouse over a face.
-
Hi Tiger Pilot, what you are wanting to write is considered a "Tool" plugin. You will need to make your own tool class, and there are specific methods it should include that will let SU access your code. For example, inside your tool class, you can make a onMouseMove method. Then while your plugins is active, SU will call your meth every time the user moves the mouse and SU will do whatever you say. In your example, you would probably make a "pickhelper" (this just helps you determine what is underneath your cursor). And eevrytime the cursor moves, you update your pickhelper and if it happens to tell you that you are hovering over a face, you would then write code that would change the color of that face, unil the face is no longer being hovered over.
That is the general idea.
You can search the forum here for some threads written by beginners for beginners about how to make a tool class, how to activate it in SU, etc.
And, you can do this using the webconsole if you would like. It will work with tool plugins. I'll see if I can cobble togther a simple example for you.
Chris
-
Thanks for the prompt reply, Chris. I will look forward to your code-snippets and will also search this forum for 'tool'. All I needed was a push in the right direction, and you gave it to me. In all the tutorials, yours included, no-one spoke of a tool, only of plugins, that's why I didn't know how to proceed.
Yoram
-
Check out the API manual on Tool class: http://code.google.com/apis/sketchup/docs/ourdoc/tool.html
-
Chris, I found a snippet that you have posted in the past which will get me started. Thanks.
Yoram
-
OK great. Come back with questions as often as needed.
Chris
Advertisement