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

Manipulate figures composed as polygon Options · View
negado
#1 Posted : Thursday, July 14, 2011 9:07:02 PM
Rank: Newbie
Groups: Member

Joined: 7/13/2011
Posts: 8
hello
I am working with VB sdk with ProcessBook pi. The problem I have is that excites a figure composed of at least 30 parties. I need to manipulate this composite figure like one without using a PI tag. similar to that driving a polygon or other figure on PI.
try this but it did not work:

composite11.FillColor = RGB (255, 0, 0)
composite11.LineColor = RGB (0, 255, 0)
composite11.Visible = True
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.
jhcoxx
#2 Posted : Monday, July 18, 2011 12:21:25 AM
Rank: Member
Groups: Member

Joined: 7/5/2010
Posts: 27
Location: Texas
You'll probably get more helpful / elegant suggestions, but maybe this will get you heading in a good direction.

The code below is structured as a subroutine - with a composite made of 30 symbols, you may not be able to do things as simply as it does, which is to just set the fill color, line color and visibility of the individual Symbols that were grouped into the Composite. Note that the parameter passed to the sub is a Symbol, not the name of the Symbol. Also note that the On Error Resume Next is critical - there most likely be some Symbols in your Composite that don't have the .FillColor property, so that lets execution continue instead of stopping with an error iwhen one of those Symbols is encountered.

You could test each Symbol to see if it has the .FillColor property (there is something like a 'GetCapability' method that can be used to see if a specific Symbol has a specified property, or you could check each Symbol via a Select Case structure using its .Type property (like the check below on whether the passed Symbol is indeed a Composite) and have in the Case statements code that would only change appropriate properties for the particular type of Symbol. However, it's a lot easier just to let PB throw an error and then ignore that error. (Generally only a good idea in strictly limited sections of code - otherwise you're suppressing errors that you really needed to know about!).


Code:


Public Sub composite(aComposite As Symbol)

    Dim aSymbol As Symbol

    If aComposite.Type <> pbSymbolComposite Then

        MsgBox "Oops - " & aComposite.Name & " isn't a composite /grouped symbol...", vbOKOnly + vbCritical

        Exit Sub

    End If

    On Error Resume Next

    For Each aSymbol In aComposite.GroupedSymbols

        aSymbol.FillColor = pbRed
        aSymbol.LineColor = pbBlue
        aSymbol.Visible = True

    Next aSymbol

 
End Sub




Some highlights: Nothing I've found will work directly on Symbols that are grouped into a Composite - either you have to access them through the Composite's .GroupedSymbols property (as above) or
you have to select the Composite, then ungroup it (ThisDisplay.SelectedSymbols(1).Ungroup), then 'walk' through .SelectedSymbols (similar to the For Each...Next above), make the changes in the individual Symbols and finally use the SelectedSymbols.Regroup method to put the Composite back together. Note that ProcessBook will cache the name of the Composite and the Symbols that made up it and if you Regroup (as opposed to Group), it will apply the same Composite name. If you just Group them, the Composite will be given a new name. PB hold the information about the Ungrouped Composite until another Composite is Ungrouped, or until PB is closed.

Hope all this helps a bit...
negado
#3 Posted : Tuesday, July 19, 2011 3:06:34 PM
Rank: Newbie
Groups: Member

Joined: 7/13/2011
Posts: 8
thanks for your help
y can solve my problem, the code works very well
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.