In my previous post I talked at length about the new tools (surface analysis display) for Dynamo that I was working on. With that previous set of tools I was able to consistently import analysis results from Grasshopper/Ladybug and use Revit’s Analysis Visualization Framework to display those results on surfaces translated from Grasshopper via Mantis Shrimp. However, the only analysis style that worked well was Marker and Text Display Style. I also briefly talked about the Colored Surface Display Style, but that one was still a work in progress and not very stable. In this post I will demonstrate a new (hopefully) improved workflow to use Colored Surface Display Style.
First things first, I tried to get away with needing to export both a surface and analysis mesh. I was able to achieve that by taking Mesh Center Points (previously used to project on Revit surface to extract UVs) and using Grasshopper’s “Surface Closest Point” to obtain those points UV coordinates on a base surface. Now instead of sending points from GH to Dynamo I am sending UVs and then just translate those into Revit UVs (we will get to that in a bit). With that new method all I need now is a set of surfaces and corresponding UVs/Values combination. All that is wrapped into one list, and attached to surface as User String.
Don’t forget that to make this definition work you will need:
Now once we are on the Dynamo side here are my Colored Surface Settings:
Here are my Color Settings:
Here are my Legend Settings:
This is all the same from my previous post so no big news here. What changed is a process to get proper UVs on a surface. Here’s how that’s done now:
First I need to extract all of the data from the exported Grasshopper geometry. Remember that it now holds user strings for the UV coordinates as well as analysis result data. To make extracting it easier I made a few changes to the Get Rhino Object User Strings node. It now requires “keys” to extract corresponding values.
Here’s how its used now:
This will give you a series of numbers matching the amount of analysis points as well as the same number of points with a suffix “A”. All number keys hold values for analysis and ones with a suffix “A” hold values for UV coordinates. Let’s use a simple filtering workflow in Dynamo to split them up:
Now that we have our UVs and since surface that we used in Grasshopper was Reparameterized (right click on a Surface Closest Point input component), we know that values represented here match analysis points on that surface in a UV Domain 0-1. Since we are not sure if that same domain characterizes surface that we imported into Revit to host out analysis we need to make sure that our UVs are re-mapped into that surfaces domain. Before we do that however we will need to convert UVs from strings to actual Dynamo UV objects. There is a new node for that and it uses a really simple code:
You can see that all we are doing here is break up the string at “,” (comma) and convert values to floats so that we can then create DS UVs from those numbers. Once we have that we can move on to the next step of making sure that our domains match. Remember that our GH UVs were in 0-1 domain so let’s re-map them accordingly. Now in that image you can see we are doing a few things. First we use Mantis Shrimp to translate our GH geometry to Dynamo, then import it into Revit as a Family Instance and finally using those instances and UVs previously converted to Design Script we Remap UV Domain to RVT Surface. Here’s the code sitting under the hood. Keep in mind that it assumes that there is only one surface (face) for each ImportInstance. That’s the reason I am using ImportInstance.ByGeometries instead of ImportInstance.ByGeometry which joins all surfaces together and makes one import.
Now that we have our UVs, Values, Surfaces and all of the settings for the Display Style, all we have left to do is put it all together with the Colored Surface Display Style:
When all is said and done we should be getting something like this:
Here are all of the test files that include Dynamo Definition, Grasshopper Definition and Rhino File. All of the nodes can be either downloaded from Download section of this site, Package Manager or simply use the source code and paste it into Python nodes/components to get the desired result.
Good luck, and remember that if you have any questions do not hesitate to ask in comments (please post pictures/files for easier troubleshooting).