Dynamo and IronPython - incompatibilities with other applications

The Dynamo team recently became aware of some reports that python in Rhino 6 was not functioning on some machines with Dynamo installed.
like this one

We’ve added some information to the Dynamo FAQ wiki entry, and would like to share it here as well in case you run into a similar problem.

we’ll also be posting a short blog post on this info.

3 Likes

Tried the instructions (i.e. disable GAC, copy dll), I get another error.
image

Could not load file or assembly 'IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=7f709c5b713576e1' or one of its dependencies. The system cannot find the file specified.

   at Dynamo.Python.IronPythonCompletionProvider..ctor()
   at PythonNodeModelsWpf.ScriptEditorWindow..ctor(DynamoViewModel dynamoViewModel)
   at PythonNodeModelsWpf.PythonNodeViewCustomization.EditScriptContent()
   at PythonNodeModelsWpf.PythonNodeViewCustomization.view_MouseDown(Object sender, MouseButtonEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

image

Hi @SpencerMAQ thanks for trying out the steps - we have not been able to reproduce this crash, but a similar issue was seen with the original post linked above. Can you tell me about your system?

  • version of revit?
  • version of Dynamo
  • Windows version?
  • Can you post a screen shot of your Dynamo Install directory - where you copied the IronPython.Modules.dll

you might also try copying all the dlls from the ironPython install folder:
ironPython, Microsoft.Scripting, Microsoft.Dynamic,IronPython.Modules, into your dynamoCore install directory.

I would like to get to the bottom of this.

1 Like

Revit 2018
Dynamo 1.3.1.1736
Windows 10

Looks like copying the other dlls worked. Not sure though if it was just the dlls that solved the problem because there seemed to be some sort of error when I didn’t copy their XMLs. After copying their corresponding XMLs, python works again.
Not really sure though if this is due to the XMLs.

Hi @SpencerMAQ actually, I can now reproduce this, it looks like the 1.x installers before our latest internal one are not delivering IronPython.dll or some of the other ironPython deps to the dynamo core installation folder.

I recreated your crash and fixed it by copying:

  • IronPython.dll
  • IronPython.Modules.dll
  • Microsoft.Scripting.dll
  • Microsoft.Scripting.MetaData.dll
  • Microsoft.Dynamic.dll

to my 1.3 dynamoCore folder.

I don’t think the xmls should matter -
Please make sure Revit is closed before copying these files over and thanks for your report.

2 Likes

I’m not sure if this is the correct place, so I apologize and remove if needed.

I’ve installed both 1.3.2 and 2.0.0 on my machine and after several hours of testing have determined that as soon as 2.0.0 is installed python scripts in both version seem to fail due to an IronPython Elevator operation Fail. The scripts are working fine in version 1.3.2 prior to the installation of 2.0.0. Also after uninstalling 2.0.0 and opening the scripts in 1.3.2 the python scripts fail.

@Nick.sipes not enough information to help. The Dynamo 2.0 installer installs the same version of ironPython as 1.3. but it also installed some missing dependencies into the dynamo core 2.0 folder, it shouldn’t have modified your existing 1.3.2 installer it’s possible it corrupted your python install though.

Maybe try repairing the ironPython installation under control panel.

What is the actual error you get?

@Michael_Kirschner2 Michael, thanks for the input.

I tried repairing and even uninstalling and reinstalling IronPython 2.7.3. None of this solved the error. Also, like I said the script works fine in Dynamo 1.3.2 fine prior to installing 2.0.0 on the same computer. Here is the script for download if you would like. Sheet Creation from Excel v1.0.dyn (45.1 KB)

The error vary slightly depending on the python script, but they are all tracing back to clr functions. Below is one example, I can post another if that would help.

The tests were run on Revit 2018.3 and window 10. I can test on Revit 2017 and 2016 if that would help.<a

Error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 6, in
IOError: System.IO.IOException: Could not add reference to assembly RevitServices
at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)
at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object references)
at Microsoft.Scripting.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Microsoft.Scripting.Interpreter.DynamicInstruction4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at DSIronPython.IronPythonEvaluator.EvaluateIronPythonScript(String code, IList bindingNames, IList bindingValues)

Here is the code for that node: (line 6 is “clr.AddReference(“RevitServices”)”)

import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

cats = IN[0]
doc = DocumentManager.Instance.CurrentDBDocument
elementlist = list()

for item in cats:
	collector = FilteredElementCollector(doc)
	collector.OfClass(FamilySymbol)
	bic = System.Enum.ToObject(BuiltInCategory, item.Id)
	collector.OfCategory(bic)
	elementlist.append(collector.ToElements())
OUT = elementlist

hmm @Nick.sipes please start a separate thread for this issue and ping me there, I think this may have to do with the upgraded .net version of the dynamoRevit assemblies in dynamo 2.x.

you can try specifying a direct path to the dll instead of just the name to make sure you are loading the right version. Also what version of revit are you running this in? Ah I see 2018.3 - yes please try in 2017 as well.

@Michael_Kirschner2 @Nick.sipes I will try and reproduce this issue. Will send an update when I find anything concrete. In the mean time, if you have any relevant information that will help me reproduce this issue, please send it my way.
Thanks,
Sid

Hi,

I’m experiencing the same problems. After installing Dynamo 2.0.0 the python scripts don’t work any more. For both versions Dynamo 2.0.0 and Dynamo 1.3.2.

I’m running Revit 2018.2 and 2017.

Please let me known if there’s any solution.

P.S. well actually the do work, but wen i try to open the script in dynamo then dynamo fails.

Greets Tim.

Object reference not set to an instance of an object.

at System.Windows.Baml2006.Baml2006Reader.Process_PropertyWithConverter()
at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
at System.Windows.Baml2006.Baml2006Reader.Process_BamlRecords()
at System.Windows.Baml2006.Baml2006Reader.Read()
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at PythonNodeModelsWpf.ScriptEditorWindow…ctor(DynamoViewModel dynamoViewModel, PythonNode nodeModel, NodeView nodeView, WindowRect& windowRect)
at PythonNodeModelsWpf.PythonNodeViewCustomization.EditScriptContent()
at PythonNodeModelsWpf.PythonNodeViewCustomization.view_MouseDown(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Hi @Tim_Lugtenburg do you have pyRevit installed?
Have you tried the suggested fix at the top of this post to uninstall the GAC entries for python and copy the dlls to the dynamo folder?

You may also want to try looking at the green notifications tab dynamo menu - if the error persists please file a github issue. I have tracked your issue internally as well but the github issue will make communication easier.

Hi,

Yes, i have pyRevit installed for 2017.

Yes, i uninstalled pyRevit and copied the dll files and that fixed it.

Thanx,.