Sketchup API--Warehouse layouts

HI!! I am working on making warehouse layouts with racking and I can not get the program to lay it out properly. Has anyone a script that could tell the program that the warehouse is 100’ x 100’ and I want racking laid out every 12’. Long shot on this one…but really curious how to make it work.

We asked ChatGPT for a script to layout a 100’x100’ warehouse with pallet racking that is 42" deep and with 8’ wide beams. And this was the script it gave.

Create a single row of frames along one side of a 100’x100’ space

Set the dimensions

total_length = 100
frame_depth = 3.5 # converted from 42" to feet
aisle_width = 5 # arbitrary aisle width for illustration purposes
frame_count = 29
beam_length = 8 # 96" converted to feet

Create frames

def create_frame(x, y, z)
group = Sketchup.active_model.entities.add_group
face = group.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0])
group.move!([x, y, z])

Create beams

def create_beam(x, y, z, length)
group = Sketchup.active_model.entities.add_group
face = group.entities.add_face([0, 0, 0], [1, 0, 0], [1, 0, -1], [0, 0, -1])
group.move!([x, y, z])

Create the layout

def create_layout(total_length, frame_depth, aisle_width, frame_count, beam_length)
entities = Sketchup.active_model.entities
x_offset = 0
y_offset = aisle_width
z_offset = 0

frame_count.times do
create_frame(x_offset, y_offset, z_offset)
create_beam(x_offset, y_offset, z_offset, beam_length)
x_offset += frame_depth

I am guessing I neee to work on creating a warehouse layout, then let AI see the warehouse to put rakcing in as needed.—Could anyone confirm if I can make this work?

Please post correctly with proper 2 space indent:

There are several topics here discussing ChatGPT’s coding ability. You should use the forum search to find them and read them.

For example, the code you posted defines variables and methods at the top level. This is a “no-no”. All code needs to be inside a namespace module and probably within a submodule.

Lastly, when posting a question such as this please say what you were expecting and what and why the result is not as you wished.

1 Like

You might find this old thread helpful.

Started with a DC, but explored ways of keeping file sizes of large warehouse models manageable and performance speedy.

1 Like