AnsweredAssumed Answered

Using Traits SDK

Question asked by mikespath on Dec 23, 2016
Latest reply on Jan 2, 2017 by jyi

Holiday Greetings All!

I'm trying to use the traits associated with an element template that references pipoints, I'm looking for an efficient way to code it so I can look up a Limit trait on an element and change it's value. The code below executes slowly and I'm sure I'm not using the right methods.

See attached bitmap showing the PIexplorer section I'm talking about, I wish to be able to set the Hi, HIHi, Lo, etc. traits in my vessel templates, then have code find and change them.

               AFAttributeList myAttributes = AFAttribute.FindElementAttributes(db, null, "*", null, db.ElementTemplates["One Hill Solutions\\Proplus\\Vessel3"], AFElementType.Any, "*", null, TypeCode.Empty, true, AFSortField.Name, AFSortOrder.Ascending, int.MaxValue);

                AFValues values = myAttributes.GetValue();

                foreach (AFValue val in values)


                    AFAttribute hi_a = val.Attribute.GetAttributeByTrait(AFAttributeTrait.LimitHiHi);

                    if (hi_a != null)


                        MessageBox.Show(string.Format("Attribute: {0}, HiHi {1}", val.Attribute, hi_a.GetValue()));