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

    Vertices and selection

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 5 Posters 470 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.
    • alexschreyerA Offline
      alexschreyer Extension Creator
      last edited by

      I am sure someone else has this figured out already: How can I move a vertex with Ruby? The transform! method is not available with a vertex, otherwise this should work:

      vertices[0].transform! transformation
      

      Also, is it possible to select an object by its ID?

      Cheers,
      Alex

      Author of "Architectural Design with SketchUp":
      http://sketchupfordesign.com/

      1 Reply Last reply Reply Quote 0
      • mitcorbM Offline
        mitcorb
        last edited by

        Are you speaking in terms of selecting vertices rather than faces or edges? If so, you might note that ThomThom is working on a script with vertices as a selection set.

        I take the slow, deliberate approach in my aimless wandering.

        1 Reply Last reply Reply Quote 0
        • alexschreyerA Offline
          alexschreyer Extension Creator
          last edited by

          I saw thomthom's plugin but what he does is way beyond what I want to do. I just want to address an object (edge, face, vertex) by ID (not by clicking!) and then transform it.

          Cheers,
          Alex

          Author of "Architectural Design with SketchUp":
          http://sketchupfordesign.com/

          1 Reply Last reply Reply Quote 0
          • scottliningerS Offline
            scottlininger
            last edited by

            Alex,

            You can transform vertices by using Entities.transform_entities method.

            There is no built in way to get at something by id. You could populate a hash yourself, though. Something like...

            entities_by_id = {}
            some_id = nil
            for ent in Sketchup.active_model.entities
              entities_by_id[ent.entityID.to_s] = ent
              some_id = ent.entityID.to_s
            end
            
            # And then get back to stuff like this
            my_last_ent = entities_by_id[some_id]
            
            

            Cheers,

            • Scott Lininger
              SketchUp Software Engineer
              Have you visited the Ruby API Docs?
            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              As Scott said, Entities.transform_entities, or by Entities.transform_by_vectors.

              Entities.transform_entities is good when you have one transformation you want to apply to all entities.

              Entities.transform_by_vectors is good when you want to transform a set entities each differently.

              @alexschreyer said:

              I am sure someone else has this figured out already: How can I move a vertex with Ruby? The transform! method is not available with a vertex, otherwise this should work:

              For Vertices, Edges and Faces you tell the containing Entities collection to perform the transformation.
              Only Groups and ComponentInstances has .transform! methods which can be used directly on the object.

              @alexschreyer said:

              Also, is it possible to select an object by its ID?

              You mean entity.entityID ? Or some other form of identification?
              Maybe this could be better answered if you described the scenario you want to solve?

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

              1 Reply Last reply Reply Quote 0
              • alexschreyerA Offline
                alexschreyer Extension Creator
                last edited by

                Thanks Thom and Scott for the suggestions. I'll try it out later today.

                @thomthom said:

                You mean entity.entityID ? Or some other form of identification?
                Maybe this could be better answered if you described the scenario you want to solve?

                The scenario would be to have a model with nothing selected. The script would then select an entity and apply a transformation based on me giving it some ID. This is easy if I select by type (e.g. "all faces") and apply the transformation on all of them but I am wondering if I can do it with an individual selection by ID.

                Cheers,
                Alex

                Author of "Architectural Design with SketchUp":
                http://sketchupfordesign.com/

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

                  I'm still confused to exactly what this ID is.

                  How are you determining which entity to transform?

                  From a user perspective, what would you do?

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

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    What kind of "ID" do you mean Alex? Entities have ID's associated with them, but they are not kept from session to session. So if you make a hash of ID's and then save them to reuse, you will have to rebuild it to match your saved list of hashes each time. That is the only way ID's seem like they would really help you. And from what I hear, that adds a LOT of size to the skp file, because you have to tag each entity that you are tracking with your own ID to match back to your database.

                    Chris

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • alexschreyerA Offline
                      alexschreyer Extension Creator
                      last edited by

                      Thanks for the replies. I'll have to get back to this later, so please don't think I am ignoring you...

                      Cheers,
                      Alex

                      Author of "Architectural Design with SketchUp":
                      http://sketchupfordesign.com/

                      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