Below is the example of using the GetMs operation to search for a model factor. The request contains an instance of opened modeling container, data extraction pattern and the data slice that corresponds to the required factor. The response contains factor key and key of the model that includes this factor.
{ "Envelope" : { "Body" : { "GetMs" : { "tMs" : { "id" : "S27!M!S!C1"
}, "tArg" : { "pattern" : { "obInst" : "true", "item" : { "key" : "2803", "problem" :
{ "metamodel" : { "tag" : "false", "visualControllerPattern" : "" } } } }, "execParams" :
{ "slice" : { "k" : "0", "id" : "261", "n" : "MyInputVavable", "vis" : "true", "variableKey" : "5156", "stubKey" : "2805", "selections" :
{ "its" : { "Item" : { "id" : { "id" : "2818" }, "variant" : "261"
} } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : {
"dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295",
"unitsDimensionKey" : "0" }, "level" : "None" }, "execGetFactorByVariable" : "true" } } } } } }
{ "Envelope" : { "Body" : { "GetMsResult" : { "id" : { "id" : "S27!M!S!C1"
}, "meta" : { "obInst" : { "obDesc" : { "@isShortcut" : "0", "i" : "MODELSPACE", "n" : "Modeling container",
"k" : "1581", "c" : "5121", "p" : "1580", "h" : "0" } }, "dirty" : "0", "item" : { "k" : "2803",
"id" : "TEMP_MODEL", "n" : "TEMP_MODEL", "vis" : "1", "type" : "Problem", "problemMd" : { "metamodel" : { "k" : "2804", "visualController" :
{ "factorKey" : "10095" } } } } } } } } }
The GetMsFactorByVarable function searches in the model for a factor that corresponds to the specified data slice. Input parameters:
ms. Instance of the opened modeling container.
modelKey. Model key.
slice. Data slice.
After execution the function returns key of the factor that is also displayed in the console window.
public static ulong? GetMsFactorByVarable(MsId ms, ulong modelKey, MsFormulaTransformSlice slice) { var getMsOp = new GetMs(); getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() { // Set data change pattern pattern = new MsMdPattern() { item = new MsItemPattern() { key = modelKey, problem = new MsProblemPattern() { metamodel = new MsMetaModelPattern() { tag = false, visualControllerPattern = new MsMetaModelVisualControllerPattern() { } } } } }, execParams = new MsMdExecParams() { slice = slice, execGetFactorByVariable = true } }; // Create proxy object for operation execution var somClient = new SomPortTypeClient(); // Set operation execution parameters var result = somClient.GetMs(getMsOp); MsMetaModelVisualController metaVC = result.meta.item.problemMd.metamodel.visualController; ulong fc = metaVC.factorKey; if (fc != null) {Console.WriteLine("Factor key: " + fc);}; return fc; }
See also: