cancel
Showing results for 
Search instead for 
Did you mean: 

vb script - color coding attribute in an entity

Former Member
0 Kudos

Hi

Can you please share any code sample you may have on how to color code a attribute in an entity using vb script?

thank you

Accepted Solutions (1)

Accepted Solutions (1)

former_member217396
Participant
0 Kudos

Hi,

I'm not sure what do you mean by "color code a attribute"...

Here is an example on seting color on the entity base on an extended attribute value

Function %Validate%(obj, ByRef message)

   ' Implement your object validation rule on <parent> here

   ' and return True in case of success, False otherwise with a message

   Dim sym

   If obj.GetExtendedAttributeText("Inherited Risk Classification/Rating") = "5 - High" Then

     For Each sym In obj.Symbols

         sym.FillColor = RGB(255,51,51)

     Next

   ElseIf obj.GetExtendedAttributeText("Inherited Risk Classification/Rating") = "4 - Moderate-High" Then

     For Each sym In obj.Symbols

         sym.FillColor = RGB(255,153,51)

     Next

   ElseIf obj.GetExtendedAttributeText("Inherited Risk Classification/Rating") = "3 - Moderate" Then

     For Each sym In obj.Symbols

         sym.FillColor = RGB(255,255,102)

     Next

   ElseIf obj.GetExtendedAttributeText("Inherited Risk Classification/Rating") = "2 - Moderate-Low" Then

     For Each sym In obj.Symbols

         sym.FillColor = RGB(102,178,255)

     Next

   ElseIf obj.GetExtendedAttributeText("Inherited Risk Classification/Rating") = "1 - Low" Then

     For Each sym In obj.Symbols

         sym.FillColor = RGB(102,204,0)

     Next

   Else

     For Each sym In obj.Symbols

         sym.FillColor = RGB(192,192,192)

     Next

   End If

  

   %Validate% = True

End Function

Rafal

Former Member
0 Kudos

Hi Rafal

Thank you for responding to my question. I am looking to change the font color of an attribute using vb script. I was browsing meta model help, but couldn't figure it out.

thank you

Krishna

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Rafal,

Unfortunately do not have sample code that I can share, but the formating of things like attributes are are kept in the SubObject attribute of the Symbol.  See this section of the metamodel help.

PdCommon . ObjectCompositeSymbol :
SubObjects As String

Get or set Sub-objects Blob. The SubObject is an attribute to specify the
display of collections of sub-objects, or change the font used to display them
in the parent symbol.
The format of the attribute is as
follows:
List1List2...Listn
Where Listn has the format:
PublicName
State+font1font2...fontn
Where:
PublicName=public name of the
sub-object
State=0: Display all;1: Display none;2: Display some
Font=OID
of object+' '+','(the ',' is optional and means that the object with this OID is
not to be displayed)+font name,size,R,G,B
For example:
EntityAttribute
2{74485EC3-D52C-4761-A703-0DF2F62A0DC6}
,Arial,10,B,0,0,0{74485EC4-D52C-4761-A703-0DF2F62A0DC6} Courier
New,10,I,255,255,0Identifier 0
means that:
For the collection of Entity
Attributes, some objects only will be displayed:
- The first object will not
be displayed because its OID is followed by a comma
- The second object will
be displayed in yellow italic size 10 Courier New
For the collection of
Identifiers, all will be displayed.

Message was edited by: Jay Stevens Beware, we have experienced issues when returning models to the repository, because of the differences between these subObjects, the merge screen displays a lot of unexpected differences. Jay

Former Member
0 Kudos

Thank you Jay. Will look into this.

Regards

Krishna