some # comments break my code!! // Error: Line 1.11113: Unterminated string.

110 views
Skip to first unread message

Rudi Hammad

unread,
Nov 13, 2015, 6:47:15 PM11/13/15
to Python Programming for Autodesk Maya
hi,
so my code breaks when he wants...if I delete all the comments it works.
If I leave the comments, sometime it works and other times it breaks...soo what is going on?
I´ve read that addind at the beginning of my code the following solves the problem:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

but it doesn´t.
what can I do?

thanks

Justin Israel

unread,
Nov 13, 2015, 9:07:56 PM11/13/15
to Python Programming for Autodesk Maya

Got an example of broken code?
That fix you mentioned is only if you use Unicode characters within your source code.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8a0861ca-0569-42eb-a918-03db2832542e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Geordie Martinez

unread,
Nov 14, 2015, 1:23:49 AM11/14/15
to python_inside_maya
unterminated string usually means a typo. 

you have one too many quotes or forgot to put a quote. 
your trace back will tell you which line it's happening in. 


Rudi Hammad

unread,
Nov 14, 2015, 7:43:33 AM11/14/15
to Python Programming for Autodesk Maya
it is weird because I can excute le code with success one time or two times. But after that it breaks. I have 2 errors:

// Error: ...ta = [\"l_indexMetacarpal\",\"l_middleMetacarpal\",\"l_ringMetacarpal\",\"l_pinkyMetacarpal\"]\n            for i in range(0,fin //
// Error: Line 2.0: Unterminated string. //

error...ta??? what is that
My comments are like # mycomment or like #--[mycomment]--#. Do you thing that #--[mycomment]--# could be causing problems.
But how can it work a couple of times with no errors, and then breaks?



El sábado, 14 de noviembre de 2015, 7:23:49 (UTC+1), Geordie Martinez escribió:
unterminated string usually means a typo. 

you have one too many quotes or forgot to put a quote. 
your trace back will tell you which line it's happening in. 

On Fri, Nov 13, 2015 at 6:07 PM, Justin Israel <justin...@gmail.com> wrote:

Got an example of broken code?
That fix you mentioned is only if you use Unicode characters within your source code.

On Sat, 14 Nov 2015 12:47 PM Rudi Hammad <rudih...@gmail.com> wrote:
hi,
so my code breaks when he wants...if I delete all the comments it works.
If I leave the comments, sometime it works and other times it breaks...soo what is going on?
I´ve read that addind at the beginning of my code the following solves the problem:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

but it doesn´t.
what can I do?

thanks

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

yury nedelin

unread,
Nov 14, 2015, 10:35:41 AM11/14/15
to python_in...@googlegroups.com

Post here exactly what you trying to run.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e95f862f-a693-46c7-a325-7c14cfe143da%40googlegroups.com.

Justin Israel

unread,
Nov 14, 2015, 11:58:35 AM11/14/15
to python_in...@googlegroups.com

And use a pastebin please, to preserve formatting.


Geordie Martinez

unread,
Nov 14, 2015, 1:45:02 PM11/14/15
to python_inside_maya
you can also use  http://tohtml.com  to quickly format code for pasting into email/forums, etc. 
paste your python in there and then copy and paste the HTML formatted content here. but no one can help you if we can't see the code. 

good luck. 

Rudi Hammad

unread,
Nov 14, 2015, 2:48:03 PM11/14/15
to Python Programming for Autodesk Maya
okey. Thanks for taking the time to check mi post, the thing is I am not getting the error anymore...I don´t know what I deleted, or what I did.
if get ther error again, I´ll post the code.
This is how I feel now ¬¬
http://d.justpo.st/media/images/2013/03/463e4e4f4acb9afc185a067b7f360321.jpg
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Chris Lesage

unread,
Nov 14, 2015, 3:37:16 PM11/14/15
to python_in...@googlegroups.com
Hey Rudi,

I believe you were trying to run Python code as MEL, judging by the error message.

Rudi Hammad

