Hi Aruna, are you asking how to programmatically create elemement templates and attributes? If that is so, you can refer to this.
If you are asking when, you should create them before instantiating any elements or attributes that will be based on these templates.
Thank you for the information.
I am aware of creating template elements. In my application i have to create dynamically templates, so when i should be creating it?
Is it that i have to check if that element has template or not ? if yes then update template attr values.
If no then create template?
i wish to understand when exactly i can do it.....
It is up to you to decide if you want to templatize your asset hierarchy. You can have elements without templates and that will be equally fine. However, we would recommend you to create elements that are based on templates as this allows for higher scalability. While the use of templates to define elements is optional, in general it provides better performance and scalability by reducing duplicate information. If you want to create elements that are based on templates, you will have to create the templates first. Then, when you are instantiating an element, you can select the option to create it based on the template.
The example I gave in the link above shows this
// Create an Element Template AFElementTemplate myElemTemplate = myDB.ElementTemplates.Add("MyElementTemplate"); myElemTemplate.Description = "Template used to create my elements"; // Create an Element from the Element Template myDB.Elements.Add("MyElement", myElemTemplate); myDB.CheckIn();
Thank you so much for your ideas
Appreciate your quick response
PIAFSDK can create Element template.
AFElementTemplate test_template = myAFServer.Databases["MyDatabase"].ElementTemplates.Add("TemplateName");
This code creates ElementTemplate.
AFAttributeTemplate test_attributetemplate = test_template.AttributeTemplates.Add("AttributeName1");
This code creates ElementTemplate Attribute.
Following code creates element by template.
AFElement new_element = AFServer.Databases["MyDatabase"].Elements.Add("element_name", AFServer.Databases["MyDatabase"].ElementTemplates["TemplateName"]);
When it runs, it creates new element and it contains attributes too.
For running these codes, you need to do checkin() if you want to show the results for the other users.