sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Explode and regroup script?

    Scheduled Pinned Locked Moved Extensions & Applications Discussions
    extensions
    26 Posts 3 Posters 4.2k 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.
    • G Offline
      gregswk
      last edited by

      @sdmitch said:

      Why? Is there a point to this exercise?

      Hi! The reason is that I can't use "drop to terrain" plugins like DropGC and Raytracer. I select the groups and click the plugin but nothing happens.
      BUT if I explode and regroup them (one by one), everything works normally. I really dont know why...

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

        @pilou said:

        From your example you want explode these 2 groups above the terrain for make only one group ?
        (because they are pasted) ? For make a "unic solid" ? So for delete internal common faces?

        If yes or similar take a look at this post! ๐Ÿ˜‰
        More this one! (for coders)

        [attachment=0:1eoovfrz]<!-- ia0 -->unic_solid.jpg<!-- ia0 -->[/attachment:1eoovfrz]

        Hi! Actually I want to remain each group without mixing with others entities, because in my case they are all buildings (after ~exploding and regrouping each one of them~ I'll use the plugin DropGC).
        I dont know why: the way the groups are now dont let me use drop to terrain plugins. Do they have any definition or sth? If yes, is there a way to reset them?

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

          SmartDrop works for any terrain but maybe that is not that you want ? ๐Ÿค“ (Right Click on Selection)

          And sure that resovle not the little mystery! ๐Ÿ˜„

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

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

            In this special case (flat terrain) ๐Ÿ˜„
            If you Select All Groups / Right Click / Make Component : the Ray Tracer works!

            Then just explode one time and you have your original groups on the terrain!

            But sure your groups have a special state! ๐Ÿ˜ฒ
            A little mystery! ๐Ÿ˜ฎ

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

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

              @pilou said:

              In this special case (flat terrain) ๐Ÿ˜„
              If you Select All Groups / Right Click / Make Component : the Ray Tracer works!

              Then just explode one time and you have your original groups on the terrain!

              But sure your groups have a special state! ๐Ÿ˜ฒ
              A little mystery! ๐Ÿ˜ฎ

              My terrain isnt flat ๐Ÿ˜ข
              Yeah...Maybe a big mystery!
              Pleasee find out for me! ๐Ÿ’š

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

                Capture.PNG
                @pilou said:

                SmartDrop works for any terrain but maybe that is not that you want ? ๐Ÿค“ (Right Click on Selection)

                And sure that resovle not the little mystery! ๐Ÿ˜„

                So, I've done the landscape above importing all those buildings solids and doing the following steps:

                1. Transforming all groups as single components using "tt_groups2comps" plugin
                2. Transforming all components as single groups using "Make_Components" plugin
                  *BUT THIS PLUGIN DOESNT MAKE ALL SELECTED COMPONENTS AS SINGLE GROUPS AT ONCE. THE "MAKE COMPONENTS TO SINGLE GROUPS" SCRIPT ONLY TRANSFORM 1 COMPONENT TO GROUP AT A TIME. SO I'VE MADE A SHORTCUT FOR THAT FUNCTION AND I KEPT REPEATING PRESSING THE SHORTCUT KEY AND THE ENTER KEY, WHICH TOOK ME A LOT OF TIME... ๐Ÿ˜ 
                3. I used Raytracer to drop all groups to the terrain

                I really would like to make this process as quickly as possible... For my future projects. Any idea? ๐Ÿ˜„
                Thank you

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

                  @gregswk said:

                  @sdmitch said:

                  Why? Is there a point to this exercise?

                  Hi! The reason is that I can't use "drop to terrain" plugins like DropGC and Raytracer. I select the groups and click the plugin but nothing happens.
                  BUT if I explode and regroup them (one by one), everything works normally. I really dont know why...

                  I'm with you, I can't figure out why this is so. But, since these are buildings, you wouldn't want them to conform to the surface like Pilou's SmartDrop demo. So something as simple as

                  mod = Sketchup.active_model
                  sel = mod.selection
                  sel.grep(Sketchup;;Group){|g|
                   t=mod.raytest([g.bounds.min,[0,0,-1]])[0]
                   g.transform!(Geom;;Transformation.new(t-g.bounds.min)) if t
                  }
                  
                  

                  This works on your groups whether they are exploded and regrouped or not.

                  Select group(s), paste code into Ruby Console, press Enter.

                  Nothing is worthless, it can always be used as a bad example.

                  http://sdmitch.blogspot.com/

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

                    Sdmitch to the rescue! ๐Ÿ˜‰

                    But that resolve not the little mystery of the 2 groups states! ๐Ÿ˜„
                    What are special on them ?
                    How do you create that ?

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

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

                      @sdmitch said:

                      @gregswk said:

                      @sdmitch said:

                      Why? Is there a point to this exercise?

                      Hi! The reason is that I can't use "drop to terrain" plugins like DropGC and Raytracer. I select the groups and click the plugin but nothing happens.
                      BUT if I explode and regroup them (one by one), everything works normally. I really dont know why...

                      I'm with you, I can't figure out why this is so. But, since these are buildings, you wouldn't want them to conform to the surface like Pilou's SmartDrop demo. So something as simple as

                      mod = Sketchup.active_model
                      > sel = mod.selection
                      > sel.grep(Sketchup;;Group){|g|
                      >  t=mod.raytest([g.bounds.min,[0,0,-1]])[0]
                      >  g.transform!(Geom;;Transformation.new(t-g.bounds.min)) if t
                      > }
                      > 
                      

                      This works on your groups whether they are exploded and regrouped or not.

                      Select group(s), paste code into Ruby Console, press Enter.

                      Hi, Sdmitch!
                      Thaaaank you so muchh!! That's all what I needed!!
                      ๐Ÿ˜„ ๐Ÿ‘ ๐Ÿ‘

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

                        @pilou said:

                        Sdmitch to the rescue! ๐Ÿ˜‰

                        But that resolve not the little mystery of the 2 groups states! ๐Ÿ˜„
                        What are special on them ?
                        How do you create that ?

                        Hi, Pilou!
                        First of all, thank you so much for all support you are giving to me. ๐Ÿ˜„
                        Yes, the groups states remain. Mystery!
                        I've used Autocad Map 3d to generate those buildings with their proper heights attaching a shapefile. Before I export, I converted polygons to solids using -convtosolid command.
                        Then I saved as .dwg to export those buildings to Sketchup.

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

                          Even genious Sdmitch has find a solution for your problem ๐Ÿ‘
                          taka a look to these architect tools by Thomthom!

                          A suite of tools to help with imported DWG files aimed at Architecture
                          Maybe there there are some tricky things nside!

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

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

                            @pilou said:

                            But that resolve not the little mystery of the 2 groups states! ๐Ÿ˜„
                            What are special on them ?
                            How do you create that ?

                            My new project for the weekend!!!!!!!!

                            Nothing is worthless, it can always be used as a bad example.

                            http://sdmitch.blogspot.com/

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

                              I believe that the problem comes from the export DXF from external program! ๐Ÿ˜„
                              (double vertices ?...)

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

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

                                @pilou said:

                                I believe that the problem comes from the export DXF from external program! ๐Ÿ˜„
                                (double vertices ?...)

                                No the problem is that the transformation.origin is not over the "surface"
                                ` name = Group#445
                                origin = (-420.075838m, -663.573913m, 8.06m)
                                x axis = [1.0,0.0,0.0]
                                y axis = [0.0,1.0,0.0]
                                z axis = [0.0,0.0,1.0]
                                x,y,z = [-16538.41882347539,-26124.9572089176,317.32283464566945]

                                name = Group#468
                                origin = (-420.075838m, -663.573913m, 8.06m)
                                x axis = [1.0,0.0,0.0]
                                y axis = [0.0,1.0,0.0]
                                z axis = [0.0,0.0,1.0]
                                x,y,z = [-16538.41882347539,-26124.9572089176,317.32283464566945]` which is why the "Drop" fails. By exploding and regrouping the group, the transformation.orig is reset to bounds.min which is over the "surface".

                                Nothing is worthless, it can always be used as a bad example.

                                http://sdmitch.blogspot.com/

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

                                  @sdmitch said:

                                  @pilou said:

                                  I believe that the problem comes from the export DXF from external program! ๐Ÿ˜„
                                  (double vertices ?...)

                                  No the problem is that the transformation.origin is not over the "surface"
                                  ` name = Group#445
                                  origin = (-420.075838m, -663.573913m, 8.06m)
                                  x axis = [1.0,0.0,0.0]
                                  y axis = [0.0,1.0,0.0]
                                  z axis = [0.0,0.0,1.0]
                                  x,y,z = [-16538.41882347539,-26124.9572089176,317.32283464566945]

                                  name = Group#468
                                  origin = (-420.075838m, -663.573913m, 8.06m)
                                  x axis = [1.0,0.0,0.0]
                                  y axis = [0.0,1.0,0.0]
                                  z axis = [0.0,0.0,1.0]
                                  x,y,z = [-16538.41882347539,-26124.9572089176,317.32283464566945]` which is why the "Drop" fails. By exploding and regrouping the group, the transformation.orig is reset to bounds.min which is over the "surface".

                                  -So that means I need to explode and regroup to reset them? Or there is another way to change their transformation.orig to bounds? Sorry, I didnt understand very well..
                                  -I'm using your script to drop the groups down to terrain, but I'm having some problem... Many groups arent dropping well, they fly. ๐Ÿ˜•
                                  flying.JPG

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

                                    @gregswk said:

                                    -I'm using your script to drop the groups down to terrain, but I'm having some problem... Many groups arent dropping well, they fly. ๐Ÿ˜•
                                    [attachment=0:373faxky]<!-- ia0 -->flying.JPG<!-- ia0 -->[/attachment:373faxky]

                                    Could you post a sample of the one's that "fly".

                                    Nothing is worthless, it can always be used as a bad example.

                                    http://sdmitch.blogspot.com/

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

                                      @sdmitch said:

                                      @gregswk said:

                                      -I'm using your script to drop the groups down to terrain, but I'm having some problem... Many groups arent dropping well, they fly. ๐Ÿ˜•
                                      [attachment=1:2366zu5c]<!-- ia1 -->flying.JPG<!-- ia1 -->[/attachment:2366zu5c]

                                      Could you post a sample of the one's that "fly".


                                      badra 5 skp 8.skp

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

                                        The problem is some groups being dropped on "top" of others already moved to the surface.

                                        So to avoid that conflict, I have modified the previous code I posted.

                                        mod = Sketchup.active_model
                                        sel = mod.selection
                                        gat = []
                                        sel.grep(Sketchup;;Group){|g|
                                         o = [g.bounds.center.x,g.bounds.center.y,g.bounds.min.z]
                                         p = mod.raytest([o,[0,0,-1]])[0];
                                         gat<<[g,Geom;;Transformation.new(p-g.bounds.min)] if p
                                        }
                                        gat.each{|g| g[0].transform!(g[1])}
                                        
                                        

                                        badra 5 skp 8.skp

                                        Nothing is worthless, it can always be used as a bad example.

                                        http://sdmitch.blogspot.com/

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

                                          @sdmitch said:

                                          The problem is some groups being dropped on "top" of others already moved to the surface.

                                          So to avoid that conflict, I have modified the previous code I posted.

                                          mod = Sketchup.active_model
                                          > sel = mod.selection
                                          > gat = []
                                          > sel.grep(Sketchup;;Group){|g|
                                          >  o = [g.bounds.center.x,g.bounds.center.y,g.bounds.min.z]
                                          >  p = mod.raytest([o,[0,0,-1]])[0];
                                          >  gat<<[g,Geom;;Transformation.new(p-g.bounds.min)] if p
                                          > }
                                          > gat.each{|g| g[0].transform!(g[1])}
                                          > 
                                          

                                          Oh my God, thank you so much, sdmitch!!
                                          It is working perfectly!! ๐Ÿ˜„ ๐Ÿ‘ ๐Ÿ‘ ๐ŸŽ‰

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

                                            Always amazazed that few line can make! Bravo! ๐Ÿ˜Ž

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

                                            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