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

    Vertex selection/transofrm plugin

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 10 Posters 2.2k Views 10 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      Here is an example of a fully functioning tool class Remus. Copy all of it into Jim's web dialog, then execute.
      ` class Remus_tool

      def onMouseMove(flags, x, y, view)
      ip = view.inputpoint x,y
      @cursor = ip.position
      view.invalidate
      end

      def draw(view)
      view.draw_points @cursor, 10, 1, "red"
      end

      end

      Sketchup.active_model.select_tool Remus_tool.new`

      The main things to learn from it are that tools are their own class. To start a tool, you have to use Sketchup.active_model.select_tool( my_tool_object ). Once you have the tool class, you can use all the cool tool methods defined in the tool classin the API. So you get access to the mouse and keyboard, for example.

      Also, in the onMouseMove, I am calling view.invalidate. Everytime that is called, SketchUp checks the draw method (if there is one(you need to add it like I did)). So everytime view.invalidate is called, the draw method does whatever it is told to do. It is only from within the draw method that you can call all the screen drawing methodsfound in the View class.

      Also, the last thing I will note about the code is that the inputpoint is finding the 2d mouse coordinates and returning a 3d position. Because the view.draw method draws in 3d model space, not 2d screen space (yes there is a draw2d method, but it didn't want to cooperate today).

      Heheehe, have fun!

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • jeff hammondJ Offline
        jeff hammond
        last edited by

        @unknownuser said:

        So I would suggest the Community elaborates a little bit more on real-life examples of vertex edition.

        for me personally, i don't edit vertices too often.. (well, i use sandbox smoove sometimes and i like it's soft selection feature but the z axis only is sort of letdown)..

        anyway, most of the times that i grab and move individual vertices is for cleaning up after certain ruby operations..
        here's an example after bending..

        pre bent shape

        after bending

        zoomed in..

        at this point, i'll use the move tool and click on misplaced vertices and drag them into place (sometimes using autofold.. sometimes erasing stray lines)

        and i just work my way around the shape til it's clean..

        v4.jpg

        so yeah, some form of auto join vertices plug would be awesome but really, i can see how it might be hard to get it too work right in multiple circumstances..

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          well, maybe first things first. This is an even simpler tool class that accesses the mouse movements. it puts the x,z coordintes to the ruby console:

          ` class Remus_tool
          def onMouseMove(flags, x, y, view)
          puts x.to_s + ", " + y.to_s
          end
          end

          Sketchup.active_model.select_tool Remus_tool.new`

          That might be slighlty simpler to look at, at first. Then start playing with all the tool class methods to see what you can do.

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • R Offline
            remus
            last edited by

            Cheers chris, thats a really cool little example. Im tempted to give it a bash now, just got to find some time in between all this uni work.

            http://remusrendering.wordpress.com/

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              You need to transform any connected set of vertices in one go, with something like...
              entities.transform_entities(transformation, [array_of_vertices])
              The transformation can be any of the transformation types - like a rotation, scaling, translate etc...
              the remaining argument(s) can be a number of comma separated entities or an array - since a vertex is an entity as far as this is concerned, so this is the way to manipulate vertices en mass. πŸ’­

              TIG

              1 Reply Last reply Reply Quote 0
              • R Offline
                remus
                last edited by

                Cheers for the tips tog, just tried that out and have managed to get transformations working for the first time πŸ˜„ (not that i ever really tried before πŸ˜› )

                http://remusrendering.wordpress.com/

                1 Reply Last reply Reply Quote 0
                • PixeroP Offline
                  Pixero
                  last edited by

                  For what its worth I'm transforming vertices in my JS-Align script. You can take a look at the code.
                  http://www.pixero.com

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    AlexMozg
                    last edited by

                    See my ArchTools VertexTool Plugin:
                    It is the part from my complex of plugins.
                    (WIP)
                    http://www.youtube.com/watch?v=R4WVAcu_nM0

                    πŸ˜„

                    1 Reply Last reply Reply Quote 0
                    • kenK Offline
                      ken
                      last edited by

                      Doesn't 1001 bit tools have a vertex move tool. At least that what I use to move a vertex. Maybe you need something else.

                      Ken

                      Fight like your the third monkey on Noah's Ark gangway.

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        Also my 2D Polyline Edit Tool effectively lets you relocate a Polyline's Vertices by picking on them and their new location, one at a time... See its code for how it does those transformations, with a 'ghost polyline' till you end it...

                        TIG

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

                        Advertisement