<?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 Renombrado de parámetros compartidos (Rename shared parameter) in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13262126#M1431</link>
    <description>&lt;P&gt;Tengo la necesidad de renombrar unos parámetros compartidos por cambios en la nomenclatura de los nombres.&lt;/P&gt;&lt;P&gt;El problema es que al hacer los nuevos parámetros se utilizo el mismo GUID de los anteriores y eso genera errores al intentar cargarlos directamente.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Estoy desarrollando un pequeño script en python que comparto más abajo para intentar realizar esta tarea. La idea es convertir el parámetro original en un parámetro de familia, renombrarlo y volver a convertirlo en parámetro de familia.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Todo el proceso se realiza sin problemas hasta el último paso, donde se vuelve a convertir a parámetro compartido. Este último paso arroja un error muy poco descriptivo (Parameter replacement failed) por lo que no se como arreglarlo:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[ERROR] Error in Transaction Context: has rolled back.
Exception : Autodesk.Revit.Exceptions.InvalidOperationException: Parameter replacement failed.
   at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle&amp;amp; exception)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;El código:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"pruebas de cambio de nombre de parametros compartidos"

from rpw import revit, db, ui, DB, UI

# Acceso global al FamilyManager
fm = doc.FamilyManager

# Obtenemos un parámetro compartido del archivo actual
def obtener_parametro_compartido(grupo, nombre):
	try:
		spFile = revit.app.OpenSharedParameterFile()
		spGroup = spFile.Groups.get_Item(grupo)
		spParam = spGroup.Definitions.get_Item(nombre)
		return spParam
	except:
		print(f"Parámetro {nombre} no encontrado.")

# Renombramos el parámetro compartido indicado
def renombrar_parametro_compartido (param, nombre):
	grupo = param.Definition.ParameterGroup
	deInstancia = param.IsInstance
	spGrupo = "220_CTN_ContentSTR"
	# Convertir en nuevo parámetro no compartido
	new_param = fm.ReplaceParameter(param, nombre, grupo, deInstancia)
	# Borrar el parámetro compartido anterior
	fm.RemoveParameter(param)
	# Volver a convertir a parámetro compartido
	spParam = obtener_parametro_compartido(spGrupo, "SNR_STR_Waterproof")
	fm.ReplaceParameter(new_param, spParam, grupo, deInstancia)
	print(f"\nParámetro renombrado: {new_param.Definition.Name}")

with db.Transaction("Nombre"):
	for param in fm.GetParameters():
		if param.Definition.Name == "SNR_Waterproof":
			renombrar_parametro_compartido(param, "SNR_STR_Waterproof")&lt;/LI-CODE&gt;&lt;P&gt;El error se produce en la línea 29, donde se vuelve a generar el parámetro compartido.&lt;BR /&gt;(He probado como macro en C# y arroja el mismo error)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gracias de antemano a quien me pueda ayudar&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jan 2025 13:21:45 GMT</pubDate>
    <dc:creator>pedro_abril</dc:creator>
    <dc:date>2025-01-15T13:21:45Z</dc:date>
    <item>
      <title>Renombrado de parámetros compartidos (Rename shared parameter)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13262126#M1431</link>
      <description>&lt;P&gt;Tengo la necesidad de renombrar unos parámetros compartidos por cambios en la nomenclatura de los nombres.&lt;/P&gt;&lt;P&gt;El problema es que al hacer los nuevos parámetros se utilizo el mismo GUID de los anteriores y eso genera errores al intentar cargarlos directamente.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Estoy desarrollando un pequeño script en python que comparto más abajo para intentar realizar esta tarea. La idea es convertir el parámetro original en un parámetro de familia, renombrarlo y volver a convertirlo en parámetro de familia.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Todo el proceso se realiza sin problemas hasta el último paso, donde se vuelve a convertir a parámetro compartido. Este último paso arroja un error muy poco descriptivo (Parameter replacement failed) por lo que no se como arreglarlo:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[ERROR] Error in Transaction Context: has rolled back.
Exception : Autodesk.Revit.Exceptions.InvalidOperationException: Parameter replacement failed.
   at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle&amp;amp; exception)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;El código:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"pruebas de cambio de nombre de parametros compartidos"

