<?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: Assembly code in system families in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4793223#M77709</link>
    <description>&lt;P&gt;Thanks Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have looked deeper in it and this is what I came up with :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Parameter par = null;&lt;BR /&gt;FamilyInstance fi = null;&lt;BR /&gt;Element element = null;&lt;BR /&gt;foreach (Element el in elemset)&lt;BR /&gt;{&lt;BR /&gt;fi = el as FamilyInstance;&lt;BR /&gt;if (fi != null) par = fi.Symbol.get_Parameter(BuiltInParameter.UNIFORMAT_CODE); &amp;nbsp;//check if the element is a family instance&lt;BR /&gt;if (par == null) //if not, it must be a system family&lt;BR /&gt;{&lt;BR /&gt;element = commandData.Application.ActiveUIDocument.Document.GetElement(el.GetTypeId());&lt;BR /&gt;if (element != null) //okay, this if may be overkill &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;{&lt;BR /&gt;foreach (Parameter ps in element.Parameters)&lt;BR /&gt;{&lt;BR /&gt;if (ps.Definition.Name == "Assembly Code")&lt;BR /&gt;{&lt;BR /&gt;par = ps;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (par != null) //if for some reason the selected element has no assembly code, skip it&lt;BR /&gt;{&lt;BR /&gt;string waarde = "2D(21.0)"; //example value&lt;BR /&gt;par.Set(waarde);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;trans.Commit();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the mysterious ifs because without them Revit returns the famous "Object not set to a reference".&lt;/P&gt;&lt;P&gt;Only little thingie I can't figure out is curtain walls. The code works when I select the elements seperatly, but when I do a selection of a complete curtain wall with mullions, panels ect. the curtain wall it self (Wall) refuses to accept the new assembly code. When I Tab-select it, the code works. I guess it has something to do with the order curtain wall items are selected ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2014 14:34:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-02-04T14:34:37Z</dc:date>
    <item>
      <title>Assembly code in system families</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4790573#M77707</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to change the assembly code of walls. here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Document doc = commandData.Application.ActiveUIDocument.Document;&lt;BR /&gt;UIApplication app = commandData.Application;&lt;/P&gt;&lt;P&gt;ElementSet elemset = commandData.Application.ActiveUIDocument.Selection.Elements;&lt;/P&gt;&lt;P&gt;Transaction trans = new Transaction(doc, "Changeparam");&lt;BR /&gt;trans.Start();&lt;/P&gt;&lt;P&gt;foreach (Element el in elemset)&lt;BR /&gt;{&lt;BR /&gt;Parameter par = el.GetParameterNoCase("assembly code");&lt;BR /&gt;if (par == null)&lt;BR /&gt;{&lt;BR /&gt;FamilyInstance fi = el as FamilyInstance;&lt;BR /&gt;if (fi != null) par = fi.Symbol.GetParameterNoCase("assembly code");&lt;BR /&gt;}&lt;BR /&gt;if (par == null)&lt;BR /&gt;{&lt;BR /&gt;par = el.get_Parameter(BuiltInParameter.UNIFORMAT_CODE); //here I can see a wall actually has an assembly code&lt;BR /&gt;}&lt;BR /&gt;if (par != null)&lt;BR /&gt;{&lt;BR /&gt;string waarde = "2D(21.0)";&lt;BR /&gt;par.Set(waarde); //It will assign the value to the assembly code of the selected wall&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;trans.Commit();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works great for family instances like Windows and Doors, but If I try it on walls, no error comes but the assembly code stays unchanged??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how to change the assembly code for walls (or any other system family) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2014 11:29:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4790573#M77707</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-02-03T11:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly code in system families</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4793095#M77708</link>
      <description>&lt;P&gt;Dear Remy,&lt;BR /&gt;&lt;BR /&gt;Thank you for your query.&lt;BR /&gt;&lt;BR /&gt;I would suggest that you clean up your code first, so that we can see better what is going on.&lt;BR /&gt;&lt;BR /&gt;I am pretty sure that you can use a built-in parameter to access the assembly code on all elements.&lt;BR /&gt;&lt;BR /&gt;That would enable you to:&lt;BR /&gt;&lt;BR /&gt;a) eliminate those mysterious if statements.&lt;BR /&gt;&lt;BR /&gt;b) eliminate your language dependency.&lt;BR /&gt;&lt;BR /&gt;You can use the debugger to explore how to clean it up, and then you can use the debugger again to ensure that the same code is actually being executed for both walls and family instances.&lt;BR /&gt;&lt;BR /&gt;Once that is done, and if it still does not work, I would suggest that you use RevitLookup to examine what the difference between walls and family instances might be in regard to the asssembly code.&lt;BR /&gt;&lt;BR /&gt;Especially, you need to check that the assembly code can be changed in all the places you need it to be via the user interface.&lt;BR /&gt;&lt;BR /&gt;If that is possible, you can use RevitLookup to see exactly how and where the data is stored, and how you can drive it programmatically to achieve the same as in the UI.&lt;BR /&gt;&lt;BR /&gt;I hope this helps.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 13:29:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4793095#M77708</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2014-02-04T13:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly code in system families</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4793223#M77709</link>
      <description>&lt;P&gt;Thanks Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have looked deeper in it and this is what I came up with :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Parameter par = null;&lt;BR /&gt;FamilyInstance fi = null;&lt;BR /&gt;Element element = null;&lt;BR /&gt;foreach (Element el in elemset)&lt;BR /&gt;{&lt;BR /&gt;fi = el as FamilyInstance;&lt;BR /&gt;if (fi != null) par = fi.Symbol.get_Parameter(BuiltInParameter.UNIFORMAT_CODE); &amp;nbsp;//check if the element is a family instance&lt;BR /&gt;if (par == null) //if not, it must be a system family&lt;BR /&gt;{&lt;BR /&gt;element = commandData.Application.ActiveUIDocument.Document.GetElement(el.GetTypeId());&lt;BR /&gt;if (element != null) //okay, this if may be overkill &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;{&lt;BR /&gt;foreach (Parameter ps in element.Parameters)&lt;BR /&gt;{&lt;BR /&gt;if (ps.Definition.Name == "Assembly Code")&lt;BR /&gt;{&lt;BR /&gt;par = ps;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (par != null) //if for some reason the selected element has no assembly code, skip it&lt;BR /&gt;{&lt;BR /&gt;string waarde = "2D(21.0)"; //example value&lt;BR /&gt;par.Set(waarde);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;trans.Commit();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the mysterious ifs because without them Revit returns the famous "Object not set to a reference".&lt;/P&gt;&lt;P&gt;Only little thingie I can't figure out is curtain walls. The code works when I select the elements seperatly, but when I do a selection of a complete curtain wall with mullions, panels ect. the curtain wall it self (Wall) refuses to accept the new assembly code. When I Tab-select it, the code works. I guess it has something to do with the order curtain wall items are selected ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 14:34:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assembly-code-in-system-families/m-p/4793223#M77709</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-02-04T14:34:37Z</dc:date>
    </item>
  </channel>
</rss>

