Thursday, January 8, 2015

Daylighting Workflow Package for Dynamo

This post is about the “Daylighting Workflow” package on Dynamo that I have published a few days ago. This package can be used as a template for daylighting that connects Dynamo to Autodesk’s Cloud Rendering Service to enable quick and accurate parametric daylighting analysis. The “Daylighting Workflow” package provides you with all the necessary nodes and complete workflow to perform parametric daylighting analysis and parse the results. You can download this package from the Dynamo Package Manager. This package is created and modified based on the blog post by Michael Krischner on DynamoBIM for Dynamo version 6.3. Image below shows the overview of the updated Daylighting Workflow Graph in Dynamo 7.4.
To explain the Dynamo code, I am using Revit Advance Sample model as test case. 


The first part of the Dynamo code gets the levels that the user wants to perform daylighting analysis. The code gets all elements at these levels and removes everything from the list other than floors. The node Element.Geometry visualizes the selected floors in Dynamo canvas. 


As you can see in this case, since shading devices in this model are created using Floor family and assigned to the same levels as building floors, they are included in the list as well (see the image below). To remove the shadings you can simply create a new level at the same height and assign shading devices to those levels. 


The second part of the code tries to get the Bottom Left, Bottom Right, and Top Left points of the floors using floor bounding box and a simple code in a code block. For the Z value of the points, the floors' Z value is added to "Work Level Height" to get the daylighting results for each floor at desk level. These points are used as the input parameters for the CloudDaylightingJob.ByViewNameDivisionsGridBoundary node.


The next step is to create Rendering Environment using Sky Model, Building Location, and Date/Time. In order to create Sky Model, you can find valid values for direct normal irradiance (DNI), diffuse horizontal irradiance (DHI), and global horizontal irradiance (GHI) values from the weather files that are built-into Autodesk Green Building Studio website. See this BPA Help page for detailed information.The values of DHI, GHI, and DNI are collected from weather data file for 9 am and 3 pm. If you have set the building location for the model in Energy Settings form Revit Analyze tab, you can use Document.Location node to get Longitude and Latitude. Using DateTime node you can set the exact time that you want to perform daylighting analysis for. In this case the Rendering Environment node creates two rendering environment based on the SkyModel  information provided for 9 am and 3 pm on September 21st. 


Note: Dynamo has two very similar node DateTime.ByDateAndTime from Dynamo Core category and DateTime.ByDateInformation from Analyze category. For daylighting analysis you need to use the one from analyze category. 

The minimum value for x and y divisions is 150. The x and y divisions are used to create a grid for daylighting sensors. In this case we have used {3D} view for creating render job as well as export cloud render data. Since Export Cloud Render Data interacts with Revit, it has to be in between transaction nodes. DoCloudRender node submits the daylighting job to Autodesk’s Cloud Rendering Service. you can see the illuminance rendering jobs and their progress on render gallery by going to View tab in Revit > Render Gallery. In this example two render jobs will be submitted to Cloud Rendering Service for 9 am and 3 pm.


In the Daylighting workflow, it is tried to create an option for customized lighting analysis. There are many users that have used Lighting Analysis for Revit (LAR). The daylighting workflow on Dynamo is created for those who want to perform lighting analysis in Revit with custom settings. in the last part of the workflow the rendering results are parsed using a Python Script based on USGBC LEED requirement for Daylighting.

