![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: Changing element type by VBA Macro Topic Summary: Created On: 30-Jan-2007 23:12 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
In a Rhapsody project I have a number of elements of "Requirement" type that need to be changed to "Comment."
In the GUI I can simply open the requirement and change the type drop-down box to "Comment" to convert each element; however, I would like to automate this process in a VBA macro but I can't find any function to do it. Is this functionality only supported in the GUI or is there an API implementation? |
|
![]() |
|
![]() |
|
Hi,
I think you have to iterate all your requirements, and for each one create a new comment with the relevant data. I don't think there is function in the API that can do it directly! Please correct me if I'm wrong ![]() Regards ------------------------- Jesper Gissel Johnson Controls Denmark, Marine Controls |
|
![]() |
|
![]() |
|
Thank you for the feedback. I believe that you are correct. The problem is that the requirements are used on many diagrams and I would prefer not to have to find and update all of those manually.
I was thinking about creating comments in place of all the requirements as you suggest. Then storing all the old requirement's GUIDs. Deleting the requirements. And then going back and forcing the GUID's of the comments to be the old equivalent requirement's GUID. This obviously isn't a very elegant solution so I was hoping that there was some API functionality to change the type in the same fashion that the GUI can. |
|
![]() |
|
![]() |
|
Hello Ranjot
Take care of one thing (Rhapsody Version 6.1MR2 at least). A requirement can have spaces in the name, but a comment can't. I've submitted a defect report. So if you change it in VBA there may be unpredictable results. The other thing, what exactly is your concern about diagrams? If you change the element type in the browser, it'll automatically update on all diagrams. Use the right-click References to check this. I haven't tried this, but if you want to go the vba way, remember that comments requirements are both of metaclass RPAnnotation. If you set the metaClass property as "RPComment", does that work? (There's no associated method, but the VBA may allow it). Also, I'm incidentally interested in why you have to change from Requirements to Comments. ------------------------- ----------------------- Matthew Thomas Panasonic Manufacturing UK Ltd |
|
![]() |
|
![]() |
|
Hi Ranjot, Jesper and Matthew
Hmmm... This doesn't look good. The Metaclass is a read-only property, so you can't change it via VBA. I suspect that if you delete the requirements, they will disappear from the diagrams then and there, and will not reappear even if you then create comments with the same GUID. (Although, if the diagrams are unloaded at the time you run the macro, it might work...) An alternative, illicit approach is (shhh!) to edit the repository files directly. Requirements are stored in structure similar to the following: Code: { IRequirement - _id = GUID 11791e8c-0cf4-4fbd-9db4-a2b34172bb5b; - _myState = 2048; - _name = "MyRequirement"; - _body = ""; } You could: 1. Open your repository files in your text editor. 2. Search for the names of the requirements you want to change to comments. 3. Edit "IRequirement" (see example above) to "IComment". 4. Save your files and open the model in Rhapsody. Each diagram will automatically detect and resolve the changes in metaclass, the same way they would if you changed the metaclass in the features dialogue while a diagram is not loaded, then loaded it. I think you should be on safe ground here. But I do not warrant that! regards, Simon ------------------------- Simon Morrish simon.morrish@eu.panasonic.com http://panasonic.co.uk Panasonic ideas for life Edited: 28-Feb-2008 at 18:54 by Simon Morrish |
|
![]() |
|
![]() |
|
Matthew, thanks for the tip on comment/requirement naming. As Simon mentioned, the metaclass is read only so we can't change that one in VBA. As for the reason we're making the changes, essentially our spec can have requirements or comments in it and Engineers sometimes change their minds about what should be categorized as what. This code would be helpful as part of a much larger synchronization process.
Simon, a couple of times I've gone "under the hood" and wrote code that made changes to SBS files. Obviously it's risky, so I'm going to try to come up with another solution. I will probably write a bit of code to automate the mouse clicks that change the type through the GUI. At least this way, there's less risk of compromising the integrity of the project. Thank you for your input. |
|
![]() |
Telelogic Rhapsody
» Rhapsody Category » Rhapsody
»
Changing element type by VBA Macro
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.