Skip to Navigation | Skip to Content

Mental Models

Aligning design strategy with human behavior

Mental Models

Python Script to Automatically Generate the Mental Model Diagram

You will need to install the Python interpreter before you can run the script. Download the latest binary release for your platform. Next, download the script for the PC or the package for the Mac that David Verba converted from the PC version. This Mac version requires a different file format, which is zipped up in the download. For the PC, use either of the "grouping" files listed as Microsoft Word and Excel templates.

Install Python, and then put the script and your file in the same folder. To run the script, click or double click it. A small window will appear with the names of all valid Word or Excel files listed, and a number to the left of each. At the command line prompt, type in the number associated with your file. If everything works correctly, an XML file (labeled with the extension "vsd") will be deposited in that folder, which should open with Visio or Omnigraffle.

In the PC version, each box can contain 48 character titles. If you change the cell color in the tower column or the task column, that box usually turns the same color in the diagram. Sometimes the tower turns a pale yellow or white instead, but I have not yet managed to debug it to find out why. In the Mac version, the colors you set the cells in Excel do not transfer to the diagram output. Yet. If you fix either of these things, let me know and I'll post the update here, along with your name and link.

I also welcome folks to post templates for some of the other spreadsheet and word processing applications that are proliferating these days. And, if you’re interested in extending the script itself, you’re more than welcome to post your additions or an entirely new script in another scripting language.

Caveat: The script (both on the PC and the Mac) is pretty finicky about the format of the Word or Excel file, and I won’t be able to help you debug it. But if you leave comments here, perhaps the community will have some experience. The script doesn’t know what to do with a space that comes at the end of a heading in Word, so it just stops. And, if your column headings in Excel aren’t exactly right, it will also stop. The screen will flash and you will be left with…nothing. So be sure to check the format of your file first.

Comments

I thought I'd post a few known quirks of the script to help people figure out why some Task Towers are not being colored:
-- script doesn't like different heights of cells (ie. 15pxls vs. 17pxls)
FIX: highlight all rows in Excel and set height to 15pxls
-- script *sometimes* doesn't like a single quote (like in a contraction "don't")
-- script doesn't like an emdash [--]

Thanks
JR

Thanks Jen! I didn't know about the line height issue. Good to know!

You might find it easier to do this with Resolver One - and IronPython based spreadsheet that will let you embed your modeling code into the spreadsheet.

http://www.resolversystems.com/

Michael Foord

Thank you Michael. If anyone does this, let me know. It would be good if it offers some additional flexibility to our Python script, such as using the font style and color from the cell in the XML version of the model.

Thanks Indi - awesome script (once I had the right version of python)! You just saved me a gazillion hours of work!

Donna

Thank you so much for sharing this script. Different types of task/diagram modifications have occurred to us when we saw the grouped data in post-it, Excel, and final diagram formats. Having this script made it effortless to regenerate a complete diagram.

The only thing I did was modify the "BOXHEIGHT" and "BOXWIDTH" parameters in the script to accommodate our rather long tasks. Thanks again!

Post a comment

We’ve enabled comment moderation on Rosenfeld Media. Upon posting your comment, it will not immediately appear on this page. Hang tight, we’ll be sure to screen it before too long. (Starred fields are required)

Buy This Book:

Ordering Info

Within This Book's Site: