sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] Boolean helper update 08122011

    Scheduled Pinned Locked Moved Plugins
    77 Posts 15 Posters 38.2k Views 15 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.
    • liquid98L Offline
      liquid98
      last edited by liquid98

      This is my modest contribution to the community:

      Booleanhelper

      The Boooleanhelper plug-in lets you quickly scale up and down your model.
      This is especially useful for those people who use Sketchup for 3d printing.
      Performing boolean operations or lathe operations on small models (mm size) is problematic in Sketchup, because Sketchup doesn't handle small faces very well.
      By scaling up the model these problems disappear. After all operations are done
      you can scale down your model to its original dimensions.
      Also useful to close small holes in your model.

      Your opinions and suggestions are welcome!

      Features:

      • Visual feedback on scale-factor.
      • Scale down at once.
      • It is possible to save your work, and scale down later. (feedback not yet provided)
      • Auto zoom extents.

      Installation:
      Open the zipfile and copy booleanhelper.rb and the folder called Booleanhelper into the SU plugins directory.

      Have fun!!

      If you have problems with unsolicited messageboxes, please download the latest version below:


      Boolean helper 08152011

      Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

      1 Reply Last reply Reply Quote 0
      • D Offline
        dedmin
        last edited by

        Thanks,
        Nice idea!
        Some suggestions - add option to scale the whole scene and to zoom extents after each scale.

        1 Reply Last reply Reply Quote 0
        • Dave RD Offline
          Dave R
          last edited by

          Interesting. How does this differ from using the Scale tool or the Tape Measure tool to resize the model or a component/group?

          Etaoin Shrdlu

          %

          (THERE'S NO PLACE LIKE)

          G28 X0.0 Y0.0 Z0.0

          M30

          %

          1 Reply Last reply Reply Quote 0
          • liquid98L Offline
            liquid98
            last edited by

            @dave r said:

            Interesting. How does this differ from using the Scale tool or the Tape Measure tool to resize the model or a component/group?

            Well this goes faster, and you don't have to remember the scale factor.
            The difference is that you don't have to select a grip point on the scaling-box,
            enter a value and press enter. And the other way round..
            If you have to that 20 times a day, you'll look for something faster!

            Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

            1 Reply Last reply Reply Quote 0
            • Dave RD Offline
              Dave R
              last edited by

              I see. Cool.

              I usually use the Tape Measure tool but maybe I'll give this a try. Thanks.

              Etaoin Shrdlu

              %

              (THERE'S NO PLACE LIKE)

              G28 X0.0 Y0.0 Z0.0

              M30

              %

              1 Reply Last reply Reply Quote 0
              • kenK Offline
                ken
                last edited by

                Well I like this plugin because I do scale up and down. However, I think 1000 is a little to much for me, so I set it to 10. 3 10's and you are at 1000. However, I did note that the scaling moves the center of the selection. It would be nice if the scaling kept the selection centered at the same location.

                So thanks for the plugin.

                Ken

                Fight like your the third monkey on Noah's Ark gangway.

                1 Reply Last reply Reply Quote 0
                • Dave RD Offline
                  Dave R
                  last edited by

                  Since I only work with components, I leverage the fact that working on a scaled up copy of the component edits the correctly sized copies too. When I need to do something that might generate the tiny faces SketchUp doesn't like, I make a copy of the component, Scale it up with the Scale tool or the Tape Measure, do my work on it and, when the editing has been completed, I close the large version of the component and delete it. No need to scale back down nor worry about where it'll end up when it is scaled back down. I never have to put components back that way because they've never been removed. It works well for things that need to be edited but don't require scaling, too. I happen to be working on one right now as a matter of fact. Of course this method doesn't help those who prefer to make groups instead. This plugin could be handy for them.


                  scaled.png


                  scaled2.png

                  Etaoin Shrdlu

                  %

                  (THERE'S NO PLACE LIKE)

                  G28 X0.0 Y0.0 Z0.0

                  M30

                  %

                  1 Reply Last reply Reply Quote 0
                  • HumpmetwiceH Offline
                    Humpmetwice
                    last edited by

                    @dave r said:

                    Since I only work with components, I leverage the fact that working on a scaled up copy of the component edits the correctly sized copies too. When I need to do something that might generate the tiny faces SketchUp doesn't like, I make a copy of the component, Scale it up with the Scale tool or the Tape Measure, do my work on it and, when the editing has been completed, I close the large version of the component and delete it. No need to scale back down nor worry about where it'll end up when it is scaled back down. I never have to put components back that way because they've never been removed. It works well for things that need to be edited but don't require scaling, too. I happen to be working on one right now as a matter of fact. Of course this method doesn't help those who prefer to make groups instead. This plugin could be handy for them.

                    Learn something new here everyday, thats cool Dave because I didn't know you could do that. I thought if you copied the component and scaled it the other one would scale as well. To be honest I don't think I've ever tried it because of thinking that way but knowing this now it will save alot of time. Thanks!

                    1 Reply Last reply Reply Quote 0
                    • Dave RD Offline
                      Dave R
                      last edited by

                      If you open the component before scaling, you'll scale all of them. If you don't open it, you only scale the one you're working on.

                      Etaoin Shrdlu

                      %

                      (THERE'S NO PLACE LIKE)

                      G28 X0.0 Y0.0 Z0.0

                      M30

                      %

                      1 Reply Last reply Reply Quote 0
                      • liquid98L Offline
                        liquid98
                        last edited by

                        @unknownuser said:

                        Well I like this plugin because I do scale up and down. However, I think 1000 is a little to much for me, so I set it to 10. 3 10's and you are at 1000. However, I did note that the scaling moves the center of the selection. It would be nice if the scaling kept the selection centered at the same location.

                        So thanks for the plugin.

                        Ken

                        Hi ken,

                        I see what you mean, I have to do some more research on ruby to fix the center problem.
                        User input for scale-factor: same thing.

                        Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                        1 Reply Last reply Reply Quote 0
                        • liquid98L Offline
                          liquid98
                          last edited by

                          @dedmin said:

                          Thanks,
                          Nice idea!
                          Some suggestions - add option to scale the whole scene and to zoom extents after each scale.

                          Hi dedmin,

                          I tested the script with auto zoom extents after scale, but the problem is that there
                          is no visual-feedback on the scaling action, you just see the same scaled object.

                          Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                          1 Reply Last reply Reply Quote 0
                          • liquid98L Offline
                            liquid98
                            last edited by

                            @unknownuser said:

                            Well I like this plugin because I do scale up and down. However, I think 1000 is a little to much for me, so I set it to 10. 3 10's and you are at 1000. However, I did note that the scaling moves the center of the selection. It would be nice if the scaling kept the selection centered at the same location.

                            So thanks for the plugin.

                            Ken

                            Hi ken,

                            I see what you mean, I have to do some more research on ruby to fix the center problem.
                            User input for scale-factor: same thing.[/quote]

                            Thanx for your input

                            Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                              Liquid98
                              Using
                              Geom::Transformation.scaling nnnnn
                              scales everything by nnnnn, probably using its 'bounds.min'
                              To do the scaling about the ORIGIN - which won't vary and therefore won't move stuff unexpectedly you should use
                              Geom::Transformation.scaling(ORIGIN, nnnnn)
                              πŸ€“

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • liquid98L Offline
                                liquid98
                                last edited by

                                @tig said:

                                Liquid98
                                Using
                                Geom::Transformation.scaling nnnnn
                                scales everything by nnnnn, probably using its 'bounds.min'
                                To do the scaling about the ORIGIN - which won't vary and therefore won't move stuff unexpectedly you should use
                                Geom::Transformation.scaling(ORIGIN, nnnnn)
                                πŸ€“

                                TIG, thanks for the suggestions, I am fully aware of the fact that
                                Geom::Transformation.scaling(ORIGIN, nnnnn) will scale
                                scale everything by nnnnn. With nnnnn as a variable.

                                But the problem is that i like 1000 while other people prefer 10, and I don't want to
                                work with a dialog box for user input because than you have to make that choice every time
                                you use script.
                                So the best case would be that the user sets the scale factor to what he likes and than the script has to remember the scale factor after sketchup is shut down.

                                Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                                  The reason I used 'nnnnn' wasn't because I was suggesting you used a variable... I was showing how to 'anchor' your scaling to the ORIGIN... and because two versions of the scaling transformation are used I didn't want to illustrate one of them in preference to the other!
                                  What you could do is set a 'global value' [$] outside of the script code parts, at the beginning; then users can easily find and edit that one part in the script if they want say x 100 instead of 1000
                                  e.g. $liquidsscalefactor=1000
                                  Then in your 'scale up' part you have
                                  Geom::Transformation.scaling(ORIGIN, $liquidsscalefactor)
                                  and in your 'scale down' part you have
                                  Geom::Transformation.scaling(ORIGIN, 1.0/$liquidsscalefactor)

                                  note the 1.0 to force a float if the $ value is an integer

                                  You could change the menus too...
                                  e.g. UI::Command.new("Scale factor "+$liquidsscalefactor.to_s){Bhelper::Groter.new()} to show the current value set...

                                  An alternative to the global $ variable is to use Sketchup.read_default('liquidsscalefactor','value') and Sketchup.write_default('liquidsscalefactor','value',nnnnn) to get/set a value with Sketchup that is always used - here replaced by 'nnnnn' in the 'write' part.
                                  You have a test that says if it's not set [first run] it's 'written' to be '1000'.
                                  Else it's set to what is 'read'; with .to_f to convert it from a string to a float value.
                                  You also add an extra item to your menu 'Set scale factor' - this opens a simple dialog and lets the user enter a value like '100' [as a string] - it's written to Sketchup as shown above and re-read back [with .to_f] when you use either of the other two options, to scale up/down... The value that we get from Sketchup.read_default() is remembered across sessions and common in all SKPs until the user resets its value...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • liquid98L Offline
                                    liquid98
                                    last edited by

                                    Hi TIG, I did some experiments today,

                                    I understand what you mean about the transformation. Using 1.0/nnnn and nnnn is just more convenient..

                                    Setting a global variable was easy. And worked right away. But I also read some wiki that said : "avoid global variables!! ". Is that why you give it ($liquidsscalefactor)such a long name?

                                    Getting a variable from input: also easy.

                                    But to get my variable lsf in to the two classes Kleiner
                                    and Groter, is something I don't understand.
                                    My input method is like this:

                                    ` class Getinfo

                                    def initialize() 
                                    
                                    	prompts = ["Enter scalefactor   "]
                                    	values = [1000]
                                    	
                                    	results = UI.inputbox prompts, values, "Scalefactor."
                                    	return if not results
                                    	@lsf, = results
                                    	
                                    	UI.messagebox @lsf.class
                                    

                                    end

                                    end`

                                    @lsf in Getinfo is a Fixnum class, is that alright?
                                    But in my two classes @lsf is NilClass (empty)

                                    I tried also $lsf and @@lsf.

                                    Any help???

                                    I attached the file I'm working on..

                                    PS:TIG, Realy cool you put all that effort in helping people with ruby and Sketchup! I'm sure lots of people can learn from your posts!


                                    booleanhelper_unf.rb

                                    Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                                      For a @@ variable to be accessible it has to be within the same 'class' - you have set three separate classes so @@ won't work between them - you need a $ global version...

                                      Because it's a global variable I suggested a 'long name' that's highly likely to be used by anyone else and cause unexpected conflicts...

                                      To make a variable that's remembered during that Sketchup session across the classes, you set it in the module using the '$' type... E.G.
                                      $liquidsscalefactor=1000.0
                                      written within the 'module' BUT outside the class/def's, I.E. as you have done, BUT you need to remove the '#'
                                      Note also how I've set it as a 'float' rather than an 'integer' by adding '.0' to the end - it's safer when doing division etc as 1/100 >>> 0 but 1/100.0 >>> 0.01 πŸ˜•
                                      This sets the value of the scaling for that Sketchup session and it is remembered across uses of the three tools.
                                      You then need to change the dialog part to [re]set it thus...
                                      values = [$liquidsscalefactor]
                                      and then later...
                                      $liquidsscalefactor, = results
                                      OR alternatively you could write it as...
                                      $liquidsscalefactor = results[0]

                                      Whenever you open Sketchup it starts at 1000, but any new value is remembered thereafter.
                                      The 1000 value is reverted after a close and reopen of Sketchup.
                                      You CAN save the value permanently so that it is always remembered between sessions using Sketchup.write_default/read_default etc... but that's for another day once you get this method working πŸ˜’

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • liquid98L Offline
                                        liquid98
                                        last edited by

                                        Hi TIG,

                                        implemented the global variable, works great!

                                        I see: the @@variable is only valid within a class right?

                                        Questions

                                        Is results[0] an element of an array? Are all these results of the inputbox stored during the session?

                                        $booleanhelperscalefactor, = results , if I omit the , $booleanhelperscalefactor becomes an array, why?

                                        To give extra info about the scale-factor I adapted the code like this:

                                        cmd = UI::Command.new("Scale factor "+$booleanhelperscalefactor.to_s) {Bhelper::Groter.new() } cmd.small_icon = File.join(imgdir, "bigger.png") cmd.large_icon = File.join(imgdir, "biggerL.png") cmd.tooltip = ("Scale factor "+$booleanhelperscalefactor.to_s) cmd.menu_text = ("Scale factor "+$booleanhelperscalefactor.to_s)

                                        The text sticks to the initial value of $booleanhelperscalefactor, when i change the scalefactor in sketchup the tooltip and menu-tekst won't change.

                                        Thnx for your help.

                                        By the way, I found the Automatic_SketchUp pdf document, a good resource!

                                        Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                                          'results' IS returned as an array - that's why πŸ˜’
                                          you can get the contents of an array in several ways
                                          array=[0,1,2,3]
                                          a,b,c,d = array
                                          a

                                          0
                                          b
                                          1
                                          etc
                                          OR as
                                          a=array[0]
                                          a
                                          0
                                          IF you have a ONE element array like yours
                                          xxx = results[0]
                                          is exactly the same as
                                          xxx, = results
                                          as xxx is set the the first [0] element in both cases...

                                          The cmd tooltip is set at the moment the the cmd is defined - so it shows the then current scalefactor.
                                          When you change the scale factor you don't change the then defined details.
                                          You COULD set the cmd as a $ variable so you know its 'handle' - use an unusual reference - say $cmdbooleanhelperscalefactor - When you change the scalefactor in the dialog also add a lie saying
                                          $cmdbooleanhelperscalefactor.tooltip = ("Scale factor "+$booleanhelperscalefactor.to_s)
                                          Not sure it'll work BUT you can see how it might be construed......

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • liquid98L Offline
                                            liquid98
                                            last edited by

                                            Hi TIG!

                                            I learned a lot today; and

                                            I got it all working!!!! 😍

                                            Thanx a lot for your help!

                                            I have two final questions though:

                                            (1)
                                            sfa = Sketchup.read_default('liquidsscalefactor','value') sff = sfa[0].to_f . . . trans = Geom::Transformation.scaling(ORIGIN, 1.0/sff)

                                            Is there a more elegant solution to convert sfa to a floating value?

                                            (2)
                                            And I don't understand why sftt is not updating when the scalefactor (sfa) is set??
                                            sfa = Sketchup.read_default('liquidsscalefactor','value') sftt = sfa[0].to_f . . . cmd.menu_text = ("Scale down with factor #{sftt}")

                                            Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                                            Advertisement