<?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: How to know if a node is visible in the scene by script in VRED Forum</title>
    <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8100004#M7125</link>
    <description>&lt;P&gt;The -2 case was bogus:&lt;/P&gt;
&lt;PRE&gt;def isVisible( node ):
    if not node.isValid():
        return true
    if not node.getActive():
        return false
    nodeParent = node.getParent()
    if nodeParent.isValid():
        if nodeParent.getType() == "Switch":
            currentChoice = nodeParent.fields().getInt32("choice")
            if currentChoice == -1:
                return false
            if currentChoice &amp;gt;= 0 and currentChoice &amp;lt; nodeParent.getNumChildren():
                activeNode = nodeParent.getChild(currentChoice)
                if activeNode.getID() != node.getID():
                    return false  
    return isVisible( node.getParent())
 &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jun 2018 09:06:17 GMT</pubDate>
    <dc:creator>michael_nikelsky</dc:creator>
    <dc:date>2018-06-29T09:06:17Z</dc:date>
    <item>
      <title>How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8095255#M7120</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;My workmates and I, have been looking for a way to know if a node is visible in the scene via script&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Groups.PNG" style="width: 149px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/516768i1C5B147946000DBC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Groups.PNG" alt="Groups.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How we can know if the "Sphere" is visible in the scene? I mean, if it is gray or if it has color in the sceenegraph tree.&lt;BR /&gt;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Pol.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Groups.PNG" style="width: 149px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/516768i1C5B147946000DBC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Groups.PNG" alt="Groups.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 15:04:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8095255#M7120</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-06-27T15:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8095386#M7121</link>
      <description>&lt;P&gt;Here is a way that you can build on.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;s = findNode('Sphere')&lt;/P&gt;&lt;P&gt;print s.getActive()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sP = s.getParent()&lt;/P&gt;&lt;P&gt;print sP.getActive()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b = findNode('Box')&lt;/P&gt;&lt;P&gt;print b.getActive()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;bP = b.getParent()&lt;/P&gt;&lt;P&gt;print bP.getActive()&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 15:46:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8095386#M7121</guid>
      <dc:creator>dlincol1</dc:creator>
      <dc:date>2018-06-27T15:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8096858#M7122</link>
      <description>&lt;P&gt;Thank you Dan,&lt;BR /&gt;After looking your script, I understand that your are suggesting us to look if the father of the node is active. However, this is what we are trying to avoid. We use to work with an extense tree and if the node is under a "Switch", the function&amp;nbsp; .getActive() will return True even the node is in color gray (what we expect to&amp;nbsp; be False) what means that the node is not visible in the scene.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In conclusion, we are looking for a way to know if a node is visible in the scene only looking to it. We would like to ask the node if it is gray or orange in the scenegraph tree.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pol.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 07:44:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8096858#M7122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-06-28T07:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8097003#M7123</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;this should do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;def isVisible( node ):
    if not node.isValid():
        return true
    if not node.getActive():
        return false
    nodeParent = node.getParent()
    if nodeParent.isValid():
        if nodeParent.getType() == "Switch":
            currentChoice = nodeParent.fields().getInt32("choice")
            if currentChoice == -1:
                return false
            if currentChoice == -2:
                return true
            activeNode = nodeParent.getChild(currentChoice)
            if activeNode.getID() != node.getID():
                return false  
    return isVisible( node.getParent())&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 08:46:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8097003#M7123</guid>
      <dc:creator>michael_nikelsky</dc:creator>
      <dc:date>2018-06-28T08:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8097060#M7124</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may try with a &lt;SPAN&gt;recursive function, sorry the comments are in spanish&lt;/SPAN&gt;&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;PRE&gt;#------------------------------------------------------------#

def IsVisible(Nodo):

    if Nodo.getActive():

        #Tomar el nodo padre
        Padre = Nodo.getParent()
        
        if Padre.getType() == "Switch":
            #Mirar si es el hijo seleccionado del Switch
            if Padre.getChild(Padre.fields().getInt32("choice")) != Nodo:
                return False #"NO VISIBLE"

        #Comprobar si el padre es el Root
        if Padre.getID() == getRootNode().getID() :
            return True #"VISIBLE"

        #Lanzar la funcion de nuevo
        return  IsVisible(Padre)

    else:
        #Si no esta activo, es "NO VISIBLE"
        return False #"NO VISIBLE"

 

#------------------------------------------------------------#

 

IsVisible(getSelectedNode())

#or

IsVisible(findNode("Sphere"))

 

#------------------------------------------------------------#&lt;/PRE&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;Best Regards!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 09:14:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8097060#M7124</guid>
      <dc:creator>hobbotuk</dc:creator>
      <dc:date>2018-06-28T09:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8100004#M7125</link>
      <description>&lt;P&gt;The -2 case was bogus:&lt;/P&gt;
&lt;PRE&gt;def isVisible( node ):
    if not node.isValid():
        return true
    if not node.getActive():
        return false
    nodeParent = node.getParent()
    if nodeParent.isValid():
        if nodeParent.getType() == "Switch":
            currentChoice = nodeParent.fields().getInt32("choice")
            if currentChoice == -1:
                return false
            if currentChoice &amp;gt;= 0 and currentChoice &amp;lt; nodeParent.getNumChildren():
                activeNode = nodeParent.getChild(currentChoice)
                if activeNode.getID() != node.getID():
                    return false  
    return isVisible( node.getParent())
 &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 09:06:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8100004#M7125</guid>
      <dc:creator>michael_nikelsky</dc:creator>
      <dc:date>2018-06-29T09:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a node is visible in the scene by script</title>
      <link>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8107136#M7126</link>
      <description>&lt;P&gt;I've previously asked for a script&amp;nbsp;to "select hidden in subtree" (script below)&lt;/P&gt;&lt;P&gt;From there you can select any parent node (including Root itself)...use the script... then Ctrl+Shift+F to Scroll to selected (or just isolate/delete etc. as you wish)&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;PRE&gt;def getHidden(node, hidden):
    if(not node.getActive()):
        hidden.append(node)
    for i in range(0, node.getNChildren()):
        getHidden(node.getChild(i), hidden)

def selectHidden():
   node = getSelectedNode()
    hidden = []
    getHidden(node, hidden)
    selectNodes(hidden)
    
KeyH = vrKey(Key_H)
KeyH.connect(selectHidden)
KeyH.setDescription("Select hidden nodes of selected subtree")&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Jul 2018 15:06:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/how-to-know-if-a-node-is-visible-in-the-scene-by-script/m-p/8107136#M7126</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-03T15:06:45Z</dc:date>
    </item>
  </channel>
</rss>

