Scripting for PhotoModeler using DDE
PhotoModeler can be controlled and have data fed to it by other Windows applications. PhotoModeler provides a DDE (Dynamic Data Exchange) interface and a set of simple DDE commands for this purpose. Most, but not every, aspect of PhotoModeler can be accessed through DDE. The full list of available DDE commands is in the PhotoModeler Help file (search the Help for “DDE”).
PhotoModeler acts as a DDE server (a server accepts DDE commands and responds to them). To talk to PhotoModeler you will need to use a DDE client (a client initiates a DDE connection to a DDE server and sends commands to it).
PhotoModeler’s DDE commands take a very simple form. All PhotoModeler DDE commands are ASCII text strings and are of the format: “commandName commandParam1 commandParm2 …”. All commands return values and a return code indicating success or failure.
To use the DDE interface of PhotoModeler:
2.Start your DDE client program.
3.The DDE client opens a DDE channel to PhotoModeler using “DDE Initiate” with the server name: “PhotoModeler” and the topic: “Data”.
4.The DDE client sends DDE commands using “DDE Request” to PhotoModeler.
5.The DDE client closes the DDE channel to PhotoModeler using “DDE Terminate”.
DDE clients can be written in many Windows programming languages but one of the easiest is Visual Basic by Microsoft. Other programs like Microsoft Word, Microsoft Excel and Autodesk AutoCAD can act as DDE clients by using Visual Basic for Applications (VBA) or any other language that supports windows API calls. The PhotoModeler Help file shows a VBA example.
Other programming languages like C, C++ and Java may also have DDE command interfaces/libraries or can access the windows API directly, for more information follow the links:
[The PhotoModeler help file has a full VBA sample.]
Native Win32 API:
The following information is specific to the Python scripting method (Python usage is widespread in many applications, including OpenOffice, and is one of the simpler programming languages).
A DDE module has been written for the Python language. Your basic program will always follow this sequence
1) Create a DDE conversation between your python program and PhotoModeler
2) Connect to PhotoModeler
3) Test the connection
4) Run your required DDE commands
5) Close the connection
To get Python working on your computer, first install Python2.5 from:
pick the Python 2.5.1 Windows installer.
Next, install Python for Windows extensions from
The following Python code as an example shows how to add layers. It opens a text file specified by the user when prompted by the program.
#This script adds layers to a photomodeler project
#create a DDE client and start conversation
s = dde.CreateServer()
#the parameter in brackets is the name of this Python file (AddLayers.py)
#create a conversation between client and server
c = dde.CreateConversation(s)
#Connect to PhotoModeler
#if the connection succeeds, proceed with requests to PhotoModeler
if c.Connected() == 1:
print “Connection established”
#prompt for layers file name
layerFileName = raw_input(“Enter a layer file name: “)
#open the file
layerFile = open(layerFileName, “r”)
print >> sys.stderr, “File could not be opened”
#get all the lines of text (command parameters) in the file and close it
lines = layerFile.readlines()
#loop through commands
#strip out leading and trailing whitespce in strings from file
for line in lines:
c.Request(“AddLayer ” + line.strip(‘n’))
print “Can’t establish connection, quitting”
The layers file is simply a text file with one layer per line e.g.
Please note: DDE is a mechanism built into Microsoft Windows and is not a system developed by Eos Systems. To that extent, PhotoModeler’s DDE capability is dependent on DDE functioning correctly on your machine.
©Copyright 2017 Eos Systems Inc.