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!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Populating components based on csv file

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    4 Posts 2 Posters 297 Views 2 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.
    • S Offline
      Sketchy2
      last edited by

      Good morning, I was curious if anyone has seen a ruby script that will add components to specified areas based on values from a spreadsheet file or CSV file? I am working on making a model of a warehouse, and would like to dynamically populate inventory in the racks/shelves based on the data from a one of those files. If this is something Sketchup can perform natively, then can anyone provide a link to a tutorial showing the steps involved? As always thank you for your help.

      P.S. I have looked at the ruby script cloud, but have not had a chance to try it out. I am not sure if it allows for users to choose their own component to use when it makes the "cloud".

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

        Barring any unmentioned requirements, it would not be a terribly difficult script to write.

        What is the format of the CSV file?

        Hi

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

          Here's a very minimal example of reading a CSV file, and placing a component instance in the model. This is just an example obviously, not tested code as I don't know what your real data is.

          
          
          IO.foreach("filename.csv") do |line|
            line.strip!
            next if line.empty?
            component_name = line.shift
            x, y, z = line.split(",").map{|e| e.to_f}
            tr = Geom;;Transformation.new([x, y, z])
            defn = Sketchup.active_model.definitions.load("path/to/" + component_name)
            Sketchup.active_model.entities.add_instance(defn, tr)
          end
          
          

          Hi

          1 Reply Last reply Reply Quote 0
          • S Offline
            Sketchy2
            last edited by

            Thank you for the reply Jim. I haven't decided on which data would be needed, since I was not sure how to approach defining different areas where the products will be located. Any advise on that? I would like to start with five aisles. Some of the racks will be able to hold six palletized items, and others will hold eight palletized items per section of rack. I would like to alot an area to use for each product. Once the racks are filled, I would like to populate the floor area, between the racks, with the same product but stacked in varying configurations from one product to another. I would probably make a component for these groups of pallets. Excel is my guru program, so I would not have any difficulty putting the data into any order needed. Is this what you meant by format, or were you asking what I plan to use as the delimiter? If you were refering to the delimiter, then probably a comma.

            I have thought about using our item numbers as the name for the components. I thought that might be a way to link the data to Sketchup. I know I can provide a full pallet number for each item. I am not sure how much work this is going to require, but I do not mind. It would be worth the time to be able to provide a way for others to visually see the ammount of inventory versus empty space available. If needed, I can post pictures/video of our setup as a visual aid. Thank you again Jim.

            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