[API] curve.move_vertices
-
If you draw a circle and move it using curve.move_vertices, the circle moves but the value of curve.center does not change.
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection curve = sel.first.curve p 'Before Move',curve.center vec=Geom;;Vector3d.new(0,0,1);pts=[] curve.vertices.each{|v| pts<<v.position+vec} curve.move_vertices(pts) p 'After Move',curve.center
-
Sounds like it does exactly what the method name implies. Scripters who did not wish the center moved would be angry if it did.
I would think it more serious if it's subclass
ArcCurve
did not move the center (unless the object is coerced into aCurve
instance.) -
The circle is an ArcCurve which is why the center is accessible isn't it?
Doing a vector transformation causes the center to move so it's not a big deal but I just thought it was strange.
-
Oh if it IS an
ArcCurve
.. I would agree, especially if the curve did not get bigger (ie, the distance from the center to all vertices should be the same, otherwise it is not an arc, it's a curve.) -
@dan rathbun said:
Sounds like it does exactly what the method name implies. Scripters who did not wish the center moved would be angry if it did.
I don't understand why you'd not expect the center to move? I mean, if all the vertices move equally, then you've moved the whole circle - surely the center value should change?
And if move_vertices makes it become not a circle, then it should not be an ArcCurve object any more.
-
Enity Info still thinks it is a circle after the move. Apparently .move_vertices is for non-ArcCurve curves.
-
@dan rathbun said:
Oh if it IS an
ArcCurve
.. I would agree... -
If I apply a transformation to the separate vertices in an circle or arc it acts differently than if I have exploded the curve. Any insights? When the vertices are a part of a circle the circle seems to dilate about the center even if the transformation is defined as
tran=Geom::Transformation.new([0,0,10])
If the curve is exploded the transformation does the expected shift of 10 in the "z" direction.
Thanks for any immediate insights.
-
I never use it
It's poorly documented.As I understand it this method expects an array of points as its argument.
curve.move_vertices([points])
Each of the vertices is then relocated to be at the matching point in the array.
It might need points and not an array - a few methods are picky like that...
It might well also need a point for each vertex that's processed.If you apply an
entities.transform_by_vectors([vertices], [vectors])
to the vertices, the vectors are transformed from each vertex.position to each new vector.position [calculated beforehand in turn] - this will should work. Since in the first method you'll have to calculate each new vertex point for the curve anyway, then getting the vector of each between the vertex.position and its new point and putting it into an array, with a matching array of vertices, seems straightforward; as these are then readily passed to the transform_by_vectors method ?The
entities.transform_entities(translation_transformation, [vertices])
would move all of the passed vertices along the very same translation vector - in effect shunting the vertices over by that same vector each time... Note that if you try some other transformation types they might fail or give odd results, e.g. a transformation that simply specifies a 'new point' could have the effect of coalescing all of the vertices into one coincident point ??How are you trying to use it exactly ?
Why aren't the other, more properly documented, methods sufficient ? -
@mptak said:
If I apply a transformation to the separate vertices in an circle or arc it acts differently than if I have exploded the curve. Any insights? When the vertices are a part of a circle the circle seems to dilate about the center even if the transformation is defined as
tran=Geom::Transformation.new([0,0,10])
If the curve is exploded the transformation does the expected shift of 10 in the "z" direction.
Thanks for any immediate insights.
In Vertex Tools I had to explode all curves for the vertices I wanted to move. Weird things happen when you move vertices connected to a
Curve
. I have never triedCurve.move_vertices
though...
Advertisement