<?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: Revit ElementTransformUtils.CopyElements returns ids of null elements ? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763323#M31700</link>
    <description>&lt;P&gt;Apologies for the confusion between &lt;SPAN&gt;`ElementIDs_Destination` and `CopiedElementsIDs`.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I wanted to make things more clear but I forgot to replace&amp;nbsp;`CopiedElementsIDs` to `ElementIDs_Destination`.&lt;/P&gt;&lt;P&gt;See below the correct code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When running this between two projects providing one wall and one door to the ElementIDs_Source variable, both elements are copied and both IDs are returned. However when the ID of the door (hosted element) is used to retrieve the door element, using the GetElement Method you get a null result. Weirdly, when checking the copied door, it has a different ID from the one returned from the&amp;nbsp;&lt;SPAN&gt;CopyElements&lt;/SPAN&gt;&amp;nbsp;method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using (Transaction tx = new Transaction(doc_Source, ("copying elements ")))
{
  tx.Start();
  CopyPasteOptions copy_paste_options = new CopyPasteOptions();
  translation = new XYZ();
  transform = Transform.Identity;
  ElementIDs_Destination=Autodesk.Revit.DB.ElementTransformUtils.CopyElements(doc_Source,ElementIDs_Source, doc_Destination, transform, copy_paste_options
);
  tx.Commit();
  foreach(ElementId i in ElementIDs_Destination)
  {
  if (doc_Destination.GetElement(i)== null)
  {
    Debug.Print("Element is null")
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Sep 2020 11:41:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-09-23T11:41:34Z</dc:date>
    <item>
      <title>Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9761560#M31696</link>
      <description>&lt;P&gt;I am using the&amp;nbsp;Autodesk.Revit.DB.ElementTransformUtils.CopyElements method defined here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.revitapidocs.com/2016/b22df8f6-3fa3-e177-ffa5-ba6c639fb3dc.htm" target="_blank" rel="noopener"&gt;https://www.revitapidocs.com/2016/b22df8f6-3fa3-e177-ffa5-ba6c639fb3dc.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This copies an element list from a document too another document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I surprisingly found that when I copy the elements the command runs without errors ok and returns a list of ids.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running the snippet below you my code&amp;nbsp; prints the "Element is null" in my console multiple times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It turns out that some of the elements of those IDs are null. Looking at the IDs sequence, I found that the elements from the source model which have the same sequence with the element IDs of the destination model which are missing, are doors elements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that elements were created (that is why the "CopyElements" methods returns the Element Ids), however, those probably gets deleted. Would that be a case that all hosted elements are null from this list? If yes, how can I get their ID of the hosted copied elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using (Transaction tx = new Transaction(doc_Source, ("copying elements ")))
{
  tx.Start();
  CopyPasteOptions copy_paste_options = new CopyPasteOptions();
  translation = new XYZ();
  transform = Transform.Identity;
  ElementIDs_Destination=Autodesk.Revit.DB.ElementTransformUtils.CopyElements(doc_Source,ElementIDs_Source, doc_Destination, transform, copy_paste_options
);
  tx.Commit();
  foreach(ElementId i in CopiedElementsIDs)
  {
  if (doc_Destination.GetElement(i)== null)
  {
    Debug.Print("Element is null")
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if anyone wants more clarification or information to provide for this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any answer or similar experience will be really appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 15:53:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9761560#M31696</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-22T15:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9761945#M31697</link>
      <description>&lt;P&gt;I can share a different example of element ids getting nulled out, in case that provides any ideas: afaik, if an element A points to another element B by storing its element id in extensible storage, and A is copied whereas B is not, the element id in the extensible storage is nulled out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 19:01:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9761945#M31697</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-09-22T19:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9761949#M31698</link>
      <description>&lt;P&gt;I see no connection in your code between&amp;nbsp;`ElementIDs_Destination` and `CopiedElementsIDs`...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 19:03:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9761949#M31698</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-09-22T19:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763305#M31699</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/413917"&gt;@jeremytammik&lt;/a&gt;many thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure what the extensive storage is and if this is relevant to my case when using the&amp;nbsp;ElementTransformUtils.CopyElements method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I meant null elements I referred to the elements not the element IDs. To clarify my initial post, the list of elements IDs the ElementTransformUtils.CopyElements method returns have not null elements. This list is fine. However, when tying to retrieve the element by its element ID, I am getting a null element. Simply, CopyElements method return IDs which do not refer to existing elements in the document.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 11:35:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763305#M31699</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-23T11:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763323#M31700</link>
      <description>&lt;P&gt;Apologies for the confusion between &lt;SPAN&gt;`ElementIDs_Destination` and `CopiedElementsIDs`.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I wanted to make things more clear but I forgot to replace&amp;nbsp;`CopiedElementsIDs` to `ElementIDs_Destination`.&lt;/P&gt;&lt;P&gt;See below the correct code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When running this between two projects providing one wall and one door to the ElementIDs_Source variable, both elements are copied and both IDs are returned. However when the ID of the door (hosted element) is used to retrieve the door element, using the GetElement Method you get a null result. Weirdly, when checking the copied door, it has a different ID from the one returned from the&amp;nbsp;&lt;SPAN&gt;CopyElements&lt;/SPAN&gt;&amp;nbsp;method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using (Transaction tx = new Transaction(doc_Source, ("copying elements ")))
{
  tx.Start();
  CopyPasteOptions copy_paste_options = new CopyPasteOptions();
  translation = new XYZ();
  transform = Transform.Identity;
  ElementIDs_Destination=Autodesk.Revit.DB.ElementTransformUtils.CopyElements(doc_Source,ElementIDs_Source, doc_Destination, transform, copy_paste_options
);
  tx.Commit();
  foreach(ElementId i in ElementIDs_Destination)
  {
  if (doc_Destination.GetElement(i)== null)
  {
    Debug.Print("Element is null")
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 11:41:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763323#M31700</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-23T11:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763737#M31701</link>
      <description>&lt;P&gt;There is not much information on how transactions should be used for this utility but I always assumed the destination document was the one you need an open transaction for as that is the document where new elements are being created. The source document is just providing items that don't change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whenever I've used it this has been the approach used, so try opening and committing a transaction on the destination document before iterating the list of ids. I believe this utility is leveraging copy/paste so I'm not sure if transactions are required, seems odd you've added to a document without opening a transaction for such.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 14:17:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763737#M31701</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2020-09-23T14:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763810#M31702</link>
      <description>&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #666666; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1035859"&gt;@RPTHOMAS108&lt;/a&gt;Apologies, I meant to write doc_Destination instead of doc_Source. I completely agree with your notes. You very correctly mentioned that CopyElements &lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #666666; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;method needs a transaction for the destination and not the source document.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using (Transaction tx = new Transaction(doc_Destination, ("copying elements ")))
{
  tx.Start();
  CopyPasteOptions copy_paste_options = new CopyPasteOptions();
  translation = new XYZ();
  transform = Transform.Identity;
  ElementIDs_Destination=Autodesk.Revit.DB.ElementTransformUtils.CopyElements(doc_Source,ElementIDs_Source, doc_Destination, transform, copy_paste_options
);
  tx.Commit();
  foreach(ElementId i in ElementIDs_Destination)
  {
  if (doc_Destination.GetElement(i)== null)
  {
    Debug.Print("Element is null")
  }
}&lt;/LI-CODE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 14:52:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763810#M31702</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-23T14:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763815#M31703</link>
      <description>&lt;P&gt;This CopyElements sample code opens a transaction on the target document, not the source, which definitely makes more sense, just as Richard suggested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2020/06/set-crop-to-section-box-linked-boundaries-and-intersections.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2020/06/set-crop-to-section-box-linked-boundaries-and-intersections.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 14:51:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9763815#M31703</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-09-23T14:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Revit ElementTransformUtils.CopyElements returns ids of null elements ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9766067#M31704</link>
      <description>&lt;P&gt;To give a better understnading about the issue I will try to provide a valid rvt model with some elements failing to be read using their id when those are copied over another file. I will post here again soon.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 14:28:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-elementtransformutils-copyelements-returns-ids-of-null/m-p/9766067#M31704</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-24T14:28:50Z</dc:date>
    </item>
  </channel>
</rss>

