![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: Helper arguments macros? Topic Summary: Created On: 27-Jun-2007 12:39 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hi there,
in the Tools Menu -> Customize you can specify new commands for the Context menu of the model's objects. Since they are applicable to specific kinds of objects it would make sense to have some macros with which I am able to specify the unit's file as arguments to such an external program. Are there such macros (e.g. %f for filename, %p for path ... ) and if yes where are they documented? Or do I have to use VBA for this? If not what can I use the external programs for, e.g.? In the docu there is an example with the cp (copy) command. How does the copy command knows what to copy ... and where to ... ? greetings Michael |
|
![]() |
|
![]() |
|
Hi Michael,
In either VBA or in an external program that uses the Rhapsody API, I have written things in two ways: a) those that work without specific reference to a particular model element - examples are a macro to check some aspect of the entire model, or to jump to a place in the model from anywhere else; b) those that work on the selected model element, for which you use the API function getSelectedElement at the beginning of your code - examples are wizards like the "Create Ports and Interfaces" wizard for the Harmony process. If you want the unit filename or the full path, there are API functions to get those, once you have found the selected element. It doesn't take too long to write these --- post again if you need any suggestions. Regards, Charlie. |
|
![]() |
|
![]() |
|
Hi charlie,
thx for the quick answer! Since I am totally new to COM programming I have a little struggle right at the beginning ;-) In the examples of the Rhapsody Documentation the Rhapsody-Application always will be started. What I need in this case is connect to an already running instance. This is what I tried: CLSID clsid; HRESULT hr = CLSIDFromProgID(OLESTR("Rhapsody.Application"), &clsid); if (FAILED(hr)) {...} // connect to running instance IRPApplication *apl = 0; hr = GetActiveObject(clsid, NULL, (IUnknown**)&apl); if (FAILED(hr)) {...} IRPProject *proj; hr = apl->activeProject (&proj); .... As soon as I hit the last line the application crashes, although the GetActiveObject succeeded and the apl is not NULL!! Any quick hints for me? Thanks in advance, greetings, Michael |
|
![]() |
|
![]() |
|
Hi Michael,
Hopefully someone else will help with doing it from C++. In VBA (e.g. from a bit of VBA in Word) you can connect to the active project like this: [CODE]ShowStatus "Connecting to Rhapsody" On Error GoTo NoRhap Set a_RpApp = GetObject(, "Rhapsody.Application") On Error GoTo EH m_RhapsodyInfo = "Rhapsody " & a_RpApp.Language & " " & a_RpApp.ToolSet & _ " Version " & a_RpApp.version & " Build " & a_RpApp.BuildNo & vbCrLf & _ "SerialNo " & a_RpApp.SerialNo & " OMROOT " & a_RpApp.OMROOT & vbCrLf Set rpy = a_RpApp.activeProject If rpy Is Nothing Then GoTo NoProj Regards, Charlie g_ProjectDirectory = rpy.currentDirectory g_ProjectFileName = rpy.filename[/CODE](Obviously I had definitions of ShowStatus, a_RpApp, rpy, g_ProjectDirectory, g_ProjectFileName and labels NoRhap, NoProj and EH, but hope it gives the idea.) Regards, Charlie |
|
![]() |
|
![]() |
|
hmmm .... may it be possible that I need the VBA Add On to use the "read and write API"??
Maybe this is the reason the application crashes as soon as I try to get access to the Rhapsody application. Strange though that the delivered C++ example (ReadAPI), which starts its own Rhapsody instance, runs without problems (at least if Rhapsody isn't running yet - but even then it exits gracefully with an error-message and not with a crash). thanks for your effort, though, Michael |
|
![]() |
Telelogic Rhapsody
» Rhapsody Category » Rhapsody
»
Helper arguments macros?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.