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

    Move groups with different measures?

    Scheduled Pinned Locked Moved Developers' Forum
    55 Posts 4 Posters 28.7k Views 4 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.
    • pilouP Offline
      pilou
      last edited by

      Before testing your new randomizer plug ๐Ÿ˜„

      I have a little problem ๐Ÿ˜„
      I have used "Grow" by Tig for make the "volume" on the left (50 groups), then my "Plug" Thomthomised ๐Ÿ˜’
      with a normal interval of course!
      Seems there is something wrong somewhere ๐Ÿ˜ฎ
      Groups are not recorded following the "grow" generation?


      humhum.jpg

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

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

        So i must use the Tig Advertissement more soon than I have expected ๐Ÿ’š

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

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

          This group.bounds.min.z. can be found somewhere or the sorting of Groups must be forged again?
          (nothing about sort, sorting in the API helping) ๐Ÿ˜ฎ

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

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Build a hash with the entities as the key and their Z posiiton as value and then sort the hash by the values.

            Thomas Thomassen โ€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

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

              Each groups has not a "time creation" trace board? So no need to remake a sorting ?
              Seems I have re-open a new nightmare door ๐Ÿ’š

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

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                Awesome Pilou! Keep it up, its looking great. You've got lots of good help around here.

                Chris

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

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

                  Try something like...

                  
                  zeds=[]
                  index=0
                  groups.each{|group|
                     zeds.push(group.bounds.min.z, index)
                     index+=1
                  }
                  zeds.sort!
                  sorted_groups=[]
                  zeds.each{|z|sorted_groups.push(groups[z[1]]) }
                  ### sorted_groups is now groups sorted by Z
                  
                  

                  TIG

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

                    Does the group.bounds.min.z only valuable in SU 7?
                    Edit seems not ๐Ÿ˜„

                    little try but seems I miss something ๐Ÿ˜„ (any doubt selection but the sorted_groups gives nothing on the screen)

                    model = Sketchup.active_model
                    entities = model.entities
                    selection = model.selection
                    groups = []
                    z=0
                    zeds=[]
                    index=0
                    groups.each{|group|
                       zeds.push(group.bounds.min.z, index)
                       index+=1
                    }
                    zeds.sort!
                    sorted_groups=[]
                    zeds.each{|z|sorted_groups.push(groups[z[1]]) }
                    ### sorted_groups is now groups sorted by Z
                    
                    sorted_groups.each do |e| 
                      point = Geom;;Point3d.new 0,0,z
                      t = Geom;;Transformation.new point
                      e.transform!(t)  
                      z =  z + 1000.mm
                    end
                    

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

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

                      it's like a snowball on the top of the mountain ๐Ÿ˜„

                      http://www.id2sorties.com/id2photos/5907205456neig.jpg

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

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

                        groups = [] then nothing set !!!
                        You emptied the groups array...
                        You need to fill it from the selection... ๐Ÿค“

                        groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)}
                        

                        TIG

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

                          another try found: undefined method โ€˜[]โ€™ ๐Ÿ˜•

                          model = Sketchup.active_model
                          entities = model.entities
                          selection = model.selection
                          
                          z=0
                          zeds=[]
                          index=0
                          sorted_groups=[]
                          
                          groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)}
                          
                          groups.each{|group|zeds.push(group.bounds.min.z, index)
                             index+=1
                          }
                          zeds.sort!
                          zeds.each{|z|sorted_groups.push(groups[z[1]]) }
                          ### sorted_groups is now groups sorted by 
                          
                          sorted_groups.each do |e| # update!
                            # Now we process the groups
                            point = Geom;;Point3d.new 0,0,z
                            t = Geom;;Transformation.new point
                            # Apply the transformation
                            e.transform!(t)
                            z = z + 100.cm
                          end
                          
                          

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

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            Is that the only error message you get?

                            @unknownuser said:

                            it's like a snowball on the top of the mountain ๐Ÿ˜„

                            You're hooked now! No way back! ๐Ÿ˜‰ ๐Ÿ˜„

                            Thomas Thomassen โ€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

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

                              Here's some tweaked code

                              def test()
                                  model = Sketchup.active_model
                                model.start_operation("Move in Z")
                                  entities = model.entities
                                  selection = model.selection
                              
                                  zeds=[]
                                  index=0
                                  sorted_groups=[]
                              
                                  groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)}
                              
                                  groups.each{|group|zeds.push([group.bounds.min.z, index])
                                     index+=1
                                  }
                                  zeds.sort!
                                  zeds.each{|z|sorted_groups.push(groups[z[1]]) }
                                  ### sorted_groups is now groups sorted by
                              
                                  z = 0.0
                                  sorted_groups.each do |e| # update!
                                    # Now we process the groups
                                    t = Geom;;Transformation.new(Geom;;Point3d.new(0,0,z))
                                    # Apply the transformation
                                    e.transform!(t)
                                    z = z + 100.cm
                                  end
                                  
                                model.commit_operation
                                return nil
                                
                              end#def
                              
                              

                              Runs as ' test'.
                              I made a typo - it needed an array [] of two items adding to zeds: zeds.push([group.bounds.min.z, index]) not two 'loose' items as in zeds.push(group.bounds.min.z, index).
                              I made your z = 0 into z = 0.0 as it needs the number as a float, not an integer...
                              Removed 'point' variable and set the point definition directly inside the transformation - not necessary but fewer variables...
                              I added a model.start_operation("")...model.commit_operation so it becomes a one step undo.
                              I added return nil at end so the Ruby-Console doesn't get clogged with info...

                              Tested it - it works...

                              TIG

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

                                Seems indeed that some corrections were necessary ๐Ÿ˜„
                                This time works like a charm! Excellent! TIG + Thomthom! Bravo! ๐Ÿ˜Ž
                                I will see all that more in detail for learn this little cryptic language ! โ˜€
                                Very funny plug! ๐Ÿ˜‰
                                For the next Pilou's foolish... ๐Ÿ’š
                                ...I need to know the "centroรฏd" (xyz) of a "bounding box's group"
                                Here of course without different measure, just for little test! ๐Ÿ˜„ (click image)


                                TIGTHOMPilou.jpg

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

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

                                  @unknownuser said:

                                  ...I need to know the "centroรฏd" (xyz) of a "bounding box's group"

                                  centre_point=group.bounds.center
                                  

                                  See http://code.google.com/apis/sketchup/docs/ for all these details ๐Ÿ˜‰

                                  TIG

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

                                    Thx I had missed this one ๐Ÿ˜‰

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

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      It'd help if you posted the error messages.

                                      However, I can still see the problem here. Sketchup::Component isn't an SU object. Check the manual, you have Sketchup::ComponentDefinition and Sketchup::ComponentInstance. In your case you're looking for a Sketchup::ComponentInstance.

                                      Thomas Thomassen โ€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

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

                                        I have replaced "Group" by "Component" but seems that is not so simple ๐Ÿ’š

                                        groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Component)}
                                        
                                            groups.each{|component|zeds.push([component.bounds.min.z, index])
                                        

                                        Else I can yet nest a component inside a group color transparent ๐Ÿ’š
                                        That works fine (just disable Edges visible) but I suppose there is another thing ๐Ÿ˜„


                                        compogroup.jpg

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

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

                                          @ Tig Some cryptic but I will see that ๐Ÿ˜‰
                                          Joint an image for no ambiguities
                                          So here the increment is 300 cm
                                          Edit sorry I have not seen all these speedy results! ๐Ÿ˜ณ

                                          @Thomthom! Yes that is that ! e.transform!(t) ๐Ÿ˜‰


                                          zzz.jpg

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

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

                                            Come back in these very dangerous territories ๐Ÿ’š

                                            As I understand that retrieve the center XYZ of the bounding box group by

                                             center = boundbox.center 
                                            

                                            but how give these 3 values(?) to these 3 variables ? ๐Ÿ˜’
                                            xc= ?
                                            yc= ?
                                            zc= ?
                                            must be trivial but yet some foggy for me ๐Ÿ˜„
                                            PS I read the API from the end to the start, and inverse but this stay mysterious found anything except that ๐Ÿ’š

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

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

                                            Advertisement