0

我正在使用 Ocean 2010.2,无法使用 CreateFunction 方法创建新函数。它说,“它在当前上下文中不存在”。任何帮助将不胜感激!

4

2 回答 2

2

如果您添加了一些有关如何尝试创建函数的代码示例,那就太好了。现在我可以建议您没有将必要的 Petrel 程序集添加到您的项目中。

这是我创建函数的示例:

Collection SimpColl = Collection.NullObject;
Function SimpFunction = Function.NullObject;
// Do not forget to use transactions
using (ITransaction trans = DataManager.NewTransaction())
{
    // Use current project to create collection
    // that will contain your function
    trans.Lock(PetrelProject.PrimaryProject);
    SimpColl = PetrelProject.PrimaryProject.CreateCollection("Simple collection");
    trans.Commit();
}

using (ITransaction trans = DataManager.NewTransaction())
{
    // Create your function in your newly created collection
    trans.Lock(SimpColl);
    SimpFunction = SimpColl.CreateFunction("Simple Function");
    trans.Commit();
}
于 2012-08-01T05:53:42.767 回答
0

可以为 Slb.Ocean.Petrel.DomainObject.Analysis.AnalysisRoot、Slb.Ocean.Petrel.DomainObject.Seismic.InterpretationCollection 和 Slb.Ocean.Petrel.DomainObject.Collection 对象调用 CreateFunction 方法。模式在所有情况下都是相同的。但是您的消息看起来不像海洋错误,但它看起来像一般的 VS 消息。出现此类消息的常见原因通常是:object 的声明和 object 的使用位于两个不同的隔离代码块中,彼此不可见。

于 2012-08-15T12:12:27.433 回答