The Python Script gets the Minimum and Maximum accepted values as inputs along with simulation results and list of levels to calculate the percentage of the area within, above, and below the threshold. The area percentages are reported a the output of the Python Script node. Below is the Python Script that is create to calculate these values.
1:  import clr  
2:  import math  
3:  clr.AddReference('ProtoGeometry')  
4:  from Autodesk.DesignScript.Geometry import *  
5:  # Import RevitAPI  
6:  clr.AddReference('RevitAPI')  
7:  import Autodesk  
8:  # Import DocumentManager and TransactionManager  
9:  clr.AddReference('RevitServices')  
10:  import RevitServices  
11:  from RevitServices.Persistence import DocumentManager  
12:  from RevitServices.Transactions import TransactionManager  
13:  # Import ToDSType(bool) extension method  
14:  clr.AddReference('RevitNodes')  
15:  import Revit  
16:  clr.ImportExtensions(Revit.Elements)  
17:  #=================================================  
18:  doc = DocumentManager.Instance.CurrentDBDocument  
19:  uiapp = DocumentManager.Instance.CurrentUIApplication  
20:  app = uiapp.Application  
21:  levels = IN[0]  
22:  illumVal = IN[1]  
23:  points = IN[2]  
24:  minAcceptedIllum = IN[3]  
25:  maxAcceptedIllum = IN[4]  
26:  Autodesk.Revit.DB.BuiltInCategory  
27:  #Collects curtain walls  
28:  rooms = Autodesk.Revit.DB.FilteredElementCollector(doc)  
29:  rooms.OfCategory(Autodesk.Revit.DB.BuiltInCategory.OST_Rooms)  
30:  #finds the rooms that are at the mentioned level and puts them in a list  
31:  rmLevelLst = []  
32:  for i in range (0, len(levels)):  
33:       roomLev = []  
34:       for rm in rooms:  
35:            if rm.Level.Name == levels[i].Name:  
36:                 occ = rm.get_Parameter("Occupancy")  
37:                 if occ.AsString() != "0":  
38:                      roomLev.append(rm)  
39:       rmLevelLst.append(roomLev)  
40:  #adds points that are in the rooms into in range list   
41:  #and total points list to calculate the percentage  
42:  Result =[]  
43:  for i in range (0, len(points)):  
44:       resList = []  
45:       for j in range (0, len(points[i])):  
46:            pntInRoomLst = []  
47:            pntInRangeLst = []  
48:            pntBelowRange = []  
49:            pntAboveRange = []  
50:            for k in range (0, len(points[i][j])):  
51:                 for occRoom in rmLevelLst[j]:  
52:                      xyz = Autodesk.Revit.DB.XYZ(points[i][j][k].X, points[i][j][k].Y, points[i][j][k].Z)  
53:                      if occRoom.IsPointInRoom(xyz):  
54:                           pntInRoomLst.append(xyz)  
55:                           if illumVal[i][j][k] < maxAcceptedIllum and illumVal[i][j][k] > minAcceptedIllum :  
56:                                pntInRangeLst.append(points[i][j][k])  
57:                           if illumVal[i][j][k] > maxAcceptedIllum:  
58:                                pntAboveRange.append(points[i][j][k])  
59:                           if illumVal[i][j][k] < minAcceptedIllum:  
60:                                pntBelowRange.append(points[i][j][k])  
61:            if len(pntInRoomLst)!=0:  
62:                 percentInRange = len(pntInRangeLst)/float(len(pntInRoomLst))  
63:                 percentAboveRange = len(pntAboveRange)/float(len(pntInRoomLst))  
64:                 percentBelowRange = len(pntBelowRange)/float(len(pntInRoomLst))  
65:            else:  
66:                 percentInRange = percentAboveRange = percentBelowRange = 0  
67:            if percentInRange == 0 and percentAboveRange == 0 and percentBelowRange == 0:  
68:                 resList.append ("There is no room in this level")  
69:            else:  
70:                 resList.append(str(round(percentInRange*100))+"%"+ " in the range - " + str(round(percentAboveRange*100))+"%"+ " aAbove the range - " + str(round(percentBelowRange*100))+"%"+ " below the range" )  
71:       Result.append(resList)  
72:  OUT = Result  
Hope this workflow is useful for your work process.

Wednesday, December 24, 2014

Dynamo Posts

Hi,

I have decided to start publishing a few posts on Building Performance Analysis (BPA) workflows on Dynamo. I will have a few posts on Optimization using Optimo as well. Optimo is a multi-objective optimization tool that enables Dynamo users to optimize problems with single and multiple objectives using evolutionary algorithms.

Dynamo "Daylighting Workflow" will be up soon. 


Sunday, June 9, 2013

Project Chronicle

In this post I am introducing a new cool tool from Autodesk Labs "Project Chronicle".

