cmds files in DP2 – creating a simple order

If you want to get your feet wet with KPL, cmds files are the easiest way to get started. Cmds stands for commands, there are many uses for these files but the most important in my opinion is the import of photo orders from other applications. To be able to use cmds files we first  we need to enable a hot folder in DP2, the steps are as follows:

  1. On the User Tasks Menu Click on categories under you see the menu option Import
  2. Click Import and look for Commands
  3. Click Commands
  4. A new window opens, select a directory (preferably one that is easy accessible for your application)
  5. click Start

That’s it, now DP2 will listen for new cmds files dropped in that directory. If  you rather have DP2 start the Commands process automatically check the Auto Start check box in the Process Commands window.
Now that DP2 is ready let learn about Cmds Files.

First of all, a cmds file is a simple text file with “.txt” extension, nothing fancy here. every cmds file must start with the following line:
Include: ~<$App.Scripts>\Cmds.txt~;

this will tell DP2 to include a long list of functions or “commands” that the file will now be able to use. Now there are two things going on in this line, the first is that we are including a file and the second one is that we are using a DP2 macro to obtain the default DP2 path to that file <$APP.Scripts>. As you can see DP2 delimits Strings with ~~ rather than the more conventional “”. There is a great number of these Macros, I will talk more about others in other articles. I also want to point out that by using <> inside ~~ we are asking DP2 to get the value of the expression inside, if we omitted  the <> we would not get the expected value, we would just output the text $App.Scripts.

Now if we follow order creation logic, the first thing we want to do is to create the order, these is easily done by using the next line:

AddOrder( OrderID, CustomerID, ImagesOrderID, BatchID, BatchSeq, Status, Type, OrderDate, ShipDate, Priority, Description, Owner );

an example of its use would be:
AddOrder( ~ORD001~,~CUST0022~);
Now this will create the order Ord001 and add it to the customer CUST002, as you can see I have omitted a lot of the parameters that are listed, this is possible because DP2 will assume the other parameters are empty.

the next step would be to add images to our order we do this with the next commnad:
AddImage( OrderID, Roll, Frame, Path, Profile, CropX, CropY, CropWidth, CropLength, RotateFromDisk, AutoBalance, LutIndex );
an example would be:
AddImage (~ORD001~,  ~ORD001~, ~image~, ~\\server\Somefolder\ORD001\image.jpg~);

If your software is doing a lot of the image manipulation then you can pass the cropX and Y values to DP2 other wise the last line is all you need. Also make sure the image location is in the network and preferably your DP2 Orders folder. Add the Order ID as the Roll, the roll is usually the folder where the orders reside (Just thname not the full path) and use the file name with no extension as the frame.You can repeat the last line for all your images.

Now we need to add into DP2 what the customer has ordered, for this we use the line:
CreateOrderItemAndJob( OrderID,Item,Sequence,ProductID,Quantity );
an example o of its use would be:
CreateOrderItemAndJob( ~ORD001~, ~~, ~~, ~MyDP2Product~, ~1~, ~Image~, ~\\server\Somefolder\ORD001\image.jpg~ );

you can see that in this example I actually added two more parameters to the line  ~Image~,~\\server\Somefolder\ORD001\image.jpg~ there is actually a lot more that you can add; this extra elements come in pairs and are used to modify element of the product like the queue, backprint etc.

Now if we wanted we can “maintain” our order items, this will create thumbnails in DP2 (this process is similar to double clicking an order item to view its thumbnail). we do that as follows:
MaintainOrderItems( ~ORD001~,~1~);

If you want to send the images automatically to print add this line
RunJobsForOrder( ~ORD001~,~1~);

Your final file will look like this:

Include: ~<$App.Scripts>\Cmds.txt~;
AddOrder( ~ORD001~,~CUST0022~);
AddImage (~ORD001~, ~ORD001~, ~image~, ~\\server\Somefolder\ORD001\image.jpg~);
CreateOrderItemAndJob( ~ORD001~, ~~, ~~, ~MyDP2Product~, ~1~, ~Image~, ~\\server\Somefolder\ORD001\image.jpg~ ) ;
MaintainOrderItems( ~ORD001~,~1~);
RunJobsForOrder( ~ORD001~,~1~) ;

Name your file something like ORD001.txt and dump it in the DP2 cmds files folder.



  1. HI. I have really enjoyed your posts about KPL. Do you have a manual or some other resources for KPL? I am having trouble finding anything online (except for your posts). Any help is greatly appreciated.



    1. Unfortunately there is nothing out there. You can see some code in the developer assistant inside DP2 but your best bet is to ask Kodak. If you have specific questions you can just ask them here too


  2. Carlos – I know this is an old post and I have used the info you supplied to create some basic KPL scripts to load images and orderItems into DP2.

    We are now adding Chroma Key capability to our images and have been successful at adding ChromaKeyBGID to an image node but would like to modify the ChromaKeyBGID for the product as it is being created. I see where I can do this manually in the GUI but need some help for the product. Many of our products have multiple nodes and I would like to apply a background for all image nodes.

    Thanks for any help you can steer me in.


    1. It’s been a while but if memory serves me right you can add this


      to the method


      so it would look like somewhat like this

      CreateOrderItemAndJob( ~ORD001~, ~~, ~~, ~MyDP2Product~, ~1~, ~Image~, ~\\server\Somefolder\ORD001\image.jpg~, ~Node.1.ChromaKeyBGID~,~BG001~) ;

      you can add more nodes by repeating the last part ~Node.2.ChromaKeyBGID~,~BG002~ and so on


  3. Hi Carlos,

    I know it’s been a while since you posted this, but I’m in the middle of integrating an application with DP2 using command files and was wondering if you could fill me in on the correct key to customize backprinting when using “CreateOrderItemAndJob”… You do mention it’s possible in your post and I’m hoping you could let me know how to do it. I know in a Job File the backprinting is usually under the SaveImage block as “Annotation1” and “Annotation2”.

    Any info you can provide would be super helpful!




    1. I am not a 100% sure but I think you can pass it like this

      CreateOrderItemAndJob( ~ORD001~, ~~, ~~, ~MyDP2Product~, ~1~, ~Image~, ~\\server\Somefolder\ORD001\image.jpg~, ~SaveImage.Annotation1~, ~YOUR TEXT~, ~SaveImage.Annotation2~, ~YOUR TEXT 2~ );

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.