You must be using an unknown character for your quotation marks. I get this error when running your code:
# Error: invalid character in identifier #
This works fine for me:
print("mesh")
Also keep in mind that Python allows single quotes
print('mesh')
And even triple quotes
print("""mesh""")
And you can use either the ‘’ or “” quotation marks.
As for your actual code…you might think about naming your function something more unique to what the function does. Also, you’re passing in a parameter but also finding that same parameter in a variable within the function, so the parameter really isn’t necessary. This updated version works for me:
def getMeshFromSelection():
obj = cmds.ls(selection = True)
shapeNode = cmds.listRelatives(obj, shapes = True)
nodeType = cmds.nodeType(shapeNode)
if nodeType == "mesh":
print("mesh")
Also, hopefully I wasn’t taking it for granted but the code you pasted had no indentation. Be sure your indentation levels match and you don’t have a mix of tabs and spaces.
Hope that helps