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

    Ruby script compatibility issue..IN vs. Metric

    Scheduled Pinned Locked Moved Plugins
    5 Posts 5 Posters 1.1k Views 5 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.
    • C Offline
      conradcliff
      last edited by

      SketchUp version: 7.1.6860
      Operating system: XP SP3

      Hey guys, first post here, looks like a great forum πŸ˜„
      So I have a bit of a problem..I've created this fairly complicated drawing using components created for google sketchup by the company that provides the actual materials and machines them for you.
      Well, along with the components they provide a ruby script to create a bill of materials after you've finished your drawing...the problem is that you apparently You must being drawing with your Sketchup Preferences Template set to:

      "Inches (Woodworking) - 2D"

      I've drawn the whole thing up in the metric woodworking template since I was using their metric products.

      Below is the script they provide free of charge on their website, if anyone could give some insight on what needs to be done in order for it to work with the metric template, or if it could work at all, I would really, REALLY appreciate it. Thanks! πŸ˜„

      #v1.1.0
      
      def get_instance(ent, def_name)
      
         output = ""
      
         ent.instances.each do |e|
      
            orig = e.transformation.origin
      
           # output << "#{def_name},#{e.bounds.width},#{e.bounds.depth},#{e.bounds.height},#{orig.x},#{orig.y},#{orig.z}\n"
      
            output << "#{def_name},#{e.bounds.width},#{e.bounds.depth},#{e.bounds.height}\n"
      
         end
      
         output
      
      end
      
      
      
      def get_all_items
      
         out = ""
      
         Sketchup.active_model.definitions.each do |e|
      
            out << get_instance(e, e.name)
      
         end
      
         out
      
      end
      
      
      
      def get_instance_login(ent, def_name)
      
         output = ""
      
         ent.instances.each do |e|
      
            orig = e.transformation.origin
      
           # output << "#{def_name},#{e.bounds.width},#{e.bounds.depth},#{e.bounds.height},#{orig.x},#{orig.y},#{orig.z};"
      
            output << "#{def_name},#{e.bounds.width},#{e.bounds.depth},#{e.bounds.height};"
      
         end
      
         output
      
      end
      
      
      
      def get_all_items_login
      
         out = ""
      
         Sketchup.active_model.definitions.each do |e|
      
            out << get_instance_login(e, e.name)
      
         end
      
         out
      
      end
      
      
      
      def export_items
      
         flomoco_login = "demo@flomoco.com"
      
      
      
      
      
         if(flomoco_login != "")
      
              model_data = "FloMoCo Component Reporter v1.1.0\n"
      
                 model_data = model_data + get_all_items_login
      
                 #model_data.gsub!('"','%22')
      
                 #model_data.gsub!('~','%7E')
      
                 web_data = "remail=" + flomoco_login + "&data=" + model_data;
      
                 dialog = UI;;WebDialog.new("FloMoCo 80/20 Instant Quoter", true, "FloMoCo_Quoter_Page", 50,50, 20, 20, true)
      
                 dialog.show
      
                 dialog.post_url("http://www.flomoco.com/c/8020_IQ_Login.pl",web_data)
      
                 UI.openURL "http://www.flomoco.com/c/8020_IQ_Login.pl?temail=#{flomoco_login}"
      
        else
      
              file_name = File.dirname(__FILE__)+"/FloMoCo_8020_BoM.txt"
      
                 f = File.new(file_name,"w")
      
                 model_data = "FloMoCo Component Reporter v1.1.0\n"
      
                 model_data = model_data + get_all_items
      
                 f.write model_data
      
                 f.close
      
                UI.openURL "file;//#{file_name}"
      
         end
      
      end
      
      
      
      if( not file_loaded?("FloMoCo_8020_quoter.rb") )
      
      
      
          add_separator_to_menu("Plugins")
      
          UI.menu("Plugins").add_item("Generate FloMoCo 8020 BoM...") { export_items}
      
      end#if
      
      
      
      file_loaded("FloMoCo_8020_quoter.rb")
      
      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        If they need the dimensions in inches set your model units to Inches in Model Info > Units.
        Open the Woodwork Inch template and note these settings and mimic then in tour model - you can swap units at any time. Sketchup uses Inches as its internal units, no matter what you model in. Indeed you can model in mm, you type 1000 OR 1000mm to get a line that length, BUT with your units still set to mm type 1m in the VCB and you'll get a 1m [1000mm] long line or even 40" to get one 40" long etc !

        TIG

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

          I don't see anything in that code the relates to any units. Appear to be only a small part of the code. Something that has to be adjusted on their side. Have you approached them about metric support?

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

          1 Reply Last reply Reply Quote 0
          • fredo6F Offline
            fredo6
            last edited by

            @conradcliff said:

            I've drawn the whole thing up in the metric woodworking template since I was using their metric products.

            If the unit of your model is centimeter, then just add .cm at the end of the width, depth and height properties. This will convert them into inches to the output.

            
                 output << "#{def_name},#{e.bounds.width.cm},#{e.bounds.depth.cm},#{e.bounds.height.cm}\n"
            
            

            If your model unit is meter, then use .m instead.

            Fredo

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

              After scanning the FloMoCo plugin, it don't see how it can be reporting the correct dimensions.

              Hi

              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