scripted/showNarrowPolyViewer.py

scripted/showNarrowPolyViewer.py
1 # -
2 # ==========================================================================
3 # Copyright (C) 1995 - 2006 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 import maya
40 
41 def showNarrowPolyViewer():
42 
43  window = maya.cmds.window()
44  form = maya.cmds.formLayout()
45  editor = maya.cmds.spNarrowPolyViewer()
46  column = maya.cmds.columnLayout(adjustableColumn=True)
47 
48  # Create some buttons that will alter the display appearance of
49  # objects in the model editor, eg. wireframe vs. shaded mode.
50  #
51  maya.cmds.button(label="Wireframe", command=("maya.cmds.spNarrowPolyViewer(\"%s\",edit=True,displayAppearance=\"wireframe\")" % (editor, )))
52  maya.cmds.button(label="Points", command=("maya.cmds.spNarrowPolyViewer(\"%s\",edit=True,displayAppearance=\"points\")" % (editor, )))
53  maya.cmds.button(label="Bounding Box", command=("maya.cmds.spNarrowPolyViewer(\"%s\",edit=True,displayAppearance=\"boundingBox\")" % (editor, )))
54  maya.cmds.button(label="Smooth Shaded", command=("maya.cmds.spNarrowPolyViewer(\"%s\",edit=True,displayAppearance=\"smoothShaded\")" % (editor, )))
55  maya.cmds.button(label="Flat Shaded", command=("maya.cmds.spNarrowPolyViewer(\"%s\",edit=True,displayAppearance=\"flatShaded\")" % (editor, )))
56  maya.cmds.floatField("angleTolerance",minValue=0,maxValue=180,value=10,step=1,precision=1,ann="tolerance",cc=("maya.cmds.spNarrowPolyViewer(\"%s\", edit=True,tol=maya.cmds.floatField(\"angleTolerance\",q=True,v=True))" % (editor, )), \
57  ec = ("maya.cmds.spNarrowPolyViewer(\"%s\", edit=True,tol=maya.cmds.floatField(\"angleTolerance\",q=True,v=True))" % (editor, )), dc = ("maya.cmds.spNarrowPolyViewer(\"%s\", edit=True,tol=maya.cmds.floatField(\"angleTolerance\",q=True,v=True))" % (editor, )), \
58  rfc = ("maya.cmds.spNarrowPolyViewer(\"%s\", edit=True,tol=maya.cmds.floatField(\"angleTolerance\",q=True,v=True))" % (editor, )))
59 
60  # Set up the window layout attachments.
61  #
62  maya.cmds.formLayout(form,edit=True,attachForm=(column, "top",0))
63  maya.cmds.formLayout(form,edit=True,attachForm=(column, "left",0))
64  maya.cmds.formLayout(form,edit=True,attachNone=(column, "bottom"))
65  maya.cmds.formLayout(form,edit=True,attachNone=(column, "right"))
66  maya.cmds.formLayout(form,edit=True,attachForm=(editor, "top", 0), attachControl = (editor, "left", 0, column))
67  maya.cmds.formLayout(form,edit=True,attachForm=(editor, "bottom", 0))
68  maya.cmds.formLayout(form,edit=True,attachForm=(editor, "right", 0))
69 
70  # Create a camera for the editor. This particular camera will
71  # have a close up perspective view of the centre of the ground plane.
72  #
73  camera = maya.cmds.camera(centerOfInterest=2.450351, position=(1.535314,1.135712,1.535314), rotation=(-27.612504,45,0), worldUp=(-0.1290301,0.3488592,-0.1290301))
74  g__MpTestPrimaryCamera = camera[0];
75 
76  # Attach the camera to the model editor.
77  #
78  maya.cmds.spNarrowPolyViewer(editor,edit=True,camera=camera[0])
79  maya.cmds.currentTime(10.0,edit=True)
80  maya.cmds.spNarrowPolyViewer(editor,edit=True,i=True)
81  maya.cmds.refresh()
82  maya.cmds.spNarrowPolyViewer(editor,edit=True,r=True)
83 
84  maya.cmds.showWindow(window)