Skip to content

Commit

Permalink
Exclude all LacingStrategy.Disabled nodes from SetArgumentLacing
Browse files Browse the repository at this point in the history
  • Loading branch information
StudioLE committed Dec 1, 2020
1 parent 3dde853 commit def9416
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ private void SetArgumentLacing(object parameter)
{
var modelGuids = DynamoSelection.Instance.Selection
.OfType<NodeModel>()
.Where(n => !(n is CodeBlockNodeModel))
.Where(n => n.ArgumentLacing != LacingStrategy.Disabled)
.Select(n => n.GUID);

if (!modelGuids.Any())
Expand Down
18 changes: 15 additions & 3 deletions test/DynamoCoreWpfTests/WorkspaceGeneralOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Uuid": "3c9d0464-8643-5ffe-96e5-ab1769818209",
"IsCustomNode": false,
"Description": "",
"Name": "DYN-2381 CBN Lacing Multiplication",
"Name": "LacingStrategyDisabled",
"ElementResolver": {
"ResolutionMap": {}
},
Expand Down Expand Up @@ -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": [
Expand All @@ -139,6 +171,11 @@
"End": "c926eafa523143eba0a5b186828cdc0f",
"Id": "f1f8c13bcb9b456cbf1b39fa466f7945"
},
{
"Start": "4e373052d56644dc93483c5a4138cdbb",
"End": "dfdfb4ccd98144ce9c2fe4e0df0e7b5b",
"Id": "70a4225c53e94be0a0eaa875206bc740"
},
{
"Start": "d5d76f7e2f5946ed922f32b38298252a",
"End": "4cc2d7cc1a4944a6aa1aef91cdefaa2d",
Expand All @@ -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"
},
Expand Down Expand Up @@ -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": [],
Expand Down

0 comments on commit def9416

Please sign in to comment.