<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic HostObjectUtils in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6461942#M63830</link>
    <description>&lt;P&gt;hi, i am trying to extract top faces of roofs in order to calculate their angles.&lt;/P&gt;&lt;P&gt;the code snippet is really short as &amp;nbsp;things should be easy:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;faces = HostObjectUtils.GetBottomFaces(element)&lt;/PRE&gt;&lt;P&gt;after that i proceeded like:&lt;/P&gt;&lt;PRE&gt;face = doc.GetElement(faces[0])
		faceNormal = face.GetGeometryObjectFromReference(faces[0]).FaceNormal
		reference = XYZ(1,1,0)
		angle = reference.AngleTo(faceNormal)* (180 / math.pi)
		TaskDialog.Show("Revit", "angle = %s degrees" %(angle))&lt;/PRE&gt;&lt;P&gt;this is working perfectly if a roof has no tilting angle.&lt;/P&gt;&lt;P&gt;if it is tilted i receive&amp;nbsp;as "face"&amp;nbsp;a Autodesk.Revit.DB.FootPrintRoof not the topface!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what am i missing? or is there a more elegant way to extract a roofs tilting angle?&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jul 2016 10:33:06 GMT</pubDate>
    <dc:creator>office</dc:creator>
    <dc:date>2016-07-27T10:33:06Z</dc:date>
    <item>
      <title>HostObjectUtils</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6461942#M63830</link>
      <description>&lt;P&gt;hi, i am trying to extract top faces of roofs in order to calculate their angles.&lt;/P&gt;&lt;P&gt;the code snippet is really short as &amp;nbsp;things should be easy:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;faces = HostObjectUtils.GetBottomFaces(element)&lt;/PRE&gt;&lt;P&gt;after that i proceeded like:&lt;/P&gt;&lt;PRE&gt;face = doc.GetElement(faces[0])
		faceNormal = face.GetGeometryObjectFromReference(faces[0]).FaceNormal
		reference = XYZ(1,1,0)
		angle = reference.AngleTo(faceNormal)* (180 / math.pi)
		TaskDialog.Show("Revit", "angle = %s degrees" %(angle))&lt;/PRE&gt;&lt;P&gt;this is working perfectly if a roof has no tilting angle.&lt;/P&gt;&lt;P&gt;if it is tilted i receive&amp;nbsp;as "face"&amp;nbsp;a Autodesk.Revit.DB.FootPrintRoof not the topface!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what am i missing? or is there a more elegant way to extract a roofs tilting angle?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 10:33:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6461942#M63830</guid>
      <dc:creator>office</dc:creator>
      <dc:date>2016-07-27T10:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: HostObjectUtils</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6465330#M63831</link>
      <description>&lt;P&gt;just found out that my math was a little rusty;-)&lt;/P&gt;&lt;P&gt;adopted my formula so now i receive correct angles.&lt;/P&gt;&lt;P&gt;but still i am exploring the object geometry&amp;nbsp;instead of HostObjectUtils&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any suggestions?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 18:02:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6465330#M63831</guid>
      <dc:creator>office</dc:creator>
      <dc:date>2016-07-28T18:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: HostObjectUtils</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6469909#M63832</link>
      <description>&lt;P&gt;One thing is that it seems you're variable names may not be helping:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;faces = HostObjectUtils.GetBottomFaces(element)
face = doc.GetElement(faces[0])&lt;/PRE&gt;&lt;P&gt;Might help if it looked more like this:&lt;/P&gt;&lt;PRE&gt;//Because GetBottomFaces returns a list of References, not elements or faces&lt;BR /&gt;IList&amp;lt;Reference&amp;gt; bottomFaceReferences = HostObjectUtils.GetBottomFaces(element);&lt;BR /&gt;&lt;BR /&gt;//GetElement Returns an element, (the element which contains the referenced geometry if you pass it a reference))
//hence this is from the department of redundancy department:&lt;BR /&gt;Element hostElement = doc.GetElement(bottomFaceReferences[0]);&lt;BR /&gt;&lt;BR /&gt;//You could get the face from the reference you have and the element from which it came:
Face face = hostElement.GetGeometryObjectFromReference(bottomFaceReferences[0]);&lt;BR /&gt;&lt;BR /&gt;//Then you can get the normal
XYZ FaceNormal = face.FaceNormal;&lt;/PRE&gt;&lt;P&gt;Element elementWhichContainsFaceReference = doc.GetElemetn(faces[0]);&lt;/P&gt;&lt;P&gt;because GetElement(Reference) returns an element (the element which owns the face reference you passed it).&amp;nbsp; I wouldn't expect GetElement to ever return a face so your question is a bit confusing:&amp;nbsp; are you actually getting a face from GetElement()?&amp;nbsp; In the future, try to not paraphrase your code because it makes it hard to follow.&amp;nbsp; Also, I would suggest that, in the case you're using "var" for these, use explicit typing so you can follow exactly what's going on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for the more elegant solution, if you're dealing with a footprint roof, each sketch line can have a different slope and is controlled by a parameter "defines slope".&amp;nbsp; Have a look at FootPrintRoof.SlopeAngle and FootPrintRoof.DefinesSlope parameters.&amp;nbsp; You can get the model curves of the footprint with FootPrintRoof.GetProfies().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure If I answered your question but I hope I made it a little clearer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 04:32:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6469909#M63832</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-01T04:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: HostObjectUtils</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6470050#M63833</link>
      <description>&lt;P&gt;ken thanks for both code and the more elegant solution!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 07:05:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/hostobjectutils/m-p/6470050#M63833</guid>
      <dc:creator>office</dc:creator>
      <dc:date>2016-08-01T07:05:08Z</dc:date>
    </item>
  </channel>
</rss>

