I have created a ruby script which extends a face normal to itself to another face. This works for faces with straight edges, but not curved. I have created a second script to explode any curved edges of a face. These two functions I’ve put within one script and added to my UI.menu. However, this works sometimes but not all the time. I can’t see where I’m going wrong. Restarting Sketchup and performing the scripts again usually solves the issue but not always! Help!!
Class: Sketchup::Selection — SketchUp Ruby API Documentation Note that the order of drawing elements (selection[0] , selection[1] and so on) in the set is in no particular order and should not be assumed to be in the same order as the user selected the drawing elements.
Most obvious is you create a custom Tool …if you familiar with…
Or a workaround can be:
If the user has selected the faces in question, you “store” them ( face_to_movetarget_face ), then remove one of them from the selection and ask by MessageBox: “Does the Target remain selected?” “Yes” or “No”, and depending on the answer, you exchange (or not) the faces.
I’m not sure I understand what you are trying to achieve. Are you looking to move the first face so that it becomes inset into the second face? If that’s right, a more straightforward way might be to gather the intersection points and draw a new face using them rather than moving the first face’s vertices one-by-one. If you don’t need the original face, you can delete it once you have extracted the intersection points.
When you move a single vertex, SketchUp redraws the edge(s) that use that vertex and will usually have to redraw the face(s) that used the vertex. It may also fold faces that became non-planar when the vertex was moved. After iterating over the vertices, with each one generating this sort of potential distortions, the geometry can be quite strange. See the attached animation, which I did using your .rb without first exploding the curve. If I explode the curve first, using your other method, it still makes a mess, just a different one. So, the issue is your algorithm, not the curves per-se.
As a more picky observation, your code would be clearer if you used the various constants defined for Face to use in classify_point (e.g. Sketchup::Face::PointInside) instead of hard-wiring the values of the constants. Because the values are bitmapped, you can build a combination of them using || and use it in your filter without creating the long, bloated line you would get if you wrote them in the loop.
@Deanby77 You are already using transform_entities which is designed to move multiple elements within a single operation. It would work better of all were transformed at the same time.
if all the vertices have the same transformation, use transform_entities
if different transforms (i.e., diffenrent vector lengths,) use transform_by_vectors