<?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 Copying elements, types and parameters in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9542634#M33952</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to copy certain elements (instances) from one project into another. The types from the copied project will already exist and be loaded into the new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have managed to copy the elements in their correct location using&amp;nbsp;ElementTransformUtils.CopyElements(), but I am struggling with copying the type parameters (like, for example, the Description and the Type Mark) and the instance parameters (like the Comments or the Mark).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to process all kinds of instances, may they be system types or family symbols, and I have tried using Element.GetOrderedParameters() and LookupParameter("ParameterName") in both types and elements and setting them from the copy project to the paste project using Parameter.AsValueString() and Parameter.SetValueString() respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here goes the question:&lt;/P&gt;&lt;P&gt;Is it possible to copy these type and instance&amp;nbsp;parameters without having to look for them by name, and in a generic manner without having to make distinctions between types and symbols?&lt;/P&gt;&lt;P&gt;If so, any and all tips would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 27 May 2020 10:12:58 GMT</pubDate>
    <dc:creator>franjavigarciavalencia</dc:creator>
    <dc:date>2020-05-27T10:12:58Z</dc:date>
    <item>
      <title>Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9542634#M33952</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to copy certain elements (instances) from one project into another. The types from the copied project will already exist and be loaded into the new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have managed to copy the elements in their correct location using&amp;nbsp;ElementTransformUtils.CopyElements(), but I am struggling with copying the type parameters (like, for example, the Description and the Type Mark) and the instance parameters (like the Comments or the Mark).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to process all kinds of instances, may they be system types or family symbols, and I have tried using Element.GetOrderedParameters() and LookupParameter("ParameterName") in both types and elements and setting them from the copy project to the paste project using Parameter.AsValueString() and Parameter.SetValueString() respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here goes the question:&lt;/P&gt;&lt;P&gt;Is it possible to copy these type and instance&amp;nbsp;parameters without having to look for them by name, and in a generic manner without having to make distinctions between types and symbols?&lt;/P&gt;&lt;P&gt;If so, any and all tips would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 10:12:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9542634#M33952</guid>
      <dc:creator>franjavigarciavalencia</dc:creator>
      <dc:date>2020-05-27T10:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9543085#M33953</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8239982"&gt;@franjavigarciavalencia&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I don't see any problem in copying the element and its instance parameter value from one document to another.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to copy the element from one document to another document, I see along with the element, the element's instance parameter, and its value is also copied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to copy the element's type parameter and its value from one document to another Via UI. I have no luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please be aware that the Revit API hardly ever supports any functionality that is not also available in the user interface.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Therefore, if the UI does not support this, the API will probably not do so either.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, it will always help to research the optimal manual approach to a solution first, before attacking the task programmatically.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this clarifies.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 13:03:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9543085#M33953</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2020-05-27T13:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9544706#M33954</link>
      <description>&lt;P&gt;I have several routines that I use to.copy Loadable as well as system family Types from template or linked models and all of the Parameters always come with them. Perhaps it would help to get the instance, then it's type and copy the type and then the instance?&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 02:14:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/9544706#M33954</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-05-28T02:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/10955981#M33955</link>
      <description>&lt;P&gt;I just came across this thread in another conversation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/phasecreated-amp-phasedemolished-after-using-copyelements/m-p/10955598/highlight/false#M61684" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/revit-api-forum/phasecreated-amp-phasedemolished-after-using-copyelements/m-p/10955598&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll add the suggestion that I made there here as well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe that when you collect a bunch of elements and copy them all together in one single operation, Revit will try to maintain and restore all their mutual relationships in the target database. Therefore, it might help if you add all possible references these elements have to other source database elements to the set of elements to copy. These references will include the element instances themselves, their types, phases, levels, views, materials, and whatever other objects you are interested in. Then you will have to test and see what Revit can do to try to avoid creating duplicates of them in the target database and map them to existing target objects instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This behaviour is hinted at in the list of extensible storage features:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2011/06/extensible-storage-features.html#7" target="_blank" rel="nofollow noopener noreferrer"&gt;https://thebuildingcoder.typepad.com/blog/2011/06/extensible-storage-features.html#7&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 09:00:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/10955981#M33955</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-02-17T09:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13224805#M33956</link>
      <description>&lt;LI-CODE lang="general"&gt;I would like to open this thread.
