<?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: Only valid for ModelItem in a Document in Navisworks API Forum</title>
    <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13711153#M8201</link>
    <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7328331"&gt;@lanneauolivier&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="60" data-end="116"&gt;Could you please explain your workflow in more detail?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-start="118" data-end="285"&gt;From the code you attached, I see that while the selection set with the list of model items is ready to be created, it hasn’t actually been added to the project yet.&lt;/P&gt;
&lt;P data-start="287" data-end="396"&gt;&lt;BR /&gt;Because the selection set isn’t part of the project, trying to access its elements results in an exception.&lt;/P&gt;
&lt;P data-start="398" data-end="645"&gt;&lt;BR /&gt;If your goal is to use &lt;CODE data-start="421" data-end="439"&gt;GetSelectedItems&lt;/CODE&gt; from the selection set, why not use the &lt;CODE data-start="480" data-end="501"&gt;ModelItemCollection&lt;/CODE&gt; directly, since you’re already passing it into &lt;CODE data-start="549" data-end="569"&gt;new SelectionSet()&lt;/CODE&gt;?&lt;BR data-start="570" data-end="573" /&gt;&lt;BR /&gt;In my opinion, the behavior you’re seeing in Navisworks seems correct.&lt;/P&gt;
&lt;P data-start="647" data-end="789" data-is-last-node="" data-is-only-node=""&gt;&lt;BR /&gt;Could you please walk me through your workflow step by step? That will help me fully understand your scenario and assist you more effectively.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jul 2025 13:21:22 GMT</pubDate>
    <dc:creator>naveen.kumar.t</dc:creator>
    <dc:date>2025-07-04T13:21:22Z</dc:date>
    <item>
      <title>Only valid for ModelItem in a Document</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13705477#M8195</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I create a new SelectionSet from a ModelItemCollection, I cannot access to properties :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;&lt;/P&gt;&lt;P&gt;ModelItemCollection items = ...&lt;/P&gt;&lt;P&gt;SelectionSet selectionSet = new SelectionSet(items);&lt;/P&gt;&lt;P&gt;ModelItemCollection itemsFromSet = selectionSet.GetSelectedItems(doc);&lt;/P&gt;&lt;P&gt;itemsFromSet .First().DisplayName; // ok&lt;/P&gt;&lt;P&gt;itemsFromSet .First().PropertyCategories; // exception here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something wrong here ? Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 08:39:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13705477#M8195</guid>
      <dc:creator>lanneauolivier</dc:creator>
      <dc:date>2025-07-01T08:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Only valid for ModelItem in a Document</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13710652#M8198</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7328331"&gt;@lanneauolivier&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Could you please try using the below code?&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;

 string selectionSetName;
 ModelItemCollection selectedItems = doc.CurrentSelection.SelectedItems;
 SelectionSet selectionSet = new SelectionSet(selectedItems);
 selectionSet.DisplayName = selectionSetName;
 doc.SelectionSets.InsertCopy(0,selectionSet);

 SelectionSet ss1 = doc.SelectionSets.ToSavedItemCollection().Where(e =&amp;gt; e.DisplayName == selectionSetName).First() as SelectionSet;
 ModelItemCollection itemsFromSet = ss1.GetSelectedItems();
 string itemDisplayName= itemsFromSet.First().DisplayName;
 MessageBox.Show(itemDisplayName);
 ModelItem item = itemsFromSet.First();
 if(item!=null)
 {
     PropertyCategoryCollection collection = item.PropertyCategories;               
 }&lt;/LI-CODE&gt;
&lt;P&gt;This code worked fine at my end.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jul 2025 06:07:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13710652#M8198</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2025-07-04T06:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Only valid for ModelItem in a Document</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13710858#M8200</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5661631"&gt;@naveen.kumar.t&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for me as well because you add the SelectionSet to the document.&lt;/P&gt;&lt;P&gt;In my case, I do not want to add the SelectionSet in the document (I also do not want to add it then delete it).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems confusing because I give the Document as an argument to selectionSet.GetSelectedItems(doc);&lt;/P&gt;&lt;P&gt;It should works&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jul 2025 08:47:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13710858#M8200</guid>
      <dc:creator>lanneauolivier</dc:creator>
      <dc:date>2025-07-04T08:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Only valid for ModelItem in a Document</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13711153#M8201</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7328331"&gt;@lanneauolivier&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="60" data-end="116"&gt;Could you please explain your workflow in more detail?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-start="118" data-end="285"&gt;From the code you attached, I see that while the selection set with the list of model items is ready to be created, it hasn’t actually been added to the project yet.&lt;/P&gt;
&lt;P data-start="287" data-end="396"&gt;&lt;BR /&gt;Because the selection set isn’t part of the project, trying to access its elements results in an exception.&lt;/P&gt;
&lt;P data-start="398" data-end="645"&gt;&lt;BR /&gt;If your goal is to use &lt;CODE data-start="421" data-end="439"&gt;GetSelectedItems&lt;/CODE&gt; from the selection set, why not use the &lt;CODE data-start="480" data-end="501"&gt;ModelItemCollection&lt;/CODE&gt; directly, since you’re already passing it into &lt;CODE data-start="549" data-end="569"&gt;new SelectionSet()&lt;/CODE&gt;?&lt;BR data-start="570" data-end="573" /&gt;&lt;BR /&gt;In my opinion, the behavior you’re seeing in Navisworks seems correct.&lt;/P&gt;
&lt;P data-start="647" data-end="789" data-is-last-node="" data-is-only-node=""&gt;&lt;BR /&gt;Could you please walk me through your workflow step by step? That will help me fully understand your scenario and assist you more effectively.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jul 2025 13:21:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13711153#M8201</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2025-07-04T13:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Only valid for ModelItem in a Document</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13711271#M8203</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5661631"&gt;@naveen.kumar.t&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The aim of my algo is to create severals SelectionSet from user inputs. (like : finding pipes where radius is x, inside boundingBox from other pipes, where properties are ...)&lt;/P&gt;&lt;P&gt;The logic is defined within an external xml I am parsing on the fly and could be quite complicated, like using adding, substracting, iterating over properties, items, ...&lt;/P&gt;&lt;P&gt;I have a List&amp;lt;SelectionSet&amp;gt; to store every SelectionSet defined by the user. I would like to manage everything as a SelectionSet, some on them are added to the document (the Sets the user is looking for), and other are working SelectionSet used by the user to acheived the search.&lt;/P&gt;&lt;P&gt;I am asking it because it makes my code more generic, but I could change for ModelItemCollection if no solution&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jul 2025 15:07:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13711271#M8203</guid>
      <dc:creator>lanneauolivier</dc:creator>
      <dc:date>2025-07-04T15:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Only valid for ModelItem in a Document</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13712676#M8206</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7328331"&gt;@lanneauolivier&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I also believe that to resolve this issue, it would be better to use &lt;STRONG data-start="141" data-end="164"&gt;ModelItemCollection&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Jul 2025 13:11:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/only-valid-for-modelitem-in-a-document/m-p/13712676#M8206</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2025-07-06T13:11:23Z</dc:date>
    </item>
  </channel>
</rss>

