I am using Ocean 2010.2 and I cannot create a new function with CreateFunction method. It says, that "it does not exist in the current context". Any help will be highly appreciated!
Asked
Active
Viewed 262 times
2 Answers
2
It would be good if you added some code example on how you try to create your function. For now I can propose that your didn't add necessary Petrel assemblies to your project.
Here is my example of creating function:
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();
}

Rail Suleymanov
- 361
- 1
- 4
- 16
0
The CreateFunction method can be called for the Slb.Ocean.Petrel.DomainObject.Analysis.AnalysisRoot, Slb.Ocean.Petrel.DomainObject.Seismic.InterpretationCollection and Slb.Ocean.Petrel.DomainObject.Collection objects. Pattern is the same in all cases. But your message doesn't look as an Ocean error, but it looks as a generic VS message. The common reason for messages like this is usually if: the declaration of object and the usage of object are located in two different isolated blocks of code and not visible to each other.

Alex
- 318
- 1
- 6