Use Sketchup default cursors
-
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
-
@thomthom said:
Do SU use
.cur
files? Isn't it just.png
?Yes your right Thom, I boo-boo'd. Posted before I tested.
SU does NOT recognize
****.cur****
files. If you try it the id for the cursor = 0. (I'm once again flabbergasted at whomever wrote the SU ruby API. They've earned 20 lashes with a Nerf-Noodle!)The API states 'image' but does not say what formats are acceptable.
I've already begun extracting the 4 images files from the cursor files, decided to do a bit of anti-aliasing work on the edges of the pencils.
DONE (Original posting now has updated zip with png images for SU cursors and buttons.)Get them...
Will also look at the Windows API and see if I can cobble up a system call to load a cursor file instead of making a call to UI.create_cursor, as UI.set_cursor should not care how the cursor got loaded into memory, it only wants a pointer (id). [Some testing has shown the UI.set_cursor canNOT deal with Windows Cursor resources, so a 'special' set_win_cursor method would be needed, using a direct Win32 API call.]
-
@thomthom said:
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/ui.html#create_cursor
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/ui.html#set_cursor
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tool.html#onSetCursorThese links you give me 404 errors . I know I've read about this somewhere else recently but can't remember where now.
EDIT:
It might have been from when I read in TT lib the other day to understand how the win32api works. Found this page now: https://bitbucket.org/thomthom/tt-library-2/src/9ff3a5f08604ed477eb4b17fd63612bfc42832dd/TT_Lib2/cursor.rb?at=Version%202.9
-
Advertisement