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.
    • 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
                            • TIGT Offline
                              TIG Moderator
                              last edited by

                              Little more elegant way...
                              I would add the optional third part to the read_default as '0'
                              Then sff=1000.0 if sff==0.0
                              I don't see any ' write_default' code ?
                              When the dialog changes the sf value the ' liquidsscalefactor' needs to be [re]written...

                              TIG

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

                                Hi TIG,

                                @unknownuser said:

                                I don't see any 'write_default' code ?

                                My complete code is now attached in the rb-file below....

                                Am I right? It has to be:

                                sfa = Sketchup.read_default('liquidsscalefactor','value', 0) sff = sfa[0].to_f

                                Instead of that I was looking for a more elegant solution like:

                                sfa = Sketchup.read_default('liquidsscalefactor','value', 0).to_f
                                

                                but that's not possible?

                                TIG, Thnx for your help once again, I lost count already πŸ˜„


                                booleanhelperunf1

                                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

                                  Your
                                  sfa = Sketchup.read_default('liquidsscalefactor', 'value', 0).to_f
                                  will work without intermediate steps... although I'd set the fall-back option to '0'.

                                  TIG

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

                                    @tig said:

                                    Your
                                    sfa = Sketchup.read_default('liquidsscalefactor', 'value', 0).to_f
                                    will work without intermediate steps... although I'd set the fall-back option to '0'.

                                    I got it working like this:

                                    sf = (Sketchup.read_default 'liquidsscalefactor', 'value', '0')[0].to_f

                                    final code in first post. Thnx!

                                    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

                                      Should NOT need the [] - the returned value should be a string '' πŸ˜•

                                      TIG

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

                                        Downloaded the latest version. Here what is happening.

                                        1. If you don't put a value to the scale, the model disappears.

                                        2. The model does not stay at it's present locations like the previous version did.

                                        Ken

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

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

                                          The scale should default to 1000 if it's not set, or to another value if it has been set before...

                                          TIG

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

                                            Hi Ken, you were right! Thanx for the feedback πŸ˜›

                                            Solved both problems,

                                            It's only possible to enter a number > 0

                                            You now can choose between scale about origin or scale about object's center.
                                            The default is to scale about the object's center. If you want to change that, open the ruby-file and uncomment
                                            (remove the #) the first line of code. Please reboot ruby to make it work.

                                            Latest version in topic-start

                                            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