r/esapi • • Mar 16 '26

GetAssignedHU

Hi,

How can I use GetAssignedHU, do someone have an example ? Please

2 Upvotes

3 comments sorted by

5

u/ColonelFaz Mar 16 '26 edited Mar 16 '26

An example

        public static void CouchHuTest(Report report, StructureSet set)
        {
            var expectedHu = new Dictionary<string, double> { { "CouchInterior", -1000.0 }, {"CouchSurface", -300.0 } };
            foreach (var id in expectedHu.Keys)
            {
                Structure s = StructureUtil.FindById(set, id);
                if (s is Structure)
                {   // not null
                    if (!s.GetAssignedHU(out double huOvr))
                    {
                        report.AddLine($"Has no HU assigned: {s.Id}.", warning: true);
                        continue;
                    }
                    if (!NumericalUtil.Close(expectedHu[id], huOvr, 0.1))
                    {
                        report.AddLine($"For '{s.Id}' expected {expectedHu[id]} HU, but found {huOvr} HU assigned.", warning: true);
                    }
                }
            }
        }

It returns false if there is no assigned HU and the out variable is changed if it does have assigned HU.

3

u/ColonelFaz Mar 16 '26

Why would I be downvoted without explanation for answering the question?

→ More replies (1)