Use Sketchup Cursors in Custom Tool

I’m trying to create a custom move tool.

I see the following code to use a ‘built in’ SketchUp cursor:

# Here we have hard coded a special ID for the pencil cursor in SketchUp.
# Normally you would use `UI.create_cursor(cursor_path, 0, 0)` instead
# with your own custom cursor bitmap:
#   CURSOR_PENCIL = UI.create_cursor(cursor_path, 0, 0)
def onSetCursor
   # Note that `onSetCursor` is called frequently so you should not do much
   # work here. At most you switch between different cursor representing
   # the state of the tool.

Taken from this example:

I’m wondering if there is a list of values for other SketchUp cursors (specifically the move tool cursor), and if they are ‘safe’ to use in an extension.

I also noticed that using UI.create_cursor the cursor does not scale correctly on Windows 10 with one monitor (4K) set to 175%, and another monitor set to 100%. The build in cursors scale correctly as does the CURSOR_PENCIL = 632

On Mac all of the built-in cursor pdf images are in

/Applications/SketchUp 2020/

I’m not sure what would happen if you passed one of these to UI.create_cursor, but I would guess that you’d get a new cursor that just happens to use the same file as the built-in.

I don’t know where the corresponding svg images are kept on Windows.

If there is a reference for the built-in cursor_id values, I don’t know it.

In win
c:\Program Files\SketchUp\SketchUp 2020\Images
c:\Program Files\SketchUp\SketchUp 2020\LayOut\Images\

Then I’m usually using to edit and create .pdf .png .svg files.

Then I’m using something like this to define in code:

  if Sketchup.version.to_i >= 16 
    EXT_PIC ||= Sketchup.platform == :platform_osx ? '.pdf' : '.svg'
    EXT_PIC ||= '.png'

  MYCURSOR ||= UI.create_cursor(File.join(File.dirname(__FILE__), "/cursorpic#{EXT_PIC}"), 8, 24)

SketchUp only supports up to 150% display scaling (aka scaled resolution on Mac.)
But with regard to cursors and toolbar buttons, the image must be a vector SVG (or PDF on Mac,) in order to be correctly and precisely scaled. (Raster image formats can get blurry.)

Last cycle I sent in a request to support 4K (200%) and 5K (266%) displays. (I think it is past time.)

I remember starting a topic on this subject. An I think at one time I had a list of all the cursor IDs.
I’ll see if I can find it.

Sure, until they change. :wink:

Since they are undocumented, they’d be subject to change at anytime, without notice.
(I also don’t know if their use would pass the EW review.)

They might change, but their names have been the same for as long as I remember (currently 3~4 months
We use it all the time for support and training

UI.set_cursor( 641 )

(at 3rd trial I got it :wink: )

1 Like

Yeah I finally added an onKeyUp event to increment the cursor up and down in my tool until I found the right one. Thanks anyway.


BTW: Be careful with the integers in set_cursor, I don’t remember exactly which one but that caused a bugsplat crash… when I did the same trials not recently.

1 Like

I didn’t find the topic over at SketchUcation. And I don’t know where that old list is.

I did recreate a bit of the first step I did before. Which was to export (a few) PNG resource images from an old SketchUp executable using Visual Studio. They have the resource id as part of the image filename.

It’s tedious, and once they’ve all been exported compiling the list is a manual job.