"Project Chronicle is a free technology preview from Autodesk Research that makes it extremely convenient and easy for users to capture, share, and learn from software workflows. Project Chronicle consists of a recording utility to capture recordings, and a website that displays the recordings as Chronicles, interactive video tutorials. The videos can be shared publicly or set to private, so that they can be used as internal training materials for a private office or classroom." (Project Chronicle Page)



The tool is free (Download here) and it is integrated with Revit and Autocad. I have created a sample video using this tool to show how it works.

Here are the steps to make this video:


1- Run Chronicle and choose the application that you want to screen record. As it is mentioned before, Chronicle is integrated with Autocad and Revit to track the user clicks and create a table of content automatically.



2- Record your video. When you finish the recording part, Chronicle opens a new window where you can edit your recording. In the current version you can only delete the parts that you do not want in your video.





3- Save and upload your video. 


4- Go to Chronicle website and log in with your user name and password and change the privacy of the video to publish it. 


5- You can embede your video in your blog or website by copying the html code using "embed" button bellow your video after you publish your video. Here is the sample video that I made to test:


Friday, February 15, 2013

Revit 2013 gbXML Export to Ecotect Problem

I have tried to export gbXML file fro Revit and open it in Ecotect, DDS-CAD Viewer and I received errors saying that it cannot be opened. Here is the error that I have received in Ecotect:


!!!!!!!!!
"Warning: IFC support is only at beta stage in this release. Whilst detailed geometry should import, ifcSpace data and complex curves may not transform correctly."
!!!!!!!!!


Since Ecotect reads UTF-8 and  Revit 2013 exports in UTF-16 format, Ecotect throws this exeption about icf.

How to solve this problem: Open your xml file with Notepad. In the file menu, Encoding change it to UTF-8 and then save your file. The following image shows this process.



Hope it works for you too.

Thursday, November 15, 2012

Revit API Programming Templates 5

There are 2 more templates that I am going to talk about in this post. These templates are created based on your questions to help you to finish your projects.

1- The first template is about using Windows Form Application and retrieving data from Revit, then changing the data, and apply it to Revit project. When you run this template the form fills up with the current number of parameters inside Revit. This template has two separate classes. the first one uses a simple form to get  a door width and then shows it in the form. The user can see the current value and then he can change it inside the form. The second class does the same thin, but it shows you how to access energy settings of a Revit Project.




2- The second template shows how you can make an add-in ribbon panel inside Revit. In order to get familiar with the process you can visit Autodesk Revit API Wiki and learn the process. I have made some changes to this process to make it more manageable.
In order to run the template, you have to add addin file to your computers addin folder. Please read the Autodesk wiki mentioned above for details. Then when you open Revit, it asks you to select a dll file. Go to "add in dll file" inside the template provided, and select the dll file. Then it will asks you to select a logo for your panel. If you have a logo please find it and select it. Otherwise, it will use an online logo of Revit for your panel. Then you will have your customized revit button in the project.



Please let me know if you have any questions.

Tuesday, November 13, 2012

Revit API Programming Templates 4

In this post I am adding a new template to our archive. This template is Windows Form Application templates which enables you to get user input for your API program. Sometimes in your Revit application you need to get user's input to achieve your goal. Designing windows from application is the most common approach to get the user input.

In order to add a windows form to your project, in Visual Studio right click on the your project in Solution Explorer. Then Add, Windows Form. Now you will have a class of Windows Form added to your project. You can right click on the Form1 and access to the background cod of the Form1 Design. You need to add some lines of code to your project which you can ind in the uploaded template.


Thursday, November 1, 2012

Revit API Programming Templates 3

This provides a Revit API programming template for using external data. This template (ExternalDataFromExcel) provides a class as an example on creating an excel file from scratch and fill it with the information from your Revit project and change the format and style of cells inside the worksheet.

The Second class in this template, provides you an example of reading an existing excel file and use the values of each cell in Revit project.

The third class, is the same as the second class. In this class, we use the data from excel file and change the type parameters of a window selected by user in Revit project. In this class the user is asked to select a window and then the code gets the type parameters of that window. Then the code reads data from excel file and changes the window type parameters respectively. This class would be a good start for those who want to update their model in Revit using external data from excel.