unread,
Nov 14, 2015, 6:04:13 PM11/14/15
to Python Programming for Autodesk Maya
hi,
I don´t think so. It is python. As soon as I deleted some coments in the code it worked. it was something about the #comments
Now it works....not sure why XD

Rudi Hammad

unread,
Nov 19, 2015, 7:27:27 AM11/19/15
to Python Programming for Autodesk Maya
okey...it is happening again.
IMPORTANT...the errors show only in eclipse. If I execute the code directly in maya´s interpreter, I don´t get any error. (  have eclipse connect to maya, and I get the error when I exceute the code in eclipse only
I also notice this happens when I duplicate a code and change some variables. For example, here I am programing spine that could be bipedal or quadruped. So I did the code for bipedal,
and then duplicated the code and changed the variables bipedal to quadruped.
I get the following errors :

// Error: ...python("#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"------------------------------------------------------------------ //
// Error: Line 1.5842: Unterminated string. //
// Error: ...python("#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"------------------------------------------------------------------ //
// Error: Line 1.5842: Unterminated string. //

the errors above happen randomly. Sometimes it work, some time it doesn´t and give the errors shown

and here is the code. Justin, I used pastebin to clone the code and paste here. Is this okey?



#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""---------------------------------------------------------------------------[ REQUISITOS ]-----------------------------------------------------------------------------"""
# modules
import maya.cmds as cmds
import coreUtilities.globalUtilities as gu
import coreUtilities.mathUtilities as mu
import setupTools.riggingTools as rt
import sys
# class objects
mathUtilities = mu.MathUtilities()
getUtilities = gu.GetUtilities()
genericRiggingTools = rt.GenericRiggingTools()

"""---------------------------------------------------------------------------[ CLASSES ]-----------------------------------------------------------------------------"""


class CreaturePoints(object):
   
    # static variables
    axis = ["x","y","z"]
       
    def bipedalChestPoint(self,chestParent="",intermediateChest=False):
       
        """--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        description: crea puntos torso, y debuggea cualquier error. Puede ser uno o varios torsos bipedos
            Los puntos se emparentan a lo declarado o seleccionado. Si se crea mas de un torso, se renombar automaticamente
            # arg1-chestParent : el seleccionado o el declarado
            # arg3-intermediateChest : crea joint intermedia en chest                  
        use: ejecutar con declaraciones o seleccino
        status: final
        author: rudi hammad
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"""
               
        #--[DEBUGGING]--#
        # 1.si no existi hip      
        if cmds.objExists("c_hip_loc")!=True:
            cmds.warning( "no c_hip_loc found in the scene. Please create a hip locator before running the script" )
            sys.exit()
        # 2.chestParent debe ser declarado o elegido
        if not chestParent:
            selection = cmds.ls(sl=True)
            # seleccionar un objeto solo para emparentar
            if len(selection) > 1 or len(selection) == 0 :
                cmds.warning(" none or more than on object selected. Please select only one ")
                sys.exit()
            else:
                chestParent = selection[0]           
        else:
            chestParent = chestParent
            # si el input declarado no existe
            if cmds.objExists(chestParent)!=True :
                cmds.warning( "chestParent input not valid, please insert an existing object as argument" )
                sys.exit()
          
                                                                              
        #--[MAIN CODE]--#
        #--[if chest exists]--#
        if cmds.objExists("c_bipedChest_loc")==True:
            # si ya existe un extra
            try:
                cmds.select( "c_bipedExtra*Chest_loc", r=True)
                chests = cmds.ls( sl=True )
                numberOfChest = len(chests)
                extraLetter = chr(ord("A")+(numberOfChest))
                toAdd = "Extra" + extraLetter
                newChest = "c_biped" + toAdd + "Chest"
            # si no exist extra
            except:
                " no extra chests found..."
                newChest = "c_bipedExtraAChest"
            # chest locator
            pos = cmds.xform( chestParent, q=True, t=True, ws=True )
            cmds.spaceLocator( n=newChest + "_loc"); cmds.xform( t=(pos[0],pos[1]*1.5,pos[2]) ); cmds.setAttr( ".overrideEnabled",1 ); cmds.setAttr( ".overrideColor",20 )
            cmds.spaceLocator( n=newChest + "End_loc" ); cmds.xform( t=(pos[0],pos[1]*2,pos[2]) )
            # properties          
            for elem in self.axis:
                cmds.setAttr( newChest + "_loc" + " Shape.localScale" + elem.upper(), 5 )
                cmds.setAttr( newChest + "End_loc" + " Shape.localScale" + elem.upper(), 5 )                           
            # parenting
            cmds.parent( newChest + "End_loc", newChest + "_loc")
            cmds.parent( newChest + "_loc", chestParent )
            # lineas 
            genericRiggingTools.lineBetweenTwoObjects(newChest + "_loc",chestParent)   
            genericRiggingTools.lineBetweenTwoObjects(newChest + "_loc",newChest + "End_loc")                                   
            # extraChest
            if intermediateChest == True:
                cmds.spaceLocator( n=newChest + "Inter_loc" ); cmds.xform( t=(pos[0],pos[1]*1.85,pos[2]) )
                cmds.parent( newChest + "Inter_loc", newChest + "End_loc")
                for elem in self.axis:
                    cmds.setAttr( newChest + "Inter_loc" + "Shape.localScale" + elem.upper(), 2.5 )
                                     
        #--[end]--#      
        cmds.select( cl=True )


    def quadrupedChestPoint(self,chestParent="",intermediateChest=False):
       
        """--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        description: crea puntos torso, y debuggea cualquier error. Puede ser uno o varios torsos quadrupedos
            Los puntos se emparentan a lo declarado o seleccionado. Si se crea mas de un torso, se renombar automaticamente
            # arg1-chestParent : el seleccionado o el declarado
            # arg3-intermediateChest : crea joint intermedia en chest                  
        use: ejecutar con declaraciones o seleccino
        status: final
        author: rudi hammad
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"""
               
        #--[DEBUGGING]--#
        # 1.si ni existi hip      
        if cmds.objExists("c_hip_loc")!=True:
            cmds.warning( "no c_hip_loc found in the scene. Please create a hip locator before running the script" )
            sys.exit()
        # 2.chestParent should be declared o selected
        if not chestParent:
            selection = cmds.ls(sl=True)
            # select only one object to parent
            if len(selection) > 1 or len(selection) == 0 :
                cmds.warning(" none or more than on object selected. Please select only one ")
                sys.exit()
            else:
                chestParent = selection[0]           
        else:
            chestParent = chestParent
            # si el input declarado no existe
            if cmds.objExists(chestParent)!=True :
                cmds.warning( "chestParent input not valid, please insert an existing object as argument" )
                sys.exit()
          
                                                                              
        #--[MAIN CODE]--#
        #--[if chest exists]--#
        if cmds.objExists("c_quadChest_loc")==True:
            # si ya existe un extra
            try:
                cmds.select( "c_quadExtra*Chest_loc", r=True)
                chests = cmds.ls( sl=True )
                numberOfChest = len(chests)
                extraLetter = chr(ord("A")+(numberOfChest))
                toAdd = "Extra" + extraLetter
                newChest = "c_quad" + toAdd + "Chest"
            # si no exist extra
            except:
                " no extra chests found..."
                newChest = "c_quadExtraAChest"
            # chest locator
            pos = cmds.xform( chestParent, q=True, t=True, ws=True )
            cmds.spaceLocator( n=newChest + "_loc"); cmds.xform( t=(pos[0],pos[1],(pos[2] + pos[1]*0.75)) ); cmds.setAttr( ".overrideEnabled",1 ); cmds.setAttr( ".overrideColor",20 )
            cmds.spaceLocator( n=newChest + "End_loc" ); cmds.xform( t=(pos[0],pos[1],(pos[2] + pos[1]*1.5)) )
            # properties          
            for elem in self.axis:
                cmds.setAttr( newChest + "_loc" + " Shape.localScale" + elem.upper(), 5 )
                cmds.setAttr( newChest + "End_loc" + " Shape.localScale" + elem.upper(), 5 )                           
            # parenting
            cmds.parent( newChest + "End_loc", newChest + "_loc")
            cmds.parent( newChest + "_loc", chestParent )
            # lineas 
            genericRiggingTools.lineBetweenTwoObjects(newChest + "_loc",chestParent)   
            genericRiggingTools.lineBetweenTwoObjects(newChest + "_loc",newChest + "End_loc")                                   
            # extraChest
            if intermediateChest == True:
                cmds.spaceLocator( n=newChest + "Inter_loc" ); cmds.xform( t=(pos[0],pos[1],(pos[2] + pos[1]*1.15)) )
                cmds.parent( newChest + "Inter_loc", newChest + "End_loc")
                for elem in self.axis:
                    cmds.setAttr( newChest + "Inter_loc" + "Shape.localScale" + elem.upper(), 2.5 )

        #--[end]--#      
                cmds.select( cl=True )

Marcus Ottosson

unread,
Nov 19, 2015, 7:36:39 AM11/19/15
to python_in...@googlegroups.com

Justin, I used pastebin to clone the code and paste here. Is this okey?

Haha! :D


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/20914bd8-540c-4839-a5e3-51c2ce6fc1f9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Marcus Ottosson

unread,
Nov 19, 2015, 7:38:06 AM11/19/15
to python_in...@googlegroups.com
What you should have done, was to copy it from pastebin, paste it in a gist, upload it to YouTube, count to 10, and paste the results here. Duh. :)
--
Marcus Ottosson
konstr...@gmail.com

