<?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 Copy Family and Type names to text parameters for all instances in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9206867#M37853</link>
    <description>&lt;P&gt;Hi, guys! First of all, let me start with the fact that I am new to writing code in Python and working with the Revit API. In this case, I tried to create a code that takes the strings from family and type names for all family instances of certain categories and then copies them to text shared text parameters, that can be used in schedules. I am using the Revit Python shell to run the script. As you will see, I have divided the code in two sections - the second one is for the system family categories, like walls, floors, roofs, etc, that only need Type names to bo transfered, while the first is for all other categories, that need both family and type name transfered. The problem is the it all seems to work fine, but for some of the categories it simply does not give results. For instance, I do not realise why it works for walls, but not for floors, and it also does work for ceilings and not for roofs, etc. Could you please help me find what the problem is? Thanks in advance! Here is the code(also available as attatchment):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;__title__= 'FamilyName\nTypeName'&lt;BR /&gt;__doc__= 'Transfers family name and Type name into shared parameters\n that can be used in schedules.'&lt;BR /&gt;__author__= 'Dani &amp;amp; Bimo'&lt;/P&gt;&lt;P&gt;# Import from Autodesk API&lt;BR /&gt;from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory&lt;/P&gt;&lt;P&gt;doc = __revit__.ActiveUIDocument.Document&lt;/P&gt;&lt;P&gt;element_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()&lt;BR /&gt;element_filter = ElementCategoryFilter(BuiltInCategory.OST_PlumbingFixtures.OST_Casework.OST_Columns.OST_Windows.OST_Furniture)&lt;BR /&gt;category = element_collector.WherePasses(element_filter).ToElements()&lt;/P&gt;&lt;P&gt;t = Transaction(doc, "Update Family/Type Name")&lt;/P&gt;&lt;P&gt;t.Start()&lt;/P&gt;&lt;P&gt;for instance in category:&lt;BR /&gt;TypeName = instance.Name&lt;BR /&gt;TypeNameDuplicate = instance.LookupParameter('TypeNameDuplicate')&lt;BR /&gt;if TypeNameDuplicate:&lt;BR /&gt;TypeNameDuplicate.Set(TypeName)&lt;BR /&gt;&lt;BR /&gt;for i in category:&lt;BR /&gt;type_id = i.GetTypeId()&lt;BR /&gt;element_type = doc.GetElement(type_id)&lt;BR /&gt;family = element_type.Family&lt;BR /&gt;name = family.Name&lt;BR /&gt;FamilyNameDuplicate = i.LookupParameter('FamilyNameDuplicate')&lt;BR /&gt;if FamilyNameDuplicate:&lt;BR /&gt;FamilyNameDuplicate.Set(name)&lt;BR /&gt;&lt;BR /&gt;t.Commit()&lt;/P&gt;&lt;P&gt;system_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()&lt;BR /&gt;system_filter = ElementCategoryFilter(BuiltInCategory.OST_Walls.OST_Ceilings.OST_Curtain_Systems.OST_CurtainWallMullions.OST_Floors.OST_ModelText.OST_Railings.OST_Roofs.OST_Stairs)&lt;BR /&gt;system_category = system_collector.WherePasses(system_filter).ToElements()&lt;/P&gt;&lt;P&gt;t.Start()&lt;/P&gt;&lt;P&gt;for system_instance in system_category:&lt;BR /&gt;SystemTypeName = system_instance.Name&lt;BR /&gt;TypeNameDuplicate = system_instance.LookupParameter('TypeNameDuplicate')&lt;BR /&gt;if TypeNameDuplicate:&lt;BR /&gt;TypeNameDuplicate.Set(SystemTypeName)&lt;BR /&gt;&lt;BR /&gt;t.Commit()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Dec 2019 13:10:55 GMT</pubDate>
    <dc:creator>danail.momchilov</dc:creator>
    <dc:date>2019-12-17T13:10:55Z</dc:date>
    <item>
      <title>Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9206867#M37853</link>
      <description>&lt;P&gt;Hi, guys! First of all, let me start with the fact that I am new to writing code in Python and working with the Revit API. In this case, I tried to create a code that takes the strings from family and type names for all family instances of certain categories and then copies them to text shared text parameters, that can be used in schedules. I am using the Revit Python shell to run the script. As you will see, I have divided the code in two sections - the second one is for the system family categories, like walls, floors, roofs, etc, that only need Type names to bo transfered, while the first is for all other categories, that need both family and type name transfered. The problem is the it all seems to work fine, but for some of the categories it simply does not give results. For instance, I do not realise why it works for walls, but not for floors, and it also does work for ceilings and not for roofs, etc. Could you please help me find what the problem is? Thanks in advance! Here is the code(also available as attatchment):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;__title__= 'FamilyName\nTypeName'&lt;BR /&gt;__doc__= 'Transfers family name and Type name into shared parameters\n that can be used in schedules.'&lt;BR /&gt;__author__= 'Dani &amp;amp; Bimo'&lt;/P&gt;&lt;P&gt;# Import from Autodesk API&lt;BR /&gt;from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory&lt;/P&gt;&lt;P&gt;doc = __revit__.ActiveUIDocument.Document&lt;/P&gt;&lt;P&gt;element_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()&lt;BR /&gt;element_filter = ElementCategoryFilter(BuiltInCategory.OST_PlumbingFixtures.OST_Casework.OST_Columns.OST_Windows.OST_Furniture)&lt;BR /&gt;category = element_collector.WherePasses(element_filter).ToElements()&lt;/P&gt;&lt;P&gt;t = Transaction(doc, "Update Family/Type Name")&lt;/P&gt;&lt;P&gt;t.Start()&lt;/P&gt;&lt;P&gt;for instance in category:&lt;BR /&gt;TypeName = instance.Name&lt;BR /&gt;TypeNameDuplicate = instance.LookupParameter('TypeNameDuplicate')&lt;BR /&gt;if TypeNameDuplicate:&lt;BR /&gt;TypeNameDuplicate.Set(TypeName)&lt;BR /&gt;&lt;BR /&gt;for i in category:&lt;BR /&gt;type_id = i.GetTypeId()&lt;BR /&gt;element_type = doc.GetElement(type_id)&lt;BR /&gt;family = element_type.Family&lt;BR /&gt;name = family.Name&lt;BR /&gt;FamilyNameDuplicate = i.LookupParameter('FamilyNameDuplicate')&lt;BR /&gt;if FamilyNameDuplicate:&lt;BR /&gt;FamilyNameDuplicate.Set(name)&lt;BR /&gt;&lt;BR /&gt;t.Commit()&lt;/P&gt;&lt;P&gt;system_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()&lt;BR /&gt;system_filter = ElementCategoryFilter(BuiltInCategory.OST_Walls.OST_Ceilings.OST_Curtain_Systems.OST_CurtainWallMullions.OST_Floors.OST_ModelText.OST_Railings.OST_Roofs.OST_Stairs)&lt;BR /&gt;system_category = system_collector.WherePasses(system_filter).ToElements()&lt;/P&gt;&lt;P&gt;t.Start()&lt;/P&gt;&lt;P&gt;for system_instance in system_category:&lt;BR /&gt;SystemTypeName = system_instance.Name&lt;BR /&gt;TypeNameDuplicate = system_instance.LookupParameter('TypeNameDuplicate')&lt;BR /&gt;if TypeNameDuplicate:&lt;BR /&gt;TypeNameDuplicate.Set(SystemTypeName)&lt;BR /&gt;&lt;BR /&gt;t.Commit()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 13:10:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9206867#M37853</guid>
      <dc:creator>danail.momchilov</dc:creator>
      <dc:date>2019-12-17T13:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9207869#M37854</link>
      <description>&lt;P&gt;Welcome to the Revit API!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot imagine that the following returns a valid built-in category enumeration value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BuiltInCategory.OST_Walls.OST_Ceilings.OST_Curtain_Systems.OST_CurtainWallMullions.OST_Floors.OST_ModelText.OST_Railings.OST_Roofs.OST_Stairs&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would certainly expect that to cause a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably need to create a logical OR filter combining individual built-in category filters for each one of those enumeration values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are two samples showing how to do so in C#:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/07/retrieve-structural-elements.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/07/retrieve-structural-elements.html&lt;/A&gt;&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>Tue, 17 Dec 2019 19:24:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9207869#M37854</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-12-17T19:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9208785#M37855</link>
      <description>&lt;P&gt;Hi, Jeremy! And thank you for your answer. Unfortunattely, that is not the cause of the problem, as in Python, that is a valid syntax. I have already tried collecting the problematic categories separately, like floors and roofs for example and the result is still the same. It is still curious that if I try to print their Type Names, the correct result is shown! It just seems the fail to override the value. I am mostly interested in Roofs and Floors, as those are the categories it will be used for most of the time (along with walls and ceilings, that already work).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 08:17:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9208785#M37855</guid>
      <dc:creator>danail.momchilov</dc:creator>
      <dc:date>2019-12-18T08:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9208941#M37856</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As Jeremy pointed out that filter syntax is strange and if it works in Python I wish it worked in C#!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you check that the shared parameter is properly assigned to all the categories that you want in Revit?&lt;/P&gt;&lt;P&gt;I know it is silly, but sometimes the problem is the silliest thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 09:41:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9208941#M37856</guid>
      <dc:creator>H.echeva</dc:creator>
      <dc:date>2019-12-18T09:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9208990#M37857</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unfortunattely, that is not the case. And I wish it would have been! As you know, Python has a much more simplified syntax than C#, which makes it possible to do things like that. I will still try to collect the family instances differently, to see if that might still be the cause. I could upload the test file if you are interested, but you will still need the Revit Python Shell to run the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 09:59:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9208990#M37857</guid>
      <dc:creator>danail.momchilov</dc:creator>
      <dc:date>2019-12-18T09:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9209037#M37858</link>
      <description>&lt;P&gt;Wow, I was unaware of that Python syntax feature. Very cool. Does it create an OR combination of the listed values? I searched for "python enum concatenation" and found no explanation of this feature.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, resolving questions like this is a very simple matter of installing RevitLookup, selecting the elements you are interested in, determining their characteristic properties, e.g., category, .NET classname, etc., and putting together the appropriate filter for them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a case such as yours, I would suggest implementing separate filters first for floors and roofs, and then using a logical OR&amp;nbsp;filter to combine them with the other filters that already work as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 10:17:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9209037#M37858</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-12-18T10:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9209061#M37859</link>
      <description>&lt;P&gt;I believe you are completely misunderstanding the enum syntax that you are using, and it is not doing what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you in fact expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For me, it just returns the last enum value and ignores all the previous ones:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;$ python3
Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; from enum import Enum
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; class Color(Enum):
...     RED = 1
...     GREEN = 2
...     BLUE = 3
...
&amp;gt;&amp;gt;&amp;gt; print (Color.RED.GREEN.BLUE)
Color.BLUE&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 10:33:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9209061#M37859</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-12-18T10:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9209925#M37860</link>
      <description>&lt;P&gt;I believe you are right actually. I just tried to sort only floors and roofs in a separate script and it worked. I really think I tried that and it did not give the correct result but maybe I was missing something else. Now I feel stupid for saying I was sure that is not the problem...... but like I said, I am quite a newbie. So thanks anyway, I just sorted it the right way and it all worked fine. I seem to have overestimated how intuitive python actually is&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 16:16:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9209925#M37860</guid>
      <dc:creator>danail.momchilov</dc:creator>
      <dc:date>2019-12-18T16:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Family and Type names to text parameters for all instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9211469#M37861</link>
      <description>&lt;P&gt;Actually the true solution is simply using&amp;nbsp;&amp;nbsp;'&lt;SPAN&gt;ElementMulticategoryFilter' . That's all:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;cat_list = [BuiltInCategory.OST_Rooms, BuiltInCategory.OST_Walls, BuiltInCategory.OST_Windows, BuiltInCategory.OST_Doors]&lt;BR /&gt;typed_list = List[BuiltInCategory](cat_list)&lt;BR /&gt;filter = ElementMulticategoryFilter(typed_list)&lt;BR /&gt;output = FilteredElementCollector(doc).WherePasses(filter).ToElements()&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 09:16:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copy-family-and-type-names-to-text-parameters-for-all-instances/m-p/9211469#M37861</guid>
      <dc:creator>danail.momchilov</dc:creator>
      <dc:date>2019-12-19T09:16:25Z</dc:date>
    </item>
  </channel>
</rss>

