Hi all,
In an automation script I would like to create an element in the same view as an existing element. I'm able to retrieve the required element and to create the new one, but I'm struggling to assign the correct view to that element. Does anyone know how to do this?
Thanks,
Stijn
Hi Stijn,
The following code can help you to retrieve the view of an element:
// Create a IDms object to go through the elements in the cluster
IDms dms = engine.GetDms();// Retrieve the elements in the cluster
ICollection<IDmsElement> dmsElements = dms.GetElements();foreach (IDmsElement dmsElement in dmsElements)
{
engine.GenerateInformation("[INFO]|Run|dmsElement.Name=" + dmsElement.Name);
engine.GenerateInformation("[INFO]|Run|dmsElement.Id=" + dmsElement.Id);
engine.GenerateInformation("[INFO]|Run|dmsElement.Host=" + dmsElement.Host.Id);// Get the views for an element
ISet<IDmsView> dmsViews = dmsElement.Views;foreach (IDmsView dmsView in dmsViews)
{
engine.GenerateInformation("[INFO]|Run|dmsView.Name=" + dmsView.Name);
}// End foreach
}// End foreach
And to create an element in a specific view, you need to create your ElementConfiguration object as follows:
elementConfiguration = new ElementConfiguration(dms, "My Element", dms.GetProtocol("My Protocol", "Production"));
elementConfiguration.Views.Add(dms.GetView("My View"));
Note that in case you know the existing element, you wan work with dms.GetElement([elementName]) or dms.GetElement([dmaId],[elementId])