Always face center-line/ Magnetic tool
-
@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
-
@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
-
@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
-
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
-
here's a fun bit of code...
now it does what the OP asked...
look below...
john
EDIT: changed back to original as my counter was failingBETTER CODE BELOW...
-
@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.
-
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
-
Hey, I want in on the fun too.
-
@sam yours looks cooler than my effort...
-
-
-
Next step is multi- attractors
-
@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 ofi 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
-
-
@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!
-
nice Philip
Advertisement