![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: addProperty method call format help needed Topic Summary: Created On: 1-Mar-2007 16:29 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Every element on a diagram has a popup menu that contains a Format option. This Format option brings up a window in which the user can change things like line style, fill pattern, font colors etc. I have a need to duplicate some of the funtionality of this Format window via a Visual Basic program (without an associated GUI).
At fist I thought this was going to be easy. I noticed using the GUI that these format values were stored in the properties (these are the ones I am interested in at this time): Format.<elementType>.Line.LineColor Format.<elementType>.Line.LineStyle Format.<elementType>.Fill.FillHatch Format.<elementType>.Fill.FillStyle Format.<elementType>.Fill.FillColor Format.<elementType>.Font.StrikeOut where <elementType> is the type of the selected element; class, transition, actor, action (on activity diagram), etc. And thus I could simply make a setPropertyValue call and change the value. For Example: <rpGraphElement>.setPropertyValue "Format.Action.Fill.FillStyle" "2" And Yeah Verily, this worked ... for my initial testing. As I expanded testing, the setPropertyValue call started failing, even for elements that it had succeeded previously. Very mistifying... I finally realized that the reason the setPropertyValue call was failing was that the graphical element I was calling it against did not already have that property added to it. The Format window actually performs an addProperty before it does the setPropertyValue. So my code now has to determine if the property is there first and if it is not then I need to call the addProperty method as well. Not a problem, I can do that... Or so I thought! According to the Help documentation addProperty has a syntax of: Visual Basic Syntax addProperty (propertyKey As String, propertyType As String, propertyValue As String) Arguments propertyKey The name of the new property. propertyType The property type. The possible values are as follows: int string enum <xxx>, <yyy>, <zzz> Boolean propertyValue The default value of the new property. I have used many different permutations of this call, using varying values for the property type (int, string, enum (and many forms of this as well), etc) and the results are always the same. The addProperty call actually succeeds and the property is created on the graphElement. With this property defined the setPropertyValue call succeeds as well. As far as the code is concerned all is well. But when I look at the element on the diagram, in Rhapsody, the color/style/whatever did not actually change. And even worse, now even the Format window can not change the value for the format option. Thankfully, I can perform an un-override operation on the element and that removes all my changes, so my model is properly functioning again but this does not solve my problem. I have concluded that I am formating the addProperty call incorrectly, especially for the ones that are obviously enumerations, and thus the property is defined in a manner that Rhapsody can not identify and it decides to not display my changes at all. That or Rhapsody has a problem in that it does not properly recognize properties (at least the ones I am interested in), that are created using the addProperty method. Mostly I am interested in Activity diagrams but I am having the same problem with OMDs so I assume that it is pandemic in all the diagrams in Rhapsody. Is there a way to make the addProperty call, for the properties I am interested, that will make this work and what do the calls look like? Can you provide an example? Or is this truely a bug in the tool? Thanks |
|
![]() |
|
![]() |
|
I have found that setting a property that affects the display of a model element only affects the next time that element is placed on a diagram, it does not change the way it is displayed when it has an existing appearance on a diagram. What I do is set these properties for the whole diagram before putting elements on it, which effectively applies a style to the way things are displayed.
You can also do some things with setGraphicalProperty to the graphical element, but these are more limited, I've found ... useful for things like change the path of a line maybe, but things like setting the line style etc are best done on the model element before display. |
|
![]() |
|
![]() |
|
Hi John,
have you tried setting the required diagram properties in your site.prp file? These will take effect when you load the model, changing the defaults to the values you set ![]() Regards, Ian |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.