sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    Select Only Solids

    已排程 已置頂 已鎖定 已移動 SketchUp Discussions
    sketchup
    22 貼文 7 Posters 4.5k 瀏覽 7 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • K 離線
      KrisM
      最後由 編輯

      I need to have only solids (groups or components) in some of my models. What I need to do is select the whole model but only those objects that are solids. I have looked at various selection plugins but nothing does what I'm after. I need to find the non solid objects in the model so that they can be fixed. Any ideas out there?

      KrisM

      1 條回覆 最後回覆 回覆 引用 0
      • Wo3DanW 離線
        Wo3Dan
        最後由 編輯

        @krism said:

        ..... I need to find the non solid objects in the model so that they can be fixed. Any ideas out there?KrisM

        I don't know of a plugin that selects just solids.
        But hovering over geometry with the 'Move' tool "temporarily" highlights what the cursor is over, as if it were selected. At that time 'Entity Info' displays whether the geometry is a group or component and if so, whether the grouped geometry is a SketchUp's solid. This without actually selecting anything.
        Maybe this will help you out.

        1 條回覆 最後回覆 回覆 引用 0
        • K 離線
          KrisM
          最後由 編輯

          I already use the entity info box to identify the solids. What I want to do is select the whole model, filter out the solids and deal with the remainder. If I have a couple of hundred objects to go through individually, it is a bit of a task.

          1 條回覆 最後回覆 回覆 引用 0
          • pilouP 離線
            pilou
            最後由 編輯

            Maybe this ?

            Frenchy Pilou
            Is beautiful that please without concept!
            My Little site :)

            1 條回覆 最後回覆 回覆 引用 0
            • K 離線
              KrisM
              最後由 編輯

              This looks like it provides information only but doesn't allow me to select a group of objects and do something to them.

              1 條回覆 最後回覆 回覆 引用 0
              • S 離線
                slbaumgartner
                最後由 編輯

                Something like this? SLBTest::all_but_solids clears the selection and then adds everything except solids to it. I assumed you wanted attention to the non-solids to fix or eliminate them, but if you want to select the solids the logic could easily be reversed by replacing "unless" with "if".

                
                require "sketchup.rb"
                
                module SLBTest
                  def self.all_but_solids
                    sel = Sketchup.active_model.selection
                    sel.clear
                    Sketchup.active_model.entities.each {|ent|
                      unless ((ent.instance_of?(Sketchup;;Group) || ent.instance_of?(Sketchup;;ComponentInstance)) && ent.manifold?)
                        sel.add ent
                      end
                    }
                  end
                end
                
                
                1 條回覆 最後回覆 回覆 引用 0
                • TIGT 離線
                  TIG Moderator
                  最後由 編輯

                  Here's a one-liner... Copy+Paste in the Ruby Console + <enter>
                  This highlights all solids in the selection.

                  s=Sketchup.active_model.selection;a=s.to_a;s.clear;s.add(a.grep(Sketchup;;ComponentInstance)+a.grep(Sketchup;;Group).select{|i|i.manifold?})
                  

                  This highlights all solids in the active_entities context.

                  m=Sketchup.active_model;s=m.selection;s.clear;s.add(m.active_entities.grep(Sketchup;;ComponentInstance)+a.grep(Sketchup;;Group).select{|i|i.manifold?})
                  

                  TIG

                  1 條回覆 最後回覆 回覆 引用 0
                  • K 離線
                    KrisM
                    最後由 編輯

                    slbaumgartner & TIG,

                    Thanks for your help. A few problems.

                    My procedure -
                    Select all entities (84 entities total, 7 non solid components, 1 line, rest are solid groups and components.
                    Run script.

                    slbaumgartner - I get an error message

                    Error: <main>:9: syntax error, unexpected keyword_end, expecting '}'
                          end ^
                    SketchUp:1:in `eval'

                    TIG -

                    First script - Get 83 Components/Groups in Entity Info box, the 1 line is deselectd, the 7 non solids are still selected.

                    2nd script - Get 84 Components/Groups in Entity Info box, which is weird since the 1 line looks like it is deselectd, the 7 non solids are still selected.


                    Solid Test1.zip

                    1 條回覆 最後回覆 回覆 引用 0
                    • S 離線
                      slbaumgartner
                      最後由 編輯

                      That sounds like a cut-and-paste error, as the code worked without that error on my system. The attached Ruby has that method and also the inverse one that selects all solids.


                      all_but_solids.rb

                      1 條回覆 最後回覆 回覆 引用 0
                      • K 離線
                        KrisM
                        最後由 編輯

                        Feeling kind of dumb here. Put the ruby in the plugin folder but cannot for the life of me find where to use it from?

                        1 條回覆 最後回覆 回覆 引用 0
                        • K 離線
                          KrisM
                          最後由 編輯

                          Also tried opening the ruby in Notepad and Notepad++, copying and pasting into the Ruby console. Nothing happens. I am obviously missing something.

                          1 條回覆 最後回覆 回覆 引用 0
                          • J 離線
                            Jim
                            最後由 編輯

                            I found myself frequently turning to the Ruby Console for making anything more than simple selections.

                            So I made a sel command, and now in the Ruby Console I can type things like:

                            sel ;all
                            sel ;edges
                            sel ;faces
                            sel ;groups
                            sel 0 [or ;none or ;clear] 
                            sel ;cons
                            sel ;invert
                            
                            

                            etc.

                            Quite efficient. It's too hackish to share at the moment. I'll try to remember to fix it up and post it.

                            Hi

                            1 條回覆 最後回覆 回覆 引用 0
                            • S 離線
                              slbaumgartner
                              最後由 編輯

                              @krism said:

                              Feeling kind of dumb here. Put the ruby in the plugin folder but cannot for the life of me find where to use it from?

                              It was a quick hack, not really a plugin. If you put it into the plugins folder, try opening the Ruby Console and typing SLBTest::all_but_solids or SLBTest::only_solids.

                              1 條回覆 最後回覆 回覆 引用 0
                              • K 離線
                                KrisM
                                最後由 編輯

                                Great. Works like a charm. Thanks very much.

                                1 條回覆 最後回覆 回覆 引用 0
                                • E 離線
                                  Einstein
                                  最後由 編輯

                                  @tig said:

                                  Here's a one-liner... Copy+Paste in the Ruby Console + <enter>
                                  This highlights all solids in the selection.

                                  s=Sketchup.active_model.selection;a=s.to_a;s.clear;s.add(a.grep(Sketchup;;ComponentInstance)+a.grep(Sketchup;;Group).select{|i|i.manifold?})
                                  

                                  This highlights all solids in the active_entities context.

                                  m=Sketchup.active_model;s=m.selection;s.clear;s.add(m.active_entities.grep(Sketchup;;ComponentInstance)+a.grep(Sketchup;;Group).select{|i|i.manifold?})
                                  

                                  Hello, TIG,
                                  I know this thread is old, but the problem hasn't been completely solved.
                                  Thank you for the script you provided. It works well with groups, but doesn't take components into account. When I run it on a selection, it will filter solids among groups, but not components. All preselected components will stay selected, no matter whether they're solid or not.
                                  Tested on SketchUp 2021.
                                  I would love to have a plugin that would consider both groups and components and could be launched from Extensions menu. Do you think you could do that?

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • TIGT 離線
                                    TIG Moderator
                                    最後由 編輯

                                    The simple code snippets should select any component_instances AND groups which are solids...
                                    Please post an example of how it doesn't work...

                                    TIG

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • E 離線
                                      Einstein
                                      最後由 編輯

                                      I have prepared an example model with:
                                      1 solid group
                                      1 non-solid group
                                      1 solid component
                                      1 non-solid component

                                      In this model your second script selected both components, regardless of their solid state, leaving both groups unselected.
                                      Your first script has removed the non-solid group from selection (I preselected all entities), but didn't filter components at all.
                                      So none of the scripts worked 100% as expected.


                                      solid entity selection - example.skp

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • TIGT 離線
                                        TIG Moderator
                                        最後由 編輯

                                        There was a typo in my code - to select all solids in the active entities context use this fixed version...

                                        m=Sketchup.active_model;s=m.selection;s.clear;a=m.active_entities;s.add(a.grep(Sketchup;;ComponentInstance)+a.grep(Sketchup;;Group).select{|i|i.manifold?})
                                        

                                        The other one, to select only solid components/groups in a selection, works OK...

                                        TIG

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • E 離線
                                          Einstein
                                          最後由 編輯

                                          That's strange.
                                          In my case, your new code still only filters groups. No components are affected.
                                          Do you think that some plugin could interfere with it?

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • E 離線
                                            Einstein
                                            最後由 編輯

                                            I also tested it in SU 2020, where I only have a few basic plugins enabled.
                                            I get the same wrong outcome.

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement