DynamoDS / DynamoRevit

Dynamo Libraries for Revit
https://dynamobim.org
342 stars 188 forks source link

Dynamo player destroys graphs #2691

Open dimven opened 3 years ago

dimven commented 3 years ago

Dynamo version

2.6.1

Revit version

2021

Operating system

Win 10

What did you do?

Ran a nicely laid out and grouped graph through dynamo player

What did you expect to see?

The same.

What did you see instead?

This POS: image

~100 nodes on top of each other and no more groups 🤦

And no, the auto node layout (Ctrl + L) is not a solution, because it's oblivious to the logical grouping of the nodes.

Bonus points:

Now the code blocks are broken too image

mjkkirschner commented 3 years ago

Hey @dimven - can you describe your workflow a bit more - maybe some background will help get to the bottom of it.

Especially given the failure to load the codeblock view - this appears to be some kind of datarace or view layer conflict - Do you have lots of addins and packages installed? (I'll assume yes?)

I think getting the list of loaded modules when this occurs, and maybe a gif of your workflow will help us understand whats going on.

https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls can be used if you don't have visual studio on this machine.

dimven commented 3 years ago

The only plugin I have on the Revit side is RevitLookup. However I do have a bunch of packages and a few view extensions in Dynamo: image

I dug through the logs from yesterday and this part stood out:

2021-04-16 09:08:33Z : Active view is now FSSD-_3D MODEL
2021-04-16 09:08:36Z : Failed to apply NodeViewCustomization for CodeBlockNodeModel
2021-04-16 09:08:36Z : System.NullReferenceException:
2021-04-16 09:08:36Z : Object reference not set to an instance of an object.
2021-04-16 09:08:36Z :    at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateClassHighlightRule(EngineController engineController)
   at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateHighlightingRules(TextEditor editor, EngineController controller)
   at Dynamo.UI.Controls.CodeBlockEditor..ctor(NodeView nodeView)
   at Dynamo.Wpf.CodeBlockNodeViewCustomization.CustomizeView(CodeBlockNodeModel model, NodeView nodeView)
   at lambda_method(Closure , NodeModel , NodeView )
   at Dynamo.Wpf.NodeViewCustomizationLibrary.TryApplyCustomization(NodeModel model, NodeView view, InternalNodeViewCustomization customization)
2021-04-16 09:08:36Z : Failed to apply NodeViewCustomization for CodeBlockNodeModel
2021-04-16 09:08:36Z : System.NullReferenceException:
2021-04-16 09:08:36Z : Object reference not set to an instance of an object.
2021-04-16 09:08:36Z :    at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateClassHighlightRule(EngineController engineController)
   at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateHighlightingRules(TextEditor editor, EngineController controller)
   at Dynamo.UI.Controls.CodeBlockEditor..ctor(NodeView nodeView)
   at Dynamo.Wpf.CodeBlockNodeViewCustomization.CustomizeView(CodeBlockNodeModel model, NodeView nodeView)
   at lambda_method(Closure , NodeModel , NodeView )
   at Dynamo.Wpf.NodeViewCustomizationLibrary.TryApplyCustomization(NodeModel model, NodeView view, InternalNodeViewCustomization customization)
2021-04-16 09:08:36Z : Failed to apply NodeViewCustomization for CodeBlockNodeModel
2021-04-16 09:08:36Z : System.NullReferenceException:
2021-04-16 09:08:36Z : Object reference not set to an instance of an object.
2021-04-16 09:08:36Z :    at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateClassHighlightRule(EngineController engineController)
   at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateHighlightingRules(TextEditor editor, EngineController controller)
   at Dynamo.UI.Controls.CodeBlockEditor..ctor(NodeView nodeView)
   at Dynamo.Wpf.CodeBlockNodeViewCustomization.CustomizeView(CodeBlockNodeModel model, NodeView nodeView)
   at lambda_method(Closure , NodeModel , NodeView )
   at Dynamo.Wpf.NodeViewCustomizationLibrary.TryApplyCustomization(NodeModel model, NodeView view, InternalNodeViewCustomization customization)
2021-04-16 09:08:36Z : Failed to apply NodeViewCustomization for CodeBlockNodeModel
2021-04-16 09:08:36Z : System.NullReferenceException:
2021-04-16 09:08:36Z : Object reference not set to an instance of an object.
2021-04-16 09:08:36Z :    at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateClassHighlightRule(EngineController engineController)
   at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateHighlightingRules(TextEditor editor, EngineController controller)
   at Dynamo.UI.Controls.CodeBlockEditor..ctor(NodeView nodeView)
   at Dynamo.Wpf.CodeBlockNodeViewCustomization.CustomizeView(CodeBlockNodeModel model, NodeView nodeView)
   at lambda_method(Closure , NodeModel , NodeView )
   at Dynamo.Wpf.NodeViewCustomizationLibrary.TryApplyCustomization(NodeModel model, NodeView view, InternalNodeViewCustomization customization)
2021-04-16 09:08:36Z : Failed to apply NodeViewCustomization for CodeBlockNodeModel
2021-04-16 09:08:36Z : System.NullReferenceException:
2021-04-16 09:08:36Z : Object reference not set to an instance of an object.
2021-04-16 09:08:36Z :    at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateClassHighlightRule(EngineController engineController)
   at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateHighlightingRules(TextEditor editor, EngineController controller)
   at Dynamo.UI.Controls.CodeBlockEditor..ctor(NodeView nodeView)
   at Dynamo.Wpf.CodeBlockNodeViewCustomization.CustomizeView(CodeBlockNodeModel model, NodeView nodeView)
   at lambda_method(Closure , NodeModel , NodeView )
   at Dynamo.Wpf.NodeViewCustomizationLibrary.TryApplyCustomization(NodeModel model, NodeView view, InternalNodeViewCustomization customization)
2021-04-16 09:08:36Z : Failed to apply NodeViewCustomization for CodeBlockNodeModel
2021-04-16 09:08:36Z : System.NullReferenceException:
2021-04-16 09:08:36Z : Object reference not set to an instance of an object.
2021-04-16 09:08:36Z :    at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateClassHighlightRule(EngineController engineController)
   at Dynamo.Wpf.Views.CodeHighlightingRuleFactory.CreateHighlightingRules(TextEditor editor, EngineController controller)
   at Dynamo.UI.Controls.CodeBlockEditor..ctor(NodeView nodeView)
   at Dynamo.Wpf.CodeBlockNodeViewCustomization.CustomizeView(CodeBlockNodeModel model, NodeView nodeView)
   at lambda_method(Closure , NodeModel , NodeView )
   at Dynamo.Wpf.NodeViewCustomizationLibrary.TryApplyCustomization(NodeModel model, NodeView view, InternalNodeViewCustomization customization)
2021-04-16 09:08:48Z : DynamoPackageManager (id: FCABC211-D56B-4109-AF18-F434DFE48139) extension is removed
2021-04-16 09:08:48Z : Goodbye

I suspect the issue was from the Monocle view extension. I updated it and can't replicate the issue any more. I think I was on the 2020.10.1 version prior to the update. It comes with a version of the Xceed Toolkit and so do Dynamo and Revit. My best guess is this was creating a version conflict and the update resolved it.

Isn't there a better way to avoid these issues? Do you know of any event similar to AppDomain.AssemblyLoad or AppDomain.AssemblyResolve that triggers before the load and can check if an assembly with that name is already loaded and use it instead?

The weird thing here was that this issue only occurred after using player. Running dynamo as usual showed no problems whatsoever.

Regarding the workflow, I didn't do anything peculiar.

louistrue commented 3 years ago

Happened to me too a few days ago. Used Dynamo Player, then opened graph directly from Player. All nodes in one place, no groups. Also have monocle installed. Closing Revit and reopening the graph in a new revit session resolved the issue for me. Everything went back to normal.

johnpierson commented 3 years ago

I suspect the issue was from the Monocle view extension. I updated it and can't replicate the issue any more. I think I was on the 2020.10.1 version prior to the update. It comes with a version of the Xceed Toolkit and so do Dynamo and Revit. My best guess is this was creating a version conflict and the update resolved it.

The previous version might have still had the Custom Node coloring feature I had before. I removed that recently as I did not like how it iterated through the node views. Do you think the view extension could have been doing this? I have seen similar errors before with graphs "stacking" nodes, (before monocle existed in some cases).

BeeBeePrime commented 2 months ago

Here's an improved version of your text: Subject: Reproducible Issue: Dynamo Graph Destruction in Revit Hello Dynamo Team, I'm not sure if anyone is still investigating this issue, but I've managed to reproduce it on my end. This information may help you identify the root cause.

Steps to Reproduce:

  1. Open an instance of Dynamo in Revit.

  2. Use a .NET plugin in Revit. One of the buttons runs a Dynamo script in the background. Here's the relevant method from my C# command class:

    public class MyPlugin : IExternalCommand
    {
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        // Get the path to the Dynamo script
        string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
        string projectDirectory = Path.GetDirectoryName(assemblyLocation);
        string scriptPath = Path.Combine(projectDirectory, "DynamoLibrary", "ExportFieldMarkers.dyn");
        return ExecuteDynamo(commandData.Application, scriptPath);
    }
    
    public Result ExecuteDynamo(UIApplication uiapp, string path)
    {
        try
        {
            if (!System.IO.File.Exists(path))
            {
                return Result.Failed;
            }
            IDictionary<string, string> journalData = new Dictionary<string, string>
            {
                { JournalKeys.ShowUiKey, false.ToString() },
                { JournalKeys.AutomationModeKey, true.ToString() },
                { JournalKeys.DynPathKey, "" },
                { JournalKeys.DynPathExecuteKey, true.ToString() },
                { JournalKeys.ForceManualRunKey, false.ToString() },
                { JournalKeys.ModelShutDownKey, true.ToString() },
                { JournalKeys.ModelNodesInfo, false.ToString() }
            };
            DynamoRevitCommandData dynamoRevitCommandData = new DynamoRevitCommandData
            {
                Application = uiapp,
                JournalData = journalData
            };
            DynamoRevit dynamoRevit = new DynamoRevit();
            dynamoRevit.ExecuteCommand(dynamoRevitCommandData);
            DynamoRevit.RevitDynamoModel.OpenFileFromPath(path, true);
            DynamoRevit.RevitDynamoModel.ForceRun();
            return Result.Succeeded;
        }
        catch (Exception)
        {
            return Result.Failed;
        }
    }
    }
  3. Run the button.

Result: The Dynamo graph is destroyed. This occurs in both Revit 2021 and Revit 2023. tv0BgMdD93 I hope this information helps in your investigation. Please let me know if you need any additional details or clarification. Best regards,