<?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 Re: Getting Edge Reference from Face in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9935208#M29713</link>
    <description>&lt;P&gt;Dear Austin,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interesting question, not trivial, and thank you for pointing out the blog post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you checked in the debugger that the two faces you pick have valid references?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can imagine that the&amp;nbsp;GetEdgesAsCurveLoops method looses the face edges' reference information, if they ever had any at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You &lt;U&gt;can&lt;/U&gt; use those curves to find the intersection, if you must.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, to obtain valid edge references, I suspect that you will have to return to the &lt;U&gt;original&lt;/U&gt; elements, retrieve their entire geometry via their Geometry property, specifying &lt;U&gt;ComputeReferences&lt;/U&gt; = true in the Options you pass in, and then search for the edges or vertices that match the intersection you determined from the curves.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The matching object from the element geometry is equipped with the valid reference you seek.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck, and please let us know how you fare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 12 Dec 2020 18:20:38 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2020-12-12T18:20:38Z</dc:date>
    <item>
      <title>Getting Edge Reference from Face</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9933499#M29712</link>
      <description>&lt;P&gt;I'm trying to grab Edge references from a Face reference (I thought about selecting the edge to begin with, but I didn't want the user to accidentally select the wrong edge), and I figured out how to get Curves but not the reference. Trying to grab the reference from those Curves returns null. I found &lt;A href="https://thebuildingcoder.typepad.com/blog/2016/04/stable-reference-string-magic-voodoo.html" target="_blank" rel="noopener"&gt;this post&lt;/A&gt; which was really helpful, but getting that edge reference to pass in is where I'm getting stuck. Any ideas would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the chunk of code I'm working with:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Reference sel1 = uidoc.Selection.PickObject(ObjectType.Face);
Reference sel2 = uidoc.Selection.PickObject(ObjectType.Face);
PlanarFace face1 = (doc.GetElement(sel1) as FamilyInstance).GetGeometryObjectFromReference(sel1) as PlanarFace;
PlanarFace face2 = (doc.GetElement(sel2) as FamilyInstance).GetGeometryObjectFromReference(sel2) as PlanarFace;
List&amp;lt;CurveLoop&amp;gt; list1 = face1.GetEdgesAsCurveLoops().ToList();
List&amp;lt;CurveLoop&amp;gt; list2 = face2.GetEdgesAsCurveLoops().ToList();
List&amp;lt;Curve&amp;gt; curves1 = new List&amp;lt;Curve&amp;gt;();
List&amp;lt;Curve&amp;gt; curves2 = new List&amp;lt;Curve&amp;gt;();
foreach (Curve c in list1[0])
{
    curves1.Add(c);
}
foreach (Curve c in list2[0])
{
    curves2.Add(c);
}
curves1.Sort(SortLines);
curves2.Sort(SortLines);
XYZ point = FindIntersection(curves1[0], curves2[0]); //Where would these edges intersect?
Edge edge1 = GetEdge(curves1[0].Reference, doc); //Use the symbol edge reference to return the instance edge reference
Edge edge2 = GetEdge(curves2[0].Reference, doc);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;*I know the point and edge variables are a bit mixed up, I'm still just trying to figure out the references.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 19:29:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9933499#M29712</guid>
      <dc:creator>AGGilliam</dc:creator>
      <dc:date>2020-12-11T19:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Edge Reference from Face</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9935208#M29713</link>
      <description>&lt;P&gt;Dear Austin,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interesting question, not trivial, and thank you for pointing out the blog post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you checked in the debugger that the two faces you pick have valid references?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can imagine that the&amp;nbsp;GetEdgesAsCurveLoops method looses the face edges' reference information, if they ever had any at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You &lt;U&gt;can&lt;/U&gt; use those curves to find the intersection, if you must.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, to obtain valid edge references, I suspect that you will have to return to the &lt;U&gt;original&lt;/U&gt; elements, retrieve their entire geometry via their Geometry property, specifying &lt;U&gt;ComputeReferences&lt;/U&gt; = true in the Options you pass in, and then search for the edges or vertices that match the intersection you determined from the curves.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The matching object from the element geometry is equipped with the valid reference you seek.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck, and please let us know how you fare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2020 18:20:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9935208#M29713</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-12-12T18:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Edge Reference from Face</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9938540#M29714</link>
      <description>&lt;P&gt;Thanks for the explanation! I checked, and the faces are indeed valid references, however, it appears they loose their reference after grabbing the PlanarFace. How would I go about finding the intersection with those curves? That's what I tried doing originally but it's referring to the edges of the family rather than the instance.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:29:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9938540#M29714</guid>
      <dc:creator>AGGilliam</dc:creator>
      <dc:date>2020-12-14T14:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Edge Reference from Face</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9939438#M29715</link>
      <description>&lt;P&gt;I ended up looping through the geometry in order to grab the edges, using GetInstanceGeometry, and all of the solids were empty. After debugging for a while I swapped GetInstanceGeometry for GetSymbolGeometry and then the solids had faces and edges. (Looking back, perhaps this was because the referenced Element was in a nested family and not activated yet?) After that worked, I added a transform to the edge curves to use the Instance coordinates instead of the Symbol. &lt;A href="https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2014/ENU/Revit/files/GUID-B4F83374-0DF6-4737-91EB-900E676E862B-htm.html" target="_blank" rel="noopener"&gt;This post&lt;/A&gt; helped a lot with the last part.&lt;BR /&gt;&lt;BR /&gt;In other words, it works! Thank you for the help!&lt;BR /&gt;&lt;BR /&gt;Here's the main section of my code (I can post the whole thing if anyone actually wants to see it):&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (Transaction t = new Transaction(doc, "header"))
{
  t.Start();
  Reference sel1 = uidoc.Selection.PickObject(ObjectType.Face);
  Reference sel2 = uidoc.Selection.PickObject(ObjectType.Face);
  GeometryObject face1 = (doc.GetElement(sel1) as FamilyInstance).GetGeometryObjectFromReference(sel1);
  GeometryObject face2 = (doc.GetElement(sel2) as FamilyInstance).GetGeometryObjectFromReference(sel2);
  List&amp;lt;Edge&amp;gt; edgeList1 = GetEdgesFromFace(sel1, doc, out Transform tran1);
  List&amp;lt;Edge&amp;gt; edgeList2 = GetEdgesFromFace(sel2, doc, out Transform tran2);
  edgeList1.Sort(SortLines);
  edgeList2.Sort(SortLines);
  Curve curve1 = TransformCurve(edgeList1[0].AsCurve(), tran1);
  Curve curve2 = TransformCurve(edgeList2[0].AsCurve(), tran2);
  XYZ intersect = FindIntersection(curve1, curve2);
  t.Commit();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 19:10:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/9939438#M29715</guid>
      <dc:creator>AGGilliam</dc:creator>
      <dc:date>2020-12-14T19:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Edge Reference from Face</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/11727658#M29716</link>
      <description>Hi Aggilliam, I'm working in some similar. I will aprecciate if you can share your code.&lt;BR /&gt;And congrats for make it works.&lt;BR /&gt;Regards.</description>
      <pubDate>Fri, 03 Feb 2023 15:14:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/getting-edge-reference-from-face/m-p/11727658#M29716</guid>
      <dc:creator>matias_m1912</dc:creator>
      <dc:date>2023-02-03T15:14:38Z</dc:date>
    </item>
  </channel>
</rss>

