If Statement/ Updating the Revit Parameter

Thank u so much dear friend for your time and helps . I’ll never forget your helps. I’ll go to my office today, test it and let you know.

1 Like

Dear friend @jacob.small

I tested your script with a small modifications. I defined some new parameters in Revit for Room object namely: HumidityMin, HumidityMax, TemperatureMin,TemperatureMax, Thermal Comfort Level (at Min Temp), and Thermal Comfort Level (at Max Temp), and modified your script a little bit to see how it works. The result shows that both Thermal Comfort Level became “Just Right” . I think it is since in condition definition, we use a constant humidity value.
Is it hard to modify this script based on the condition I showed above?

4

8

This is the modified script that I used:

//first define the variables
RoomSeason =
Rooms.GetParameterValueByName(
“Season”
);
RoomRHMax =
Rooms.GetParameterValueByName(
“HumidityMax”
);
RoomRHMin =
Rooms.GetParameterValueByName(
“HumidityMin”

);

RoomTempMax =
Rooms.GetParameterValueByName(
“TemperatureMax”
);
RoomTempMin =
Rooms.GetParameterValueByName(
“TemperatureMin”
);
WinterRH30Range =
{20.5,25.5};
WinterRH60Range =
{20,24};
SummerRH30Range =
{24.5,28};
SummerRH60Range =
{23,25.5};

/get the minimum temp for each space based
on season and RH
/
MinTemp =
RoomSeason == “Winter”?
RoomRHMin == {30,60}?
WinterRH30Range[0]:

		WinterRH60Range[0]:
	RoomSeason == "Summer"?
		RoomRHMin=={30,60}?
			SummerRH30Range[0]:
			SummerRH60Range[0]:
	"No Season";

/get the maximum temp for each space based
on season and RH
/
MaxTemp =
RoomSeason == “Winter”?
RoomRHMax=={60,70}?
WinterRH30Range[1]:
WinterRH60Range[1]:
RoomSeason == “Summer”?
RoomRHMax==30?
SummerRH30Range[1]:
SummerRH60Range[1]:
“No Season”;

/Check the temp against the min and max temp,
and define a string accordingly
/
GetWorkingRangeCheck =
RoomTempMin<MinTemp?
“Too Cold”:
RoomTempMax>MaxTemp?
“Too Hot”:
“Just Right”;
//Set the working range check value
Rooms.SetParameterByName(
“Thermal Comfort Level (at Min Temp)”,
GetWorkingRangeCheck
);
Rooms.SetParameterByName(
“Thermal Comfort Level (at Max Temp)”,
GetWorkingRangeCheck
);

