Tuesday, October 28, 2014

Occupancy Calculations and JavaScript

The other day I read a post at Revit Add-ons about integrating Java Scripts into Revit. I was intrigued by an example it described which provides a connection between a java script calculation (formula) and assigns it to a parameter. A very common request among Revit users is to be able to associate with a formula with a Shared Parameter, and in this case occupancy calculations. Timing is a funny thing because an email came in the same day asking for advice doing these calculations.

The application is called LazJS and is currently offering a beta version 1.0. Fwiw, I created an Occupancy Calculation sample project years ago which you can download HERE. I thought I'd open that project and try LazJS out on it. Since we can't put a calculated value in a tag the example uses a schedule so we can transfer values manually. With the advent of the API there are more options but for anyone who is leery of programming it's still a bit intimidating.

I found it was really easy to get this installed and configure LazJS to fill in the values for me automatically and keep them updated if I make any changes. This is the dialog that appears for their ParamJS tool. I started by choosing the Rooms category. Then I chose the parameter that is in my room tag. Then I dragged the parameter whose value I wanted to be in the tag up to the code editor window. Once the code was present I clicked Run, seeing values in the results window I clicked Save.

Now whenever I add a room and assign a occupancy type its tag fills in the appropriate Occupancy Factor for me (the script does). Same for any editing I do of existing rooms.

Worth a closer look if only for this piece of their whole application.


Dan Tartaglia said...

Hi Steve,

Very interesting. We are thinking of creating a Revit API tool to keep Calculated values/Shared parameters up to date for various schedules including our Life Safety Plan. I asked for the beta to see what it can do.


Anonymous said...

You could also try the Dynamo Way.