<?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 Determine if Category has Tag assigned to it in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7509434#M55070</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very simple question here; I've been experimenting with Annotations in Revit and using the API to automatically put down tags onto objects in the Project space.&amp;nbsp; Which is simple enough, but I'm stuck on finding a way to determine whether or not an object type has a tag assigned to it before we use the create new Indepedent Tag function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've become farmiliar with Jeremy Tammik's post here -&amp;nbsp;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/set-tag-type.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/set-tag-type.html&lt;/A&gt; which goes over the process of changing a Tag type for a category after it has been placed, however; if for some reason a project does not have a tag family assigned to a category, you can't actually put down a tag.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I go about checking, and possibly adding, for a tag family on a category before I try placing one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2017 20:47:55 GMT</pubDate>
    <dc:creator>mhillis</dc:creator>
    <dc:date>2017-11-01T20:47:55Z</dc:date>
    <item>
      <title>Determine if Category has Tag assigned to it</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7509434#M55070</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very simple question here; I've been experimenting with Annotations in Revit and using the API to automatically put down tags onto objects in the Project space.&amp;nbsp; Which is simple enough, but I'm stuck on finding a way to determine whether or not an object type has a tag assigned to it before we use the create new Indepedent Tag function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've become farmiliar with Jeremy Tammik's post here -&amp;nbsp;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/set-tag-type.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/set-tag-type.html&lt;/A&gt; which goes over the process of changing a Tag type for a category after it has been placed, however; if for some reason a project does not have a tag family assigned to a category, you can't actually put down a tag.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I go about checking, and possibly adding, for a tag family on a category before I try placing one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 20:47:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7509434#M55070</guid>
      <dc:creator>mhillis</dc:creator>
      <dc:date>2017-11-01T20:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if Category has Tag assigned to it</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7517968#M55071</link>
      <description>&lt;P&gt;Before attaching a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;IndependentTag&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to a element, you can do following steps to check if a tag element connected with a specific element:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;FilteredElementCollector&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to collect&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;IndependentTag&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in current document or current view, then extract&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ElementId&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;which represents associated elements (such as doors, windows) from&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;IndependentTag.TaggedElementId&lt;/STRONG&gt;or&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;IndependentTag.&lt;/SPAN&gt;&lt;SPAN&gt;TaggedLocalElementId&lt;/SPAN&gt;&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;Check&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ElementId&lt;/STRONG&gt;s of picked elements if they are contained in the id list from the step1. If yes, then exclude this element from your tag creation task or abort any tag creation operations.&amp;nbsp;What to do is up to you.&lt;/LI&gt;
&lt;LI&gt;Or, implement&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ISelectionFilter&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;based on&amp;nbsp;id list from the step1 to exclude elements in this list, and pass it into your element picking operation. Then you will obtain elements without a tag attached.&lt;/LI&gt;
&lt;/OL&gt;
&lt;DIV&gt;Hope it helps.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Cheers,&lt;/DIV&gt;</description>
      <pubDate>Sun, 05 Nov 2017 09:35:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7517968#M55071</guid>
      <dc:creator>eason.kangEDLV4</dc:creator>
      <dc:date>2017-11-05T09:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if Category has Tag assigned to it</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7522234#M55072</link>
      <description>&lt;P&gt;If there are tags loaded for a category, then there exists a tag Family. You can make a collector for families, checking for the tagcategory. if the collector doesn't find families, then there is no tag Family loaded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;			StringBuilder sb = new StringBuilder();
			List&amp;lt;string&amp;gt; tempList = new List&amp;lt;string&amp;gt;();
			foreach (Category cat in document.Settings.Categories)
			{
				if (!cat.IsTagCategory) continue;
				Family  categorytagFamily = new FilteredElementCollector(document)
					.OfClass(typeof(Family))
					.Cast&amp;lt;Family&amp;gt;()
					.Where( f =&amp;gt; f.FamilyCategory.Id.IntegerValue == cat.Id.IntegerValue)
					.FirstOrDefault();
				if (categorytagFamily!=null)
					tempList.Add(string.Format("&amp;lt;{0}&amp;gt; {1}, there are tags loaded",(BuiltInCategory)cat.Id.IntegerValue,cat.Name));
			}
			tempList.Sort();
			foreach( string s in tempList) sb.AppendLine(s);
			TaskDialog.Show("tagList", sb.ToString());
&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Nov 2017 00:12:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7522234#M55072</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-11-07T00:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if Category has Tag assigned to it</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7537523#M55073</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2083518"&gt;@FAIR59&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;If there are tags loaded for a category, then there exists a tag Family. You can make a collector for families, checking for the tagcategory. if the collector doesn't find families, then there is no tag Family loaded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;			StringBuilder sb = new StringBuilder();
			List&amp;lt;string&amp;gt; tempList = new List&amp;lt;string&amp;gt;();
			foreach (Category cat in document.Settings.Categories)
			{
				if (!cat.IsTagCategory) continue;
				Family  categorytagFamily = new FilteredElementCollector(document)
					.OfClass(typeof(Family))
					.Cast&amp;lt;Family&amp;gt;()
					.Where( f =&amp;gt; f.FamilyCategory.Id.IntegerValue == cat.Id.IntegerValue)
					.FirstOrDefault();
				if (categorytagFamily!=null)
					tempList.Add(string.Format("&amp;lt;{0}&amp;gt; {1}, there are tags loaded",(BuiltInCategory)cat.Id.IntegerValue,cat.Name));
			}
			tempList.Sort();
			foreach( string s in tempList) sb.AppendLine(s);
			TaskDialog.Show("tagList", sb.ToString());
&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I apologize to all for how long this took to reply to, but I wanted to update and inform everyone that this method gave me exactly what I was looking for.&amp;nbsp; A quick note, for those who are using 2014, the Category.IsTagCategory property does not exist (it was added in 2015 it seems); however, an extremely simple work around, I've found is simply checking to see if the Category.Name field contains the text "Tags".&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2017 19:26:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-category-has-tag-assigned-to-it/m-p/7537523#M55073</guid>
      <dc:creator>mhillis</dc:creator>
      <dc:date>2017-11-12T19:26:23Z</dc:date>
    </item>
  </channel>
</rss>

