Design Script for Condition Statement

Hello guys

For thermal comfort monitoring, I am working on a work flow in Dynamo. Now I am in the step that I must define the conditions (Relative Humidity and Temperature of each room). First I used the script written by @jacob.small for the following condition as shown in the attached image:

Relative Humidity -------- Acceptable Operating Temperature
If 30% -----------------------------------------24.8-28
If 60% -----------------------------------------23-25.5

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(
	"Working Range Check",
	CalculatedWorkingRange
);

Now I am going to modify this script based on the new conditions as shown in the following table:

4

Could you please help me to modify this script? Thank u so much in advance

Regards

You just need to replace this value with the new one… so RH30Min = 24.5;

Thanks. As you see in the attached table, the new condition statements have been changed.

The previous condition was when RH=30% then the temperature should be between 24.5-28, and when the RH=60%, then the temperature should be between 23-25.5

Now I want to say if the 30=<RH<60, then the temperature should be between 24.5-28, and when the 60=<RH<70, then the temperature should be between 23-25.5 .
So instead of (==) in the first condition, I am going to use (=< <) in the new condition

Oh… just noticed the change with the RH now being a range. I think the correct syntax for that would be to change

to:

CalculatedWorkingRange =
RH >=60 && RH <=70?

and

to

//if the RH is 30
RH >=30 && RH <=60?
1 Like

@MOJTABA256 If the parameter value of Acceptable Operating Temperature is text indicating the range, then …
aot = rh>=30 && rh<60 ? "24.5 - 28°C" : (rh>=60 && rh<70 ? "23 - 25.5°C" : "23 - 28°C");

if you need to populate min and max separately…

aotMin = rh>=30 && rh<60 ? 24.5 : (rh>=60 && rh<70 ? 23 : 23);

aotMax = rh>=30 && rh<60 ? 28 : (rh>=60 && rh<70 ? 25.5 : 28);

rh being the input in each case
Note that a default value is specified for cases where the input rh is beyond the specified range

1 Like

Links to resources about how to do what is showed would probably be useful to complete the answer, such as these maybe:
http://dynamoprimer.com/en/07_Code-Block/7-2_Design-Script-syntax.html
http://dynamobim.org/help-center/

1 Like

Thank you so much dear @awilliams , @Vikram_Subbaiah and @Yna_Db for your response.
I modified my script and finally it worked. Then I tried to color coding my rooms based on “Working Range Check” parameter. I want to highlight the room in red color when “Working Range Check” is hot and also too hot, and in blue when “Working Range Check” is too cold and also too cold, and in yellow when “Working Range Check” parameter is unaccepted humidity. I tried to do it by writing a script but unfortunately it doesn’t work. I attached it here. Could you please look at my script and tell me where the problem is? Thank you

1

2

You want an OR statement for if the room is Too Hot! OR Also Too Hot!. It can’t be both.
image

2 Likes