sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Always face center-line/ Magnetic tool

    Scheduled Pinned Locked Moved Plugins
    56 Posts 9 Posters 2.2k Views 9 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.
    • D Offline
      driven
      last edited by

      @jeff hammond said:

      ... i didn't realize things like that were possible.

      nor did I...

      I improved the script to only do one redraw after the move [was trigging twice]...

      there are probably other ways to do this, but it seams to work...

      john

      learn from the mistakes of others, you may not live long enough to make them all yourself...

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        updated working version...

        class JcB_MoveToolObserver < Sketchup;;ToolsObserver
            def onToolStateChanged(tools, tool_name, tool_id, tool_state)
              attractor = Sketchup.active_model.selection[0].definition.name == 'attractor'
              moved = tool_state.to_s == '0' && tool_name.to_s == 'MoveTool'
              @count = 0 unless @count == 1
              
              update = attractor && moved
                if update
                  selection = Sketchup.active_model.selection[0].parent.instances[0]
                  @count = @count + 1
                  puts(" first click of " + tool_name.to_s ) if @count == 1
                  if @count == 2
                    puts(" second click of " + tool_name.to_s )
                    $dc_observers.get_latest_class.redraw_with_undo(selection)
                    @count = 0
                  end
                end
            end
         end
        
         Sketchup.active_model.tools.add_observer(JcB_MoveToolObserver.new) if not defined? JcB_MoveToolObserver
         
        

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          here's a fun bit of code...
          now it does what the OP asked...
          auto update, slows a bit over 64 items...

           look below...
          

          john
          EDIT: changed back to original as my counter was failing

          BETTER CODE BELOW...

          learn from the mistakes of others, you may not live long enough to make them all yourself...

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

            @unknownuser said:

            the other thing I was wondering if arrow keys can be used to move the dc's 'attractor'

            You need a Tool to get the key-presses, then read-update-write the position values depending on which key was pressed, then redraw the DC.


            This file was made specifically for Jeff's DC Magnet Beer model.

            Hi

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              cheers Jim,
              that works and is much cleaner than i was attempting...

              what other thing can we do with ruby to manipulate DC's?

              I'll see if I can turn this into a pick point version...

              john

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                Hey, I want in on the fun too.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  @sam yours looks cooler than my effort...

                  click anywhere to move 'magnet'...
                  driven-dc-tool_v2_2.gif
                  john

                  learn from the mistakes of others, you may not live long enough to make them all yourself...

                  1 Reply Last reply Reply Quote 0
                  • sdmitchS Offline
                    sdmitch
                    last edited by

                    @driven said:

                    @sam yours looks cooler than my effort...

                    [attachment=1:3ueqjjsy]<!-- ia1 -->driven-dc-tool_v2.rb<!-- ia1 -->[/attachment:3ueqjjsy]
                    [attachment=0:3ueqjjsy]<!-- ia0 -->driven-dc-tool_v2_2.gif<!-- ia0 -->[/attachment:3ueqjjsy]
                    john

                    ๐Ÿ˜ฎ ๐Ÿ˜ณ ๐Ÿ˜†

                    Nothing is worthless, it can always be used as a bad example.

                    http://sdmitch.blogspot.com/

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      with cursor...modified <a class=@Jeff's DC, @Jim's code..." title="modified @Jeff's DC, @Jim's code..." class=" img-fluid img-markdown" />

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 Reply Last reply Reply Quote 0
                      • gillesG Offline
                        gilles
                        last edited by

                        Next step is multi- attractors ๐Ÿ’š

                        " c'est curieux chez les marins ce besoin de faire des phrases "

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

                          @gilles said:

                          Next step is multi- attractors ๐Ÿ’š

                          heh.. yeah.. i thought about it but it would be really weird to do in DC..
                          that kind of math is probably possible in DC but once things start getting complex, it's either hard to keep track of or you end up with really long/weird formulas that are equally hard to keep track of ๐Ÿ˜‰

                          i guess first you'd have to apply a 'strength' to a single magnet (so far, these aren't really magnets.. the objects just all point at the 'magnet' but the attractor isn't actually pulling on them)

                          then make two of those magnets and let the strengths fight each other

                          dotdotdot

                          1 Reply Last reply Reply Quote 0
                          • Flippie123F Offline
                            Flippie123
                            last edited by

                            @jeff hammond said:

                            @gilles said:

                            Next step is multi- attractors ๐Ÿ’š
                            make two of those magnets and let the strengths fight each other

                            Yep like this image


                            Magnetic architecture.jpg

                            1 Reply Last reply Reply Quote 0
                            • Flippie123F Offline
                              Flippie123
                              last edited by

                              @jolran said:

                              Interesting!

                              I'm working on a parametric modeler that could hopefully(one day ๐Ÿ˜’ ) do this sort of things.

                              I was able to make this urban plan combining Jeff's Beer tool ๐Ÿ‘ and this new Modelur Pre Beta, urban design plugin which in combination with a 'height-' 'and a build-up-area'-map really awesomefies Jeff's beer tool. ๐ŸŽ‰ ๐Ÿค“

                              Click on the image for a larger one!


                              Urban plan.JPG

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

                                nice Philip ๐Ÿ‘

                                dotdotdot

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

                                Advertisement