Hi Danny,
Here's some sample code that gets the level in the hierarchy (you may have seen this in the DDK)
// An example of how to determine the level of the current DCO object.
if (CurrentDCO.ObjectType() == Level.Batch)
{
WriteLog("Batch Level");
}
else if (CurrentDCO.ObjectType() == Level.Document)
{
WriteLog("Document Level");
}
else if (CurrentDCO.ObjectType() == Level.Page)
{
WriteLog("Page Level");
string imageName = CurrentDCO.ImageName; // We are at the page level, here is how to obtain the image name.
WriteLog("Image name: " + imageName);
}
else if (CurrentDCO.ObjectType() == Level.Field)
{
WriteLog("Field Level");
}
Here is some other code that sets a variable:
// Here is an example of setting a variable in the DCO. If the variable does not exist, it will be created.
bool result = localSmartObj.DCONavSetValue("@B.MyVariable", smartP1);
if (result)
{
WriteLog("MyVariable was set in the DCO at the batch level.");
}
else
{
WriteLog("MyVariable was not set in the DCO");
}
I haven't tested this, but here goes:
// Get current objects
var oDoc = CurrentDCO; // Current document
var oBatch = oDoc.Parent(); // Parent batch
var oPage = oDoc.GetChild(0); // First page
// Set variables
oDoc.set_Variable("P8_DocumentType", "TestDocType");
oPage.set_Variable("Identifier", "testIdentifier");
I hope this helps!
Shaun