Is there a way to call functions from Autodesk.Revit.DB namespace using the C# nodes? That way we can call the Revit API from the comfort of Grasshopper to do additional functions (such as assigning mass floors to masses etc)
1 Like
scottd
(Scott Davidson)
December 10, 2019, 3:37pm
2
We currently only have the Python technique documented:
# Writing Python in Grasshopper in Revit
This guide is about writing a custom Python component in Grasshopper while running Rhino.inside Revit.
This grasshopper definition is available as a [download here as ghpython-revit.gh...](samples\ghpython-revit.gh)
##<img src="images/Python.png" width="35px"> GH Python component
The GHPython component contains the inputs, outputs and a code editor. To get started with the component go to the Math tab in Grasshopper and drag out the Python component.
<img src="images/ghpython-component-detail.png" width="100%" align="center">
For a detail guide on the GHPython component in Grasshopper, please review [Your First Python Script in Grasshopper Guide](https://developer.rhino3d.com/guides/rhinopython/your-first-python-script-in-grasshopper/)
Double-click on the component to open the Python editor:
This file has been truncated. show original
The C# is a little different and we would like to streamline the process for C# components. Although I do not expect the change for a few weeks at least.
fraguada
(Luis Fraguada)
December 10, 2019, 8:40pm
3
As @scottd mentioned, we don’t have too many examples documented. One of the original samples creates a TopographySurface
from points. Here is the definition: https://github.com/mcneel/rhino.inside-revit/blob/master/src/RhinoInside.Revit/Samples/Sample3.ghx
and here is the code it calls:
<item name="AdditionalSource" type_name="gh_string" type_code="10"> ElementId topographySurfaceId = ElementId.InvalidElementId;
void UpdateTopographySurface(Document doc, IList<XYZ> points)
{
// Delete previous surface if exists
try { doc.Delete(topographySurfaceId); }
catch (Autodesk.Revit.Exceptions.ArgumentException) {}
// Create a new TopographySurface
topographySurfaceId = TopographySurface.Create(doc, points).Id;
}</item>
<item name="CustomUsing" type_name="gh_bool" type_code="1">true</item>
<item name="Description" type_name="gh_string" type_code="10">A C#.NET scriptable component</item>
<item name="EditorPosition" type_name="gh_drawing_point" type_code="30">
<X>4</X>
<Y>66</Y>
</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">884cfbe3-a9ab-41f5-92a5-28371cb35f74</item>
<item name="Name" type_name="gh_string" type_code="10">C# Script</item>
<item name="NickName" type_name="gh_string" type_code="10">TopographySurface</item>
<item name="OutParameter" type_name="gh_bool" type_code="1">true</item>
This file has been truncated. show original