<?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: Invalid Syntax Error in Maya 2022 in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/invalid-syntax-error-in-maya-2022/m-p/12073362#M971</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code with the right indentation levels, if someone else wants to reproduce the issue:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

def set_visibility_overrides():
    # Get the selected geometries
    selected_geometries = cmds.ls(selection=True, dag=True, shapes=True)
    
    for geometry in selected_geometries:
        # Check if the geometry has the attribute "rsEnableVisibilityOverrides"
        if cmds.attributeQuery("rsEnableVisibilityOverrides", node=geometry, exists=True):
            # Set the value of "rsEnableVisibilityOverrides" to 1
            cmds.setAttr(geometry + ".rsEnableVisibilityOverrides", 1)
            print("Set rsEnableVisibilityOverrides to 1 for:", geometry)
        else:
            print("Attribute 'rsEnableVisibilityOverrides' not found for", geometry)
        
# Call the function
set_visibility_overrides()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't say for sure, because you didn't post the full error message.&lt;/P&gt;&lt;P&gt;But my guess is, that you are not running it from a correct place in Maya. This is a Python script, so it needs to be run from a place that Maya looks at as being Python.&lt;BR /&gt;1) Python Tab in the Script editor&lt;BR /&gt;2) A shelfbutton that is set to be read as Python&lt;/P&gt;&lt;P&gt;3)A shortcut that is set to be read as Python&lt;BR /&gt;You probably accidentally ran it from a MEL Tab or from a shelfbutton/shortcut that is set to be read as MEL. Which would result in the Following error message:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// Error: def set_visibility_overrides(): // 
// Error: Line 3.30: Syntax error //&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have a Python synthax problem, and I accidentally fixed it somehow, the error message would look like this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;# Error: invalid syntax # &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have the first error message, run it from one of the places I mentioned above and you should be fine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jul 2023 08:51:17 GMT</pubDate>
    <dc:creator>Kahylan</dc:creator>
    <dc:date>2023-07-01T08:51:17Z</dc:date>
    <item>
      <title>Invalid Syntax Error in Maya 2022</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/invalid-syntax-error-in-maya-2022/m-p/12073079#M970</link>
      <description>&lt;P&gt;Hello everyone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use a script to automate the turn-on of the Visibility on Redshift for all selected objects. But every time I run it it says "Syntax Error".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import maya.cmds as cmds&lt;/P&gt;&lt;P&gt;def set_visibility_overrides():&lt;BR /&gt;# Get the selected geometries&lt;BR /&gt;selected_geometries = cmds.ls(selection=True, dag=True, shapes=True)&lt;/P&gt;&lt;P&gt;for geometry in selected_geometries:&lt;BR /&gt;# Check if the geometry has the attribute "rsEnableVisibilityOverrides"&lt;BR /&gt;if cmds.attributeQuery("rsEnableVisibilityOverrides", node=geometry, exists=True):&lt;BR /&gt;# Set the value of "rsEnableVisibilityOverrides" to 1&lt;BR /&gt;cmds.setAttr(geometry + ".rsEnableVisibilityOverrides", 1)&lt;BR /&gt;print("Set rsEnableVisibilityOverrides to 1 for:", geometry)&lt;BR /&gt;else:&lt;BR /&gt;print("Attribute 'rsEnableVisibilityOverrides' not found for", geometry)&lt;/P&gt;&lt;P&gt;# Call the function&lt;BR /&gt;set_visibility_overrides()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone spot the error? Or is it just a thing of my Maya preferences?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2023 02:33:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/invalid-syntax-error-in-maya-2022/m-p/12073079#M970</guid>
      <dc:creator>3d160emiliano</dc:creator>
      <dc:date>2023-07-01T02:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Syntax Error in Maya 2022</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/invalid-syntax-error-in-maya-2022/m-p/12073362#M971</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code with the right indentation levels, if someone else wants to reproduce the issue:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

def set_visibility_overrides():
    # Get the selected geometries
    selected_geometries = cmds.ls(selection=True, dag=True, shapes=True)
    
    for geometry in selected_geometries:
        # Check if the geometry has the attribute "rsEnableVisibilityOverrides"
        if cmds.attributeQuery("rsEnableVisibilityOverrides", node=geometry, exists=True):
            # Set the value of "rsEnableVisibilityOverrides" to 1
            cmds.setAttr(geometry + ".rsEnableVisibilityOverrides", 1)
            print("Set rsEnableVisibilityOverrides to 1 for:", geometry)
        else:
            print("Attribute 'rsEnableVisibilityOverrides' not found for", geometry)
        
# Call the function
set_visibility_overrides()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't say for sure, because you didn't post the full error message.&lt;/P&gt;&lt;P&gt;But my guess is, that you are not running it from a correct place in Maya. This is a Python script, so it needs to be run from a place that Maya looks at as being Python.&lt;BR /&gt;1) Python Tab in the Script editor&lt;BR /&gt;2) A shelfbutton that is set to be read as Python&lt;/P&gt;&lt;P&gt;3)A shortcut that is set to be read as Python&lt;BR /&gt;You probably accidentally ran it from a MEL Tab or from a shelfbutton/shortcut that is set to be read as MEL. Which would result in the Following error message:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// Error: def set_visibility_overrides(): // 
// Error: Line 3.30: Syntax error //&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have a Python synthax problem, and I accidentally fixed it somehow, the error message would look like this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;# Error: invalid syntax # &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have the first error message, run it from one of the places I mentioned above and you should be fine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2023 08:51:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/invalid-syntax-error-in-maya-2022/m-p/12073362#M971</guid>
      <dc:creator>Kahylan</dc:creator>
      <dc:date>2023-07-01T08:51:17Z</dc:date>
    </item>
  </channel>
</rss>

