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

    Keeping track of a face

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 225 Views 3 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

      In a script, if I pushpull a selected face, face.pushpull dist,true, the new face is the last entity in the model. If I then rotate that face, it is still the last entity in the model. But if I scale the face, it is no longer the last entity and apparently has a new entityID as well. How can I keep track of or find this face?

      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

        Can you attach your own 'id' attribute to it [say id=Time.to_f] - this is [often] transfered across entities... not sure about faces though...

        TIG

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

          When I select the face, and assign a reference to it:
          mod = Sketchup.active_model sel = mod.selection f = sel[0]
          Then use the native scale tool..
          f still points to the same face object,
          f.entityID and f.__id__ remain unchanged.

          ❓

          I'm not here much anymore.

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

            @sdmitch said:

            How can ... find this face?

            Where ents is some Sketchup::Entities collection instance:

            before = ents.find_all{|e| e.is_a?(Sketchup;;Face)}
            # do something that creates a new face(s) object HERE
            after = ents.find_all{|e| e.is_a?(Sketchup;;Face)}
            new_faces = after - before
            

            new_faces will be an array of faces created after the before "snapshot".

            💭

            I'm not here much anymore.

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

              Dan, When the pushpull is executed there are n+1 faces created where n is the number of sides of the face so after-before will return the new faces but not the specific face. Since it is the new copy of the face that is created by the pushpull that I am interested in there is no way to to get its' ID since the pushpull operation returns nil and nothing more.

              I misspoke earlier, the new face created by the pushpull is the first entity added to the file so saving the length of the model entities gives the index of the new face.

              After further testing, it seems that the script works almost without fail in a empty model but often fails in a model that isn't. So back to the drawing board.

              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

                Well now I am confused about what you are doing because you indicated the problem was after a scaling.

                I'm not here much anymore.

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

                  Yes I thought it was but that, as it turns out, that is not the case. I was originally trying to run the script in a model that had other entities and the script failed after the scaling function when the face seemed to turn into an edge. But later, in an empty model, the script ran without a problem so the face was not "lost" as I first thought. I'm just as confused as you are now that it works sometimes.

                  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

                    When you pushpull a face the number of extra faces made in the model can be found - as discussed. Since the 'new face' [which from a user perspective is the 'original face' relocated along the face's normal] has the same normal as the original [which you can already have remembered in a reference] and none of the other new faces share this normal.
                    It gets messy unless your new geometry is being kept inside a group [even temporarily] because the pushpulled result might coincide with one or more preexisting faces that have the same [or reversed] normal as the original face and thereby several new faceS made could have matching normals but the preexisting ones now subsumed into the pushpulled form will be missed in any before/after ents comparisons. Therefore making the new geometry in a group is highly recommended... you can pushpull, get the new face by matching normals, then intersect the face with the model's entities and re-get all faces inside the group with matching normals. Thus what's in the group mimics what would have happened without any grouping BUT lets you collect all of the newly made faces, should any be split by [potential] merging with existing geometry...

                    TIG

                    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