Use Sketchup default cursors
-
I was playing around with a new tool, and was wondering if there is an easy way to use Sketchup cursors, or do I have to use custom cursors?
For example I want to use the pencil cursor in my own tool. Are there constants setup that I can pass to UI.set_cursor()?
-
Nothing built-in - you'll need to create your own, but you can screenshot them easily enough.
-
How about the wait cursor, is there a way to display that?
-
Hello!
I've seen plugins such as the one from 1001bit.com that change the cursor when launching a plugin (like when deciding the position of a stair.)
UI.set_cursor should be helpful.
Does someone have a short code to share to give an example?
Help is welcome. -
-
Right thomthom, thanks
It changes it with an image. How to replace it by a square that fits values you entered previously? By putting a temporary component that draws the square and that follows the mouse path?
Or how to get the same effect that I see on this advertisement from 3skng i see on the bottom? -
Not sure if this is what you're talking about, but there are methods you can use to draw things directly to the viewport without adding geometry to the model.
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/view.html#draw
-
Nothing happens...Not even errors on Ruby console.
I tried
model = Sketchup.active_model view = model.active_view point1 = Geom;;Point3d.new 0,0,0 point2 = Geom;;Point3d.new 10,10,0 point3 = Geom;;Point3d.new 10,20,0 point4 = Geom;;Point3d.new 10,30,0 status = view.draw_polyline point1, point2, point3, point4
Or
point = [] model = Sketchup.active_model view = model.active_view point[0] = Geom;;Point3d.new 0,0,0 point[1] = Geom;;Point3d.new 10,10,0 status = view = view.draw GL_LINES, point
-
@unknownuser said:
The draw method is used to do basic drawing. This method can only be called from within the draw method of a tool that you implement in Ruby.
-
I don't get it.
What does that mean? Can you give me a short example? -
You can only use the .draw methods from within a custom ruby Tool.
You must create a Tool http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tool.html
Implement the Tool.draw method http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tool.html#draw
and do your drawings from that method.I've attached a quick and dirty test code.
-
Thank you for such a "dirty" code!
Now I get it -
In the onMouseMove definition, view.invalidate match better. (I've seen that thanks to an old post from Jim)
def onMouseMove(flags, x, y, view) view.invalidate end
I don't really understand why in deactivate(view) refresh makes it and not in onMouseMove. Nevermind.
It's now easy to follow the mouse move and to replace the cursor with the .draw method.Thanks again!
-
ah, the
.refresh
method is new to 7.1 I think - I was just testing it - comparing it to the old.invalidate
.Also, note that my test code is by no means a standard for best practice. For a real tool that draws you probably want to add extra code to ensure you only draw when you have new changes to draw. Drawing on every mousemove isn't very efficient - it's just a quick'n dirty way to test some code.
-
Do SU use
.cur
files? Isn't it just.png
? -
I've only used .pngs', but I suspect the extension is less important. I think SU uses the freeimage lib which supports many formats. (I'm clearly making a lot of guesses about how things work.)
-
If it reads .cur format, I wonder how it deals with the hotspot point of the cursor. Since the .cur format has that stored within, but .png does not. And the method that creates the cursor expected you to input hotspot co-ords.
Only way is to test it.
-
Yea, weird that the .cur format isn't supported. With these PNGs you always have to remember where the hotspot for the cursor is...
-
UPDATED!
Here are 4 Yellow pencil cursors I made myself with Visual Studio (and converted to png with Paint.NET)
They point NorthEast, NorthWest, SouthEast & SouthWest.Given in Windows .curformat, so you may use with any Windows Application; .. OR..
and in .pngimage format for use with Sketchup custom tool(s) / plugins.
- 32x32 png cursor images have hotpoint as part of filename
- button images have size (16 or 24) as part of filename
I grant permission to use freely for NON-COMMERCIAL purposes. I however reserve and retain Copyright under US code, and International Treaty (Berne Convention.)
[read Copyright.txt for tips on use with Ruby, where to install etc.]
UPDATED! Originally only in .cur format; Now given in png format with small and large button images as well. Cleaned up the bmp after conversion to png, and did anti-aliasing work on edges. ENJOY!
-
%(#408000)[Yellow Pencil Cursors UPDATED!
Now also in png image format; w/ new anti-aliasing edge work, small and large button images.
See original post link below:]http://forums.sketchucation.com/viewtopic.php?f=180&t=22204&p=198338#p198338
Advertisement