from rpw import revit, db, ui, DB, UI

# Acceso global al FamilyManager
fm = doc.FamilyManager

# Obtenemos un parámetro compartido del archivo actual
def obtener_parametro_compartido(grupo, nombre):
	try:
		spFile = revit.app.OpenSharedParameterFile()
		spGroup = spFile.Groups.get_Item(grupo)
		spParam = spGroup.Definitions.get_Item(nombre)
		return spParam
	except:
		print(f"Parámetro {nombre} no encontrado.")

# Renombramos el parámetro compartido indicado
def renombrar_parametro_compartido (param, nombre):
	grupo = param.Definition.ParameterGroup
	deInstancia = param.IsInstance
	spGrupo = "220_CTN_ContentSTR"
	# Convertir en nuevo parámetro no compartido
	new_param = fm.ReplaceParameter(param, nombre, grupo, deInstancia)
	# Borrar el parámetro compartido anterior
	fm.RemoveParameter(param)
	# Volver a convertir a parámetro compartido
	spParam = obtener_parametro_compartido(spGrupo, "SNR_STR_Waterproof")
	fm.ReplaceParameter(new_param, spParam, grupo, deInstancia)
	print(f"\nParámetro renombrado: {new_param.Definition.Name}")

with db.Transaction("Nombre"):
	for param in fm.GetParameters():
		if param.Definition.Name == "SNR_Waterproof":
			renombrar_parametro_compartido(param, "SNR_STR_Waterproof")&lt;/LI-CODE&gt;&lt;P&gt;El error se produce en la línea 29, donde se vuelve a generar el parámetro compartido.&lt;BR /&gt;(He probado como macro en C# y arroja el mismo error)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gracias de antemano a quien me pueda ayudar&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 13:21:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13262126#M1431</guid>
      <dc:creator>pedro_abril</dc:creator>
      <dc:date>2025-01-15T13:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Renombrado de parámetros compartidos (Rename shared parameter)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13262574#M1432</link>
      <description>&lt;P&gt;Muy difícil. Puede ser que es imposible. Aquí una explicación:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="model-response-message-contentr_7dc2cd4a7e822705" class="markdown markdown-main-panel stronger" dir="ltr"&gt;
&lt;P data-sourcepos="1:1-1:136"&gt;Alright, let's tackle the question of renaming shared parameters in Revit. This is a common point of confusion for Revit API developers.&lt;/P&gt;
&lt;P data-sourcepos="3:1-3:143"&gt;&lt;STRONG&gt;The Short Answer:&lt;/STRONG&gt; You cannot directly rename a shared parameter definition once it's created and especially if it's been used in a project.&lt;/P&gt;
&lt;P data-sourcepos="5:1-5:34"&gt;&lt;STRONG&gt;The Why (and the workarounds):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="7:1-7:397"&gt;The core issue lies in how Revit manages shared parameters. They are stored in an external text file (.txt) and referenced by their GUID (Globally Unique Identifier). This GUID is the immutable identifier. Renaming the parameter within the shared parameter file &lt;EM&gt;does not&lt;/EM&gt; change the GUID. Therefore, Revit still recognizes the parameter by its original GUID, effectively ignoring the name change.&lt;/P&gt;
&lt;P data-sourcepos="9:1-9:316"&gt;If the parameter is already used in a Revit project (assigned to families, project parameters, schedules, etc.), changing the name in the shared parameter file will lead to inconsistencies and potential data loss. Revit relies on the GUID to maintain the link between the project and the shared parameter definition.&lt;/P&gt;
&lt;P data-sourcepos="11:1-11:36"&gt;&lt;STRONG&gt;What you &lt;EM&gt;can&lt;/EM&gt; do (Workarounds):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="13:1-13:115"&gt;Since direct renaming is impossible, we must employ workarounds. Here are the most common and effective approaches:&lt;/P&gt;
&lt;OL data-sourcepos="15:1-114:0"&gt;
&lt;LI data-sourcepos="15:1-110:0"&gt;
&lt;P data-sourcepos="15:5-15:64"&gt;&lt;STRONG&gt;Creating a New Shared Parameter and Transferring Values:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="17:5-17:55"&gt;This is the cleanest and most recommended approach.&lt;/P&gt;
&lt;UL data-sourcepos="19:5-24:0"&gt;
&lt;LI data-sourcepos="19:5-19:95"&gt;Create a new shared parameter with the desired name and properties (type, group, etc.).&lt;/LI&gt;
&lt;LI data-sourcepos="20:5-20:81"&gt;Use the Revit API to iterate through elements that use the old parameter.&lt;/LI&gt;
&lt;LI data-sourcepos="21:5-21:61"&gt;Read the value of the old parameter for each element.&lt;/LI&gt;
&lt;LI data-sourcepos="22:5-22:66"&gt;Set the value of the new parameter to the retrieved value.&lt;/LI&gt;
&lt;LI data-sourcepos="23:5-24:0"&gt;(Optional) Remove the old parameter from the elements.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P data-sourcepos="25:5-25:26"&gt;&lt;STRONG&gt;Code Example (C#):&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV class="code-block ng-tns-c1396053791-30 ng-trigger ng-trigger-codeBlockRevealAnimation"&gt;
&lt;DIV class="code-block-decoration ng-tns-c1396053791-30 header-formatted gds-title-s ng-star-inserted"&gt;&lt;SPAN class="ng-tns-c1396053791-30"&gt;C#&lt;/SPAN&gt;
&lt;DIV class="buttons ng-tns-c1396053791-30 ng-star-inserted"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="ng-tns-c1396053791-30 formatted-code-block-internal-container"&gt;
&lt;DIV class="animated-opacity ng-tns-c1396053791-30"&gt;
&lt;PRE class="ng-tns-c1396053791-30"&gt;&lt;CODE class="code-container ng-tns-c1396053791-30 formatted" role="text" data-test-id="code-content" data-sourcepos="27:5-100:9"&gt;&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; Autodesk.Revit.DB;
&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; Autodesk.Revit.UI;
&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; System.Collections.Generic;
&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; System.Linq;

&lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;void&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;RenameSharedParameter&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Document doc, &lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; oldParameterName, &lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; newParameterName&lt;/SPAN&gt;)&lt;/SPAN&gt;
{
    &lt;SPAN class="hljs-comment"&gt;// Get the shared parameter file&lt;/SPAN&gt;
    DefinitionFile sharedParamsFile = doc.Application.OpenSharedParameterFile();
    &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (sharedParamsFile == &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;)
    {
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"Error"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"No shared parameter file found."&lt;/SPAN&gt;);
        &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt;;
    }

    &lt;SPAN class="hljs-comment"&gt;//Find old parameter definition&lt;/SPAN&gt;
    Definition oldDefinition = FindSharedParameterDefinition(sharedParamsFile, oldParameterName);
    &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (oldDefinition == &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;)
    {
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"Error"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;$"Parameter '&lt;SPAN class="hljs-subst"&gt;{oldParameterName}&lt;/SPAN&gt;' not found."&lt;/SPAN&gt;);
        &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt;;
    }

            &lt;SPAN class="hljs-comment"&gt;//Find shared parameter group&lt;/SPAN&gt;
            DefinitionGroup &lt;SPAN class="hljs-keyword"&gt;group&lt;/SPAN&gt; = oldDefinition.OwnerGroup;

    &lt;SPAN class="hljs-comment"&gt;// Create new parameter definition&lt;/SPAN&gt;
    ExternalDefinitionCreationOptions options = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; ExternalDefinitionCreationOptions(newParameterName, oldDefinition.ParameterType);
            Definition newDefinition = &lt;SPAN class="hljs-keyword"&gt;group&lt;/SPAN&gt;.Definitions.Create(options);

    &lt;SPAN class="hljs-comment"&gt;// Find all elements using the old parameter&lt;/SPAN&gt;
    FilteredElementCollector collector = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; FilteredElementCollector(doc);
    collector.WhereElementIsNotElementType(); &lt;SPAN class="hljs-comment"&gt;// Exclude element types&lt;/SPAN&gt;

    List&amp;lt;Element&amp;gt; elementsWithParameter = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; List&amp;lt;Element&amp;gt;();
    &lt;SPAN class="hljs-keyword"&gt;foreach&lt;/SPAN&gt; (Element element &lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; collector)
    {
        &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (element.GetParameters(oldParameterName).Count &amp;gt; &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;)
        {
            elementsWithParameter.Add(element);
        }
    }
    &lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; (Transaction trans = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; Transaction(doc, &lt;SPAN class="hljs-string"&gt;"Transfer Parameter Values"&lt;/SPAN&gt;))
    {
        trans.Start();
        &lt;SPAN class="hljs-keyword"&gt;foreach&lt;/SPAN&gt; (Element element &lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; elementsWithParameter)
        {
            Parameter oldParam = element.LookupParameter(oldParameterName);
            Parameter newParam = element.LookupParameter(newParameterName);
            &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (oldParam != &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt; &amp;amp;&amp;amp; newParam != &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;)
            {
                newParam.Set(oldParam.AsValueString()); &lt;SPAN class="hljs-comment"&gt;// Transfer the value - Adapt as needed for different parameter types&lt;/SPAN&gt;
            }
        }
        trans.Commit();
    }
}

    &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;private&lt;/SPAN&gt; Definition &lt;SPAN class="hljs-title"&gt;FindSharedParameterDefinition&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;DefinitionFile file, &lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; parameterName&lt;/SPAN&gt;)&lt;/SPAN&gt;
    {
        &lt;SPAN class="hljs-keyword"&gt;foreach&lt;/SPAN&gt; (DefinitionGroup &lt;SPAN class="hljs-keyword"&gt;group&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; file.Groups)
        {
            &lt;SPAN class="hljs-keyword"&gt;foreach&lt;/SPAN&gt; (Definition definition &lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;group&lt;/SPAN&gt;.Definitions)
            {
                &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (definition.Name == parameterName)
                {
                    &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; definition;
                }
            }
        }
        &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;;
    }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P data-sourcepos="102:5-102:38"&gt;&lt;STRONG&gt;Key improvements in this code:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL data-sourcepos="104:5-110:0"&gt;
