Skip to content

Commit d81b6b0

Browse files
committed
Adds safeguards when resetting material properties
1 parent c3dbc90 commit d81b6b0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/osut/utils.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,11 @@ def resetUo(lc = nil, film = nil, index = nil, uo = nil, uniq = false)
528528

529529
mt = m.clone(m.model).to_MasslessOpaqueMaterial.get
530530
mt.setName(id)
531-
mt.setThermalResistance(r)
531+
532+
unless mt.setThermalResistance(r)
533+
return invalid("Failed #{id}: RSi#{de_r.round(2)}", mth)
534+
end
535+
532536
lc.setLayer(index, mt)
533537

534538
return r
@@ -558,8 +562,15 @@ def resetUo(lc = nil, film = nil, index = nil, uo = nil, uniq = false)
558562

559563
mt = m.clone(m.model).to_StandardOpaqueMaterial.get
560564
mt.setName(id)
561-
mt.setConductivity(k)
562-
mt.setThickness(d)
565+
566+
unless mt.setThermalConductivity(k)
567+
return invalid("Failed #{id}: K#{k.round(3)}", mth)
568+
end
569+
570+
unless mt.setThickness(d)
571+
return invalid("Failed #{id}: #{(d*1000).to_i}mm", mth)
572+
end
573+
563574
lc.setLayer(index, mt)
564575

565576
return r

0 commit comments

Comments
 (0)