sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Use Sketchup default cursors

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 7 Posters 5.8k Views 7 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      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.

      Error 404 (Not Found)!!1

      favicon

      (code.google.com)

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • C Offline
        confitex architure
        last edited by

        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
        
        
        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @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.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • C Offline
            confitex architure
            last edited by

            I don't get it.
            What does that mean? Can you give me a short example?

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              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.


              test.rb

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • C Offline
                confitex architure
                last edited by

                Thank you for such a "dirty" code! 😄
                Now I get it

                1 Reply Last reply Reply Quote 0
                • C Offline
                  confitex architure
                  last edited by

                  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!

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    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.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Do SU use .cur files? Isn't it just .png?

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jim
                        last edited by

                        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.)

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          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.

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            Yea, weird that the .cur format isn't supported. With these PNGs you always have to remember where the hotspot for the cursor is...

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              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!


                              Four Directional yellow pencil Cursors.
                              Free for NON-COMMERCIAL use.
                              Author retains Copyright.
                              [read Copyright.txt for tips on use with Ruby.]

                              I'm not here much anymore.

                              1 Reply Last reply Reply Quote 0
                              • Dan RathbunD Offline
                                Dan Rathbun
                                last edited by

                                %(#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

                                I'm not here much anymore.

                                1 Reply Last reply Reply Quote 0
                                • Dan RathbunD Offline
                                  Dan Rathbun
                                  last edited by

                                  @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.]

                                  I'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • eneroth3E Offline
                                    eneroth3
                                    last edited by

                                    @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#onSetCursor

                                    These 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

                                    My website: http://julia-christina-eneroth.se/

                                    1 Reply Last reply Reply Quote 0
                                    • tt_suT Offline
                                      tt_su
                                      last edited by

                                      http://www.sketchup.com/intl/en/developer/docs/ourdoc/ui#set_cursor
                                      http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool#onSetCursor

                                      1 Reply Last reply Reply Quote 0
                                      • 1
                                      • 2
                                      • 2 / 2
                                      • First post
                                        Last post
                                      Buy SketchPlus
                                      Buy SUbD
                                      Buy WrapR
                                      Buy eBook
                                      Buy Modelur
                                      Buy Vertex Tools
                                      Buy SketchCuisine
                                      Buy FormFonts

                                      Advertisement