Populating components based on csv file
-
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".
-
Barring any unmentioned requirements, it would not be a terribly difficult script to write.
What is the format of the CSV file?
-
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 -
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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement