<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[checking if an object is selected]]></title><description><![CDATA[<p dir="auto"><em>On 27/07/2018 at 20:01, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hey there,</p>
<p dir="auto">I'm trying to make a simple script that will do two different functions depending on if an object is already selected or not selected in the current document. In the end, I'd like to just be able to select the first object if nothing is already selected otherwise I'd like it to pass and not select the first object. I've tried a bunch of ways already but this code seems to have got me the furthest way there.</p>
<p dir="auto">Any ideas how I can do this? Thanks!</p>
<pre><code>import c4d
  
  
  
def main() :
    
    currDoc = c4d.documents.GetActiveDocument()
    selection = currDoc.GetSelection()
    
    if selection == None:
        print 'need a selection'
        
    else:
        print 'an object is already selected'
    
if __name__=='__main__':
    main()
  

</code></pre>
]]></description><link>http://developers.maxon.net/forum/topic/10885/14332_checking-if-an-object-is-selected</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 16:56:02 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/10885.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Sep 2018 10:50:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to checking if an object is selected on Sat, 01 Sep 2018 10:50:47 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 30/07/2018 at 12:21, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Thanks those all worked really well. I ended up using GetActiveObject() to make the switch</p>
]]></description><link>http://developers.maxon.net/forum/post/55314</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55314</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:50:47 GMT</pubDate></item><item><title><![CDATA[Reply to checking if an object is selected on Sat, 01 Sep 2018 10:50:44 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 30/07/2018 at 01:46, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hello,</p>
<p dir="auto">it is also possible to check if a given object is selected by checking the bit <em>c4d.BIT_ACTIVE</em>. The bit is accessed with <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/index.html?highlight=getbit#BaseList2D.GetBit" target="_blank" rel="noopener noreferrer nofollow ugc">BaseList2D.GetBit()</a></p>
<pre><code>  
sceneObject = doc.GetFirstObject()  
  
while sceneObject is not None:  
   
  if sceneObject.GetBit(c4d.BIT_ACTIVE) :  
      print(sceneObject.GetName())  
      print("Object selected")  
    
  sceneObject = sceneObject.GetNext()  
</code></pre>
<p dir="auto">best wishes,<br />
Sebastian</p>
]]></description><link>http://developers.maxon.net/forum/post/55313</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55313</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to checking if an object is selected on Sat, 01 Sep 2018 10:50:41 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 27/07/2018 at 23:02, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">try BaseDocument.GetActiveObjects()</p>
]]></description><link>http://developers.maxon.net/forum/post/55312</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55312</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:50:41 GMT</pubDate></item></channel></rss>