sketchucation logo sketchucation
    • Login
    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!
    ๐Ÿ›ฃ๏ธ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [Plugin] Components to Grid

    Scheduled Pinned Locked Moved Plugins
    22 Posts 7 Posters 23.5k 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.
    • CadFatherC Offline
      CadFather
      last edited by

      Hi TIG - is it possible to have all the components placed along the red axis? i tried modifying the script but i always get the components on top of each other.. ๐Ÿ˜’

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

        This [simpler] version spaces the component-instances 2m apart along the red/x axis [no stacking into a 'square']

        require 'sketchup.rb'
        module CADfather
              unless file_loaded?(File.basename(__FILE__))
                UI.menu('Tools').add_item('Components to Grid'){self.compogrid()}
              end
              file_loaded(File.basename(__FILE__))
              def self.compogrid()
                m=Sketchup.active_model;m.start_operation("ALL!"); ds=m.definitions; ns=[]; ds.to_a.find_all{|d|next if d.group?||d.image?; ns<<d.name}; ns.sort!; l=m.layers.add("ALL!");puts"\nLaying out ALL Components...\n\n"; es=m.active_entities; p=Geom;;Point3d.new(0,0,0); x=2.m; ns.length.times{|i|puts ns[i]; tr=Geom;;Transformation.new(p); n=es.add_instance(ds[ns[i]],tr);n.layer=l; p.x+=x};puts"\nDone.";m.commit_operation
              end #def
        end #module
        

        If the Ruby Console is open it reports what it's doing...
        Change the x=2.m for a different spacing in red/x if desired...

        TIG

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

          Thanks TIG - much appreciated - i'll try integrating it into the grid plugin.. ๐Ÿ‘ ๐Ÿ˜„

          1 Reply Last reply Reply Quote 0
          • gullfoG Offline
            gullfo
            last edited by

            TIG script examples - an interesting side effect - if you have a component made of other components it pulls it apart and distributes them... in this example i have a DC component of an acoustic window which has frames and seals as sub-components. in a way, this could be handy for creating a "how to assemble" guide because it pulls it apart in order of nesting...

            otoh this may not be a desired effect for the script in the end...


            Untitled.jpg

            Glenn

            http://www.runnel.com

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

              The OP asked for all components to be displayed on a grid.
              The code is very adaptable.
              It ignores Groups and Images although it could as easily display those as well, or instead.
              This version displays just components that have instances that are either in the model's entities or inside a non-component-entities context [i.e. inside a group that is not itself inside a component definition]

              require 'sketchup.rb'
                  module CADfather
                        unless file_loaded?(File.basename(__FILE__))
                          UI.menu('Tools').add_item('Components to Grid'){self.compogrid_used()}
                        end
                        file_loaded(File.basename(__FILE__))
                        def self.compogrid_used()
                          m=Sketchup.active_model
                          m.start_operation("ALL!")
                          ds=m.definitions
                          ns=[]
                          def self.recurse_parent(c)
                            begin
                              return c.parent
                            rescue
                              return nil
                            end
                          end
                          ds.to_a.find_all{|d|
                            next unless d.instances[0]
                            next if d.group?
                            next if d.image?
                            skip=true
                            d.instances.each{|i|
                              if i.parent==m
                                skip=false
                                break
                              elsif i.parent.group?
                                i.parent.instances.each{|g|
                                  c=g
                                  while c 
                                    c=self.recurse_parent(c)
                                    if m==c
                                      skip=false
                                      c=nil
                                      break
                                    end
                                  end
                                }
                              end
                            }
                            next if skip
                            ns<<d.name
                          }
                          ns.sort!;
                          l=m.layers.add("ALL!")
                          puts"\nLaying out ALL Components...\n\n"
                          es=m.active_entities
                          p=Geom;;Point3d.new(0,0,0);
                          x=2.m
                          ns.length.times{|i|
                            puts ns[i]
                            tr=Geom;;Transformation.new(p)
                            n=es.add_instance(ds[ns[i]],tr)
                            n.layer=l
                            p.x+=x}
                          puts"\nDone."
                          m.commit_operation
                        end #def
                  end #module
              

              TIG

              1 Reply Last reply Reply Quote 0
              • A Offline
                Amazing Artist
                last edited by

                TIG Thanks

                [color=#FF40FF:20ov4k9m]T[/color:20ov4k9m][color=#FF40F9:20ov4k9m]h[/color:20ov4k9m][color=#FF40F2:20ov4k9m]a[/color:20ov4k9m][color=#FF40EC:20ov4k9m]t[/color:20ov4k9m][color=#FF40E5:20ov4k9m]'[/color:20ov4k9m][color=#FF40DF:20ov4k9m]s[/color:20ov4k9m] [color=#FF40D2:20ov4k9m]m[/color:20ov4k9m][color=#FF40CC:20ov4k9m]y[/color:20ov4k9m] [color=#FF40BF:20ov4k9m]s[/color:20ov4k9m][color=#F940B9:20ov4k9m]t[/color:20ov4k9m][color=#F240B2:20ov4k9m]o[/color:20ov4k9m][color=#EC40AC:20ov4k9m]r[/color:20ov4k9m][color=#E540A6:20ov4k9m]y[/color:20ov4k9m][color=#DF40A0:20ov4k9m],[/color:20ov4k9m] [color=#D24093:20ov4k9m]a[/color:20ov4k9m][color=#CC408D:20ov4k9m]n[/color:20ov4k9m][color=#C54086:20ov4k9m]d[/color:20ov4k9m] [color=#C53A7A:20ov4k9m]I[/color:20ov4k9m][color=#CC3373:20ov4k9m]'[/color:20ov4k9m][color=#D22D6D:20ov4k9m]m[/color:20ov4k9m] [color=#DF2060:20ov4k9m]s[/color:20ov4k9m][color=#E51A5A:20ov4k9m]t[/color:20ov4k9m][color=#EC1353:20ov4k9m]i[/color:20ov4k9m][color=#F20D4D:20ov4k9m]c[/color:20ov4k9m][color=#F90646:20ov4k9m]k[/color:20ov4k9m][color=#FF0040:20ov4k9m]i[/color:20ov4k9m][color=#F9004D:20ov4k9m]n[/color:20ov4k9m][color=#F20059:20ov4k9m]g[/color:20ov4k9m] [color=#E50073:20ov4k9m]t[/color:20ov4k9m][color=#DF0080:20ov4k9m]o[/color:20ov4k9m] [color=#D20099:20ov4k9m]i[/color:20ov4k9m][color=#CC00A6:20ov4k9m]t[/color:20ov4k9m][color=#C500B2:20ov4k9m]![/color:20ov4k9m]

                1 Reply Last reply Reply Quote 0
                • pilouP Offline
                  pilou
                  last edited by

                  For SU 2017 Make
                  Incompatible with LightUP! ๐Ÿ˜ฎ
                  Curiously icons of LightUp apear!

                  bizarrerie.jpg

                  And LightUp Disconnected
                  don't take a selection but all components on the scene! ๐Ÿ˜ฎ

                  Here must be display only "XTE" Selected : that is not the case! ๐Ÿ˜‰
                  All is recalled! (even the top view text who is not visible at the Plugin call! )

                  biz4.jpg

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

                  1 Reply Last reply Reply Quote 0
                  • jujuJ Offline
                    juju
                    last edited by

                    @pilou said:

                    For SU 2017 Make
                    Incompatible with LightUP! ๐Ÿ˜ฎ
                    Curiously icons of LightUp apear!

                    [attachment=1:2yvqwupx]<!-- ia1 -->bizarrerie.jpg<!-- ia1 -->[/attachment:2yvqwupx]

                    And LightUp Disconnected
                    don't take a selection but all components on the scene! ๐Ÿ˜ฎ

                    Here must be display only "XTE" Selected : that is not the case! ๐Ÿ˜‰
                    All is recalled! (even the top view text who is not visible at the Plugin call! )

                    [attachment=0:2yvqwupx]<!-- ia0 -->biz4.jpg<!-- ia0 -->[/attachment:2yvqwupx]

                    Pilou, are you OK? I don't see what this has to do with the thread above? Perhaps start your own thread or look for the thread this is supposed to be in?

                    Save the Earth, it's the only planet with chocolate.

                    1 Reply Last reply Reply Quote 0
                    • pilouP Offline
                      pilou
                      last edited by

                      ?
                      It's not the thread about Plugin "Components to Grid"?
                      What better place to report that it is not compatible (for me in any case) with Light UP ?
                      And it has curious behavior with the selection Components ? (for me in any case)

                      Out of that i just reinstall SketchUp and must verify if above is always true!
                      It will be my first Plugin to reload from a little thousand! ๐Ÿ˜„

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

                      1 Reply Last reply Reply Quote 0
                      • pilouP Offline
                        pilou
                        last edited by

                        Alas not better ! ๐Ÿ˜ข
                        My SketchUp is absolutly new! Only "Component on Grid" installed! ๐Ÿค“

                        So no conflict possible! (like Light Up above) ๐Ÿ˜‰

                        not_better.jpg

                        If i add new volumes : the same! that is making snowball ! All is redrawn! ๐Ÿ˜ฎ

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

                        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