I want to create Element using template by passing path.
Now I want to create Element 'Child3' by passing path.
How can I do that?
I have not tested the code snippet below but it should work. Don't forget to check in!
AFDatabase myDb = new PISystems()["AFSERVERNAME"].Databases["DatabaseName"];
AFElement myElement = myDb.Elements["ParentName"];
AFElementTemplate myElementTemplate = myDb.ElementTemplates["myTemplateName"];
Hopefully, this is what you are looking for!
Have you looked into the option using AF Builder plug-in to Microsoft Excel? The plug-in ships together with the AF Client installation.
If you prefer building your own application, I suggest watching the training video Basics of AF Programming Part 1 available at the Training Center together with more useful training resources. Please also have a look into the Tutorial - Create AF Element Templates from a CSV File available at the Library. Last but not least, please download and install PI AF Developer Tools_2014 R2 from the Download Center, category "PI Asset Framework". After installing this package you will find AF SDK Reference (AFSDK.chm) at %PIHOME%\Help\ with some code examples in VB.Nat and C#
In addition to what Gregor and Marcos provide you can always use the FindObject method and provide a path.
For example, I want to add a tank to Division 1 and my AF Database has top level element "My Plant" followed by a list of divisions. I first obtain the Division 1 element and then I can add a new element to it.
AFElement myElement = AFObject.FindObject(@"\\AFServerName\AFDatabaseName\My plant\Division 1") as AFElement;
Also, if you need to find multiple elements the AFElement class has a FindElementsbyPath method.
Thanks a lot Marcos. It worked for me
Thanks to Gregor, Dan for your information.
Retrieving data ...