0

我正在尝试使用 Visual Studio (C#) 创建 Rhapsody 插件,但无法创建它。我在这里找到了解决我的问题的两个选项,但没有一个可行。

我正在使用以下代码:

using System;
using System.Runtime.InteropServices;
using rhapsody;

public class Class1: IRPInternalOEMPlugin {

    public int ActiveProjectAboutToChange() {
        throw new NotImplementedException();
    }

    public int ActiveProjectHasChanged() {
        throw new NotImplementedException();
    }


    public string OnMenuItemSelect(string menuItem) {

        RPApplication rpy = (RPApplication)Marshal.GetActiveObject("Rhapsody.Application");
        rpProject proj;
        proj = rpy.activeProject();
        proj.addPackage("PackageTest");
        return "Success";
    }


    public string OnMenuItemSelectWithParameters(string menuItem, string parameters) {
        throw new NotImplementedException();
    }


    public int RhapPluginAnimationStopped() {
        throw new NotImplementedException();
    }


    public int RhpPluginAnimationStarted() {
        throw new NotImplementedException();
    }


    public int RhpPluginCleanup() {
        throw new NotImplementedException();
    }


    public void RhpPluginDoCommand(string theCommand) {
        throw new NotImplementedException();
    }


    public int RhpPluginFinalCleanup() {
        throw new NotImplementedException();
    }

    public int RhpPluginInit() {
        throw new NotImplementedException();
    }


    public int RhpPluginInvokeItem() {
        throw new NotImplementedException();
    }


    public void RhpPluginOnIDEBuildDone(string buildStatus) {
        throw new NotImplementedException();
    }

    public int RhpPluginSetApplication(RPApplication pRPApp) {
        throw new NotImplementedException();
    }


    public int RhpSavingProject() {
        throw new NotImplementedException();
    }
}

Rhapsody 没有给我任何错误。我该如何解决?

4

2 回答 2

0

开发 rhapsody 插件的文档化和“官方”方式是使用 Java。您可以在 IBM 帮助站点上找到很多关于此的文档。

在您的情况下,可以使用 Try/catch 在 Java 中轻松调试错误消息。

我有同事也使用 C#,但结果好坏参半。

我强烈建议如果您没有重大限制,请切换到 Java 并继续进行插件开发。

于 2017-11-03T15:04:32.470 回答
0

必须是插件吗?您可以通过 COM 从 C# 访问 Rhapsody:

using rhapsody;

//...

RPApplication application = (RPApplication)Marshal.GetActiveObject("Rhapsody.Application");
RPProject project = application.activeProject();
RPCollection allElements = project.getNestedElementsRecursive();

foreach (RPModelElement element in allElements)
{
    //do something
}
于 2018-01-31T20:43:42.387 回答