0

UPDATE: The process needs to set as the active object first. THe new question is how to do this.

PetrelSystem.ActiveObjectService.GetActiveObject<Process>()

The above call doesn't work. Is there another way to set the active object for processes? There doesn't seem to be one Type for a process in the process tree so I doubt anything using generics will work.

OLD QUESTION: I'm having trouble launching a process's settings dialog using the API call DialogBuilder.ShowSettings(object domainObject). It seems to work for the Import Data process but I can't get it to launch any other dialogs.

I have tried traversing the Processes tree to get the process domain objects and I have tried using PetrelSystem.ProcessDiagram.FindProcess(string name) to obtain the process. Both have the same result when passed into DialogBuilder.ShowSettings.

Is this a known issue with the API in 2011?

This is how I traverse the tree

 IObservableElementEnumerableFactory service = CoreSystem.GetService<IObservableElementEnumerableFactory>(PetrelProject.Processes);
 IObservableElementEnumerable elemEnum = service.GetEnumerable(PetrelProject.Processes);

        indentLevel++;
        if (elemEnum != null)
        {
            foreach (object obj in elemEnum)
            {
                var cmo = cmoMananeger.CreateCMO(obj, addText, indentLevel);
                //add it to tree then add its children
                if (cmo != null)
                {
                    if (indentLevel > 0)
                    {
                        comboBox1.Items.Add(cmo);
                        processToCMO.Add(cmo, obj);
                    }
                    traverseTree(obj, indentLevel, addText);
                }
            }
        }
        indentLevel--;

And then try to launch the process after

  var process = processToCMO[comboBox1.SelectedItem as ContextMenuObject];
  if (!PetrelSystem.DialogBuilder.IsSettingsVisible(process))
        PetrelSystem.DialogBuilder.ShowSettings(process);

This is how I'm trying to launch the process via the find process method

var PROCESS = PetrelSystem.ProcessDiagram.FindProcess((comboBox1.SelectedItem as ContextMenuObject).DisplayText);
        if (PROCESS != null)
        {
            if (!PetrelSystem.DialogBuilder.IsSettingsVisible(PROCESS))
                PetrelSystem.DialogBuilder.ShowSettings(PROCESS);
        }

The method I'm using works fine for other panes like the input and models. It is only the processes pane that it is having problems with.

Cheers for the help!

Ashley Kelham
  • 106
  • 2
  • 7

1 Answers1

1

IProcessDiagram.ActiveProcess property gets or sets the active process.

I wrote a simple test that registers for the ActiveProcessChanged event, and when the end user selects a different process, the event handler shows that process's settings dialog. This worked for the ~10 native Petrel processes that I tried. I tested on both 2011.2 and 2012.

PetrelSystem.DialogBuilder.ShowSettings(PetrelSystem.ProcessDiagram.ActiveProcess);

Regards, Delaina

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
Delaina
  • 21
  • 1