Script request -- drop to touch
-
Sometimes, I can't find an anchor point. I want to position objects such that their lines touch, not anchor points. For instance, consider a square positioned just to the left and top of a triangle with a right angle on the bottom-right. Say I want to position the square so that it just touches the diagonal line of the triangle. To do it in Sketchup manually I need to group the square, draw a line from the square to the triangle, position the square on the intersection point of the line and the triangle, then delete the line. With more complex positionings it gets very tricky and difficult. I would love a way to do this with a Ruby script.
I'm thinking simple here-- just specify Z+/-, X+/- or Y+/- as well as the two objects (groups) in question and then the script would move one group to the other group so that their closest lines or planes juuuust touch. A script that can take X/Y/Z angles would be even better.
-
I'm thinking that a picture of what you want would help.
-
Hi, sure. Just pretend these circles are complex 3d polygons and the blue circle doesn't necessarily hit any anchor point on the green circles such that no other geometry.
The object is for the lowest relative point (not anchor point) on the green circle to just touch the highest relative point on the blue circle.
To do this manually i'd need to find the lowest point on the blue circle, draw a line down, intersect the line with the bottom geometry and get an anchor point at the intersection of the line and the green circles, while hoping that the blue circle geometry does not intersect any other green circle geometry on the way down.
-
Sketchyphysics3 makes that automatically
Just set your volume as "Sphere" or "Convex" (so "surface" must have minimum thick)
Run animation
Save / Exit
Reload you have your result! (here with SPh 2.1 )PS Look if maybe my little thread about drop can help don't make that?
-
Thanks for the idea. Sketchyphysics 3 might do the trick. Might not work for complex objects, though, and it is a bit of a clumsy method...
The undrop multiple sounds fun, but I can't find a link to the final version.
-
Sketchyphysics is the closest thing out there to what you want. Its seriously complicated to write a script like that IMO.
Chris
-
wouldn't it work to draw a construction line from blue center to green center, then move from intersection point blue to intersection point green?
-
example:
-
That won't work on complex shapes though.
-
WELL... if you want to get picky!
-
About Sketchyphysics
A little trick if you want that your objets are still straight fall down at the end
Just put 2 big boxes (one in front of, one behind) so objects are jamed in!
About undrop
just copy/past that in the Web console
Select yours groups and press "Eval"
Change z = z + 100.cm as you want
(for copy all Code follow click blue "Select All"model = Sketchup.active_model model.start_operation("Move in Z") entities = model.entities selection = model.selection zeds=[] index=0 sorted_groups=[] groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)} groups.each{|group|zeds.push([group.bounds.min.z, index]) index+=1 } zeds.sort! zeds.each{|z|sorted_groups.push(groups[z[1]]) } ### sorted_groups is now groups sorted by z z = 0.0 sorted_groups.each do |e| # update! # Now we process the groups t = Geom;;Transformation.new(Geom;;Point3d.new(0,0,z)) # Apply the transformation e.transform!(t) z = z + 100.cm end model.commit_operation return nil
Advertisement