<?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: Checking if entity is selected in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6527749#M9637</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If you has a selection as &lt;STRONG&gt;AcDbObjectIdArray&lt;/STRONG&gt; - its &lt;STRONG&gt;find()&lt;/STRONG&gt; method is fast enough.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yeah it's fast enough for one-offs, but&amp;nbsp;I have&amp;nbsp;connected objects that cannot easily be grouped, since they potentially belong to more than one group and need to be able to move independently. In order for me to move them correctly I need to know whether they themselves are selected, and whether the things they are connected to are selected. This potentially involves searching the "selected" array many hundreds or thousands of times for my most complex moves. I was considering maintaining my own 'selected' property to speed this up.&lt;/P&gt;</description>
    <pubDate>Sun, 28 Aug 2016 21:20:36 GMT</pubDate>
    <dc:creator>Kyudos</dc:creator>
    <dc:date>2016-08-28T21:20:36Z</dc:date>
    <item>
      <title>Checking if entity is selected</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6524270#M9634</link>
      <description>&lt;P&gt;Before I embark on developing an alternative can I just double check...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only way to check if an &lt;STRONG&gt;AcDbObject&lt;/STRONG&gt; / &lt;STRONG&gt;AcDbEntity&lt;/STRONG&gt; is selected is to iterate through a selection set (or equivalent array) - correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no "selected" property of the object (e.g., &lt;STRONG&gt;isSelected&lt;/STRONG&gt;) that AutoCAD maintains?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Meaning the time taken to check if something is selected varies with the size of the selection?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 04:58:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6524270#M9634</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2016-08-26T04:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if entity is selected</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6524780#M9635</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;The only way to check if an &lt;STRONG&gt;AcDbObject&lt;/STRONG&gt; / &lt;STRONG&gt;AcDbEntity&lt;/STRONG&gt; is selected is to iterate through a selection set (or equivalent array) - correct?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;as far as i know, thats the only way we have.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Meaning the time taken to check if something is selected varies with the size of the selection?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;yeah, but we are talking about milliseconds &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;well, for example, try this code, to check was the entity selected before command starts or not.&lt;/P&gt;&lt;PRE&gt;//dont forget to add ACRX_CMD_USEPICKSET | ACRX_CMD_REDRAW to the command, that will use this function
bool isEntitySelected(AcDbObjectId eId2Check)
{
	bool isSelected = false;
	AcDbObjectId eId;
	ads_name one_ent;
	long len = 0L;
	struct resbuf *grip_set = NULL, *ents = NULL;
	int res = acedSSGetFirst(&amp;amp;grip_set, &amp;amp;ents);
	if (res == RTNORM)
	{
		if (ents) 
		{
			if (ents -&amp;gt;restype == RTPICKS) 
			{		
				acedSSLength(ents-&amp;gt;resval.rlname, &amp;amp;len);

				for (long a = 0; a &amp;lt; len; a++)
				{
					if (ads_ssname(ents-&amp;gt;resval.rlname,a,one_ent)!=RTNORM)continue;
					if(acdbGetObjectId(eId, one_ent)!= Acad::eOk)continue;
					if (eId == eId2Check)
					{
						isSelected = true;
						break;
					}
				}
				acedSSFree(ents-&amp;gt;resval.rlname);
			}
			acutRelRb(ents);
		}

		if (grip_set) 
		{
			if (grip_set-&amp;gt;restype == RTPICKS) acedSSFree(grip_set-&amp;gt;resval.rlname);
			acutRelRb(grip_set);
		}
	}
	return isSelected;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 11:27:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6524780#M9635</guid>
      <dc:creator>nick83</dc:creator>
      <dc:date>2016-08-26T11:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if entity is selected</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6526958#M9636</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/542776"&gt;@Kyudos&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;... There is no "selected" property of the object (e.g., &lt;STRONG&gt;isSelected&lt;/STRONG&gt;) that AutoCAD maintains?...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It seems that you do not understand the basic principles of ObjectARX. For example, about that AcDbXXXX classes are related only to the database and have no knowledge about the AutoCAD UI (selection is a UI unit).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you has a selection as &lt;STRONG&gt;AcDbObjectIdArray&lt;/STRONG&gt; - its &lt;STRONG&gt;find()&lt;/STRONG&gt; method is fast enough.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 20:19:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6526958#M9636</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-08-27T20:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if entity is selected</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6527749#M9637</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If you has a selection as &lt;STRONG&gt;AcDbObjectIdArray&lt;/STRONG&gt; - its &lt;STRONG&gt;find()&lt;/STRONG&gt; method is fast enough.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yeah it's fast enough for one-offs, but&amp;nbsp;I have&amp;nbsp;connected objects that cannot easily be grouped, since they potentially belong to more than one group and need to be able to move independently. In order for me to move them correctly I need to know whether they themselves are selected, and whether the things they are connected to are selected. This potentially involves searching the "selected" array many hundreds or thousands of times for my most complex moves. I was considering maintaining my own 'selected' property to speed this up.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Aug 2016 21:20:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6527749#M9637</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2016-08-28T21:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if entity is selected</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6527772#M9638</link>
      <description>&lt;P&gt;You can use AcEdSSGetFilter class in order to check adding/removing object to selection set.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Aug 2016 21:29:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/checking-if-entity-is-selected/m-p/6527772#M9638</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-08-28T21:29:19Z</dc:date>
    </item>
  </channel>
</rss>

