In order to read the geometries in grasshopper, I have created a battery name "ghx2rvt" which gets objects, surfaces, and Breps as input, recognizes their type and creates a "csv" file with the data that Revit needs to create the same geometry using Revit API. To create the geometries in Revit, an application named"ghx2rvt" is created. If the user runs this application, Revit API reads the csv file and creates the geometries in Revit. This program is still under construction and needs more work in the following parts:
- Create the real-time link
- Increase the variety of geometries can be exported by grasshopper
- Increase the variety of geometries can be imported by Revit
- Providing an application panel which is easy to use in grasshopper
- Providing an application panel which covers various capabilities in Revit.
A few number of geometries are chosen to be exported from grasshopper to Revit. The first one is "Point" which is the base for all other geometries. ghx2rvt battery has the capability of getting a list of points and create them in Revit. The list of points should be connected to the anyObject input of the ghx2rvt battery. This battery takes the X, Y, and Z coordinate of the point and writes it down on the ghx2rvt.csv file, with the symbol of point. Later when this files is read by Revit API, it can recognize that the object is a point. Figure-1 shows the points, that are result of a surface division, exported to Revit. The user can manipulate this points in Revit.
Figure 1 - Points from Grasshopper to Revit
For creating lines in the Revit based on the respective geometry in grasshopper, I wrote a function in Revit API which takes the end points of the line and creates the line. For each line, the ghx2rvt battery adds a line to ghx2csv battery that has the end points of the line and its symbol. Seeing the symbol of a line, Revit API calls line function and creates the line. The ghx2evt battery gets a list of line, which can be connected to anyObject input. Figure-2 shows a list of line that is made in Revit based on the existing geometry in grasshopper.
Figure 2 - Lines from Grasshopper to Revit
In order to import circles to Revit from grasshopper, the center point of the circle and its radius is needed. Therefore, these information will be written to ghx2rvt.csv file. Revit API reads these information and creates circles by their center point and radius in Revit.
Figure 3 - Circle (Curves) from Grasshopper to Revit
The process of creating nurbscurves and splines is the same as creating points. Putting each list of curves in an reference point array, gives us an option to create nurbscurves or splines.
Figure 4 - NurbsCurves from Grasshopper to Revit
In order to create surface one step is added to creating nurbscurves. The curves are inserted to a array of arrays. By lofting between these curves the surface an be created.
Figure 5 - Surfaces from Grasshopper to Revit
Using the same methodology, we can create 3D geometries such as Box and Ellipsoid which are shown in Image 6 and 7.
Figure 6 - Box (Extruded Geometry) from Grasshopper to Revit
Figure 7 - Revolved geometry from Grasshopper to Revit
The following video demonstrates that how the ghx2rvt battery can be used. In this video all above-mentioned examples are demonstrated. The video has an case that exports all object at one step to Revit. In this case Revit API separates the objects based on their symbol in the ghx2rvt.csv file and creates them without any problem.
Video 1 - Demonstrates the process of "ghx2rvt" battery
You can download the source code here. See the comments for details and more updates.
Thanks for reading.