Anthony Tan

unread,
Nov 19, 2015, 8:27:22 AM11/19/15
to python_in...@googlegroups.com
Python as part of the language specification requires you to use whitespace to mark out logical blocks within your code - the formatting is *incredibly* important. 
 
Basically, dump your code in pastebin, hit submit, and paste the link here. Something like this: http://pastebin.com/xrUxit9b
 
That was me taking the code in this email and putting it into pastebin which is obviously not right (or at least, it looks wrong to me, so I'm presuming it's something lost here) - you need to do that with the actual code you're trying to run from your editor.
 
Also, check you've got whatever you've got configured for your eclipse-maya setup is right? There's a whole additional set of problems that could be introduced there.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Justin Israel

unread,
Nov 19, 2015, 11:36:01 AM11/19/15
to python_in...@googlegroups.com

Hah, ya it would be helpful to *actually* get the pastebin link, which preserved formatting. We don't want long code in these messages. Anything more than,  say,  10 lines should be a link to something external that makes the code readable.

Even after we see it in pastebin form, I feel it could just be a bug in the eclipse plugin that talks to Maya. Because if your script continues to work in Maya via standard importing, but breaks when you send it over the wire from eclipse.. it may just be that developer tool.


Rudi Hammad

unread,
Nov 19, 2015, 1:57:00 PM11/19/15
to Python Programming for Autodesk Maya
okey, sorry guys..
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Nov 19, 2015, 2:14:07 PM11/19/15
to Python Programming for Autodesk Maya

So, how about that pastebin link?


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2024c723-550c-4e94-ae34-542ea390f2b1%40googlegroups.com.

Marcus Ottosson

unread,
Nov 19, 2015, 2:35:00 PM11/19/15
to python_in...@googlegroups.com

okey, sorry guys..

No offense, Rudi. It’s just funny sometimes the way in which things can get misunderstood. :)

If you post a link to that pastebin, I’m sure we’ll be able to help you narrow down this problem.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rudi Hammad

unread,
Nov 20, 2015, 5:17:59 PM11/20/15
to Python Programming for Autodesk Maya
no offense taken. I just saw how to use properly pastebin. next time I´ll do it fine.
by the way! I "solved" the problem.
When I used the shortcut or the button send highlighted to maya, it gave me the error. But it worked fine with sent entire text to maya.
So I restored it to default the keyboard binding, and it works fine now.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages