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

    [Plugin] Make Fur v.2.1.0(20140323)

    Scheduled Pinned Locked Moved Plugins
    650 Posts 255 Posters 1.1m Views 254 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.
    • thomthomT Offline
      thomthom
      last edited by

      Good stuff! πŸ‘

      Very nice plugin this. Shaping up good.

      Another remark: menu names, can you also avoid version number in the menu names? Keep them static? Because when the menu name changes between updates the shortcuts assigned to them doesn't work any more.

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

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

        hmmm...
        I now see the problem daredevil talked about.

        tak2hata:
        When the user's locale is decimal you can't use the comma to get the various components of the vectors.
        2010-05-20 12h02_47.png

        "0,400mm,0mm,0mm" is interpreted as x=0, y=400, z=0

        The problem is this:

        
          def fur_dialog_ini
            @fur_units_metric = false
            @fur_units_metric = true if ( 0.to_l.to_s )["m"]
            @delim = ","
            @delim = ";" if Sketchup.get_locale.upcase == "FR"
          end
        
        

        This code only checks for FR Sketchup locale. But there are many more that uses , comma as decimal delimiter. Norwegian for instance.
        But, Sketchup.get_locale does not return the locale of the system. It returns the language code of Sketchup.
        For instance, I use Norwegian locales, but use English SU. Sketchup.get_locale returns en-US

        I've been recently struggling with this myself.
        And the hack I ended up using to find the user's comma decimal separator was this: @decimal_separator ||= 1.2.to_l.to_s.match(/\d(\D)\d/)[1]
        See http://forums.sketchucation.com/viewtopic.php?f=180&t=28346 for more info.

        Now, this only gives you what the comma separator is. I've not found a way to find the list separator. Just I think you can catch most cases by assuming locales with comma as decimal separator uses ; as list separator.

        So to revise your code:

        
          def fur_dialog_ini
            @fur_units_metric = false
            @fur_units_metric = true if ( 0.to_l.to_s )["m"]
            decimal_sep = 1.2.to_l.to_s.match(/\d(\D)\d/)[1]
            @delim = ";" if decimal_sep == ','
          end
        
        

        Then there is the other part of that method:
        @fur_units_metric = false @fur_units_metric = true if ( 0.to_l.to_s )["m"]
        Use model.options to get the user units.
        http://code.google.com/apis/sketchup/docs/ourdoc/model.html#options

        It returns an OptionManager that gives you access to some OptionsProvider classes.
        http://code.google.com/apis/sketchup/docs/ourdoc/optionsmanager.html
        http://code.google.com/apis/sketchup/docs/ourdoc/optionsprovider.html

        To inspect the available options, use this snippet:
        Sketchup.active_model.options.keys.each {|key| p key; Sketchup.active_model.options[key].each {|k,v| puts "> #{k} - #{v}"} }

        Using that you can see that model.options["UnitsOptions"] gives you all the info you need about the model units.
        model.options["UnitsOptions"]["LengthUnit"] gives you the unit type.

        The unit types are:
        // LENGTH_FORMAT: 0 = Decimal, 1 = Arcitectural, 2 = Engineering // LENGTH_UNITS: 0 = Inches, 1 = Feet, 2 = Millimeters 3 = centimeters, 4 = Meters // LENGTH_PRECISION: number of decimal places to show
        (Found this in the Google SketchUp 7\Resources\en-US\i18n.dat file)

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

        1 Reply Last reply Reply Quote 0
        • GaieusG Offline
          Gaieus
          last edited by

          @frederik said:

          ...Only in UK in Europe (and I believe on Cypres too) they drive in the left side... πŸ˜‰

          And Ireland, too.

          Gai...

          1 Reply Last reply Reply Quote 0
          • W Offline
            watkins
            last edited by

            Countries that drive on the left

            Link Preview Image
            File:Countries driving on the left or right.svg - Wikipedia

            favicon

            (en.wikipedia.org)

            Quite a few.

            1 Reply Last reply Reply Quote 0
            • soloS Offline
              solo
              last edited by

              @unknownuser said:

              Countries that drive on the left

              Looks like a British commonwealth map. πŸ˜•

              http://www.solos-art.com

              If you see a toilet in your dreams do not use it.

              1 Reply Last reply Reply Quote 0
              • GaieusG Offline
                Gaieus
                last edited by

                Yeah. Though already a minority of the countries, still "the sun never sets over the countries that drive on the left".
                πŸ˜„

                Gai...

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

                  @unknownuser said:

                  This code only checks for FR Sketchup locale.

                  And when French user uses directly FR Locale "." (modified) whith English SU version seems there is no problem? πŸ˜‰
                  wind.jpg

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

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tak2hata
                    last edited by

                    Hi, All.
                    I update this to v1.3e.
                    Thomas,Thank you very very much!
                    At last, I also understood.
                    I use your code "decimal_sep = 1.2.to_l.to_s.match(/\d(\D)\d/)[1]".
                    and model.options["UnitsOptions"]["LengthUnit"] >= 2 then unit is metric.
                    It not depend to Sketchup locale.

                    I think that this is perhaps no problem.
                    please reply when there is a problem.

                    Thanks


                    by TAK2HATA

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

                      @tak2hata said:

                      I use your code "decimal_sep = 1.2.to_l.to_s.match(/\d(\D)\d/)[1]".
                      and model.options["UnitsOptions"]["LengthUnit"] >= 2 then unit is metric.
                      It not depend to Sketchup locale.

                      I think that this is perhaps no problem.
                      please reply when there is a problem.

                      I think that should work.

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

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

                        Oh - you posted update already! I see. I'll try it out then.

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

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

                          😞 1.3e not working for me.

                          Error: #<NoMethodError: undefined method[]' for nil:NilClass>
                          C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:734:in fur_dialog_ini' C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:741:in fur_webdialog'
                          C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:1414
                          C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:1413:in call'

                          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

                            With 1.3e I get Error: #<TypeError: no implicit conversion to float from nil> C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:1326:ininitialize'
                            C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:1326:in new' C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:1326:in s_to_vec'
                            C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:713:in show_webdialog' C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:658:in call'`
                            with the 'web-dialog' accept button.
                            You must be passing an empty argument to a defn ?

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              tak2hata
                              last edited by

                              @thomthom said:

                              😞 1.3e not working for me.

                              Error: #<NoMethodError: undefined method[]' for nil:NilClass>
                              C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:734:in fur_dialog_ini' C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:741:in fur_webdialog'
                              C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:1414
                              C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/fur_en.rb:1413:in call'

                              I think this is LengthFormat or LengthPrecision problem.
                              So I will change code..

                              
                              def fur_dialog_ini
                              	unitoptions = Hash.new
                              	Sketchup.active_model.options["UnitsOptions"].each{|key ,val| unitoptions[key] = val }
                              	Sketchup.active_model.options["UnitsOptions"]["LengthFormat"] = 0 if unitoptions["LengthFormat"] != 0
                              	Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"] = 1 if unitoptions["LengthPrecision"] == 0
                              	@fur_units_metric = false
                              	lunit = unitoptions["LengthUnit"]
                              	@fur_units_metric = true if lunit >= 2
                              	lprec = Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"]
                              	@decimal_sep = 1.2.to_l.to_s.match(/\d(\D)\d/)[1]
                              	@delim = ","
                              	@delim = ";" if @decimal_sep == ','
                              	unitoptions.each{|key ,val| Sketchup.active_model.options["UnitsOptions"][key] = val }
                              end
                              
                              

                              @tig said:

                              With 1.3e I get Error: #<TypeError: no implicit conversion to float from nil> C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:1326:ininitialize'
                              C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:1326:in new' C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:1326:in s_to_vec'
                              C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:713:in show_webdialog' C:/Program Files/Google/Google SketchUp 7/Plugins/fur_en.rb:658:in call'`
                              with the 'web-dialog' accept button.
                              You must be passing an empty argument to a defn ?

                              Sorry,I will change the code.


                              by TAK2HATA

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

                                Why are you doing this?

                                Sketchup.active_model.options["UnitsOptions"].each{|key ,val| unitoptions[key] = val } Sketchup.active_model.options["UnitsOptions"]["LengthFormat"] = 0 if unitoptions["LengthFormat"] != 0 Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"] = 1 if unitoptions["LengthPrecision"] == 0

                                You're changing the model settings.

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

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

                                  This whole thing makes no sense...

                                  
                                      def fur_dialog_ini
                                         unitoptions = Hash.new
                                         Sketchup.active_model.options["UnitsOptions"].each{|key ,val| unitoptions[key] = val }
                                         Sketchup.active_model.options["UnitsOptions"]["LengthFormat"] = 0 if unitoptions["LengthFormat"] != 0
                                         Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"] = 1 if unitoptions["LengthPrecision"] == 0
                                         @fur_units_metric = false
                                         lunit = unitoptions["LengthUnit"]
                                         @fur_units_metric = true if lunit >= 2
                                         lprec = Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"]
                                         @decimal_sep = 1.2.to_l.to_s.match(/\d(\D)\d/)[1]
                                         @delim = ","
                                         @delim = ";" if @decimal_sep == ','
                                         unitoptions.each{|key ,val| Sketchup.active_model.options["UnitsOptions"][key] = val }
                                      end
                                  
                                  
                                  

                                  You create an hash to store model UnitOptions, then change them and then restore the original values...?

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

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

                                    From what I could understand, that method could be condensed to:

                                        
                                        def fur_dialog_ini
                                           units = Sketchup.active_model.options["UnitsOptions"]["LengthUnit"]
                                           @fur_units_metric = (units >= 2) # true if units are 2 or greater
                                           @decimal_sep = 1.2.to_l.to_s.match(/\d(\D)\d/)[1]
                                           @delim = (@decimal_sep == ',') ? ";" ; ","
                                        end
                                    
                                    

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

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      tak2hata
                                      last edited by

                                      Hmmm,
                                      When LengthFormat is Architectural or LengthPrecision = 0,
                                      "1.2.to_l.to_s.match(/\d(\D)\d/)[1]" return error.

                                      Is that problem excluding this?


                                      by TAK2HATA

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

                                        Ah, yes. I see the problem. ..hm... this needs some more thinking... 😞

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

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

                                          Ok - turns out that you can't trust the SU methods to extract the decimal separator as model settings affects the length to string formatting. (Should have thought of that. 😳 )

                                          Looking at there seems to mostly be just comma or period as decimal separator. At least if you make that assumption it will cover most.

                                          So here is an alternative:

                                          
                                            def get_decimal_separator
                                              # If this raises an error the decimal separator is not '.'
                                              '1.2'.to_l
                                              return '.'
                                            rescue
                                              return ','
                                            end
                                          
                                            def fur_dialog_ini
                                              @decimal_sep ||= get_decimal_separator
                                              @delim ||= (@decimal_sep == ',') ? ";" ; ","
                                            end
                                          
                                          

                                          This snippet makes some assumptions:
                                          Only comma or period as decimal separator.
                                          If the separator is a period then comma is used as list separator.
                                          If the separator is a comma then ; is used as list separator.

                                          The method is working out the decimal separator is by trial and error.

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

                                          1 Reply Last reply Reply Quote 0
                                          • J Offline
                                            jchau2007
                                            last edited by

                                            wow... keep it coming. Thanks.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 7
                                            • 8
                                            • 9
                                            • 10
                                            • 11
                                            • 32
                                            • 33
                                            • 9 / 33
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement