FootPrintRoof.SlopeAngle property value meanings and unit

By Joe Ye

Issue

I retrieved the slope angle of a footprint roof via API. However the return angle is not as I anticipate. Within the footprint roof editor, for instance,  I can see the slope angle for each side is 30 degree for one footprint roof. However the angle I get via API is 27.64.  Would you please explain what’s the reason?

Here is the code fragment I used to read the slope angle.

// roofRef variable represents a reference of a picked element        FootPrintRoof footPrintRoof = roofRef.Element as FootPrintRoof;        ModelCurveArrArray roofProfile = footPrintRoof.GetProfiles();             string str = "";             foreach (ModelCurveArray curveArr in roofProfile)        {          foreach (ModelCurve modelCurve in curveArr)          {            double angle = footPrintRoof.get_SlopeAngle(modelCurve);            str += string.Format("Angle of Model Line id: {0} is {1}n",                   modelCurve.Id, angle * 180 / Math.PI);          }        }

 

Solution

The slope angle obtained by SlopeAngle() property is not in radian, but it is a "slope". That’s the ratio of two sides. eg the slope angle value 0.5 is the result of 0.5”/1”. This is the ratio of the vertical distance and the horizontal distance.

The slope angle in radian can be calculated by Math.Atan() method from the slope value. Accordingly the slope angle in degree can be calculated by multipling the angle in radian and 180/Math.PI.

Here is the revised code to obtain slope angle in degree.

// roofRef variable represents a reference of a picked element        FootPrintRoof footPrintRoof = roofRef.Element as FootPrintRoof;        ModelCurveArrArray roofProfile = footPrintRoof.GetProfiles();             string str = "";             foreach (ModelCurveArray curveArr in roofProfile)        {          foreach (ModelCurve modelCurve in curveArr)          {            double angle = footPrintRoof.get_SlopeAngle(modelCurve);            str += string.Format("Angle of Model Line id: {0} is {1}n",                       modelCurve.Id, Math.Atan(angle) * 180 / Math.PI);               }        }

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading