Below is the example of using the SetMs operation to delete a variable. The request contains an instance of opened modeling container, parameters of operation execution, data slice that corresponds to the variable to be deleted, and the pattern for getting changed data. After execution the operation returns the changed model.
{ "SetMs" : { "tMs" : { "id" : "CEOHFIGABHNBFOAEACLDIHAAFIBLHLNEJJHHIHEGOIMCAOGA!M!S!CPOKJBJGABHNBFOAEFABNMBGBLLNHOPAEHKDKCJFDLLMFBFKJ" }, "tArg" : { "pattern" : { "obInst" : "true", "item" : { "key" : "92146", "metaModel" : { "calculationChain" : "Remove" } } }, "meta" : { "item" : { "k" : "92146", "type" : "MetaModel", "metaModelMd" : { "calculationChain" : { "its" : { "Item" : { "k" : "1", "type" : "Variable" } } } } } } } } }
{ "SetMsResult" : { "id" : { "id" : "CEOHFIGABHNBFOAEACLDIHAAFIBLHLNEJJHHIHEGOIMCAOGA!M!S!CPOKJBJGABHNBFOAEFABNMBGBLLNHOPAEHKDKCJFDLLMFBFKJ" } } }
The SetMsDelVar function deletes the specified variable from the model. Input parameters:
ms. Opened modeling container instance.
metaKey. Key of the metamodel that contains the variable.
varKeyDel. Variable key.
After execution the function returns the instance of opened modeling container without the specified variable.
public static MsId SetMsDelVar(MsId ms, ulong metaKey, ulong varKeyDel) { var setMsOp = new SetMs(); setMsOp.tMs = ms; setMsOp.tArg = new SetMsArg() { // Set data change pattern pattern = new MsMdPattern() { item = new MsItemPattern() { key = metaKey, metaModel = new MsMetaModelPattern() { calculationChain = ListOperation.Remove } } }, // Set data that must be changed meta = new MsMd() { item = new MsItem() { k = metaKey, type = MsItemType.MetaModel, metaModelMd = new MsMetaModel() { calculationChain = new MsCalculationChainEntries() { its = new MsCalculationChainEntry[] { new MsCalculationChainEntry() { k = varKeyDel, type = MsCalculationChainType.Variable } } } } } } }; // Create a proxy object for operation execution var somClient = new SomPortTypeClient(); // Set operation execution parameters var result = somClient.SetMs(setMsOp); return result.id; }
See also: