Friday fun with Python Code

While I was fooling around with some Python code, I suddenly thought “How do I make it go ‘BING!’?”

The answer is very simple: import winsound

Make a Python script block and put the following code in it:

import clr
from Autodesk.DesignScript.Geometry import *

#Here's a bit of fun
import winsound
# Play Windows exit sound. Put this line where you want it to go BING
# winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
# Hmm, I wonder what I could do with this?

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

  winsound.PlaySound("SystemExit", winsound.SND_ALIAS)

#Assign your output to the OUT variable.
OUT = 0

This will play the default Windows Exit noise (bl-bl-bl-bl-bing!) when it runs.

Attached is a very, very basic DYN file that does the same thing.BING.dyn (2.2 KB)

Docs for winsound:

So far I have used just the basic Windows standard sounds as very simple audio feedback for when various functions in graphs work or not. Given there is no visual output of errors from Python scripts, this provides a useful way of knowing if a script has run successfully or not, or for finding out how flow works within Dynamo scripts.

edits: spellinge mustokes, Python script errors.


This is going to be so much fun…

Hehe, reminded me of a little script I once tweeted:


Heh, I have a script that checks the line types in the project. If they only have standard ones then a pop up window opens and tells them to call a coworker and ask for a cookie. Hasn’t happened yet though.