Here is an example of how the code might look. The following copies an existing object (so you can set properties that will be shared between the racks beforehand, such as dimension for example). It then sets the location in the model and the tree and copies the send to port logic and connections to the new object.
Object queue = Model.find("QueueName");
Object storage = Model.find("RackName");
// Create copy
Object copy = createcopy(storage, queue.up);
// Copy location, tree rank and sendtoport
copy.location = queue.location;
copy.rank = queue.rank + 1;
copy.setVariable("sendtoport", queue.getVariable("sendtoport"));
// Copy connections
for(int in = 1; in <= queue.inObjects.length; in++)
{
contextdragconnection(queue.inObjects[in], copy, "A");
}
for(int center = 1; center <= queue.centerObjects.length; center++)
{
contextdragconnection(queue.centerObjects, copy, "S");
}
for(int out = 1; out <= queue.outObjects.length; out++)
{
contextdragconnection(copy, queue.outObjects[out], "A");
}