From def94160b9aa813ea2e43baca67353dd54f2b42c Mon Sep 17 00:00:00 2001 From: Laurence Elsdon Date: Tue, 1 Dec 2020 18:03:13 +0000 Subject: [PATCH] Exclude all LacingStrategy.Disabled nodes from SetArgumentLacing --- .../ViewModels/Core/WorkspaceViewModel.cs | 2 +- .../WorkspaceGeneralOperations.cs | 18 +++++-- ...ckNodes.dyn => LacingStrategyDisabled.dyn} | 51 ++++++++++++++++++- 3 files changed, 65 insertions(+), 6 deletions(-) rename test/core/visualization/{LacingStrategyCodeBlockNodes.dyn => LacingStrategyDisabled.dyn} (77%) diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index 2100a2f4e6e..ac6161c9fcb 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -1128,7 +1128,7 @@ private void SetArgumentLacing(object parameter) { var modelGuids = DynamoSelection.Instance.Selection .OfType() - .Where(n => !(n is CodeBlockNodeModel)) + .Where(n => n.ArgumentLacing != LacingStrategy.Disabled) .Select(n => n.GUID); if (!modelGuids.Any()) diff --git a/test/DynamoCoreWpfTests/WorkspaceGeneralOperations.cs b/test/DynamoCoreWpfTests/WorkspaceGeneralOperations.cs index 00f4c890062..d840bc2e820 100644 --- a/test/DynamoCoreWpfTests/WorkspaceGeneralOperations.cs +++ b/test/DynamoCoreWpfTests/WorkspaceGeneralOperations.cs @@ -115,19 +115,22 @@ public void VerifyGlobalLacingStrategyUpdatesForLacingStrategies() } [Test] - public void VerifyLacingStrategyCantBeChangedOnCodeBlocks() + public void VerifyLacingStrategyDisabledCantBeChanged() { // Arrange - var openPath = Path.Combine(TestDirectory, @"core\visualization\LacingStrategyCodeBlockNodes.dyn"); + var openPath = Path.Combine(TestDirectory, @"core\visualization\LacingStrategyDisabled.dyn"); ViewModel.OpenCommand.Execute(openPath); var workspace = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel; Guid codeBlockNodeId = Guid.Parse("5a35517215434699afe122bc51aeff7d"); + Guid pythonNodeId = Guid.Parse("cd679ac2203f42c18b30e44bb6c5238e"); Guid typicalNodeId = Guid.Parse("ab8afb7c1dfe4dd0994662f3306fc530"); var codeBlockNode = workspace.NodeFromWorkspace(codeBlockNodeId); + var pythonNode = workspace.NodeFromWorkspace(pythonNodeId); var typicalNode = workspace.NodeFromWorkspace(typicalNodeId); - // Verify initial lacing state is Auto and nodes return correct number of results + // Verify initial lacing state is Auto var codeBlockNodeLacingStart = codeBlockNode.ArgumentLacing; + var pythonNodeLacingStart = pythonNode.ArgumentLacing; var typicalNodeLacingStart = typicalNode.ArgumentLacing; // Act @@ -136,36 +139,45 @@ public void VerifyLacingStrategyCantBeChangedOnCodeBlocks() ViewModel.CurrentSpaceViewModel.SelectAllCommand.Execute(null); ViewModel.CurrentSpaceViewModel.SetArgumentLacingCommand.Execute(LacingStrategy.Longest.ToString()); var codeBlockNodeLacingLongest = codeBlockNode.ArgumentLacing; + var pythonNodeLacingLongest = pythonNode.ArgumentLacing; var typicalNodeLacingLongest = typicalNode.ArgumentLacing; // Modify lacing strategy to Auto ViewModel.CurrentSpaceViewModel.SelectAllCommand.Execute(null); ViewModel.CurrentSpaceViewModel.SetArgumentLacingCommand.Execute(LacingStrategy.Auto.ToString()); var codeBlockNodeLacingAuto = codeBlockNode.ArgumentLacing; + var pythonNodeLacingAuto = pythonNode.ArgumentLacing; var typicalNodeLacingAuto = typicalNode.ArgumentLacing; // Modify lacing strategy to CrossProduct ViewModel.CurrentSpaceViewModel.SelectAllCommand.Execute(null); ViewModel.CurrentSpaceViewModel.SetArgumentLacingCommand.Execute(LacingStrategy.CrossProduct.ToString()); var codeBlockNodeLacingCross = codeBlockNode.ArgumentLacing; + var pythonNodeLacingCross = pythonNode.ArgumentLacing; var typicalNodeLacingCross = typicalNode.ArgumentLacing; // Change lacing back to Shortest ViewModel.CurrentSpaceViewModel.SelectAllCommand.Execute(null); ViewModel.CurrentSpaceViewModel.SetArgumentLacingCommand.Execute(LacingStrategy.Shortest.ToString()); var codeBlockNodeLacingShortest = codeBlockNode.ArgumentLacing; + var pythonNodeLacingShortest = pythonNode.ArgumentLacing; var typicalNodeLacingShortest = typicalNode.ArgumentLacing; // Assert Assert.AreEqual(LacingStrategy.Disabled, codeBlockNodeLacingStart); + Assert.AreEqual(LacingStrategy.Disabled, pythonNodeLacingStart); Assert.AreEqual(LacingStrategy.Auto, typicalNodeLacingStart); Assert.AreEqual(LacingStrategy.Disabled, codeBlockNodeLacingLongest); + Assert.AreEqual(LacingStrategy.Disabled, pythonNodeLacingLongest); Assert.AreEqual(LacingStrategy.Longest, typicalNodeLacingLongest); Assert.AreEqual(LacingStrategy.Disabled, codeBlockNodeLacingAuto); + Assert.AreEqual(LacingStrategy.Disabled, pythonNodeLacingAuto); Assert.AreEqual(LacingStrategy.Auto, typicalNodeLacingAuto); Assert.AreEqual(LacingStrategy.Disabled, codeBlockNodeLacingCross); + Assert.AreEqual(LacingStrategy.Disabled, pythonNodeLacingCross); Assert.AreEqual(LacingStrategy.CrossProduct, typicalNodeLacingCross); Assert.AreEqual(LacingStrategy.Disabled, codeBlockNodeLacingShortest); + Assert.AreEqual(LacingStrategy.Disabled, pythonNodeLacingShortest); Assert.AreEqual(LacingStrategy.Shortest, typicalNodeLacingShortest); } diff --git a/test/core/visualization/LacingStrategyCodeBlockNodes.dyn b/test/core/visualization/LacingStrategyDisabled.dyn similarity index 77% rename from test/core/visualization/LacingStrategyCodeBlockNodes.dyn rename to test/core/visualization/LacingStrategyDisabled.dyn index 08f404b7344..488634c46bb 100644 --- a/test/core/visualization/LacingStrategyCodeBlockNodes.dyn +++ b/test/core/visualization/LacingStrategyDisabled.dyn @@ -2,7 +2,7 @@ "Uuid": "3c9d0464-8643-5ffe-96e5-ab1769818209", "IsCustomNode": false, "Description": "", - "Name": "DYN-2381 CBN Lacing Multiplication", + "Name": "LacingStrategyDisabled", "ElementResolver": { "ResolutionMap": {} }, @@ -126,6 +126,38 @@ ], "Replication": "Disabled", "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", + "NodeType": "PythonScriptNode", + "Code": "# Load the Python Standard and DesignScript Libraries\r\nimport sys\r\nimport clr\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n\r\n# The inputs to this node will be stored as a list in the IN variables.\r\ndataEnteringNode = IN\r\n\r\n# Place your code below this line\r\n\r\n# Assign your output to the OUT variable.\r\nOUT = 0", + "Engine": "CPython3", + "VariableInputPorts": true, + "Id": "cd679ac2203f42c18b30e44bb6c5238e", + "Inputs": [ + { + "Id": "dfdfb4ccd98144ce9c2fe4e0df0e7b5b", + "Name": "IN[0]", + "Description": "Input #0", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "71f838eee0e44ddcbedaf5623e447614", + "Name": "OUT", + "Description": "Result of the python script", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Runs an embedded Python script." } ], "Connectors": [ @@ -139,6 +171,11 @@ "End": "c926eafa523143eba0a5b186828cdc0f", "Id": "f1f8c13bcb9b456cbf1b39fa466f7945" }, + { + "Start": "4e373052d56644dc93483c5a4138cdbb", + "End": "dfdfb4ccd98144ce9c2fe4e0df0e7b5b", + "Id": "70a4225c53e94be0a0eaa875206bc740" + }, { "Start": "d5d76f7e2f5946ed922f32b38298252a", "End": "4cc2d7cc1a4944a6aa1aef91cdefaa2d", @@ -158,7 +195,7 @@ "ScaleFactor": 1.0, "HasRunWithoutCrash": true, "IsVisibleInDynamoLibrary": true, - "Version": "2.8.0.2471", + "Version": "2.10.0.3355", "RunType": "Automatic", "RunPeriod": "1000" }, @@ -214,6 +251,16 @@ "Excluded": false, "X": 699.0, "Y": 513.2 + }, + { + "ShowGeometry": true, + "Name": "Python Script", + "Id": "cd679ac2203f42c18b30e44bb6c5238e", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 696.00000000000023, + "Y": 667.19999999999993 } ], "Annotations": [],