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

      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
              • thomthomT Offline
                thomthom
                last edited by

                boundbox.center returns an object of type Point3d. You can check what an object is by checking the .class value of an object. That gives you an indication to where to look.

                
                xc= boundbox.center.x
                yc= boundbox.center.y
                zc= boundbox.center.z
                
                

                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

                  Many thx! โ˜€
                  It's always the more easy ans usefull who is not written as example ๐Ÿ˜’

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

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

                    ??? = error : in โ€˜initializeโ€™: undefined local variable or method โ€˜boundboxโ€™ ๐Ÿ˜ฎ

                    model = Sketchup.active_model
                    entities = model.entities
                    selection = model.selection
                    #groups = []
                    xp=100  # Pivot Point 
                    yp=100
                    zp=100
                    
                    xc=0  #Center Point of the grouped object
                    yc=0
                    zc=0
                    
                    xe=0  #End Point of the grouped object
                    ye=0
                    ye=0
                    
                    selection.each do |e| # update!
                      # Skip all entities that aren't groups
                      next unless e.is_a? Sketchup;;Group
                      # Now we process the groups
                    
                     center = boundbox.center 
                            xc= boundbox.center.x # ??? error
                    	yc= boundbox.center.y
                    	zc= boundbox.center.z
                    	
                    xe=xc
                    ye=yc
                    ze=zc
                    if xc<xp 
                    xe =xc - 100
                    end
                      if xc>xp 
                    xe =xc +100
                    end
                    
                    if yc<yp 
                    ye =yc - 100
                    end
                      if yc>yp 
                    ye =yc +100
                    end
                    
                    if zc<zp
                    ze =zc - 100
                    end
                      if zc>zp
                    ze =zc +100
                    end
                    
                      point = Geom;;Point3d.new xe,ye,ze
                      t = Geom;;Transformation.new point
                      # Apply the transformation
                      e.transform!(t)
                    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

                      That's because of center = boundbox.center <- you haven't referenced boundbox yet.

                      
                      center = boundbox.center
                              xc= boundbox.center.x # ??? error
                         yc= boundbox.center.y
                         zc= boundbox.center.z
                      
                      

                      change to

                      
                      center = e.bounds.center
                         xc= center.x
                         yc= center.y
                         zc= center.z
                      
                      

                      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

                        Thx! โ˜€
                        More easy with that ๐Ÿ˜„ Works like a charm ๐Ÿ˜Ž
                        I can now test some natures of explodes ๐Ÿ’š


                        explode.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

                          Funny thing ๐Ÿ˜„


                          explode.jpg

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

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

                            Looking good Pilou!
                            Instant assembly drawings! ๐Ÿ˜„ This should come in handy.

                            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

                              @unknownuser said:

                              Instant assembly

                              Alas for the inverse, that must be more tricky! ๐Ÿ˜•
                              Better is use the Undo ๐Ÿ’š

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

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

                                hm... You could store the relative position you move the entities by in and attribute dictionary. Then perform the opposite when you want to reassemble.

                                though, that will fail if the user moves anything...
                                Maybe, you could store the original absolute position before you move stuff. Then you can reassemble back to that original position. That would allow the user to move things around as they please.

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

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

                                  Store the original transformation in a dictionary attached to the group/component. Then to unexplode, just re-apply that transformation onto the group. It will go right back where it belongs.

                                  I wrote that crazy scrambler script a while ago that does this and it worked very well.

                                  Chris

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

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

                                    In theory that must be more easy ๐Ÿ˜‰
                                    Just select that you want and apply a "negative" translation : a deflation ๐Ÿ˜‰
                                    Maybe my next ๐Ÿ˜„
                                    And the above is not yet perfect! The Pivot Point seems not have the wished result wanted ๐Ÿ˜’
                                    be continued...

                                    Ps When Groups or Components are nested how to process automatically?
                                    A plug for make each components individual is maybe existing?
                                    Edit
                                    one exist for group by TIG Explode2groups

                                    miss now somethings transform Transform2goups or Explode2Components ๐Ÿ˜„

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

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

                                      @Chris Any chance to see it somewhere? ๐Ÿ˜„

                                      PS
                                      A plug for make each components individual is maybe existing?
                                      Edit
                                      one exist for group by TIG Explode2groups

                                      miss now somethings for components Transform2goups or Explode2Components

                                      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

                                        take the componentInstance, add it to a group, then explode the component instance.

                                        And I posted my scrambler script here. I'll see if I can find the thread.

                                        Chris

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

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

                                          @Chris thx for the Info โ˜€
                                          Fredo6 has inside the FredoScale something who transform any selection of groups or Components in "Unique" groups or componants! (each become individual)
                                          (last icon)

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

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

                                            Some tests ๐Ÿ’š Put the code inside the WebConsole by Jim Foltz
                                            Press "Eval" button and have fun ๐Ÿ˜„
                                            Veyron model is from 3Dwarehouse!

                                            model = Sketchup.active_model
                                            entities = model.entities
                                            selection = model.selection
                                            
                                            xp=100  # Pivot Point (as you want)
                                            yp=100
                                            zp=100
                                            
                                            q=50 # Measure of translation (as you want) 
                                            
                                            selection.each do |e| # update!
                                              # Skip all entities that aren't groups or components (replace follow "ComponentInstance" by "Group" if you have groups
                                              next unless e.is_a? Sketchup;;ComponentInstance  # Now we process the component or group
                                             center = e.bounds.center #Center Point of the grouped object
                                               xc= center.x
                                               yc= center.y
                                               zc= center.z
                                               
                                            xe=xc #End Point of the grouped object
                                            ye=yc
                                            ze=zc
                                            
                                            if xc<xp
                                             xe =xc - q
                                            end
                                            
                                            if xc>xp
                                             xe =xc + q
                                            end
                                            
                                            if yc<yp
                                             ye =yc - q
                                            end
                                            
                                            if yc>yp
                                             ye =yc + q
                                            end
                                            
                                            if zc<zp
                                             ze =zc - q
                                            end
                                            
                                            if zc>zp
                                             ze =zc + q
                                            end
                                            
                                              point = Geom;;Point3d.new xe,ye,ze
                                              t = Geom;;Transformation.new point
                                              # Apply the transformation
                                              e.transform!(t)
                                            end
                                            

                                            veyron.jpg

                                            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