Copy-Paste Items in Petrel using Ocean…?

我怕爱的太早我们不能终老 提交于 2019-12-11 08:09:56

问题


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;

回答1:


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).



来源:https://stackoverflow.com/questions/24242116/copy-paste-items-in-petrel-using-ocean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!