How do dictionaries work?

Hello!

I need help understanding Dictionaries and their related actions in Shortcuts. I’m a Camera Operator in film and TV and I’m trying to solve a problem. Often while working on set I use a Viewfinder app to determine where a shot will be and measure the camera height in inches. I’d like to build a shortcut that I can input the height in inches and spit out the tools needed to achieve the height.

The items I most often use are things like tall tripod, short tripod and a camera dolly which booms to different heights.

Should I create a dictionary that holds each item in their different orientations as Keys and their heights as Values?

Then how would I pose the questions to the input so it could show different results?

Ideally I’d like questions to be like “what is your camera height?” And the results read like “You can achieve x height with Dolly in low mode or Tall Baby Tripod with slider”

Thanks so much! This would be a great help if I could make this work

1 Like

Here’s how I’d approach this.

Let’s start with a set of fictional equipment. Some of it can be set to any height between two points. Some only specific heights. I’ve used cm here, but your set would obviously be specified in inches.

Item of Equipment Type Minimum Height (cm) Maximum Height (cm) Available Fixed Heights (cm)
Dolly A Variable 150 275 -
Dolly B Variable 220 290 -
Tripod C Variable 30 110 -
Mount D Fixed - - 140
Tripod E Variable 80 170 -
Mount F Fixed - - 80, 90, 100, 110, 120

This can be expressed as a dictionary of equipment. Each item has an entry in that dictionary. Each item can also be set as a dictionary. Each having a common attribute that specifies if it is capable of variable or fixed heights. Depending upon that the item then also has either a couple of attributes specifying a minimum and maximum height, or an attribute specifying a list of specific heights.

Once set-up and a height is captured it is a case of working through all the items (enumeration). If it is a variable height, check between the minimum and maximum heights. If a fixed height item, check against each available height in the list.

At the end, if there are any matches, display them.

Here’s a shortcut that does just that.

Hopefully that’s the sort of shortcut you were after.

4 Likes

This is outstanding! I’ve duplicated your example and loaded in the appropriate heights (adjusted for inches) and added the always present measurements of the camera and fluid head. Now at a tap I can quickly gauge what gear will work in any scenario from as low as 7” to upwards of 80”.

Thank you very much, I’ve learned from your example and can’t wait to apply it in other ways.

2 Likes