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.
{ "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" } } } } } }
{ "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: