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!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    CPoints at Bounding Box corners?

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    15 Posts 3 Posters 639 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      If you read the code it gets the bounds of the selection and adds cpoints at the bounds corners - that's all you need to know πŸ˜•
      Select some geometry and copy/paste the code into the Ruby Console to see what it does...

      TIG

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

        Doesn't take into account groups / components that are not aligned to the model axis.

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

        1 Reply Last reply Reply Quote 0
        • Rich O BrienR Offline
          Rich O Brien Moderator
          last edited by

          @tig said:

          If you read the code it gets the bounds of the selection and adds cpoints at the bounds corners - that's all you need to know πŸ˜•
          Select some geometry and copy/paste the code into the Ruby Console to see what it does...

          I realise how to use it. It's was the trapping comment that had me puzzled.

          Thanks anyway. Both of ye πŸ‘

          Download the free D'oh Book for SketchUp πŸ“–

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

            It does... in that it returns the bounds of the selection, and NOT individual objects within the selection, and a selection's bounding-box is always parallel to the axes irrespective of the selected objects' transformation... πŸ˜•
            Rich didn't ask for cpoints at the corners of one selected object's bounds.
            I gave him cpoints at the corners of the selection's bounds - which might not be the same thing for rotated individual groups/instances...

            TIG

            1 Reply Last reply Reply Quote 0
            • Rich O BrienR Offline
              Rich O Brien Moderator
              last edited by

              Being able to select a series of groups and components then it places cpoints at all bounding boxes would be sweet.

              Download the free D'oh Book for SketchUp πŸ“–

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

                Try this

                m=Sketchup.active_model;m.start_operation("BBcpts");m.selection.each{|e|next unless e.class==Sketchup;;Group or e.class==Sketchup;;ComponentInstance;t=e.transformation;e=e.definition if e.class==Sketchup;;ComponentInstance;b=Geom;;BoundingBox.new;e.entities.each{|a|b.add(a.bounds)};8.times{|i|m.active_entities.add_cpoint(b.corner(i).transform(t))}};m.commit_operation
                

                adds cpoints at the 8 corners of each selected group/instance's bbox, accounting for transformations... One step undoable.

                TIG

                1 Reply Last reply Reply Quote 0
                • Rich O BrienR Offline
                  Rich O Brien Moderator
                  last edited by

                  Is getting these control point within the group/component possible?

                  It's anchors for alignment that I'm looking for. If it's too much hassle forget it.

                  On a layer would be kinda cool too πŸ˜•

                  Download the free D'oh Book for SketchUp πŸ“–

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

                    I originally has them inside each container but [foolishly] assumed you wanted them outside!

                    m=Sketchup.active_model;m.start_operation("BBcpts");m.selection.each{|e|next unless e.class==Sketchup;;Group or e.class==Sketchup;;ComponentInstance;e=e.definition if e.class==Sketchup;;ComponentInstance;b=Geom;;BoundingBox.new;e.entities.each{|a|b.add(a.bounds)};8.times{|i|e.entities.add_cpoint(b.corner(i)).layer=m.layers.add("BBCP")}};m.commit_operation
                    

                    This version puts the cpoints within each container and uses layer 'BBCP' for them.

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • Rich O BrienR Offline
                      Rich O Brien Moderator
                      last edited by

                      Can i put it in a class then a def and load it to plugins?

                      Or is it a module?

                      Actually forget it πŸ˜’

                      Download the free D'oh Book for SketchUp πŸ“–

                      1 Reply Last reply Reply Quote 0
                      • Rich O BrienR Offline
                        Rich O Brien Moderator
                        last edited by

                        Sorry, Thanks TIG πŸ‘

                        Download the free D'oh Book for SketchUp πŸ“–

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

                          module ROB
                          
                          menu=UI.menu("Plugins").add_item("BBcpts"){self.bbcpts()}unless file_loaded?(File.basename(__FILE__)) 
                          file_loaded(File.basename(__FILE__))
                           
                          def self.bbcpts()
                          ### paste the main code here...
                          end
                          
                          end
                          

                          Copy/paste the code into a file in the Plugins folder called ROB-bbcpts.rb
                          Usage: type ROB.bbcpts OR pick "BBcpts" off the Plugins menu etc...

                          TIG

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

                          Advertisement