In Petrel, is it possible to COPY-PASTE items in input tree using ocean? I need to have a copy of a specific well or strategy somewhere; how can I do this?
For example if I want to have a copy of this well (myWell):
Tubing = e.Data.GetData(typeof(TubingString)) as TubingString;
Borehole myWell=Tubing.Borehole;
into my boreholecollection (Borhol):
WellRoot Welrot = Slb.Ocean.Petrel.DomainObject.Well.WellRoot.Get(PetrelProject.PrimaryProject);
BoreholeCollection Borhol = Welrot.BoreholeCollection;
Or have a copy of DevelopmentStrategy (oldStrategy):
EclipseFormatSimulator.Arguments args=WellKnownSimulators.ECLIPSE100.GetEclipseFormatSimulatorArguments(theCase);
DevelopmentStrategy oldStrategy=args.Strategies.DevelopmentStrategies.First();
into DevelopmentStrategyCollection (strategycol):
SimulationRoot simroot = SimulationRoot.Get(PetrelProject.PrimaryProject);
DevelopmentStrategyCollection strategycol=simroot.DevelopmentStrategyCollection;
Many domain objects that have copy/paste functionality in Petrel implement an interface called ICopyable
. However, I don't believe this is consistent for all domain objects. A more reliable way of copy/pasting a domain object would be through the use of the ICopyableFactory
service.
Borehole borehole = ...;
ICopyable copyable = borehole as ICopyable;
if (copyable == null)
{
ICopyableFactory factory = CoreSystem.GetService<ICopyableFactory>(borehole);
copyable = factory.GetCopyable(borehole);
}
if (copyable != null)
{
IDataSourceManager sourceMgr = ...;
IDataSourceManager targetMgr = ...;
IProjectInfo sourceProjectInfo = ...;
IProjectInfo targetProjectInfo = ...;
ICoordinateReferenceSystem sourceCrs = ...;
ICoordinateReferenceSystem targetCrs = ...;
ICoordinateOperation coordinateOperation = ...;
CopyContext.Element ignoreElements = ...;
CopyContext.Identify identity = ...;
object targetCollection = ...;
object snapshot = copyable.GetSnapshot();
CopyContext context = new CopyContext(sourceMgr, targetMgr,
sourceProjectInfo, targetProjectInfo, sourceCrs, targetCrs
coordinateOperation, ignoreElements, identity, targetCollection,
snapshot);
Borehole copy = copyable.Copy(context) as Borehole;
}
ICopyable.Copy
takes a lot of parameters because this method is also used for the reference project tool (for copying domain objects between projects). If you are copying a domain object within the same project, all of your associated source/target properties will be the same (i.e. targetMgr = sourceMgr
).