<?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: Why does GroupType.Groups contain ungrouped groups? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298344#M26181</link>
    <description>&lt;P&gt;I recently had a somewhat similar problem (working w/ completely different objects though). It seems like in some cases the value returned by a Revit API object's property or method is always the same as when it was first obtained from the API, even after regenerating the model. To resolve this in my case I had to obtain a new copy of the object from the API after regenerating the model (e.g. myElement = myDocument.GetElement(myElementId);). I don't know if this will help in your situation but I hope it does.&lt;/P&gt;</description>
    <pubDate>Fri, 07 May 2021 17:11:00 GMT</pubDate>
    <dc:creator>mhannonQ65N2</dc:creator>
    <dc:date>2021-05-07T17:11:00Z</dc:date>
    <item>
      <title>Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10289821#M26175</link>
      <description>&lt;P&gt;The following code prints the same number twice:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var groupType = group.GroupType;
Debug.Print(groupType.Groups.Size.ToString());
group.UngroupMembers();
Debug.Print(groupType.Groups.Size.ToString());&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this the correct behavior?&lt;/P&gt;&lt;P&gt;What do I need to do to make sure&amp;nbsp;groupType.Groups always returns the correct GroupSet?&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 14:46:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10289821#M26175</guid>
      <dc:creator>stefanome</dc:creator>
      <dc:date>2021-05-04T14:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10290632#M26176</link>
      <description>&lt;P&gt;Regenerate the model?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.33" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.33&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 20:05:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10290632#M26176</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-05-04T20:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10291256#M26177</link>
      <description>&lt;P&gt;Thanks for the tip, but I just tried and regenerating doesn't help.&lt;/P&gt;&lt;P&gt;It looks like I need to end and restart the transaction.&lt;/P&gt;&lt;P&gt;This code shows that GroupType.Groups still reports the ungrouped group after doc.Regenerate() and finally disappears after committing and restarting a new transaction. I tried to get a new reference to the GroupType, hoping that avoiding some caching would help, but it didn't:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;tx.Start("Test 1");

var elementIds = new List&amp;lt;ElementId&amp;gt;
{
    Utils.CreateModelLine(new XYZ(0, 0, 0), new XYZ(1, 0, 0), doc).Id,
    Utils.CreateModelLine(new XYZ(0, 1, 0), new XYZ(1, 1, 0), doc).Id,
    Utils.CreateModelLine(new XYZ(0, 2, 0), new XYZ(1, 2, 0), doc).Id,
};
var group1 = doc.Create.NewGroup(elementIds);
var group2 = doc.Create.PlaceGroup(new XYZ(0, 5, 0), group1.GroupType);
var group3 = doc.Create.PlaceGroup(new XYZ(0, 10, 0), group1.GroupType);
Debug.Print(group1.GroupType.Groups.Size.ToString());

group2.UngroupMembers();
Debug.Print(group1.GroupType.Groups.Size.ToString());

doc.Regenerate();
Debug.Print(group1.GroupType.Groups.Size.ToString());

var groupType = new FilteredElementCollector(doc)
    .OfClass(typeof(GroupType))
    .Cast&amp;lt;GroupType&amp;gt;()
    .FirstOrDefault(gt =&amp;gt; gt.Name == group1.GroupType.Name);
Debug.Print(groupType.Groups.Size.ToString());

tx.Commit();

tx.Start("Test 2");

Debug.Print(groupType.Groups.Size.ToString());
groupType = new FilteredElementCollector(doc)
    .OfClass(typeof(GroupType))
    .Cast&amp;lt;GroupType&amp;gt;()
    .FirstOrDefault(gt =&amp;gt; gt.Name == group1.GroupType.Name);
Debug.Print(groupType.Groups.Size.ToString());

