I am wondering if it is possible to Pushpull a face of one component to the next component. For example, if I have a three cubes in a line, is it possible for me to use ruby code to Pushpull the face of one of the cubes to the next cube it would come in contact with? I know SolidWorks has a feature like this that is called “Up to next” but I would like to do something like this in Sketchup using ruby script.
If the cubes are the same size and are aligned exactly, it shouldn’t be too hard. As @eneroth suggests, one technique would be to cast a ray using the normal to the face you will pushpull as the vector and some point on that face as the origin of the ray. But if they are misaligned or not the same size another method would be needed because a ray from any particular point might miss the next cube entirely!
This begs a question: how were the cubes created? If you built them using your own Ruby code, you could just as well keep track of where you put them and then you’d know how far to pushpull.
I like the idea of the raytest, but I can’t figure out how to get the coordinates of where my ray is hitting the next face. Also, there are a variety of different components that I’m using, so the distances between components are always slightly different.