YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Any way to make lines dynamic Options · View
bgrizz
#1 Posted : Friday, August 07, 2009 9:20:12 PM
Rank: Newbie
Groups: Member

Joined: 8/7/2009
Posts: 2
Does anyone know if there is a way to draw a line dynamically? I'm essentially trying to draw a compass on my Process Book page. I've figured out how to make the line do what I want, if I set D = 90 it points east, 270 it points west etc. However, when I try to assign D as a variable that gets it's data from Pi it doesn't work. It usually says "Object doesn't support this property or method".

Does anyone have any ideas on how to work around this problem?


Sub Value4_DataUpdate()

Dim MyLine As Line
Dim D As Object
Set D = ThisDisplay.Value4

Set MyLine = ThisDisplay.MyLine


With MyLine
.Name = "MyLine"

'Changes direction of arrow based on winddir value
D = Value4.DataPoint

.Endpoints(1).x = -14586 'left
.Endpoints(1).y = 13415 'top

.Endpoints(2).x = (-14586) + (Sin(D / 180 * 3.14159) * 185)
.Endpoints(2).y = 13415 + (Cos(D / 180 * 3.14159) * 185)


'set line color and styles
.LineColor = pbBlue
.LineStyle.Style = 0
.LineStyle.Weight = 2

'add arrow on right.
.LineStyle.End = 3

End With



End Sub
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
RJK Solutions
#2 Posted : Friday, August 07, 2009 10:02:30 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Hello, welcome to the forum.

Well I presume Value4 is a ProcessBook Value symbol, so this is the type for your variable.
A Value symbol then has a method to return the current value, "object.GetValue(vrDate, vrStatus)". Use this for your current value - vTime will give you the time for the value.

If I was to use your code I would change it to:

Code:
Sub Value4_DataUpdate()

Dim MyLine As Line
Set MyLine = ThisDisplay.MyLine

Dim D As Value, vTime As Variant, vStat As Variant
Set D = ThisDisplay.Value4

With MyLine
    .Name = "MyLine"

    'Changes direction of arrow based on winddir value
    .Endpoints(1).X = -14586 'left
    .Endpoints(1).Y = 13415 'top
   
    .Endpoints(2).X = (-14586) + (Sin(D.GetValue(vTime, vStat) / 180 * 3.14159) * 185)
    .Endpoints(2).Y = 13415 + (Cos(D.GetValue(vTime, vStat) / 180 * 3.14159) * 185)
   
    'set line color and styles
    .LineColor = pbBlue
    .LineStyle.Style = 0
    .LineStyle.Weight = 2
   
    'add arrow on right.
    .LineStyle.End = 3
End With

End Sub
Principal Consultant
Real-Time Data Management @ Wipro Technologies
bgrizz
#3 Posted : Monday, August 10, 2009 3:14:34 PM
Rank: Newbie
Groups: Member

Joined: 8/7/2009
Posts: 2
Wow! You rock! That works perfectly. I knew there was someway to get it. Thanks a bunch!!


Awesome forum too. I'll definitely be back.

-BG
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.