• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

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.
  • P Offline
    pilou
    last edited by 17 Sept 2016, 16:58

    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
    • S Offline
      sdmitch
      last edited by 17 Sept 2016, 18:02

      @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 18 Sept 2016, 14:23

        @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
        • S Offline
          sdmitch
          last edited by 18 Sept 2016, 16:56

          @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 18 Sept 2016, 19:51

            @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
            • S Offline
              sdmitch
              last edited by 18 Sept 2016, 21:34

              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 18 Sept 2016, 21:57

                @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
                • P Offline
                  pilou
                  last edited by 18 Sept 2016, 22:13

                  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
                  • G Offline
                    gregswk
                    last edited by 18 Sept 2016, 23:09

                    @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])}
                    > 
                    

                    I'm sorry, Sdmitch... There is still one problem.. πŸ˜•
                    Capture2.JPG
                    Capture3.JPG
                    The groups are moving by Z axis perfectly, but when it goes down to terrain, they are changing their X and Y positions. They are messing with each other.. πŸ˜•
                    Why is it happening?

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdmitch
                      last edited by 19 Sept 2016, 01:08

                      @gregswk said:

                      @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-o)] if p
                      > > }
                      > > gat.each{|g| g[0].transform!(g[1])}
                      > > 
                      

                      I'm sorry, Sdmitch... There is still one problem.. πŸ˜•
                      [attachment=2:kcc5danh]<!-- ia2 -->Capture2.JPG<!-- ia2 -->[/attachment:kcc5danh]
                      [attachment=1:kcc5danh]<!-- ia1 -->Capture3.JPG<!-- ia1 -->[/attachment:kcc5danh]
                      The groups are moving by Z axis perfectly, but when it goes down to terrain, they are changing their X and Y positions. They are messing with each other.. πŸ˜•
                      Why is it happening?

                      Oops. My bad. I forgot to change the "origin" in the transformation. Code has been fixed.


                      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 19 Sept 2016, 02:59

                        @sdmitch said:

                        Oops. My bad. I forgot to change the "origin" in the transformation. Code has been fixed.

                        Wonderful, Sdmitch!
                        Now it is perfect!!! πŸŽ‰ πŸŽ‰
                        Thank you so much!!! πŸ˜„

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

                        Advertisement