1#!/pxrpythonsubst 2# 3# Copyright 2017 Pixar 4# 5# Licensed under the Apache License, Version 2.0 (the "Apache License") 6# with the following modification; you may not use this file except in 7# compliance with the Apache License and the following modification to it: 8# Section 6. Trademarks. is deleted and replaced with: 9# 10# 6. Trademarks. This License does not grant permission to use the trade 11# names, trademarks, service marks, or product names of the Licensor 12# and its affiliates, except as required to comply with Section 4(c) of 13# the License and to reproduce the content of the NOTICE file. 14# 15# You may obtain a copy of the Apache License at 16# 17# http://www.apache.org/licenses/LICENSE-2.0 18# 19# Unless required by applicable law or agreed to in writing, software 20# distributed under the Apache License with the above modification is 21# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 22# KIND, either express or implied. See the Apache License for the specific 23# language governing permissions and limitations under the Apache License. 24# 25 26from pxr import Usd, UsdUI 27import unittest 28 29class TestUsdUISceneGraphPrim(unittest.TestCase): 30 def test_Basic(self): 31 fileName = "sceneGraph.usda" 32 stage = Usd.Stage.CreateNew(fileName) 33 34 # Create this prim first, since it's the "entrypoint" to the layer, and 35 # we want it to appear at the top 36 rootPrim = stage.DefinePrim("/ANode") 37 38 # Test Node 39 sceneGraphPrim = UsdUI.SceneGraphPrimAPI.Apply(rootPrim) 40 assert(sceneGraphPrim) 41 42 # Test displayName 43 displayNameAttr = sceneGraphPrim.GetDisplayNameAttr() 44 assert displayNameAttr 45 displayNameAttr = sceneGraphPrim.CreateDisplayNameAttr() 46 assert displayNameAttr, "Failed creating display attribute" 47 assert displayNameAttr.GetTypeName() == 'token', \ 48 "Type of position attribute should be 'token', not %s" % \ 49 displayNameAttr.GetTypeName() 50 displayNameAttr.Set('foo') 51 52 # Test Display Color 53 displayGroupAttr = sceneGraphPrim.GetDisplayGroupAttr() 54 assert displayGroupAttr 55 displayGroupAttr = sceneGraphPrim.CreateDisplayGroupAttr() 56 assert displayGroupAttr, "Failed creating display color attribute" 57 assert displayGroupAttr.GetTypeName() == 'token', \ 58 "Type of position attribute should be 'token', not %s" % \ 59 displayGroupAttr.GetTypeName() 60 displayGroupAttr.Set("bar") 61 62 stage.GetRootLayer().Save() 63 64if __name__ == "__main__": 65 unittest.main() 66