Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String not callable
#1
So I followed a video from the Autodesk scripting and SDK learning channel



Everything works fine, mostly, but I can't get the last part to work, the string just keeps resulting in an error, and when I do the edit expression part it opens the text editor instead of the expression editor. Does anyone with fresher eyes know what the problem is here? I'm using Maya 2016. Wall

import maya.cmds as c

selectionList = c.ls (orderedSelection=True, type='transform')

if len(selectionList) >=2:
    
    targetName = selectionList[0]
    
    selectionList.remove(targetName)
    
    locatorGroupName = c.group(empty=True, name='expansion_locator_grp#')
    
    maxExpansion = 100
    
    newAttributeName = 'expansion' 
    
    if not c.objExists ('%s.%s' % (targetName, newAttributeName)):
        
        c.select(targetName)
        
        c.addAttr(longName=newAttributeName, shortName='exp', attributeType='double', min=0, max=maxExpansion, defaultValue=maxExpansion, keyable=True)
       
    for objectName in selectionList:
        
        coords = c.getAttr('%s.translate' % (objectName))[0]
        
        locatorName=c.spaceLocator(position=coords, name='%s_loc#'%(objectName)) [0]
        
        c.xform (locatorName, centerPivots=True)
        
        c.parent(locatorName, locatorGroupName)
        
        pointConstraintName= c.pointConstraint([targetName, locatorName], objectName, name='%s_pointConstraint#'%(objectName)) [0]
                                      
        c.expression(alwaysEvaluate=True,
                    name='%s_attractWeight'%(objectName),
                    object= pointConstraintName,
                    string='%sW0=%s-%s.%s'(targetName, maxExpansion, targetName, newAttributeName))
                    
        c.connectAttr ('%s.%s'%(targetName, newAttributeName),
                      '%s.%sW1'%(pointConstraintName, locatorName))
           
    c.xform (locatorGroupName, centerPivots=True)
Error is this
# Error: line 1: TypeError: file <maya console> line 38: 'str' object is not callable #
Reply


Messages In This Thread
String not callable - by nexahs - Feb-08-2019, 10:46 PM
RE: String not callable - by ichabod801 - Feb-08-2019, 10:52 PM
RE: String not callable - by nexahs - Feb-09-2019, 01:45 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020