• Login
sketchucation logo sketchucation
  • Login
๐Ÿค‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Always face center-line/ Magnetic tool

Scheduled Pinned Locked Moved Plugins
56 Posts 9 Posters 2.2k Views
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 12 Dec 2014, 03:09

    @jeff
    that's really good...

    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
      jeff hammond
      last edited by 12 Dec 2014, 04:22

      @driven said:

      @jeff
      that's really good...

      thanks.


      a few more additions (right-click--> dynamic components -> component options)

      โ€ข pick the number of boxes (square array)
      โ€ข how many beers? (straightness of rows and columns waver)

      DC_Magnet_Beer.skp

      Screen Shot 2014-12-11 at 11.16.14 PM.png

      dotdotdot

      1 Reply Last reply Reply Quote 0
      • J Offline
        jeff hammond
        last edited by 12 Dec 2014, 04:59

        .

        1024 boxes, a 12-pack, and change the shape of the box component

        beermag.jpg

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • F Offline
          Flippie123
          last edited by 12 Dec 2014, 05:54

          @Jeff

          I just made this and gave it a twist. Very awesome! ๐ŸŽ‰ ๐Ÿ‘


          Capture4.JPG

          1 Reply Last reply Reply Quote 0
          • J Offline
            jeff hammond
            last edited by 12 Dec 2014, 07:06

            @flippie123 said:

            I just made this and gave it a twist.

            yeah, it's something to do with replacing the box component with one on a different axis.. haven't quite figured out how to control it properly.. i made it this far:

            beermag2.jpg

            dotdotdot

            1 Reply Last reply Reply Quote 0
            • J Offline
              jeff hammond
              last edited by 12 Dec 2014, 17:30

              sweet!
              (i'm not sure how to use the code but the gif looks cool ๐Ÿ˜‰ ๐Ÿ‘ )

              dotdotdot

              1 Reply Last reply Reply Quote 0
              • D Offline
                driven
                last edited by 12 Dec 2014, 17:53

                @jeff hammond said:

                ...i'm not sure how to use the code ...

                just paste into 'Ruby Console' hit return, will run till end of session...
                it's only active when inside the DC so you can do other modelling...

                I can put it in a rbz with the DC if you want...

                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
                • J Offline
                  jeff hammond
                  last edited by 12 Dec 2014, 18:08

                  @driven said:

                  @jeff hammond said:

                  ...i'm not sure how to use the code ...

                  just paste into 'Ruby Console' hit return, will run till end of session...
                  it's only active when inside the DC so you can do other modelling...

                  I can put it in a rbz with the DC if you want...

                  john

                  oh nice. i see now.
                  it works along with the dynamic component i posted.. i didn't realize things like that were possible.

                  but yeah, that's a lot better than manually triggering the redraw ๐Ÿ‘

                  dotdotdot

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by 12 Dec 2014, 21:33

                    @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 13 Dec 2014, 00:13

                      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 13 Dec 2014, 22:45

                        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 14 Dec 2014, 19:41

                          @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 15 Dec 2014, 11:55

                            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
                            • S Offline
                              sdmitch
                              last edited by 15 Dec 2014, 15:09

                              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 15 Dec 2014, 15:12

                                @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
                                • S Offline
                                  sdmitch
                                  last edited by 15 Dec 2014, 15:52

                                  @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 15 Dec 2014, 19:14

                                    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 15 Dec 2014, 19:25

                                      Next step is multi- attractors ๐Ÿ’š

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

                                      1 Reply Last reply Reply Quote 0
                                      • J Offline
                                        jeff hammond
                                        last edited by 15 Dec 2014, 20:02

                                        @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
                                        • F Offline
                                          Flippie123
                                          last edited by 16 Dec 2014, 06:00

                                          @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
                                          • 1
                                          • 2
                                          • 3
                                          • 3 / 3
                                          3 / 3
                                          • First post
                                            44/56
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement