Moving a curved face/surface
-
As the title says, how do I move the curved face/surface? I'm able to iterate and get the individual faces and I tried
face[0].pushpull distance
within the loop but the faces take off in different directions.
I tried
face[0].transform!(Geom;;Transformation.new([0, distance, 0]))
but that doesn't work.
I also tried adding the faces to selection and doing something with that but I can't get anything to work.
Thanks...
-
Found this post which helped me find the solution...
https://forums.sketchup.com/t/transform-a-model-vertex-by-vertex/38771/7Here's the code I'm using with some notes... if something can be improved or changed please let me know? I can also add the code to iterate the faces if needed?
Basically you need the vertices of all the faces you want to move and each vertex needs a cooresponding vector to be moved to. That way you can pass the 2 arrays to
transform_by_vectors(vertices, vectors)
. Andif you're using sub components like I am, make sure you're in the correct entities context (not sure I'm using all the proper terminology here) oe else you get a mess as a result.
Like Tig explained in the post I shared...
@unknownuser said:
... if every vector has a separate vector-transformation you need to pass two full arrays - in one go!
vectors=[] //array of position to move vertices vertices=[] //array of face vertices from the individual faces that make up the surface vertices.flatten! //in my case I need to flatten the array vertices.uniq! //make sure there are no duplicate vertex vertices.each{|vector| position=vector.position.clone position.x +=distance vectors.push vector.position.vector_to(position) } component_entity.transform_by_vectors(vertices, vectors)
Hopefully this helps others out because it wasn't easy to find or understand... but it works!
Advertisement