sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [Plugin] Select by Z

    Scheduled Pinned Locked Moved Plugins
    25 Posts 7 Posters 17.9k Views 7 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      Yes, that's OK.
      But I'd just use this:

      
      ###...
      if ss.empty? or not ss[0].class==Sketchup;;Face
        UI.messagebox("Must Select a Face First...")
        return nil
      end
      ### then rest of code assuming it does get past this test...
      

      'return nil' simply stops the process...
      Note how I also added a test to see if the first thing in the selection is not a Face...
      You will winkle a script out of me bit by bit... πŸ˜‰

      TIG

      1 Reply Last reply Reply Quote 0
      • EarthMoverE Offline
        EarthMover
        last edited by

        So kind my friend. Thanks for making me work for it! I'm looking through code to try and determine how to also have the selection apply to edges, but the variables for edges are greater. If I could figure out how to apply it to just work with edges that exist solely on an xy plane....

        3D Artist at Clearstory 3D Imaging
        Guide Tool at Winning With Sketchup
        Content Creator at Skapeup

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

          edge.start.position.z==edge.end.position.z
          

          is 'flat'
          you could also get the lower value with

          edge.bounds.min.z
          

          ?

          TIG

          1 Reply Last reply Reply Quote 0
          • EarthMoverE Offline
            EarthMover
            last edited by

            ss=model.selection; face=ss[0]; ss.clear

            So I assume this lines tells sketchup if the selection is a face then process this line

            model.active_entities.each{|e|ss.add(e)if e.class==Sketchup::Face and e.bounds.min.z==face.bounds.min.z}

            And this says to add to the selection all other faces with the with z bounds.

            To translate this to apply for edges, is it as simple as changing the name face to edges and defining it further with the xy constraint code you provided? I tried it a few different ways and I keep getting errors.

            3D Artist at Clearstory 3D Imaging
            Guide Tool at Winning With Sketchup
            Content Creator at Skapeup

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

              Correct - test that the entities are Edges...

              e.class==Sketchup;;Edge
              

              Then test to see if same height as edge=ss[0] ###you need to have got edge's min.z...
              There are several ways of testing for entity types - the [probable] fastest is e.class==Sketchup::Edge but there are also
              e.is_a?("Edge") e.kind_of?("Edge") e.typename=="Edge"
              etc...
              Now you can also try code to manipulate a selection so that say only edges or faces are left in it...
              For example:

              ss.each{|e|ss.remove(e) if not e.class==Sketchup;;Face}### leaves only faces
              ### OR
              ss.each{|e|ss.remove(e) if not e.class==Sketchup;;Edge}### leaves only edges
              

              TIG

              1 Reply Last reply Reply Quote 0
              • EarthMoverE Offline
                EarthMover
                last edited by

                def selectedgesbyz()
                  model=Sketchup.active_model
                  ss=model.selection; Edge=ss[0]; ss.clear
                  model.active_entities.each{|e|ss.add(e)if e.class==Sketchup;;Edge and e.bounds.min.z==edge.start.position.z==edge.end.position.z}
                end#if
                UI.menu("Plugins").add_item("Select Edges by Z"){selectedgesbyz} if not file_loaded?(File.basename(__FILE__))
                file_loaded(File.basename(__FILE__))
                

                Got this so far. Something is wrong in the syntax. Can you show me the error to my ways. I have no idea how the language works, but it's been a good mental exercise and I'd love to learn more. Thanks for your help.

                3D Artist at Clearstory 3D Imaging
                Guide Tool at Winning With Sketchup
                Content Creator at Skapeup

                1 Reply Last reply Reply Quote 0
                • B Offline
                  BTM
                  last edited by

                  @earthmover said:

                  def selectedgesbyz()
                  >   model=Sketchup.active_model
                  >   ss=model.selection; Edge=ss[0]; ss.clear
                  >   model.active_entities.each{|e|ss.add(e)if e.class==Sketchup;;Edge and e.bounds.min.z==edge.start.position.z==edge.end.position.z}
                  > end#if
                  > UI.menu("Plugins").add_item("Select Edges by Z"){selectedgesbyz} if not file_loaded?(File.basename(__FILE__))
                  > file_loaded(File.basename(__FILE__))
                  

                  Got this so far. Something is wrong in the syntax. Can you show me the error to my ways. I have no idea how the language works, but it's been a good mental exercise and I'd love to learn more. Thanks for your help.

                  Well, first problem is that you capitalized edge in edge=ss[0]. Second, you can't have something like 'if a==b==c'. You have to seperate it into 'if a==b and a==c'. Here's a working example.

                  def selectedgesbyz()
                    model=Sketchup.active_model
                    ss=model.selection; edge=ss[0]; ss.clear
                    model.active_entities.each{|e|ss.add(e)if e.class==Sketchup;;Edge and (e.bounds.min.z)==(edge.start.position.z) and (e.bounds.min.z)==(edge.end.position.z)}
                  end#if
                  UI.menu("Plugins").add_item("Select Edges by Z"){selectedgesbyz} if not file_loaded?(File.basename(__FILE__))
                  file_loaded(File.basename(__FILE__))
                  
                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    Thanks - BTM ... all variables must start with a lower-case letter and test 'x==y and z==a' are both the correct way forward... We'' make a scripter out of EarthMover yet πŸ˜†

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • EarthMoverE Offline
                      EarthMover
                      last edited by

                      Thanks BTM - that makes sense and I follow the logic behind the code. Perhaps I will try and find time to learn the language. I am good at obsessing and not so good at multi-tasking, so it may have to wait till the snow is falling and my work slows down.

                      Regarding the script, it indeed is working. However, it is not properly defining the edges end bounds. The script is selecting any edge which has one of the their bounds (verticies) corresponding with the selection, so it is thus selecting also vertical lines and diagonal lines who's start bounds is on the Z in relevance to the selection. Any suggestions for further defining the end bounds so that the script will only select lines only completely on the same XY plane as the selection?

                      3D Artist at Clearstory 3D Imaging
                      Guide Tool at Winning With Sketchup
                      Content Creator at Skapeup

                      1 Reply Last reply Reply Quote 0
                      • B Offline
                        BTM
                        last edited by

                        @earthmover said:

                        Thanks BTM - that makes sense and I follow the logic behind the code. Perhaps I will try and find time to learn the language. I am good at obsessing and not so good at multi-tasking, so it may have to wait till the snow is falling and my work slows down.

                        Regarding the script, it indeed is working. However, it is not properly defining the edges end bounds. The script is selecting any edge which has one of the their bounds (verticies) corresponding with the selection, so it is thus selecting also vertical lines and diagonal lines who's start bounds is on the Z in relevance to the selection. Any suggestions for further defining the end bounds so that the script will only select lines only completely on the same XY plane as the selection?

                        Ah, here:

                        def selectedgesbyz()
                          model=Sketchup.active_model
                          ss=model.selection; edge=ss[0]; ss.clear
                          model.active_entities.each{|e|ss.add(e)if e.class==Sketchup;;Edge and (edge.start.position.z)== (edge.end.position.z) and (e.bounds.min.z)==(edge.start.position.z) and (e.bounds.max.z)==(edge.start.position.z)}
                        end#if
                        UI.menu("Plugins").add_item("Select Edges by Z"){selectedgesbyz} if not file_loaded?(File.basename(__FILE__))
                        file_loaded(File.basename(__FILE__))
                        
                        1 Reply Last reply Reply Quote 0
                        • EarthMoverE Offline
                          EarthMover
                          last edited by

                          Thanks BTM! It's working great. I see defining the max bounds for the edges was the trick!

                          3D Artist at Clearstory 3D Imaging
                          Guide Tool at Winning With Sketchup
                          Content Creator at Skapeup

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

                            Hello,

                            I was searching for long for such a plugin. So, first of all thanks for it, it's quite useful to select all the contour lines at one level (topography).

                            I just wondered if it is possible to make a small improvement on the execution procedure.

                            In addition of the current method (select one edge or face and then execute the plugin), could it be possible to execute the plugin first and then enter a Z value on the VCB (I don't know if the name is correct, the little box on the right bottom πŸ˜‰) and finally validate with "enter"?

                            In order to keep the current method, the general procedure could be:

                            1. Execute the plugin
                            2. Enter a value on the VCB OR select an edge or a face
                            3. Push "enter"

                            At each step some short information could be displayed on the status bar.

                            I just discover ruby and its power and unfortunately I don't really have the time to learn it so that I can make this modification.

                            Thank you

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

                              Any chance to get a rbz version that can b installed in 2019 or higher?

                              1 Reply Last reply Reply Quote 0
                              • BoxB Offline
                                Box
                                last edited by

                                The version in the extension store by Tig works in newer versions.

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

                                Advertisement