I'm finding copyElement method really slow. When I call it in a foreach function it is like it will refresh UI in every call. So copyElements seems to be the solution. But I'm having problems because returnIds do not map 1.by 1 to inputIds.

So, is there a way to make it match 1 to 1 or to make single copy to refresh at the end of the transaction?

Regards&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 22 Dec 2024 05:06:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13224805#M33956</guid>
      <dc:creator>gjordanp</dc:creator>
      <dc:date>2024-12-22T05:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13224999#M33957</link>
      <description>&lt;P&gt;Yes, the input and output collections are unsorted, so they do not match their elements one-to-one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two things to try come to mind:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use some other kind of identification marker id on your input elements that is included in the copy, so you can match them yourself afterwards&lt;/LI&gt;
&lt;LI&gt;Use a transaction group wrapping individual calls to CopyElement in subtransactions&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The latter might enable using CopyElement one by one and yet retain the speed of one single top-lvele transaction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2024 07:59:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13224999#M33957</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-12-22T07:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13225347#M33958</link>
      <description>&lt;P&gt;Thanks Jeremy! Didn't though about the first one. I'll try both and let you know&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2024 12:34:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13225347#M33958</guid>
      <dc:creator>gjordanp</dc:creator>
      <dc:date>2024-12-22T12:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Copying elements, types and parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13226929#M33959</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attached my code to work with the first option you suggested. It works perfectly fine when originDocument is different than destinationDocument, but when I'm trying to copy in the same document, "Mark" parameter values are not copied to the copied elements. Even that I have verify in the line before the copyElements, that the elements to be copied have the Mark Parameter Value.&lt;BR /&gt;&lt;BR /&gt;¿Any Thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using Autodesk.Revit.Attributes;&lt;BR /&gt;using Autodesk.Revit.DB;&lt;BR /&gt;using Autodesk.Revit.DB.Structure;&lt;BR /&gt;using Autodesk.Revit.DB.Visual;&lt;BR /&gt;using Autodesk.Revit.UI;&lt;BR /&gt;using Autodesk.Revit.UI.Selection;&lt;BR /&gt;using RevitMV.Auth.services;&lt;BR /&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Windows.Controls;&lt;/P&gt;&lt;P&gt;namespace RevitMV&lt;BR /&gt;{&lt;BR /&gt;[Transaction(TransactionMode.Manual)]&lt;BR /&gt;class RB_LS_CopyPasteLosas : MN_MasterClass&lt;BR /&gt;{&lt;BR /&gt;public override Result ExecuteTool(ExternalCommandData commandData, ref string message, ElementSet elements)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;UIApplication rvtUIApp = commandData.Application;&lt;BR /&gt;UIDocument rvtUIDoc = rvtUIApp.ActiveUIDocument;&lt;BR /&gt;Autodesk.Revit.ApplicationServices.Application revitApp = rvtUIApp.Application;&lt;BR /&gt;Document m_rvtDoc = rvtUIDoc.Document;&lt;BR /&gt;List&amp;lt;View&amp;gt; openViews = GetAllOpenViews(rvtUIApp);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;View originView;&lt;BR /&gt;View destinationView;&lt;BR /&gt;IList&amp;lt;Reference&amp;gt; refs;&lt;BR /&gt;Document originDoc;&lt;BR /&gt;Document destinationDoc;&lt;BR /&gt;XYZ puntoInicio;&lt;BR /&gt;XYZ puntoFinal;&lt;BR /&gt;int copiedBarsCount = 0;&lt;BR /&gt;int pastedBarsCount = 0;&lt;/P&gt;&lt;P&gt;List&amp;lt;ElementId&amp;gt; detailItemBarras_list = new List&amp;lt;ElementId&amp;gt;();&lt;BR /&gt;List&amp;lt;List&amp;lt;ElementId&amp;gt;&amp;gt; rebarToCopy_list = new List&amp;lt;List&amp;lt;ElementId&amp;gt;&amp;gt;();&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rebarToCopy_list_flat = new List&amp;lt;ElementId&amp;gt;();&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rbcCopiedIds = new List&amp;lt;ElementId&amp;gt;();&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rbCopiedIds = new List&amp;lt;ElementId&amp;gt;();&lt;/P&gt;&lt;P&gt;using (Transaction trans1 = new Transaction(m_rvtDoc))&lt;BR /&gt;{&lt;BR /&gt;trans1.Start("CopyPaste - Copiar Barras");&lt;/P&gt;&lt;P&gt;Selection sel = rvtUIDoc.Selection;&lt;BR /&gt;ElementoSimboloFiltro selFilter = new ElementoSimboloFiltro();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;refs = sel.PickObjects(ObjectType.Element, selFilter, "Elija las barras a aplicar CopyPaste");&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;copiedBarsCount = refs.Count;&lt;/P&gt;&lt;P&gt;//Ocultamos los rebars para mejorar seleccion e puntos&lt;BR /&gt;RB_LS_ArmarLosas.HideCategoryTemporary(m_rvtDoc, BuiltInCategory.OST_Rebar);&lt;BR /&gt;&lt;BR /&gt;//Seleccionamos punto de origen&lt;BR /&gt;Selection selection1 = rvtUIDoc.Selection;&lt;BR /&gt;puntoInicio = selection1.PickPoint("Seleccione punto de origen, Se copiara desde el punto de origen al punto de destino");&lt;BR /&gt;originDoc = rvtUIApp.ActiveUIDocument.Document;&lt;BR /&gt;originView = originDoc.ActiveView;&lt;/P&gt;&lt;P&gt;//Buscamos los detail item y los Rebars a ser copiados.&lt;BR /&gt;foreach (var reference in refs)&lt;BR /&gt;{&lt;BR /&gt;//Elemento simbolico de losas&lt;BR /&gt;Element detailItemBarras = originDoc.GetElement(reference.ElementId) as Element;&lt;BR /&gt;//Obtenemos los rebar containers&lt;BR /&gt;List&amp;lt;RebarContainer&amp;gt; rebarContainerList = RB_LS_ArmarLosas.GetRebarContainersFromSymbol(originDoc, detailItemBarras);&lt;BR /&gt;List&amp;lt;Rebar&amp;gt; rebarList = RB_LS_ArmarLosas.GetRebarFromSymbol(originDoc, detailItemBarras);&lt;BR /&gt;//Creamos la lista de ids de los rebar containers&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rebarContainersToCopy = rebarContainerList.Select(rc =&amp;gt; rc.Id).ToList();&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rebarToCopy = rebarList.Select(rb =&amp;gt; rb.Id).ToList();&lt;/P&gt;&lt;P&gt;detailItemBarras_list.Add(detailItemBarras.Id);&lt;BR /&gt;rebarToCopy_list.Add(rebarContainersToCopy.Count &amp;gt; 0 ? rebarContainersToCopy : rebarToCopy);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rebarToCopy_list_flat = rebarToCopy_list.SelectMany(innerList =&amp;gt; innerList).ToList();&lt;/P&gt;&lt;P&gt;//CopyElement Entrega los elementos copiados en desorden, por lo que:&lt;BR /&gt;//Agregamos parametro para identificar las barras copiadas, en el parametro Mark se agrega el indice de la lista.&lt;BR /&gt;detailItemBarras_list.ForEach(e =&amp;gt; originDoc.GetElement(e).LookupParameter("Mark").Set(detailItemBarras_list.IndexOf(e).ToString()));&lt;BR /&gt;//Agregamos parametro para identificar las barras copiadas, en el parametro Mark se agrega el indice de la lista&lt;BR /&gt;rebarToCopy_list_flat.ForEach(e =&amp;gt; originDoc.GetElement(e).LookupParameter("Mark").Set(rebarToCopy_list_flat.IndexOf(e).ToString()));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var openDocuments = GetAllOpenDocumnets(rvtUIApp);&lt;BR /&gt;//Cuadro de dialogo para seleccion vista de destino&lt;BR /&gt;var dlg = new RB_DG_LS_CopyPaste(openDocuments);&lt;BR /&gt;dlg.ShowDialog();&lt;/P&gt;&lt;P&gt;if (dlg.DialogResult == false) return Result.Failed;&lt;/P&gt;&lt;P&gt;destinationView = dlg.SelectedView;&lt;BR /&gt;destinationDoc = destinationView.Document;&lt;/P&gt;&lt;P&gt;//Se muestran rebars nuevamente&lt;BR /&gt;RB_LS_ArmarLosas.DeactivateTemporaryView(m_rvtDoc);&lt;/P&gt;&lt;P&gt;//Make visible Mark Values for next transaction&lt;BR /&gt;originDoc.Regenerate();&lt;/P&gt;&lt;P&gt;trans1.Commit();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//Activamos el documento de destino&lt;BR /&gt;if (destinationDoc.PathName != originDoc.PathName)&lt;BR /&gt;{&lt;BR /&gt;rvtUIDoc=new UIDocument(destinationView.Document);&lt;BR /&gt;rvtUIApp.OpenAndActivateDocument(destinationDoc.PathName);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;destinationDoc = originDoc;&lt;BR /&gt;}&lt;BR /&gt;//Change la vista activa&lt;BR /&gt;rvtUIDoc.ActiveView = destinationView;&lt;BR /&gt;rvtUIDoc.RefreshActiveView();&lt;/P&gt;&lt;P&gt;//Hacemos la seleccion de destino&lt;BR /&gt;Selection selection2 = rvtUIDoc.Selection;&lt;BR /&gt;puntoFinal = selection2.PickPoint("Seleccione punto de destino, Se copiara desde el punto de origen al punto de destino");&lt;BR /&gt;destinationDoc = rvtUIApp.ActiveUIDocument.Document;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (Transaction trans2 = new Transaction(destinationDoc))&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;trans2.Start("CopyPaste - Pegar Barras");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;destinationDoc.Regenerate();&lt;/P&gt;&lt;P&gt;//transformation&lt;BR /&gt;Transform transform = Transform.CreateTranslation(new XYZ(puntoFinal.X - puntoInicio.X, puntoFinal.Y - puntoInicio.Y, destinationView.GenLevel.ProjectElevation - originView.GenLevel.ProjectElevation));&lt;BR /&gt;Transform transformSymbol = Transform.CreateTranslation(new XYZ(puntoFinal.X - puntoInicio.X, puntoFinal.Y - puntoInicio.Y, 0));&lt;/P&gt;&lt;P&gt;//Copypasteoptiones&lt;BR /&gt;CopyPasteOptions copyPasteOptions = new CopyPasteOptions();&lt;/P&gt;&lt;P&gt;//Copiamos los symbolos de las losas&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; simbCopiedId_list = ElementTransformUtils.CopyElements(originView, detailItemBarras_list, destinationView, transformSymbol, copyPasteOptions).ToList();&lt;/P&gt;&lt;P&gt;//Copiamos los Rebar&lt;BR /&gt;rbcCopiedIds = ElementTransformUtils.CopyElements(originDoc, rebarToCopy_list_flat, destinationDoc, transform, copyPasteOptions).ToList();&lt;/P&gt;&lt;P&gt;//Ordenamos los ids copiados por el parametro Mark&lt;BR /&gt;simbCopiedId_list = simbCopiedId_list.OrderBy(e =&amp;gt; int.Parse(destinationDoc.GetElement(e).LookupParameter("Mark").AsValueString())).ToList();&lt;/P&gt;&lt;P&gt;//Ordenamos los ids copiados por el parametro Mark, producto que CopyElement devuelve una lista desordenada.&lt;BR /&gt;rbcCopiedIds = rbcCopiedIds.OrderBy(e =&amp;gt; int.Parse(destinationDoc.GetElement(e).LookupParameter("Mark").AsValueString())).ToList();&lt;/P&gt;&lt;P&gt;//Eliminamos el Mark para el documento de destino.&lt;BR /&gt;rbcCopiedIds.ForEach(e =&amp;gt; destinationDoc.GetElement(e).LookupParameter("Mark").Set(""));&lt;BR /&gt;simbCopiedId_list.ForEach(e =&amp;gt; destinationDoc.GetElement(e).LookupParameter("Mark").Set(""));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//Reconstruimos las listas de los ids copiados&lt;BR /&gt;List&amp;lt;List&amp;lt;ElementId&amp;gt;&amp;gt; rbcCopiedIds_list = new List&amp;lt;List&amp;lt;ElementId&amp;gt;&amp;gt;();&lt;BR /&gt;int index = 0;&lt;BR /&gt;foreach (var simbCopiedId in simbCopiedId_list)&lt;BR /&gt;{&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rbcCopiedIds_aux = new List&amp;lt;ElementId&amp;gt;();&lt;/P&gt;&lt;P&gt;rbcCopiedIds_aux = rbcCopiedIds.GetRange(index, rebarToCopy_list[index].Count);&lt;/P&gt;&lt;P&gt;rbcCopiedIds_list.Add(rbcCopiedIds_aux);&lt;/P&gt;&lt;P&gt;index += rebarToCopy_list[index].Count;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//Asignamos los hosts y los UID a los rebar containers y rebar&lt;BR /&gt;pastedBarsCount = 0;&lt;/P&gt;&lt;P&gt;List&amp;lt;ElementId&amp;gt; simbolsToDelete = new List&amp;lt;ElementId&amp;gt;();&lt;BR /&gt;List&amp;lt;ElementId&amp;gt; rebarToDelete = new List&amp;lt;ElementId&amp;gt;();&lt;/P&gt;&lt;P&gt;foreach (var simbCopiedId in simbCopiedId_list)&lt;BR /&gt;{&lt;BR /&gt;FamilyInstance copiedSymbolElement = destinationDoc.GetElement(simbCopiedId) as FamilyInstance;&lt;BR /&gt;List&amp;lt;Floor&amp;gt; losas_host = RB_LS_ArmarLosas.GetLosaHostFromSymbol(destinationDoc, copiedSymbolElement);&lt;BR /&gt;if (losas_host.Count == 0)&lt;BR /&gt;{&lt;BR /&gt;//Borramos los elementos copiados si no tienen host&lt;BR /&gt;simbolsToDelete.Add(simbCopiedId);&lt;BR /&gt;rebarToDelete.AddRange(rbcCopiedIds_list[simbCopiedId_list.IndexOf(simbCopiedId)]);&lt;BR /&gt;continue;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Floor losaHost = losas_host?.First();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach (ElementId rbcId in rbcCopiedIds_list[simbCopiedId_list.IndexOf(simbCopiedId)])&lt;BR /&gt;{&lt;BR /&gt;Element rebarCopied = destinationDoc.GetElement(rbcId);&lt;BR /&gt;if (rebarCopied is RebarContainer rbcCopied)&lt;BR /&gt;{&lt;BR /&gt;rbcCopied.SetHostId(destinationDoc, losaHost.Id);&lt;BR /&gt;FN_Rebar.AssignRbcParam(rbcCopied, FN_params.RB_uId, copiedSymbolElement.UniqueId, ParamType.s);&lt;BR /&gt;rbcCopied.SetUnobscuredInView(destinationView, true);&lt;BR /&gt;}&lt;BR /&gt;else if (rebarCopied is Rebar rbCopied)&lt;BR /&gt;{&lt;BR /&gt;rbCopied.SetHostId(destinationDoc, losaHost.Id);&lt;BR /&gt;rbCopied.LookupParameter(FN_params.RB_uId).Set(copiedSymbolElement.UniqueId);&lt;BR /&gt;rbCopied.SetUnobscuredInView(destinationView, true);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;pastedBarsCount++;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//Borrar elementos sin host&lt;BR /&gt;destinationDoc.Delete(simbolsToDelete);&lt;BR /&gt;destinationDoc.Delete(rebarToDelete);&lt;/P&gt;&lt;P&gt;trans2.Commit();&lt;BR /&gt;}&lt;BR /&gt;catch (Exception e)&lt;BR /&gt;{&lt;BR /&gt;LoggerMain.Logger.Error(e, "Error al hacer CopyPaste Losas");&lt;BR /&gt;TaskDialog.Show("Error", e.Message);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;using (Transaction trans3=new Transaction(originDoc))&lt;BR /&gt;{&lt;BR /&gt;trans3.Start("Borramos parametro Mark de barras y simbolos de Origen");&lt;/P&gt;&lt;P&gt;try&lt;BR /&gt;{&lt;BR /&gt;////Borramos el parametro Mark para el documento de origen.&lt;BR /&gt;rebarToCopy_list_flat.ForEach(e =&amp;gt; originDoc.GetElement(e).LookupParameter("Mark").Set(""));&lt;BR /&gt;detailItemBarras_list.ForEach(e =&amp;gt; originDoc.GetElement(e).LookupParameter("Mark").Set(""));&lt;BR /&gt;}&lt;BR /&gt;catch (Exception e)&lt;BR /&gt;{&lt;BR /&gt;LoggerMain.Logger.Error(e, "Error al borrar el Mark");&lt;BR /&gt;TaskDialog.Show("Error", e.Message);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;trans3.Commit();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if (destinationView.Document != originDoc)&lt;BR /&gt;{&lt;BR /&gt;rvtUIDoc = new UIDocument(destinationView.Document);&lt;BR /&gt;rvtUIApp.OpenAndActivateDocument(destinationDoc.PathName);&lt;BR /&gt;}&lt;BR /&gt;//Change view&lt;BR /&gt;rvtUIDoc.ActiveView = destinationView;&lt;BR /&gt;rvtUIDoc.RefreshActiveView();&lt;/P&gt;&lt;P&gt;//Mensaje final&lt;BR /&gt;TaskDialog.Show("Copy Paste exitoso", "Barras copiadas: " + copiedBarsCount + "\nBarras pegadas: " + pastedBarsCount);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;catch (Exception e)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;LoggerMain.Logger.Fatal(e, "Error al hacer CopyPaste Losas");&lt;BR /&gt;TaskDialog.Show("Error", e.Message);&lt;BR /&gt;return Result.Failed;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LoggerMain.ProcesoExitosoInfo();&lt;BR /&gt;return Result.Succeeded;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public class ElementoSimboloFiltro : ISelectionFilter&lt;BR /&gt;{&lt;BR /&gt;public bool AllowElement(Element elem)&lt;BR /&gt;{&lt;BR /&gt;if (elem.Category != null)&lt;BR /&gt;{&lt;BR /&gt;if (elem.Name.Contains("SPR_SYM_Losa") || elem.Name.Contains("Armaduras con empalmes"))&lt;BR /&gt;{&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;public bool AllowReference(Reference reference, XYZ xyz)&lt;BR /&gt;{&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public List&amp;lt;View&amp;gt; GetAllOpenViews(UIApplication uiApp)&lt;BR /&gt;{&lt;BR /&gt;List&amp;lt;View&amp;gt; openViews = new List&amp;lt;View&amp;gt;();&lt;/P&gt;&lt;P&gt;foreach (Document doc in uiApp.Application.Documents)&lt;BR /&gt;{&lt;BR /&gt;// Get the active document&lt;BR /&gt;UIDocument uiDoc = new UIDocument(doc);&lt;/P&gt;&lt;P&gt;// Get all open UIViews&lt;BR /&gt;IList&amp;lt;UIView&amp;gt; uiViews = uiDoc.GetOpenUIViews();&lt;/P&gt;&lt;P&gt;foreach (UIView uiView in uiViews)&lt;BR /&gt;{&lt;BR /&gt;// Get the view ID from the UIView and convert it to a View object&lt;BR /&gt;View view = doc.GetElement(uiView.ViewId) as View;&lt;BR /&gt;if (view != null)&lt;BR /&gt;{&lt;BR /&gt;openViews.Add(view);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return openViews;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public List&amp;lt;Document&amp;gt; GetAllOpenDocumnets(UIApplication uiApp)&lt;BR /&gt;{&lt;BR /&gt;List&amp;lt;Document&amp;gt; openDocs = new List&amp;lt;Document&amp;gt;();&lt;/P&gt;&lt;P&gt;foreach (Document doc in uiApp.Application.Documents)&lt;BR /&gt;{&lt;BR /&gt;openDocs.Add(doc);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return openDocs;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2024 11:40:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copying-elements-types-and-parameters/m-p/13226929#M33959</guid>
      <dc:creator>gjordanp</dc:creator>
      <dc:date>2024-12-23T11:40:23Z</dc:date>
    </item>
  </channel>
</rss>

