|
|
Rank: Newbie Groups: Member
Joined: 1/28/2011 Posts: 3 Location: UK
|
Hello, Info: Using PI 2.16. Have no access to newer software or SDK. Part 1What i want to do: I want to group several squares and values together into one group and then move them upon clicking a button. Thus, this could then be used to "slide" in a what i need, before then being slid out again upon another button. I am able to move a square using say: but a group doesnt have a name attached and hence i can't reference it in VBA. Part 2 I use a lot of datasets in PI, but i cant multistate a dataset, so how can i do it please? Thank you James
|
|
|
|
|
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.
|
|
|
Rank: Newbie Groups: Member
Joined: 1/28/2011 Posts: 3 Location: UK
|
For instance if i do this: Code: Sub macro1()
rectangle.Selected = True Rectangle1.Selected = True SelectedSymbols.Group = "bob"
End Sub
It will group my two rectangles and then give me a "Run time error 438, Object doesnt support this property or method". How can i then get hold of this group? Does it even reconise the name bob? James
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Hello James, Wow, Processbook 2.16 is old stuff Some sample code for creating a group, which forms a symbol of type "Composite", you would do the following: Code: Dim Comp As Composite
ThisDisplay.SelectedSymbols.RemoveAll ThisDisplay.Rectangle1.Selected = True ThisDisplay.Rectangle2.Selected = True
Set Comp = ThisDisplay.SelectedSymbols.Group Comp.Name = "Bob"
Debug.Print Comp.Name
Comp.Left = Comp.Left - 10
As for the datasets in 2.16 I am not sure without having it in front of me. When you select a symbol and go "Edit -> Multistate", where it has PI Point do you have a drop down to select a dataset? I am sure this was proably added to later version of ProcessBook... Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/28/2011 Posts: 3 Location: UK
|
Hello, After a bit of fiddling (debug.print doesnt seem to work!) , i got the following to work, allowing for it to be called from another module too. Code: Public Comp As Composite Sub macro() ThisDisplay.SelectedSymbols.RemoveAll ThisDisplay.Rectangle.Selected = True ThisDisplay.Rectangle1.Selected = True
Set Comp = ThisDisplay.SelectedSymbols.Group Comp.Name = "bob"
Debug.Print Comp.Name MsgBox (Comp.Name)
Comp.Left = Comp.Left - 10
End Sub
Sub macro2()
ThisDisplay.SelectedSymbols.RemoveAll
MsgBox (Comp.Name) Comp.Left = Comp.Left - 10
End Sub
[code] Problem is now, if i close the processbook and open it up again, although the group is still there, its not named. Is there anyway to save the name permantley for that group? If not, do i have to (each time i open the book) set all the symbols into a group again? In response to your question, how do i call that group With regarding datasets, when you go to symbol and multistate all you have is Server, tag search and tag, there is no way to get to the datasets. On the flip side, is it possible therefore, do make say a value, a multistate using a dataset in VB, even if you have to copy and paste into vb the whole equation? Ta James
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
You will need to re-establish your Composite variable to the group of symbols. When you open your display get the symbol by... Code: Dim Comp As Composite Set Comp = ThisDisplay.Symbols("bob") ...
Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Me, just under a diferrent user name, sorry! Er, after doing this: Code: Public Comp As Composite Sub macro() 'ThisDisplay.SelectedSymbols.RemoveAll 'ThisDisplay.SelectedSymbols.All 'ThisDisplay.Symbols.Selected
'ThisDisplay.Rectangle.Selected = True 'ThisDisplay.Rectangle1.Selected = True
Set Comp = ThisDisplay.SelectedSymbols.Group Comp.Name = "bob"
Debug.Print Comp.Name MsgBox (Comp.Name)
Comp.Left = Comp.Left - 10
End Sub
And then closing the book, reopen it and have this code running under this display Code: Private Sub Display_open()
Dim Comp As Composite Set Comp = ThisDisplay.Symbols("bob")
End Sub
I get: Runtime error: -2147467259 (80004005) Automation Error Unspecfifed Error Erm any clues? J
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
It would appear the above errors out on the line that refers to set comp as part
Any ideas?
J
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
More intresting info. It would appear its the "setting" that VBA doesnt like. The error points to this line here: Code: Set Code = ThisDisplay.Symbols("bob")
However if I run this: Code:
Sub testing() Dim disp As Display Set disp = ThisDisplay Dim sym As Symbol
For Each sym In disp.Symbols If sym.Name = "Composite9" Then
'Put it to make sure code sees the symbol MsgBox "yes" sym.Left = sym.Left - 10
End If Next sym
End Sub
This works like a dream, I can even do it upon reopening the book So to cap so far: A) Its possible to move ANYTHING, including PI data B) I am still stumped on how to "call" the symbols once the book is closed and reopened without looping through them as say above. So, thoughts? J
|
|
|
|
Guest
|