/// <summary> /// Sets the Current selection /// </summary> /// <param name="model"></param> public static void KeepSelection(DynamoModel model) { foreach (dynamic item in model.CurrentWorkspace.CurrentSelection) { model.AddToSelection(item); } }
public void MAGN_5029_CopyPasteWarning() { // Details are available in defect // http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5029 // Cutting and pasting Curve.PointAtParameter in run automatically // causes "variable has not yet been defined" warning message DynamoModel model = ViewModel.Model; string openPath = Path.Combine(TestDirectory, @"core\WorkflowTestFiles\\GeometryDefects\MAGN_5029_CopyPasteWarning.dyn"); RunModel(openPath); AssertNoDummyNodes(); // check all the nodes and connectors are loaded Assert.AreEqual(4, model.CurrentWorkspace.Nodes.Count); Assert.AreEqual(5, model.CurrentWorkspace.Connectors.Count()); //CGet Curve.PointAtParameter node and copy paste it. string nodeID = "de3e5067-d7e2-4e47-aca3-7f2531614892"; var pointAtParameterNode = model.CurrentWorkspace.NodeFromWorkspace(nodeID); // Copy and paste the PointAtParameter Node model.AddToSelection(pointAtParameterNode); model.Copy(); // Copy the selected node. model.Paste(); // Paste the copied node. RunCurrentModel(); // check all the nodes and connectors are updated Assert.AreEqual(5, model.CurrentWorkspace.Nodes.Count); Assert.AreEqual(7, model.CurrentWorkspace.Connectors.Count()); // Make sure we are able to get copy pasted PointAtParameter node. var newPointAtPArameterNode = model.CurrentWorkspace.Nodes[4]; var guid = newPointAtPArameterNode.GUID.ToString(); // Checking there is no Warning or Error on node after copy paste. Assert.AreNotEqual(ElementState.Error, newPointAtPArameterNode.State); Assert.AreNotEqual(ElementState.Warning, newPointAtPArameterNode.State); AssertPreviewCount(guid, 10); for (int i = 0; i <= 9; i++) { var extractedCurves = GetPreviewValueAtIndex(guid, i) as Point; Assert.IsNotNull(extractedCurves); } }