<?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: The issue about Selection.PickObjects() method when picking group elements. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12442519#M8131</link>
    <description>&lt;P&gt;Sorry, my first post says not clear question and using keword 'issue' seems to offend development team. I didn't intend it...&lt;BR /&gt;&lt;BR /&gt;I just want to make users unable to select nested group elements when they run my custom function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;I need to write more detailed explanation about this...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;First, I wanted to make a function to ungroup all nested items that belong to group, like exploding all nested block on AutoCAD.&lt;BR /&gt;&lt;BR /&gt;To do that, I tried recursive function. And I thought that the picking prompt (PickObjects()) should not allow&lt;BR /&gt;picking nested groups not to meet the exception&amp;nbsp;&lt;U&gt;&lt;FONT color="#000000"&gt;BuiltInFailures.GroupFailures.DontEditNestedGroup.&lt;/FONT&gt;&lt;/U&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;And created filter class that allows Group and applied to the method PickObjects().&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;(Filter class is here)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    public class GroupFilter : ISelectionFilter
    {
        public bool AllowElement(Element elem)
        {
            if (elem is Group)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool AllowReference(Reference reference, XYZ position)
        {
            return false;
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;BR /&gt;&lt;/FONT&gt;I expected this will users not to pick nested groups, like just picking elements without using API. But it allowed to pick nested groups, just allowed picking only Group elements whether it's nested or not.&lt;BR /&gt;&lt;BR /&gt;And after reading your reply, I've tried to modify my filter class in several ways but could not find a way for that.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I discussed this with them, and they say: What actually is the question or concern? The selection behavior? The ungrouping behavior? Both? The thread is informative but doesn't clearly ask a question or assert a problem. I suspect that &lt;U&gt;it would be possible to write a selection filter that excludes nested groups&lt;/U&gt;, if desired. This would lead to behavior closer to other behaviour in Revit UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I searched some properties or methods on revit 2024 api sdk that returns whether the group element is nested or not, but couldn't find.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2023 01:09:02 GMT</pubDate>
    <dc:creator>itsjakk3</dc:creator>
    <dc:date>2023-12-15T01:09:02Z</dc:date>
    <item>
      <title>The issue about Selection.PickObjects() method when picking group elements.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12437589#M8127</link>
      <description>&lt;P&gt;I've found that when picking group elements by API and by no-API (Manually picking objects in Revit),&lt;/P&gt;&lt;P&gt;there is the difference about accessibility of pickable elements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I caught this while designing the method to ungroup all nested groups as separated elements by recursive method.&lt;/P&gt;&lt;P&gt;And then, I thought that this can lead users to see exceptions more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So that if there is intention of this when designing API, it would be better if there is an option about picking.&lt;BR /&gt;(like an optional bool type parameter that make users only pick not nested parent group).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, I'm new in this Revit API... So that it may be that I didn't find about the explanation of this on the forum or API or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. First, I've created the nested groups.&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6342923736112w960h540r214" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6342923736112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6342923736112w960h540r214');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6342923736112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Picking test.&lt;/P&gt;&lt;P&gt;1) By API : can pick all nested groups.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="itsjakk3_0-1702431743306.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1304107i1556EDA1215CFD65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="itsjakk3_0-1702431743306.png" alt="itsjakk3_0-1702431743306.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) By no-API : can pick only parent groups (the highest element of tree).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="itsjakk3_1-1702431910051.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1304109i3E57919C06C6003D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="itsjakk3_1-1702431910051.png" alt="itsjakk3_1-1702431910051.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Of course this way also can pick child groups by pressing tab key. But if I trying to ungroup it,&lt;BR /&gt;directly warning shows up.&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6342922899112w960h540r352" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6342922899112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6342922899112w960h540r352');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6342922899112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. And then, I've tried to ungroup them through the method below :&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;LI-CODE lang="csharp"&gt; public class ExplodeNestedGroup_NoDeletion_YesRecursive : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var uiapp = commandData.Application;
            var app = uiapp.Application;
            var uidoc = uiapp.ActiveUIDocument;
            var doc = uidoc.Document;

            var groupElementIds = uidoc.Selection.PickObjects(ObjectType.Element, new GroupFilter())
                .Select(e =&amp;gt; e.ElementId)
                .ToList();
            UngroupAll(groupElementIds, doc);

            return Result.Succeeded;
        }

        public void UngroupAll(IEnumerable&amp;lt;ElementId&amp;gt; elemIds, Document doc)
        {
            using (var tr = new Transaction(doc, "Ungroup"))
            {

                foreach (ElementId elemId in elemIds)
                {
                    if (doc.GetElement(elemId) is Group groupElement)
                    {
                        tr.Start();
                        var ungroupedIds = groupElement.UngroupMembers();
                        tr.Commit();
                        UngroupAll(ungroupedIds, doc);
                    }
                }
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(for easier way to design the unit tests, I've set transaction starting just before ungrouping members.)&lt;/P&gt;&lt;P&gt;Filter Class is below:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class GroupFilter : ISelectionFilter
    {
        public bool AllowElement(Element elem)
        {
            if (elem is Group)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool AllowReference(Reference reference, XYZ position)
        {
            return false;
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, the exception window shows up.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="itsjakk3_2-1702432437686.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1304112i54E21F4C027FB11E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="itsjakk3_2-1702432437686.png" alt="itsjakk3_2-1702432437686.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought that if I add the deletion of parent element from document, it could be solved.&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;&lt;LI-CODE lang="csharp"&gt;if (doc.GetElement(elemId) is Group groupElement)
                    {
                        tr.Start();
                        var ungroupedIds = groupElement.UngroupMembers();
                        doc.Delete(elemId);
                        tr.Commit();
                        UngroupAll(ungroupedIds, doc);
                    }&lt;/LI-CODE&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;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6342922196112w960h540r18" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6342922196112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6342922196112w960h540r18');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6342922196112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 02:42:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12437589#M8127</guid>
      <dc:creator>itsjakk3</dc:creator>
      <dc:date>2023-12-13T02:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: The issue about Selection.PickObjects() method when picking group elements.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12438642#M8128</link>
      <description>&lt;P&gt;I have &lt;A href="https://autodesk.slack.com/archives/C0SR6NAP8/p1702474568442579" target="_blank"&gt;asked&lt;/A&gt; the development team for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 13:36:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12438642#M8128</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-12-13T13:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: The issue about Selection.PickObjects() method when picking group elements.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12440721#M8129</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;thank you for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 09:51:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12440721#M8129</guid>
      <dc:creator>itsjakk3</dc:creator>
      <dc:date>2023-12-14T09:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: The issue about Selection.PickObjects() method when picking group elements.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12441812#M8130</link>
      <description>&lt;P&gt;I discussed this with them, and they say: What actually is the question or concern? The selection behavior? The ungrouping behavior? Both? The thread is informative but doesn't clearly ask a question or assert a problem. I suspect that it would be possible to write a selection filter that excludes nested groups, if desired. This would lead to behavior closer to other behaviour in Revit UI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 17:57:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12441812#M8130</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-12-14T17:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: The issue about Selection.PickObjects() method when picking group elements.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12442519#M8131</link>
      <description>&lt;P&gt;Sorry, my first post says not clear question and using keword 'issue' seems to offend development team. I didn't intend it...&lt;BR /&gt;&lt;BR /&gt;I just want to make users unable to select nested group elements when they run my custom function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;I need to write more detailed explanation about this...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;First, I wanted to make a function to ungroup all nested items that belong to group, like exploding all nested block on AutoCAD.&lt;BR /&gt;&lt;BR /&gt;To do that, I tried recursive function. And I thought that the picking prompt (PickObjects()) should not allow&lt;BR /&gt;picking nested groups not to meet the exception&amp;nbsp;&lt;U&gt;&lt;FONT color="#000000"&gt;BuiltInFailures.GroupFailures.DontEditNestedGroup.&lt;/FONT&gt;&lt;/U&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;And created filter class that allows Group and applied to the method PickObjects().&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;(Filter class is here)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    public class GroupFilter : ISelectionFilter
    {
        public bool AllowElement(Element elem)
        {
            if (elem is Group)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool AllowReference(Reference reference, XYZ position)
        {
            return false;
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;BR /&gt;&lt;/FONT&gt;I expected this will users not to pick nested groups, like just picking elements without using API. But it allowed to pick nested groups, just allowed picking only Group elements whether it's nested or not.&lt;BR /&gt;&lt;BR /&gt;And after reading your reply, I've tried to modify my filter class in several ways but could not find a way for that.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I discussed this with them, and they say: What actually is the question or concern? The selection behavior? The ungrouping behavior? Both? The thread is informative but doesn't clearly ask a question or assert a problem. I suspect that &lt;U&gt;it would be possible to write a selection filter that excludes nested groups&lt;/U&gt;, if desired. This would lead to behavior closer to other behaviour in Revit UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I searched some properties or methods on revit 2024 api sdk that returns whether the group element is nested or not, but couldn't find.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 01:09:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/the-issue-about-selection-pickobjects-method-when-picking-group/m-p/12442519#M8131</guid>
      <dc:creator>itsjakk3</dc:creator>
      <dc:date>2023-12-15T01:09:02Z</dc:date>
    </item>
  </channel>
</rss>

