listRelatives ( chosenCamera, p = 1 ) camShape = chosenCamera confirm = mc. warning ( 'Select camera or run in a perspective viewport' ) else : camObj = mc. listRelatives ( chosenCamera, s = True ) if not chosenCamera : mc. modelPanel ( currentPanel, q = True, cam = True ) chosenCamera = mc. getPanel ( typeOf = currentPanel ) = 'modelPanel' : chosenCamera = mc. nodeType ( selShp ) = 'camera' : chosenCamera = selShp else : currentPanel = mc. listRelatives ( selection, s = True ))) = 'transform' ] #gives us the shape if mc. ls ( sl = True ) chosenCamera = False if len ( selection ) > 0 : selShp = ( selection, mc. Plugs into 'focusDistance' of camera shape''' # choose cam selection = mc. append ( ) return points def createZDistanceTool (): '''creates controllers to help with the focus distance. append ( ) for i in reversed ( range ( rezx )): points. append ( ) for j in range ( rezx ): points. append ( ) for i in range ( rezy / 2 ): for j in reversed ( range ( rezx )): points. append ( ) for j in reversed ( range ( rezy )): points. Import maya.cmds as mc def oneCurveGrid ( rezx = 10, rezy = 10, scalex = 1, scaley = 1 ): points = sx = 1.0 / ( rezx - 1 ) sy = 1.0 / ( rezy - 1 ) for i in range ( rezx / 2 ): for j in range ( rezy ): points. ls ( sl = 1, hd = 1 ) motionPathCurveOnSurface = curveOnSurfaceFromCurve ( selectedCurve ) motionPathWithNormalsAndFlow ( object, motionPathCurveOnSurface ) zDepth control tool flow ( object, dv = flowLatticeSides ) selectedCurve = mc. pathAnimation ( object, c = motionPathCurve, wut = "normal", f = 1, ua = axes, fa = axes ) flowLatticeSides = flowLatticeSides ] = flowSpans mc. playbackOptions ( q = 1, maxTime = 1 )) else : mc. playbackOptions ( q = 1, minTime = 1 ), etu = mc. pathAnimation ( object, c = motionPathCurve, wut = "normal", f = 1, ua = axes, fa = axes, fm = 1, stu = mc. xform ( object, q = 1, os = 1, bb = 1 ) axes = sorted ( - bbox, 'x', 0 ),( bbox - bbox, 'y', 1 ),( bbox - bbox, 'z', 2 )]) if useTimeline : mc. xform ( object, a = True, ro = ( 0, 0, 0 ) ) bbox = mc. 5, 0 ),( 0.5, 1 * v / 3 ), ( 0.5, 2 * v / 3 ), ( 0.5, v ))) return cOs def motionPathWithNormalsAndFlow ( object, motionPathCurve, useTimeline = True, flowSpans = 10 ): mc. curveOnSurface ( loftObj, d = 3, uv = ((. getAttr ( loftShp + '.minMaxRangeV.maxValueV' ) cOs = mc. listRelatives ( loftObj, s = 1 ) v = mc. loft ( offset1, offset2, u = 1, ch = 1 ) loftShp = mc. offsetCurve ( curveObj, ugn = 0, d =- offsetDistance ) loftObj = mc. offsetCurve ( curveObj, ugn = 0, d = offsetDistance ) offset2 = mc.
#select object and curve and run code import maya.cmds as mc def curveOnSurfaceFromCurve ( curveObj, offsetDistance =. connectAttr ( obj + '.uVal', pathA + '.uValue', f = 1 ) Pop-up (HUD) slider to change channel box attribute speed pathAnimation ( obj, follow = True, fm = 1, c = pathShp ) mc. duplicate ( profile, n = profile + '_copy' ) mc. group ( n = 'copies', em = 1 ) for i in range ( count ): obj = mc. listRelatives ( path, s = 1 ) profile = mc. promptDialog ( query = True, text = True )) path = mc. Check uVal attr on objects to displace along curve \n\n Number of copies spread on curve:', button =, defaultButton = 'OK', cancelButton = 'Cancel', tx = 10, dismissString = 'Cancel' ) if result = 'OK' : count = int ( mc. promptDialog ( title = 'Copy along curve', message = 'Uses motionPath to spread copies of your first object on the second object selected (a path) \n This means you can animate the curve.