Python API 2.0 Reference
python/api1/py1SimpleEmitterTest.py
1 #-
2 # ==========================================================================
3 # Copyright (C) 2020 Autodesk, Inc. and/or its licensors. All
4 # rights reserved.
5 #
6 # The coded instructions, statements, computer programs, and/or related
7 # material (collectively the "Data") in these files contain unpublished
8 # information proprietary to Autodesk, Inc. ("Autodesk") and/or its
9 # licensors, which is protected by U.S. and Canadian federal copyright
10 # law and by international treaties.
11 #
12 # The Data is provided for use exclusively by You. You have the right
13 # to use, modify, and incorporate this Data into other products for
14 # purposes authorized by the Autodesk software license agreement,
15 # without fee.
16 #
17 # The copyright notices in the Software and this entire statement,
18 # including the above license grant, this restriction and the
19 # following disclaimer, must be included in all copies of the
20 # Software, in whole or in part, and all derivative works of
21 # the Software, unless such copies or derivative works are solely
22 # in the form of machine-executable object code generated by a
23 # source language processor.
24 #
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
26 # AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
27 # WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF
28 # NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
29 # PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE, OR
30 # TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS LICENSORS
31 # BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL,
32 # DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK
33 # AND/OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY
34 # OR PROBABILITY OF SUCH DAMAGES.
35 #
36 # ==========================================================================
37 #+
38 
39 #
40 # Autodesk Script File
41 # MODIFY THIS AT YOUR OWN RISK
42 #
43 # Creation Date: 23 November 2006
44 #
45 # Description:
46 # This script creates a new spSimpleEmitter node and animates
47 # it to move and spin
48 #
49 # Procedures:
50 # simpleEmitter
51 #
52 
53 import maya.cmds as cmds
54 
55 def simpleEmitter():
56  def keyTR(name):
57  axes = ['tx','tx', 'tz', 'rx', 'ry', 'rz']
58  for a in axes:
59  cmds.setKeyframe ('{}.{}'.format(name,a))
60 
61  cmds.file (force=True, newFile=True)
62  cmds.currentUnit (linear='centimeter', angle='degree', time='film')
63 
64  name = 'simpleEmitter'
65 
66  # Load the plug-in emitter and create an emitter node
67  cmds.loadPlugin ('py1SimpleEmitter.py')
68  cmds.createNode ('py1SimpleEmitter', name=name)
69 
70  # Create particle object and connect to the plugin emitter node
71  cmds.particle (name='particles')
72  cmds.connectDynamic ('particles', em=name)
73 
74  cmds.setAttr ('{}.rate'.format(name), 200 )
75  cmds.setAttr ('{}.speed'.format(name), 25 )
76 
77  cmds.playbackOptions (minTime=0.00, maxTime=60.0)
78  cmds.currentTime (0)
79  cmds.play (wait=True, forward=True)
80 
81  # make some keyframes on emitter
82  cmds.currentTime (0)
83  cmds.select (name, replace=True)
84  keyTR(name)
85 
86  cmds.currentTime (30)
87  cmds.move (-2.011944, 6.283524, -2.668834, relative=True)
88  cmds.move (0, 0, 12.97635, relative=True, localSpace=True, worldSpaceDistance=True)
89  cmds.rotate (0, -75.139762, 0, relative=True, objectSpace=True)
90  keyTR(name)
91 
92  cmds.currentTime (60)
93  cmds.move (0, 0, -14.526107, relative=True)
94  cmds.move (0, -8.130523, 0, relative=True)
95  cmds.rotate (0, 0, 78.039751, relative=True, objectSpace=True)
96  cmds.rotate (0, 0, 53.86918, relative=True, objectSpace=True)
97  keyTR(name)
98 
99  cmds.playbackOptions (minTime=0.00, maxTime=60.0)
100  cmds.currentTime (0)
101  cmds.play (wait=True, forward=True)
102 
103 simpleEmitter()