sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [API] curve.move_vertices

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 5 Posters 170 Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sdmitchS Offline
      sdmitch
      last edited by

      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
      
      

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        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 a Curve instance.)

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          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.

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            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.)

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @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.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                Enity Info still thinks it is a circle after the move. Apparently .move_vertices is for non-ArcCurve curves.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @dan rathbun said:

                  Oh if it IS an ArcCurve.. I would agree...

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    mptak
                    last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      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 ? πŸ˜•

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @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 tried Curve.move_vertices though...

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement