本文整理汇总了C#中Dynamo.Models.DynamoModel.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# DynamoModel.ExecuteCommand方法的具体用法?C# DynamoModel.ExecuteCommand怎么用?C# DynamoModel.ExecuteCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Models.DynamoModel
的用法示例。
在下文中一共展示了DynamoModel.ExecuteCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunCommandLineArgs
private static XmlDocument RunCommandLineArgs(DynamoModel model, StartupUtils.CommandLineArguments cmdLineArgs)
{
var evalComplete = false;
if (string.IsNullOrEmpty(cmdLineArgs.OpenFilePath))
{
return null;
}
if (!(string.IsNullOrEmpty(cmdLineArgs.CommandFilePath)))
{
Console.WriteLine("commandFilePath option is only available when running DynamoSandbox, not DynamoCLI");
}
model.OpenFileFromPath(cmdLineArgs.OpenFilePath, true);
Console.WriteLine("loaded file");
model.EvaluationCompleted += (o, args) => { evalComplete = true; };
if (!string.IsNullOrEmpty(cmdLineArgs.PresetFilePath))
{
//first load the openfile nodegraph
var originalGraphdoc = XmlHelper.CreateDocument("tempworkspace");
originalGraphdoc.Load(cmdLineArgs.OpenFilePath);
var graph = NodeGraph.LoadGraphFromXml(originalGraphdoc, model.NodeFactory);
//then load the presetsfile nodegraph (this should only contain presets),
var presetsDoc = XmlHelper.CreateDocument("presetstempworkspace");
presetsDoc.Load(cmdLineArgs.PresetFilePath);
//when we load the presets we need to pass in the nodeModels from the original graph
var presets = NodeGraph.LoadPresetsFromXml(presetsDoc, graph.Nodes);
//load the presets contained in the presetsfile into the workspace,
model.CurrentWorkspace.ImportPresets(presets);
}
//build a list of states, for now, none, a single state, or all of them
//this must be done after potentially loading states from external file
var stateNames = new List<String>();
if (!string.IsNullOrEmpty(cmdLineArgs.PresetStateID))
{
if (cmdLineArgs.PresetStateID == "all")
{
foreach (var state in model.CurrentWorkspace.Presets)
{
stateNames.Add(state.Name);
}
}
else
{
stateNames.Add(cmdLineArgs.PresetStateID);
}
}
else
{
stateNames.Add("default");
}
var outputresults = new List<Dictionary<Guid, List<object>>>();
XmlDocument doc = null;
foreach (var stateName in stateNames)
{
Guid stateGuid = Guid.Empty;
var state = model.CurrentWorkspace.Presets.Where(x => x.Name == stateName).FirstOrDefault();
if (state != null)
{
stateGuid = state.GUID;
}
model.ExecuteCommand(new DynamoModel.ApplyPresetCommand(model.CurrentWorkspace.Guid, stateGuid));
model.ExecuteCommand(new DynamoModel.RunCancelCommand(false, false));
while (evalComplete == false)
{
Thread.Sleep(250);
}
//if verbose was true, then print all nodes to the console
if (!String.IsNullOrEmpty(cmdLineArgs.Verbose))
{
doc = new XmlDocument();
var resultsdict = new Dictionary<Guid, List<object>>();
foreach (var node in model.CurrentWorkspace.Nodes)
{
var portvalues = new List<object>();
foreach (var port in node.OutPorts)
{
var value = node.GetValue(port.Index, model.EngineController);
if (value.IsCollection)
{
portvalues.Add(GetStringRepOfCollection(value));
}
else
{
portvalues.Add(value.StringData);
}
}
resultsdict.Add(node.GUID, portvalues);
}
outputresults.Add(resultsdict);
populateXmlDocWithResults(doc, outputresults);
}
evalComplete = false;
//.........这里部分代码省略.........