Hi Madhu,
Welcome to the forum!
Apologies, for some reason I completely missed your original post.
I presume so far you have got to the point of getting/setting the format of a Trend using the "TrendFormat" object.
In order to refer to the Elements, you can use the "pbTrendELEMENT" enumeration, e.g. pbTrendELEMENT.pbPen1. For each trace on your trend, the trace index refers to the pen number - the 1st trace = pbPen1 etc. What you need to do is parse the traces on the trend and set the format accordingly.
Below is some example code where I look for the PI tag "sinusoid" and then change the format of that particular trace.
Code:
Sub ParseTrend(ByVal TheTrend As Trend)
' If there are no traces, don't parse the Trend.
If TheTrend.TraceCount = 0 Then Exit Sub
Dim TF As TrendFormat
Set TF = TheTrend.GetFormat()
Dim iTrace As Integer, sTag As String
For iTrace = 1 To TheTrend.TraceCount
sTag = TheTrend.GetTagName(iTrace)
' Check to see if "\" is present...
' If so it is a PI tag...
' Otherwise a dataset (AF or PI Calc)
If InStr(1, sTag, "\") > 0 Then
sTag = Trim(Split(sTag, "\")(3))
If LCase(Trim(sTag)) = "sinusoid" Then
Dim iElementEnum As Integer
Select Case iTrace
Case 1: iElementEnum = pbTrendELEMENT.pbPen1
Case 2: iElementEnum = pbTrendELEMENT.pbPen2
Case 3: iElementEnum = pbTrendELEMENT.pbPen3
Case 4: iElementEnum = pbTrendELEMENT.pbPen4
Case 5: iElementEnum = pbTrendELEMENT.pbPen5
'... etc
'Be careful, pbPen8 = index 12, pbPen 9 = index 17!!!
Case Else: iElementEnum = -1
End Select
If Not iElementEnum = -1 Then
TF.Elements(iElementEnum).LineStyle = pbLSolid
TF.Elements(iElementEnum).LineWidth = pbMedium
TF.Elements(iElementEnum).Color = pbRed
End If
End If
End If
Next iTrace
Call TheTrend.SetFormat(TF)
Set TF = Nothing
End Sub
Hope this helps!
Rhys
OSIsoft PI System SpecialistsPI consultancy on PI Systems, PISDK, AFSDK, OLEDB etc and PI custom developments. Well pretty much anything to do with PI!