I think it needs a little more modifications as follows:

  1. Modification in RH condition ( [30=<RH<60 instead of 30 in your script], and [ 60=<RH< 70 instead of 60 in your script )
  2. Using Two Thermal Comfort Level parameter instead of only one, one at Min Temp, and one at Max Temp.

Since the values of my humidity list are not constant (30 or 60), for most of the cases, rooms comfort level becomes “Just Right”, so I have to give a range to my humidity like my temp as shown in the table below.

Thank you so much

4

One too many changes in the desired input here, so I will be dropping out of actual coding for now.

  1. To modify the RH, you can either play with the boolean tests (a.GetParameterValueByName(“RH”) > 60? 60:30 should work), or use something like Math.Floor(a.GetParameterValueByName(“RH”)/30)*30 to set the values to 0 (less than 30 values), 30 (over 30 but less than 60 values), 60 (over 60 but less than 90 values) or 90 (over 90 values), which I hope you never have outside of a literal sauna.

  2. To use the min temp and max temp, instead of working the script to do both in one go, use a two code blocks modified slightly off my last code (after you get the RH working). The first would do the minimum temps. The second would do the maximum temps.


I feel like what this eventually gets at is an application of a basic psychrometric chart (yes I had to google it - been at least a dozen years since I’ve had a mechanical systems class). Eventually it would get to a request (from you or others) to rework the code to take into account all the other variables which affect thermal comfort (more or less air temp, radiant temperature, air speed, humidity, metabolic rate, and clothing level). Since I am not a mechanical engineer, I am not qualified to do that type of work. I can however recognise a good calculator though (GIMME MORE BUTTONS!), and know how to use Google.

So after a quick search, I decided to check if it was possible for a curious individual to use the CBE Thermal Comfort Tool, via mining data from a Revit model with Dynamo. I wrote a script that for used what data I had (temps and RH randomly assigned) to work with their bulk upload feature which uses a CSV. This made use of a series of nested Datashapes UI++ modules to create a several consecutive popups (bottom up from clothing to air speed), which set default values if a room hadn’t yet had a parameter filled in yet. It worked, but I then had some issues:

  1. It appears to only check for compliance and the output isn’t very clear or informational (no specifics about too hot/too cold).
  2. There doesn’t appear to be a download feature after the tests are run. You’re stuck in html land.

It was possible to download the results after running the upload, but the chart lost most functionality once on the local machine. I was able to read it with dynamo, but I’m not sure what good it was as everything had been shuffled by the conversion to HTML formatting, and there were no labels to be seen anywhere. So the data proved too difficult to find, but it I know it is in there somewhere.

Since that failed, it could be possible to re-work the code they have on their github for use directly in Dynamo, but I’m not currently motivated enough to run the various format changes, and wouldn’t know that I had succeeded without a good dataset and a mechanical engineer behind me checking results and formula inputs.

If anyone is interested I can look at cleaning up and posting my dyn file for the failed attempt later this week (next weekend?), but for now I have to catch a train.

3 Likes

It might be worth pointing out that most (or all) of this could be done in a schedule. This would give you live feedback on updates and wouldn’t require you to run a Dynamo script.

2 Likes

Thank you friend for your great explanations. Yes. I am interested if you want to post your dyn file.
And also I have another question. I exactly followed and used your first script as shown in the attached image. But the result was wrong. It should be “Also Too Hot” but it is “Your Condensation is Showing”. Do you know what is wrong with it?

9

And could you please tell me instead of (RH == 60?) in the script how we can say (Is RH between 30 and 60) in the script? Thank you so much dear friend for all your helps and time

Regards

From a quick scan it looks like your indents are all messed up.

1 Like

Could also be the difference of 60 and 60.00? I would need to see the dataset.

1 Like

Thanks Nick for your comment. The script that I used ( Special thanks to dear @jacob.small for his help) is as follows:

RH =
rooms.GetParameterValueByName(
“Humidity”
);

Temp =
rooms.GetParameterValueByName(
“Temperature”
);
RH30Min = 24.8;
RH30Max = 28;
RH60Min = 23;
RH60Max = 25.5;

//then do some logic work

CalculatedWorkingRange =
RH == 60?
//is the temp less than the max?
Temp<RH60Min?
“Also Too Cold!”:
//if not is the temp over the max?
Temp>RH60Max?
“Also Too Hot!”:
//if so than the temp is good
"Also Just Right!":
// but if the RH was neither 60 nor 30…
“Your condensation is showing”;
//if the RH is 30
RH == 30?
//is the temp less than the min?
Temp < RH30Min?
“Too Cold!”:
//if not is the temp over the max?
Temp > RH30Max?
“Too Hot!”:
//if not the temp is good
"Just Right!":
//and set my parameter value with my result
rooms.SetParameterByName(
“Thermal Comfort Level”,
CalculatedWorkingRange
);

Could you please tell me how to modify my indents? Thanks

Dear friend I attached the images of the values from MySQL and Dynamo that I used.

10

11

12

Do you know what is wrong with my script which shows “Your condensation is showing” instead of "Also Tooh Hot, since the temperature (34.52) is greater that predefined RH60Max (25.5). Is it because of my indents as @Nick_Boyts said. Thanks

It makes things way easier. if you post your code as Preformatted Text </>. Otherwise I can’t really tell how your indents are setup at all.

Please find the attached dynamo file. Thanks again

Dynamo File.dyn (5.2 KB)

I don’t have your revit dataset, so the script isn’t helping much in terms of the dataset, and re-typing the stuff from the screenshots isn’t really how I want to spend my evening.

Are you pulling the data from the mysql or the revit model?

Can you confirm that the 60.00 is still an integer (Object.Type node will do this)?

I attached the Revit model. The value of Humidity and Temperature (assigned to the Room) were extracted from MySQL database. The model is a simple building. I created one Room only and three parameters namely “Humidity, Temperature, Working Range Check” according to your script. The values were already assigned to the Revit model. I attached both Revit model and DYN file here. Thanx a lot

Dynamo File.dyn (5.2 KB)

I attached the Revit model. The value of Humidity and Temperature (assigned to the Room) were extracted from MySQL database. The model is a simple building. I created one Room only and three parameters namely “Humidity, Temperature, Working Range Check” according to your script. The values were already assigned to the Revit model. I attached both my Revit and DYN file here. Thanx a lot

Dynamo File.dyn (5.2 KB)