tx.Commit();&lt;/LI-CODE&gt;&lt;P&gt;I tried using a SubTransaction, but didn't help.&lt;/P&gt;&lt;P&gt;At this point I do have a workaround, but I don't like to create transactions only because I can't rely on GroupType.Groups not reporting ungrouped groups.&lt;/P&gt;&lt;P&gt;Any advice?&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 04:04:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10291256#M26177</guid>
      <dc:creator>stefanome</dc:creator>
      <dc:date>2021-05-05T04:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10291464#M26178</link>
      <description>&lt;P&gt;Glad to hear you were able to discover a workaround.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, committing the transaction is the next level up after regeneration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry I cannot offer any further suggestions, though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 06:46:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10291464#M26178</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-05-05T06:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10292162#M26179</link>
      <description>&lt;P&gt;"I tried using a SubTransaction, but didn't help.&lt;/P&gt;&lt;P&gt;At this point I do have a workaround, but I don't like to create transactions only because I can't rely on GroupType.Groups not reporting ungrouped groups."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just firing off the top of my head here but... instead of transactions and subtransactions you might try a transaction group with transactions within it... works just a little differently and perhaps that difference will be a little cleaner in the end...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just my Two cents, take it for what it's worth &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-G&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 12:56:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10292162#M26179</guid>
      <dc:creator>GaryOrrMBI</dc:creator>
      <dc:date>2021-05-05T12:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10292850#M26180</link>
      <description>&lt;P&gt;Using a transaction group seem to be the best workaround. Here are the steps:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;transactionGroup.Start
transaction.Start
group.UngroupMemebers
group.GroupType.Groups still contains the ungrouped group
transaction.Commit
group.GroupType.Groups does not contain the ungrouped group&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately such a workaround cannot be used in a generic case, because wrapping the group.UngroupMembers inside its own transaction only because any following groupType.Groups would return the wrong result is ugly, because it requires any caller to use a transaction group rather than a transaction.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 17:23:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10292850#M26180</guid>
      <dc:creator>stefanome</dc:creator>
      <dc:date>2021-05-05T17:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298344#M26181</link>
      <description>&lt;P&gt;I recently had a somewhat similar problem (working w/ completely different objects though). It seems like in some cases the value returned by a Revit API object's property or method is always the same as when it was first obtained from the API, even after regenerating the model. To resolve this in my case I had to obtain a new copy of the object from the API after regenerating the model (e.g. myElement = myDocument.GetElement(myElementId);). I don't know if this will help in your situation but I hope it does.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 17:11:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298344#M26181</guid>
      <dc:creator>mhannonQ65N2</dc:creator>
      <dc:date>2021-05-07T17:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298410#M26182</link>
      <description>&lt;P&gt;Thanks for the advice. I just tried and in this stale case the cached info sticks around even after getting a new element. Adding these two lines before closing the transaction to my code, still return the wrong value:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;group1 = doc.&lt;/SPAN&gt;&lt;SPAN&gt;GetElement&lt;/SPAN&gt;&lt;SPAN&gt;(group1.&lt;/SPAN&gt;&lt;SPAN&gt;Id&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;Group&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Debug&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Print&lt;/SPAN&gt;&lt;SPAN&gt;(groupType.&lt;/SPAN&gt;&lt;SPAN&gt;Groups&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Size&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ToString&lt;/SPAN&gt;&lt;SPAN&gt;());&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;groupType=doc.&lt;/SPAN&gt;&lt;SPAN&gt;GetElement&lt;/SPAN&gt;&lt;SPAN&gt;(group1.&lt;/SPAN&gt;&lt;SPAN&gt;GroupType&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Id&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;GroupType&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Debug&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Print&lt;/SPAN&gt;&lt;SPAN&gt;(groupType.&lt;/SPAN&gt;&lt;SPAN&gt;Groups&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Size&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ToString&lt;/SPAN&gt;&lt;SPAN&gt;());&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 17:45:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298410#M26182</guid>
      <dc:creator>stefanome</dc:creator>
      <dc:date>2021-05-07T17:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298460#M26183</link>
      <description>&lt;P&gt;Did you regenerate the model before getting the new element?&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 18:12:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298460#M26183</guid>
      <dc:creator>mhannonQ65N2</dc:creator>
      <dc:date>2021-05-07T18:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298528#M26184</link>
      <description>Yes, as suggested by Jeremy, but didn't help.</description>
      <pubDate>Fri, 07 May 2021 18:40:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10298528#M26184</guid>
      <dc:creator>stefanome</dc:creator>
      <dc:date>2021-05-07T18:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why does GroupType.Groups contain ungrouped groups?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10310830#M26185</link>
      <description>&lt;P&gt;Summarised for posterity:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2021/05/refreshment-cloud-model-path-angle-and-direction.html#4" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2021/05/refreshment-cloud-model-path-angle-and-direction.html#4&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 14:33:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-does-grouptype-groups-contain-ungrouped-groups/m-p/10310830#M26185</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-05-13T14:33:43Z</dc:date>
    </item>
  </channel>
</rss>

