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

    [Plugin] Click2flip v1.0 20110928

    Scheduled Pinned Locked Moved Plugins
    23 Posts 11 Posters 19.7k Views 11 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.
    • B Offline
      byrnebm
      last edited by

      I was just wondering if there was some way of naming the faces. I was hoping to be able to assign the room name to the horizontal face ie the floor of the room. So when i copy the parameters returned by relazionefacce to a spreadsheet I would know what room the results refer to.

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

        You could of course add an attribute to each face and later match the tabulated values to those, but it means manually adding them all - that's why I used the 'id' - but that only exists per session so isn't that useful later either...
        When I code with attributes I usually add a time-stamp id as it's unique enough - if you have two attributes with the value 'office' only one might get found.
        Tools like 'flattery' add a unique attribute code to every selected face and then use this in matching parts together later. You could do something similar - add an attribute to every selected face and use the attribute in your tabulated forms. You'd then need a second simple tool to 'find face by id' - it opens a dialog, you'd paste the attribute value from the tabulated data, and it finds the face by its attribute and then highlights that face for you...
        Change 'FACCIA' to say 'ID'.
        Modify the code thus...

        faces.each{|face|
          tid=(Time.now.to_f*1000).to_i
          face.set_attribute('BB','id',tid)if not face.get_attribute('BB','id',nil)
          ### if it already has an id it's kept...
          tid=face.get_attribute('BB','id',0)
          ###
          name=tid.to_s
          ### ...
        
        

        Now write a new tool to find a face by id...

        module TIG
         def self.findfacebyid()
          model=Sketchup.active_model
          ss=model.selection
          ss.clear
          results=inputbox(['ID; '],[0],'FindFaceByID')
          return nil unless results
          id=results[0].to_i
          model.active_entities.each{|e|ss.add(e)if e.get_attribute('BB','id',nil)==id}
         end
        end
        

        Usage: type TIG.findfacebyid
        or make a second menu item using it - follow the other menu item as a guide...
        Copy+paste an id from the table into the dialog
        The faces' IDs will persist across sessions provided the model is saved...
        I used 'BB' as the attribute-library based on your initials, but you can use anything you want...
        🤓

        TIG

        1 Reply Last reply Reply Quote 0
        • G Offline
          Gillman
          last edited by

          Just wanted to thank you for this great plug-in. It has already saved me a ton of time.

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

            A wonderful plugin! thank you TIG!I think TIG-flipBacks.rb is much more easier than other face reversers until now~

            paranoia is a higher form of awareness...

            1 Reply Last reply Reply Quote 0
            • 3 Offline
              3dsmax9
              last edited by

              it's great to have a lot of choice thanks TIG, personally i prefer this one FrontFace1-2 : http://forums.sketchucation.com/viewtopic.php?t=13380

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

                @3dsmax9 said:

                it's great to have a lot of choice thanks TIG, personally i prefer this one FrontFace1-2 : http://forums.sketchucation.com/viewtopic.php?t=13380

                haha! I'm using frontface and Click2flip, they have different feature~ I appreciate the amazing performance of the former, while the latter is faster when I have so many small faces to reverse at once!

                paranoia is a higher form of awareness...

                1 Reply Last reply Reply Quote 0
                • artmusicstudioA Offline
                  artmusicstudio
                  last edited by

                  hi tig,
                  i am not a programmer, but as flipped faces always happen in skp and in complicated structures it is sometimes difficult to select them one after another, i had a following idea for this script

                  1. could it flip ALL SELECTED faces at once (of course with your "automatic" identificaton?

                  2. could it become an option :

                  make all front / make all back / make all faces the side, which is "higher" represented (sorry for this english....means with 100 faces, when 3 are back and the rest is front, it would make all front and vice versa)

                  by that i could double-click & select all connected faces and define all at once

                  thanx stan

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

                    Isn't a pair of shortcut-keys, to 'Reverse' and 'Orient' to match the just reversed face, going to do most of this ?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • artmusicstudioA Offline
                      artmusicstudio
                      last edited by

                      @tig said:

                      Isn't a pair of shortcut-keys, to 'Reverse' and 'Orient' to match the just reversed face, going to do most of this ?

                      yes, you're right. maybe for selection (if there is any) or all elements.
                      so this 'make positive/negative' feature would be great and a real time-saver.
                      regards stan

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        clubber2k
                        last edited by

                        Wow, magical! 👍 👍 👍

                        looked for something like this way back and didn't find.

                        only issue is that the automatic decision making stress me out. on complex models it might flip the right one facing to me, but also another that should be facing in another direction and I didn't even notice...

                        can you add an option using the same concept to just label all the wrong facing faces - allowing more precise decision making?

                        thanks 😎

                        1 Reply Last reply Reply Quote 0
                        • Dave RD Offline
                          Dave R
                          last edited by

                          You might find it useful to set the back face color to something more easily discernible. I use a green I'd never use in the model as a color/texture.

                          Etaoin Shrdlu

                          %

                          (THERE'S NO PLACE LIKE)

                          G28 X0.0 Y0.0 Z0.0

                          M30

                          %

                          1 Reply Last reply Reply Quote 0
                          • C Offline
                            clubber2k
                            last edited by

                            @dave r said:

                            You might find it useful to set the back face color to something more easily discernible. I use a green I'd never use in the model as a color/texture.

                            Yes - that's a generally good idea but since sometimes you have materials on the back side you need to go monochrome and back too see whats going on.. anyway since this plugin already exist - adding a label option will add great usability if possible..

                            1 Reply Last reply Reply Quote 0
                            • CadFatherC Offline
                              CadFather
                              last edited by

                              great and simple tool, would be super-fab if able to flip curved faces as well!

                              ...i thought combining the 2 bits of code above might do the trick:

                              1, click2flip
                              2, flip selection

                              the idea being that if i click on a curved face, i'm also selecting it and therefore running the 2nd script might reverse the whole curved face, say a cylinder. (ideally i thought it could be toggled by pressing an accelerator key) a fair bit beyond my christmas powers... surely possible though..?

                              class TIG;;Click2flip
                                @@BEEP=false
                                def initialize()
                                  @ip  = nil
                                  @ip1 = nil
                                end
                                def activate()
                                  @ip  = Sketchup;;InputPoint.new
                                  @ip1 = Sketchup;;InputPoint.new
                                  @msg="Click back of face to flip it..."
                                  self.reset()
                                end
                                def deactivate(view)
                                  view.invalidate
                                end
                                def onCancel(flag, view)
                                  view.invalidate
                                  Sketchup.send_action("selectSelectionTool;")
                                  return nil
                                end
                                def resume(view)
                                  Sketchup;;set_status_text(@msg, SB_PROMPT)
                                end
                                def reset()
                                  Sketchup;;set_status_text(@msg, SB_PROMPT)
                                end
                                def onMouseMove(flags, x, y, view)
                                  @ip.pick(view, x, y)
                                  if @ip != @ip1
                                      view.invalidate if @ip.display? or @ip1.display?
                                      @ip1.copy!(@ip)
                                      view.tooltip = @ip1.tooltip
                                  end
                                end
                                def onLButtonDown(flags, x, y, view)
                                  if @ip1.valid?
                                      @pt=@ip1.position
                                      ph = view.pick_helper
                                      ph.do_pick(x,y)
                                      @face = ph.picked_face
                                      self.flipper() if @face
                                  end
                                end
                                def flipper()
                                  normal=@face.normal
                                  vector=@pt.vector_to(Sketchup.active_model.active_view.camera.eye)
                                  angle=normal.angle_between(vector)
                                  if angle > 90.degrees
                                    @face.reverse!
                                    UI.beep if @@BEEP
                                  end#if
                                end
                              end#class
                              
                              def self.flipBacks()
                                model=Sketchup.active_model
                                eye=model.active_view.camera.eye
                                faces=[]
                                Sketchup.active_model.selection.each{|e|faces << e if e.class==Sketchup;;Face}
                                return nil unless faces[0]
                                model.start_operation("Flip Selected Back Faces...")
                                faces.each{|face|
                                  normal=face.normal
                                  vector=face.bounds.center.vector_to(eye)
                                  angle=normal.angle_between(vector)
                                  face.reverse! if angle > 90.degrees
                                }
                                model.commit_operation
                              end
                              

                              EDIT: actually just noticed the second script only flips half a cylinder (the side to the screen), the back remains undone.

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

                              Advertisement