&lt;LI data-sourcepos="104:5-104:60"&gt;Handles &lt;CODE&gt;DefinitionFile&lt;/CODE&gt; opening and error checking.&lt;/LI&gt;
&lt;LI data-sourcepos="105:5-105:104"&gt;Uses &lt;CODE&gt;FindSharedParameterDefinition&lt;/CODE&gt; function to locate shared parameter definition in the file.&lt;/LI&gt;
&lt;LI data-sourcepos="106:5-106:81"&gt;Uses &lt;CODE&gt;ExternalDefinitionCreationOptions&lt;/CODE&gt; to create new shared parameters.&lt;/LI&gt;
&lt;LI data-sourcepos="107:5-107:88"&gt;Uses &lt;CODE&gt;FilteredElementCollector&lt;/CODE&gt; to find all elements that use the old parameter.&lt;/LI&gt;
&lt;LI data-sourcepos="108:5-108:45"&gt;Uses Transactions for data integrity.&lt;/LI&gt;
&lt;LI data-sourcepos="109:5-110:0"&gt;Includes handling for different parameter types by using &lt;CODE&gt;AsValueString()&lt;/CODE&gt;. Consider more robust type handling for real-world scenarios.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI data-sourcepos="111:1-114:0"&gt;
&lt;P data-sourcepos="111:5-111:58"&gt;&lt;STRONG&gt;Using a Parameter Binding File (Less Recommended):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="113:5-113:212"&gt;This approach is less common and generally not advised for simple renaming. It involves manipulating the parameter binding file (which links shared parameters to categories). It's complex and prone to errors.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P data-sourcepos="115:1-115:15"&gt;&lt;STRONG&gt;In Summary:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="117:1-117:471"&gt;Renaming shared parameters directly is not possible due to Revit's internal handling of GUIDs. The recommended approach is to create a new shared parameter and transfer the values from the old parameter to the new one using the Revit API. This ensures data integrity and avoids potential issues. The provided code example offers a robust and practical implementation of this method. Remember to adapt the value transfer part to handle different parameter types correctly.&lt;/P&gt;
&lt;P data-sourcepos="117:1-117:471"&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Jan 2025 16:36:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13262574#M1432</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-01-15T16:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Renombrado de parámetros compartidos (Rename shared parameter)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13265316#M1433</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Thank you very much for the answer.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;As you say, it is very difficult to handle this situation when they are already in use in a project.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Thanks for the example, I found it very didactic and I will reuse it in my tool.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;It is true that my code is designed for families and once I try to load them in a project I get errors. It is only valid in new projects.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Anyway I publish the correction to my code for families:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(Translated with DeepL.com (free version))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Muchas gracias por la respuesta.&lt;BR /&gt;Como dices, es muy difícil manejar esta situación cuando ya están en uso en un proyecto.&lt;BR /&gt;Gracias por el ejemplo, me ha resultado muy didáctico y lo reutilizaré en mi herramienta.&lt;BR /&gt;&lt;BR /&gt;Es verdad que mi código está pensado para familias y que una vez intento cargarlos en algún proyecto me da errores. Sólo es válido en proyectos nuevos.&lt;/P&gt;&lt;P&gt;De todas maneras publico la corrección a mi código para familias:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"pruebas de cambio de nombre de parametros compartidos"

