Creating a Modeling Scenario Copy

Below is the example of using the SetMs operation to create a modeling scenario copy. The request contains an instance of opened modeling container, parameters of operation execution, and the scenario to be added. After executing the operation returns tree of model scenarios.

SOAP request:

- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <SetMs xmlns="http://www.fsight.ru/PP.SOM.Som">
- <tMs xmlns="">
  <id>S57!M!S!C1</id>
  </tMs>
- <tArg xmlns="">
- <pattern>
  <obInst>true</obInst>
  <scenarios>Add</scenarios>
  </pattern>
- <meta>
- <scenarios>
- <nodes>
- <it isFolder="false">
  <k>0</k>
  <id />
  <n>Base (copy1)</n>
  <vis>true</vis>
- <scenDesc isShortcut="false">
  <i>OBJ1628</i>
  <n>Base</n>
  <k>1628</k>
  <c>5124</c>
  <p>1627</p>
  <h>false</h>
  </scenDesc>
  </it>
  </nodes>
  </scenarios>
  </meta>
- <metaGet>
  <obInst>true</obInst>
  <scenarios>Get</scenarios>
  </metaGet>
  </tArg>
  </SetMs>
  </s:Body>
  </s:Envelope>

SOAP response:

- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Body>
- <SetMsResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <id xmlns="">
  <id>S57!M!S!C1</id>
  </id>
- <meta xmlns="">
- <obInst>
- <obDesc isShortcut="0">
  <i>MODELSPACE</i>
  <n>Modeling container</n>
  <k>1581</k>
  <c>5121</c>
  <p>1580</p>
  <h>0</h>
  </obDesc>
  </obInst>
  <dirty>0</dirty>
- <scenarios>
- <nodes>
- <it isFolder="0">
  <k>1628</k>
  <id>OBJ1628</id>
  <n>Base</n>
  <vis>1</vis>
- <scenDesc isShortcut="0">
  <i>OBJ1628</i>
  <n>Base</n>
  <k>1628</k>
  <c>5124</c>
  <p>1627</p>
  <h>0</h>
  </scenDesc>
  </it>
- <it isFolder="0">
  <k>5371</k>
  <id>OBJ5371</id>
  <n>Base (copy1)</n>
  <vis>1</vis>
- <scenDesc isShortcut="0">
  <i>OBJ5371</i>
  <n>Base (copy1)</n>
  <k>5371</k>
  <c>5124</c>
  <p>1627</p>
  <h>0</h>
  </scenDesc>
  </it>
  </nodes>
  </scenarios>
  </meta>
  </SetMsResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

    {
     "SetMs" : 
      {
       "tMs" : 
        {
         "id" : "S3!M!S!C1"
        },
       "tArg" : 
        {
         "pattern" : 
          {
           "obInst" : "true",
           "scenarios" : "Add"
          },
         "meta" : 
          {
           "scenarios" : 
            {
             "nodes" : 
              {
"it" : 
{
"@isFolder" : "false",
"k" : "0",
"id" : "",
"n" : "Basic (copy)",
"vis" : "true",
"scenDesc" : 
{
"@isShortcut" : "false",
"i" : "OBJ1628",
"n" : "Basic",
"k" : "1628",
"c" : "5124",
"p" : "1627",
"h" : "false"
}
}
}
}
          },
         "metaGet" : 
          {
           "obInst" : "true",
           "scenarios" : "Get"
          }
        }
      }
    }
  }
}

JSON response:

    {
     "SetMsResult" : 
      {
       "id" : 
        {          "id" : "S3!M!S!C1"         },        "meta" :         {          "obInst" :           {            "obDesc" :             {              "@isShortcut" : "0",
"i" : "MODELSPACE",
"n" : "Modeling container",
"k" : "1581",
"c" : "5121",
"p" : "1580",
"h" : "0"
}
},
"dirty" : "0",
"scenarios" : 
{
"nodes" : 
{
"it" : 
[
{
"@isFolder" : "0",
"k" : "1628",
"id" : "OBJ1628",
"n" : "Basic",
"vis" : "1",
"scenDesc" : 
{
"@isShortcut" : "0",
"i" : "OBJ1628",
"n" : "Basic",
"k" : "1628",
"c" : "5124",
"p" : "1627",
"h" : "0"
}
},
{
"@isFolder" : "0",
"k" : "5131",
"id" : "OBJ5131",
"n" : "Basic (copy)",
"vis" : "1",
"scenDesc" : 
{
"@isShortcut" : "0",
"i" : "OBJ5131",
"n" : "Basic (copy)",
"k" : "5131",
"c" : "5124",
"p" : "1627",
"h" : "0"
}
},
{
"@isFolder" : "0",
"k" : "5133",
"id" : "OBJ5133",
"n" : "Basic (copy)",
"vis" : "1",
"scenDesc" : 
{
"@isShortcut" : "0",
"i" : "OBJ5133",
"n" : "Basic (copy)",
                   "k" : "5133",
                   "c" : "5124",
                   "p" : "1627",
                   "h" : "0"
                  }
                },
                {
                 "@isFolder" : "0",
                 "k" : "5135",
                 "id" : "OBJ5135",
"n" : "Basic (copy)",
"vis" : "1",
"scenDesc" : 
{
"@isShortcut" : "0",
"i" : "OBJ5135",
"n" : "Basic (copy)",
"k" : "5135",
"c" : "5124",
"p" : "1627",
                   "h" : "0"
                  }
                }
              ]
            }
          }
        }
public static MsScenarioTree SetMsScenarioCopy(MsId ms, ulong modelKey, MsScenarioNode sc)
{
    sc.isFolder = false;
    sc.k = 0;
    sc.n = sc.n + " (copy)";
    sc.vis = true;
    sc.id = "";
    sc.p = 0;
    sc.moveTo = null; 
    var setMsOp = new SetMs();
    // Set operation execution parameters
    setMsOp.tMs = ms;
    setMsOp.tArg = new SetMsArg()
    {
        pattern = new MsMdPattern()
        {scenarios = ListOperation.Add},
        meta = new MsMd()
        {
            scenarios = new MsScenarioTree
            {
                nodes = new MsScenarioNode[] { sc }
            }
        },
        metaGet = new MsMdPattern() { scenarios = ListOperation.Get }
    };
    // Create a proxy object for operation execution
    var somClient = new SomPortTypeClient();
    // Execute operation
    var result = somClient.SetMs(setMsOp);
    return result.meta.scenarios;
}

See also:

SetMs: Operation