"Could not add reference to assembly RevitServices" Dynamo python error


#1

Hi, I finally had a chance to test the latest Dynamo (but Dynamo Studio). I am interested in learning the basics of Dynamo Python node.

I tried to follow the two exercises for Dynamo Python, from official Primer. I got stuck on both Exercise 1 (getting document data) and Exercise 2 (creating a curve). The error messages are located at the end of this reply. I assume it maybe has something with the:

 

clr.AddReference(“RevitNodes”)

import Revit

 

Can Dynamo Studio even import Revit classes and methods? Here is the attached dynamo_python file.

I would be grateful for any kind of help.

Thank you.


Here is the error message I am getting for Exercise 1:

 
<div id=“yui_3_16_0_1_1452540696656_5819”>
<div id=“yui_3_16_0_1_1452540696656_5844”>Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.</div>
<div id=“yui_3_16_0_1_1452540696656_5843”>Traceback (most recent call last):</div>
<div id=“yui_3_16_0_1_1452540696656_5842”> File “<string>”, line 4, in <module></div>
<div id=“yui_3_16_0_1_1452540696656_5841”>IOError: System.IO.IOException: Could not add reference to assembly RevitNodes</div>
<div id=“yui_3_16_0_1_1452540696656_5840”> at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)</div>
<div id=“yui_3_16_0_1_1452540696656_5839”> at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object reference)</div>
<div id=“yui_3_16_0_1_1452540696656_5838”> at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)</div>
<div id=“yui_3_16_0_1_1452540696656_5818”> at Microsoft.Scripting.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5823"&gt; at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5824"&gt; at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5825"&gt; at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5826"&gt; at Microsoft.Scripting.Interpreter.DynamicInstruction4.Run(InterpretedFrame frame)</div>
<div id=“yui_3_16_0_1_1452540696656_5837”> at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)</div>
<div id=“yui_3_16_0_1_1452540696656_5827”> at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)</div>
<div id=“yui_3_16_0_1_1452540696656_5836”> at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)</div>
<div id=“yui_3_16_0_1_1452540696656_5835”> at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)</div>
<div id=“yui_3_16_0_1_1452540696656_5828”> at DSIronPython.IronPythonEvaluator.EvaluateIronPythonScript(String code, IList bindingNames, IList bindingValues)</div>
<div></div>
<div></div>
<div>And here is the one for Exercise 2:</div>
<div></div>
<div>
<div id=“yui_3_16_0_1_1452540696656_5860”>
<div id=“yui_3_16_0_1_1452540696656_5859”>Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.</div>
<div id=“yui_3_16_0_1_1452540696656_5861”>Traceback (most recent call last):</div>
<div id=“yui_3_16_0_1_1452540696656_5862”> File “<string>”, line 3, in <module></div>
<div id=“yui_3_16_0_1_1452540696656_5863”>IOError: System.IO.IOException: Could not add reference to assembly RevitServices</div>
<div id=“yui_3_16_0_1_1452540696656_5864”> at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)</div>
<div id=“yui_3_16_0_1_1452540696656_5865”> at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object reference)</div>
<div id=“yui_3_16_0_1_1452540696656_5866”> at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)</div>
<div id=“yui_3_16_0_1_1452540696656_5867”> at Microsoft.Scripting.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5868"&gt; at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5869"&gt; at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5870"&gt; at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)&lt;/div&gt; &lt;div id="yui_3_16_0_1_1452540696656_5871"&gt; at Microsoft.Scripting.Interpreter.DynamicInstruction4.Run(InterpretedFrame frame)</div>
<div id=“yui_3_16_0_1_1452540696656_5872”> at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)</div>
<div id=“yui_3_16_0_1_1452540696656_5873”> at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)</div>
<div id=“yui_3_16_0_1_1452540696656_5874”> at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)</div>
<div id=“yui_3_16_0_1_1452540696656_5875”> at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)</div>
<div id=“yui_3_16_0_1_1452540696656_5876”> at DSIronPython.IronPythonEvaluator.EvaluateIronPythonScript(String code, IList bindingNames, IList bindingValues)</div>
</div>
</div>
</div>
 


#2

Any help with this issue please?
How do Revit Dynamo methods differ from the Dynamo Studio ones?


#3

Hi George,

I am not sure if i understand you properly.

Dynamo is a visual programming extension for Autodesk Revit that allows you to manipulate data, sculpt geometry, explore design options, automate processes, and create links between multiple applications.

Read this for Dynamo Studio:

  1. http://dynamobim.org/what-is-autodesk-dynamo-studio/

  2. http://www.autodesk.com/products/dynamo-studio/features/all/gallery-view

Hope it helps!


#4

Hi Kulkul,

Thank you for the reply.

By “Revit Dynamo methods” I meant: “Revit Dynamo functions which are members of Revit Dynamo’s SDK classes”.

In the initial reply of this topic, I am trying to replicate first two Revit Dynamo Python exercise examples from the official Dynamo Primer.

However some kind of error message appears (on both Exercise 1 and Exercise 2). I would like to know what is the cause for these errors and whether or not the cause might be that Dynamo Studio does not support some of the methods (or classes, modules…), Revit Dynamo does. For example, the “RevitNodes” module?


#5

Hi George,

I have modified your dyn script dynamo_python. Try now it is working.

Following things which i noticed in your script:

  1. It is asking for reference points but you were feeding only points.

  2. You need to use this script in Mass family.

Good Luck!

 


#6

Thank you Kulkul,

When I open your dynamo file I get an information that your Dynamo file has been saved with more recent version of Dynamo then mine. When I try to open the dynamo file nevertheless, the following error message on “Reference Points” nodes:

Warning: Node of type 'Dynamo.Graph.Nodes.ZeroTouch.DSFunction' is now deprecated

When I check the version of my

 

 

Dynamo Studio, it says that it is up-date (Help->About):

0.9.0.3072 (up to date)
Does this mean that the most recent version of Dynamo Studio still lags behind the most recent version of Revit Dynamo?

#7

I am using Dynamo version 0.9. It seems your using older version of Dynamo for Revit. Install Dynamo version 0.9 for Revit then your good to go.


#8

Good day, George

As you guessed in your initial reply, Revit assemblies can only be accessed from Dynamo, when it is executed as a plugin from inside Revit.

Dynamo Studio does not have support for the Revit API on its own.


#9

@Kulkul: I can not install the latest Revit Dynamo, as I do not own Revit. I can only install the latest Dynamo Studio (0.9.0.3072). It looks like the latest Dynamo Studio version still lags behind the latest Revit Dynamo version (meaning Revit Dynamo has a newer version).

@Dimitar: Thank you for the explanation.
Would you mind checking the dynamo example from the upper initial reply?
What should the “Revit” module be replaced with in Dynamo Studio?
Is it even possible to replicate the Revit Dynamo Python examples in Dynamo Studio (by relying on some Dynamo Studio API instead of Revit API)?


#10

Make sure you’ve loaded the “ProtoGeometry” assembly. After that you’ll be able to import the full geometry module.

For a simple line, you could use the exact same syntax in python that you’d use in a code block - the node’s name. That’s the beauty of Dynamo :slight_smile:


#11

Thank you for the help Dimitar.

It is good to know that the name of each of Dynamo nodes actually corresponds to the function names from the SDK.

If Revit assemblies can not be accessed in Dynamo Studio, does that mean that I can not replicate the first Dynamo Python Exercise (Exercise 01) in Dynamo Studio:

 

import clr
# Import DocumentManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#Assign your output to the OUT variable
#OUT is defined as a list of three items
OUT=[doc,uiapp,app]

 

?