<?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: Adding Parameters with a specific GUID in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450682#M8050</link>
    <description>&lt;P&gt;Thank you very much for your kind suggestion and porting offer!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I think it might be a good idea to capture this, and I am sure a C# variant would be much appreciated as well. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2023 15:52:38 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2023-12-19T15:52:38Z</dc:date>
    <item>
      <title>Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12448462#M8044</link>
      <description>&lt;DIV&gt;&lt;P class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;I have a requirement to add parameters and bind them to most if not all elements in a model (and one parameter to be bound to a type instead; your blog was most helpful with that), but I'm running into a few issues.&lt;BR /&gt;&lt;BR /&gt;Currently my code creates a shared parameter file if not found, creates a group, and then adds the parameters to it. The problem comes as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;Sometimes the parameters are "duplicated" because I can't seem to specify a GUID for the parameter; I can only search for it by name - and the shared parameter file was not sent to me for testing, only the Revit File.&lt;BR /&gt;&lt;BR /&gt;Revit GUIDs seem to be type 4, which is frustrating because those are fully random and that means I can't predict them at all, which means I can't really test for a specific GUID.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If the file is already created (because I was using another Revit document) the parameters "exist" in the document but aren't bound to anything, which frustrates the dupe checks because the parameter exists by name; however an insert/reinsert rebinding will work.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I can determine via code right now if I have to write the file from scratch, but I haven't yet run into the situation where the customer has a parameter file and I just need to add to it (which I'm sure happens all the time).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If the file does exist, I would rather be able to set a specific GUID instead of clobbering the user's file with our own (that seems the only way to set a particular GUID is to write a shared parameter file with the GUID and then tell Revit to use that file).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;The goal here is that the user can click one button and our parameters are set up to facilitate two-way data binding between our system and the Revit Model.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;DIV&gt;&lt;P class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P class=""&gt;&lt;SPAN&gt;Am I missing something in the API that allows me to specify a GUID? What are the best practices around this? Does the Revit API have some way to modify the shared parameter file or only the binding functions?&lt;BR /&gt;&lt;BR /&gt;I found this related issue,&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P class=""&gt;&lt;SPAN&gt;&lt;A href="https://stackoverflow.com/questions/77652588/editing-sharedparameterfile-deleting-shared-parameter-entry" target="_blank" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/77652588/editing-sharedparameterfile-deleting-shared-parameter-entry&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P class=""&gt;&lt;SPAN&gt;However it's not answered nor is it exactly my problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 18 Dec 2023 15:45:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12448462#M8044</guid>
      <dc:creator>oknott</dc:creator>
      <dc:date>2023-12-18T15:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12449924#M8045</link>
      <description>&lt;P&gt;Afaik, you cannot specify the parameter GUID yourself. It is assigned internally by Revit, with no external influence possible. This question was raised in the past, when people wished to define different language display labels for one single parameter. If it were possible to specify a GUID, this would be easy to achieve. Unfortunately, you cannot, and no perfect solution is known.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 08:30:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12449924#M8045</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-12-19T08:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450142#M8046</link>
      <description>&lt;P&gt;Maybe the new parameter service will solve all your problems:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://goto.archi/blog/post/how-to-migrate-revit-parameters-into-the-parameter-service" target="_blank"&gt;https://goto.archi/blog/post/how-to-migrate-revit-parameters-into-the-parameter-service&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 11:04:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450142#M8046</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-12-19T11:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450536#M8047</link>
      <description>&lt;P&gt;Is this what you are looking for?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ExternalDefinitionCreationOptions.GUID Property -&amp;gt; C# public Guid GUID { get; set; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Revit API ExternalDefinitionCreationOptions Members&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The GUID to use for this parameter definition. If not explicitly set, a random GUID is used."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We use this day in / day out for our new Shared Parameters.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 14:44:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450536#M8047</guid>
      <dc:creator>studio-a-int</dc:creator>
      <dc:date>2023-12-19T14:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450606#M8048</link>
      <description>&lt;P&gt;Wow, cool. I didn't know you could set it yourself nowadays. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 15:21:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450606#M8048</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-12-19T15:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450667#M8049</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp; - If you want to post a more complete code in your blog for posterity, below is the Python code. If you want also the C#, let me know and I post the C# code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use either Visual Studio Tools -&amp;gt; Create GUID or Python below Python code to generate the GUID&lt;/P&gt;&lt;P&gt;import uuid&lt;BR /&gt;yourGuid = str(uuid.uuid4())&lt;/P&gt;&lt;P&gt;# Your GUID will be like 8-4-4-4-12&lt;BR /&gt;yourGuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"&lt;/P&gt;&lt;P&gt;We do not recommend, but of course if you want to change the GUID as you want, make the changes.&lt;BR /&gt;Keep in mind the algorithms to create global unique id are developed to prevent as much as possible duplicates&lt;BR /&gt;in large dynamic systems.&lt;/P&gt;&lt;P&gt;Then you can use the following Python code to create a new Shared Parameter definition with your own GUID:&lt;/P&gt;&lt;P&gt;app = DocumentManager.Instance.CurrentUIApplication.Application&lt;BR /&gt;yourSharedParamDefFile = r"yourDefinitionFile.txt"&lt;BR /&gt;app.SharedParametersFilename = yourSharedParamDefFile&lt;BR /&gt;sharedParametersFileName = app.OpenSharedParameterFile().Filename&lt;BR /&gt;paraGroup = app.OpenSharedParameterFile().Groups.get_Item("YourParameterGroup") # verify in your Definition File the name of the Group under which you want to create the Shared Parameter&lt;BR /&gt;newParaOptions = ExternalDefinitionCreationOptions("yourSharedParaName", ParameterType.Text) # Text, Integer, Number, Length, Area, Volume, etc. - look at the API for Parameter Type enumerations&lt;BR /&gt;newParaOptions.UserModifiable = False # Users cannot modify it, only Revit API&lt;BR /&gt;newParaOptions.Visible = False # Users cannot see it in the properties, but the parameter appears in schedules, etc.&lt;BR /&gt;newParaOptions.GUID = Guid(yourGuid) # set the Guid&lt;BR /&gt;createYourNewParameter = paraGroup.Definitions.Create(newParaOptions)&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 15:45:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450667#M8049</guid>
      <dc:creator>studio-a-int</dc:creator>
      <dc:date>2023-12-19T15:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450682#M8050</link>
      <description>&lt;P&gt;Thank you very much for your kind suggestion and porting offer!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I think it might be a good idea to capture this, and I am sure a C# variant would be much appreciated as well. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 15:52:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12450682#M8050</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-12-19T15:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Parameters with a specific GUID</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12455887#M8051</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the agnostic method in C#.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void createSharedParameterDefinition()&lt;BR /&gt;{&lt;BR /&gt;// Code provided courtesy of:&lt;BR /&gt;// Studio A International, LLC&lt;BR /&gt;// &lt;A href="http://www.studio-a-int.com" target="_blank"&gt;http://www.studio-a-int.com&lt;/A&gt;&lt;BR /&gt;// The below code creates a new Shared Parameter in an existing Definition File&lt;BR /&gt;// If a Shared Parameter with the same name is already in the Definition File,&lt;BR /&gt;// the execution code will end with an error&lt;BR /&gt;// You can generate your own GUID to assign it to the Shared Parameter&lt;BR /&gt;// Use either Visual Studio Tools -&amp;gt; Create GUID&lt;BR /&gt;// Or Python code to generate the GUID&lt;BR /&gt;// import uuid&lt;BR /&gt;// yourGuid = str(uuid.uuid4())&lt;BR /&gt;// or other programming tools of your choice&lt;BR /&gt;System.Guid yourGuid = new Guid("2778bb70-c715-4a9d-bdc1-76add223f228");&lt;BR /&gt;// Shared Parameters Definition file&lt;BR /&gt;string yourSharedParamDefFile = @"YourDrive\YourSharedParametersDefinitionFile.txt";&lt;BR /&gt;// Shared Parameter name&lt;BR /&gt;string yourSharedParaName = "NewSharedParaNameUnitTesting";&lt;BR /&gt;// Initialize a StringBuilder to collect execution results/errors.&lt;BR /&gt;StringBuilder sbCreateSharedParameterDefinition = new StringBuilder();&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Autodesk.Revit.DB.Document activeDoc = CreateSharedParameterDefinitionCommand.doc;&lt;BR /&gt;Autodesk.Revit.ApplicationServices.Application app = activeDoc.Application;&lt;BR /&gt;app.SharedParametersFilename = yourSharedParamDefFile;&lt;BR /&gt;// Open the Shared Parameters File&lt;BR /&gt;Autodesk.Revit.DB.DefinitionFile sharedParametersFile = app.OpenSharedParameterFile();&lt;BR /&gt;string sharedParametersFileName = app.OpenSharedParameterFile().Filename;&lt;BR /&gt;// Select under which Definition Group the new Shared Parameter will be placed&lt;BR /&gt;DefinitionGroup paraGroup = app.OpenSharedParameterFile().Groups.get_Item("YOURGROUP");&lt;BR /&gt;// Create new Options for the Shared Parameter&lt;BR /&gt;// older APIs uses below method&lt;BR /&gt;// Autodesk.Revit.DB.ExternalDefinitionCreationOptions newParaOptions = new ExternalDefinitionCreationOptions(yourSharedParaName, ParameterType.Text); // # Text, Integer, Number, Length, Area, Volume, etc. - look at the API for Parameter Type enumerations&lt;BR /&gt;// newer APIs uses below method&lt;BR /&gt;Autodesk.Revit.DB.ExternalDefinitionCreationOptions newParaOptions = new ExternalDefinitionCreationOptions(yourSharedParaName, SpecTypeId.String.Text);&lt;BR /&gt;newParaOptions.UserModifiable = false; // Users cannot modify it, only Revit API can modify this parameter&lt;BR /&gt;newParaOptions.Visible = false; // Users cannot see it in the properties, but the parameter appears in schedules, etc.&lt;BR /&gt;newParaOptions.GUID = yourGuid; // set the above GUID to this new Shared Parameter&lt;BR /&gt;paraGroup.Definitions.Create(newParaOptions);&lt;BR /&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;sbCreateSharedParameterDefinition.AppendLine(ex.Message.ToString());&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (sbCreateSharedParameterDefinition.Length &amp;lt; 1)&lt;BR /&gt;{&lt;BR /&gt;System.Windows.Forms.MessageBox.Show("Shared Parameter Definition:" +&lt;BR /&gt;"\r\n" +&lt;BR /&gt;"\r\n" + " " + yourSharedParaName +&lt;BR /&gt;"\r\n" +&lt;BR /&gt;"\r\n" + "was created.", "Task complete");&lt;BR /&gt;}&lt;BR /&gt;else if (sbCreateSharedParameterDefinition.Length &amp;gt; 0)&lt;BR /&gt;{&lt;BR /&gt;System.Windows.Forms.MessageBox.Show("Shared Parameter Definition was not created because:" +&lt;BR /&gt;"\r\n" +&lt;BR /&gt;"\r\n" + " " + sbCreateSharedParameterDefinition.ToString(), "Error");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 14:21:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-parameters-with-a-specific-guid/m-p/12455887#M8051</guid>
      <dc:creator>studio-a-int</dc:creator>
      <dc:date>2023-12-21T14:21:42Z</dc:date>
    </item>
  </channel>
</rss>