from rpw import revit, db, ui, DB, UI

# Acceso global al FamilyManager
fm = doc.FamilyManager

# Obtenemos un parámetro compartido del archivo actual
def obtener_parametro_compartido(grupo, nombre):
	try:
		spFile = revit.app.OpenSharedParameterFile()
		spGroup = spFile.Groups.get_Item(grupo)
		spParam = spGroup.Definitions.get_Item(nombre)
		return spParam
	except:
		print(f"Parámetro {nombre} no encontrado.")

# Renombramos el parámetro compartido indicado
def renombrar_parametro_compartido (param, nombre):
	grupo = param.Definition.ParameterGroup
	deInstancia = param.IsInstance
	spGrupo = "220_CTN_ContentSTR"
	# Convertir en nuevo parámetro no compartido
        # CORRECCION: generamos un parametro intermedio
        # con diferente nombre, así no interfiere con el siguiente paso
	new_param = fm.ReplaceParameter(param, nombre + "_AUX", grupo, deInstancia)
	# Borrar el parámetro compartido anterior
	fm.RemoveParameter(param)
	# Volver a convertir a parámetro compartido
	spParam = obtener_parametro_compartido(spGrupo, "SNR_STR_Waterproof")
	fm.ReplaceParameter(new_param, spParam, grupo, deInstancia)
	print(f"\nParámetro renombrado: {spParam.Definition.Name}")

with db.Transaction("Nombre"):
	for param in fm.GetParameters():
		if param.Definition.Name == "SNR_Waterproof":
			renombrar_parametro_compartido(param, "SNR_STR_Waterproof")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 16:31:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13265316#M1433</guid>
      <dc:creator>pedro_abril</dc:creator>
      <dc:date>2025-01-16T16:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Renombrado de parámetros compartidos (Rename shared parameter)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13265387#M1434</link>
      <description>&lt;P&gt;Thank you for your appreciation and sample code!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 17:02:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/renombrado-de-parametros-compartidos-rename-shared-parameter/m-p/13265387#M1434</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-01-16T17:02:17Z</dc:date>
    </item>
  </channel>
</rss>

