sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Move an edge?

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 6 Posters 672 Views 6 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.
    • daikuD Offline
      daiku
      last edited by

      This seems so basic, but how do you move an edge? It does not have a transform! method. I tried transforming the two point3d objects of the two vertices, but could not get it to work.

      Clark Bremer
      http://www.northernlightstimberframing.com

      1 Reply Last reply Reply Quote 0
      • jolranJ Offline
        jolran
        last edited by

        Heh πŸ˜„ good question, havent tried. Maybe you will have to group the edge temporarely?

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

          Entities.transform_by_vectors
          and
          Entities.transform_entities

          mention that you must be in the correct edit context.

          I'm not here much anymore.

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

            @daiku said:

            I tried transforming the two point3d objects of the two vertices, but could not get it to work.

            Geom::Point3d objects are an abstract class. Meaning that a Sketchup::Model does not have these objects in it's Entities.

            Only subclasses of Sketchup::Entity can be stored into the model. Most of what you "see" in a model, are subclasses of Sketchup::Drawingelement (which is a child class of Sketchup::Entity.)

            You would need to transform a Sketchup::Vertex, not a Geom::Point3d object.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • daikuD Offline
              daiku
              last edited by

              @dan rathbun said:

              Only subclasses of Sketchup::Entity can be stored into the model. Most of what you "see" in a model, are subclasses of Sketchup::Drawingelement (which is a child class of Sketchup::Entity.)

              You would need to transform a Sketchup::Vertex, not a Geom::Point3d object.

              But Sketchup::Vertex is not a subclass of Drawingelement, and does not respond to transform!

              Clark Bremer
              http://www.northernlightstimberframing.com

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

                Sketchup::Vertex.superclass

                Sketchup::Entity

                There are many objects "in the model" that are not subclasses of Sketchup::Drawingelement

                examples:
                Sketchup::Layer Sketchup::Page Sketchup::Material
                etc.

                Only Group and ComponentInstance have a transform!() method.

                But that does NOT mean you cannot apply a transformation using the methods in the Entities object...

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • daikuD Offline
                  daiku
                  last edited by

                  OK, So I need to put all the edges I want to move into an entities container, and then use the container's transform methods. Can I put existing geometry into an entities container? It seems that the only way to add an edge is to pass in the endpoints, and it will return the resulting edge. Doesn't seem like this will add the original edge, but rather create a new one.

                  Clark Bremer
                  http://www.northernlightstimberframing.com

                  1 Reply Last reply Reply Quote 0
                  • daikuD Offline
                    daiku
                    last edited by

                    Misunderstood how entities.transform_entities works. It's a method of an existing entities container (in my case, a comp def). You pass it the transform, and an array of entities to be transformed. Moving forward again!

                    Clark Bremer
                    http://www.northernlightstimberframing.com

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

                      The API is badly phrased....
                      You are making it seem more complicated that it is or needs to be...
                      You can group.transform!(transformation) and ditto for instances and point3d [useful if you are using them to construct edges etc].
                      You can't .transform! an edge or a face etc.
                      You can use one of the two entities methods to transform entities and vertices.
                      The entities need to be the entities where the listed objects are... so let's say we have an array of edges to be translated called 'edges' that should all be in the same 'context'...
                      tr=Geom::Transformation.translation(Geom::Vector3d.new(0,0,1))

                      to move everything up in the z 1".

                      edges[0].parent.entities.transform_entities(tr, edges)

                      all of the edges move up 1"

                      Now let's assume we have an array of faces that we want to move in the same way - one way is to move their vertices [you could of course get the faces and their edges in an array and .uniq! it, then transform those as an alternative]
                      verts=[] faces.each{|face|verts << face.vertices} verts.flatten! verts.uniq! faces[0].parent.entities.transform_entities(tr, verts)
                      this method is very common.
                      The other method is entities.transform_by_vectors(objs_array, verts_array)
                      If the vector is the same for each object you could use the ents.transform_entities(translation_transformation) method, but this alternative allows you to manipulate an array [of say vertices] by individual vectors en mass - you need to compile two arrays - an array of objects (which are often vertices) and an array of matching vectors - one for each object to be transformed; this is useful when the vertices need to move by different amounts - see my DropVertices ruby for an example of this...

                      TIG

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

                        TIG ya might as well break down and write up a Transformation tutorial for the new SCF section.

                        I'm not here much anymore.

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

                          I have struggled with this problem also. When I use the vector transform to change the z value of a curve vertex by an offset or absolute amount, it seems to work as expected. But, trying to do the same with the x or y value, gives some rather strange results and I'm baffled as to why.

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

                          http://sdmitch.blogspot.com/

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

                            Moving one vertex and then perhaps another will often have a quite different results, compared to moving them all in one fell swoop with the entities. transformation methods that do all of the changes together...

                            TIG

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

                              @tig said:

                              Moving one vertex and then perhaps another will often have a quite different results, compared to moving them all in one fell swoop with the entities. transformation methods that do all of the changes together...

                              Plus - it's much much faster to perform one big entity transformation instead of many.

                              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