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. A coworker stored production assets in Dropbox. Chaos ensued.

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.