def demo_animation(): '''Show how to do animation''' rt.resetMaxFile(rt.Name('noPrompt')) sphere = rt.sphere() set_animation_ranges() animate_transform(sphere) playback_animation()
def setUpClass(self): rt.resetMaxFile(rt.Name("noprompt")) self.rootA = rt.Box() self.boxA = rt.Box() self.boxA.parent = self.rootA self.gizmoA = rt.AsoboBoxGizmo() self.gizmoA.parent = self.rootA self.rootB = rt.Box() self.boxb = rt.Box() self.boxb.parent = self.rootB self.gizmoB = rt.AsoboBoxGizmo() self.gizmoB.parent = self.rootB self.rootLOD0 = rt.Box() self.rootLOD0.name = "test_LOD0" self.rootLOD1 = rt.Box() self.rootLOD1.name = "test_LOD1" self.rootLOD2 = rt.Box() self.rootLOD2.name = "test_LOD2" self.rootLOD3 = rt.Box() self.rootLOD3.name = "test_LOD3" self.exportPath = os.path.join( rt.pathConfig.getCurrentProjectFolder(), "Tools\\3DSMAX\\FlightSimPackage\\src\\samples\\Export\\") multiExporter.run(prompt=False, skip_conversion=True)
def demo_simple_dialog(): """ Entry point for QDialog demo making use of PySide2 and pymxs """ # reset 3ds Max rt.resetMaxFile(rt.Name('noPrompt')) dialog = PyMaxDialog(GetQMaxMainWindow()) dialog.show()
def setUpClass(self): rt.resetMaxFile(rt.Name("noprompt")) projectPath = rt.pathConfig.getCurrentProjectFolder() self.path = os.path.join( projectPath, "Tools\\3DSMAX\\FlightSimPackage\\src\\samples\\Master_Bear_Adult_FOR_TESTING.max" ) perforce.P4edit(self.path) rt.loadMaxFile(self.path, quiet=True) multiExporter.run(prompt=False, skip_conversion=True)
def main(): """Demonstrate cloning""" rt.resetMaxFile(rt.Name('noPrompt')) obj = rt.sphere(radius=3) create_instance_clones(obj, 10, rt.Point3(5, 0, 0)) rt.MaxOps.CloneNodes(obj, cloneType=INST, offset=rt.Point3(0, 25, 0), expandHierarchy=True)
def create_items(): """Create all the items in the sample.""" rt.resetMaxFile(rt.Name('noPrompt')) y_line = create_materials(0.0) + 40.0 y_line = create_modifiers(y_line) + 40.0 y_line = create_helpers(y_line) + 40.0 y_line = create_shapes(y_line) + 40.0 y_line = create_objects(y_line) + 40.0 y_line = create_lights(y_line) + 40.0 y_line = create_cameras(y_line) + 40.0
def setUpClass(self): rt.resetMaxFile(rt.Name("noprompt")) tp = rt.Box() tp.name = "topParent" fc = rt.Box() fc.name = "firstChild" fc.parent = tp for i in range(10): fsc = rt.Box() fsc.name = "childNum{0}".format(i) fsc.parent = fc print("setup Hierarchy")
def main(): """Create a mesh, color it, and output information about its maps.""" # reset the scene rt.resetMaxFile(rt.Name('noPrompt')) # create a mesh mesh = make_pyramid_mesh() print("Updating the color per vertex channel") rt.setNumCPVVerts(mesh, 2) rt.buildVCFaces(mesh) rt.setVertColor(mesh, 1, rt.Color(255, 0, 0)) rt.setVertColor(mesh, 2, rt.Color(0, 0, 255)) rt.setVCFace(mesh, 1, rt.Point3(1, 1, 2)) rt.setVCFace(mesh, 2, rt.Point3(1, 2, 2)) rt.setVCFace(mesh, 3, rt.Point3(2, 2, 2)) rt.setVCFace(mesh, 4, rt.Point3(1, 1, 1)) rt.setCVertMode(mesh, True) rt.update(mesh) output_channels(mesh)
def load_and_verify(): """Load and verify scene_with_app_chunk.max""" rt.resetMaxFile(rt.Name('noPrompt')) rt.loadMaxFile("scene_with_app_chunk.max") print("scene with AppChunk is loaded.") # Find the "MyTeapot123" node teapot_node = rt.getNodeByName("MyTeapot123") if teapot_node is None: print("Error: Incorrect saved scene.") else: print(rt.getAppData(teapot_node, 678)) obj = teapot_node.baseObject print(rt.getAppData(obj, 1234)) print(rt.getAppData(obj, 2345)) rt.clearAllAppData(obj) print("No 9432 app data {}".format(rt.getAppData(obj, 9432) is None)) print("No 7890 app data {}".format(rt.getAppData(teapot_node, 9432) is None)) print(rt.getAppData(teapot_node.Material, 4567))
def setUpClass(self): rt.resetMaxFile(rt.Name("noprompt")) self.A = rt.Box() self.A.name = "x0_levelofdetailzero" self.B = rt.Box() self.B.name = "x12_testingSoul" self.C = rt.Box() self.C.name = "testingSoul_LOD1" self.D = rt.Box() self.D.name = "testing_LOD23_Soul_LOD234" self.GA = rt.BoxGizmo() self.GA.name = "Collider_A" self.GA.parent = self.D self.GB = rt.BoxGizmo() self.GB.name = "Collider_B" self.GB.parent = self.D self.GC = rt.BoxGizmo() self.GC.name = "Collider_C" self.GC.parent = self.GB self.E = rt.Box() self.E.parent = self.GC self.F = rt.Box() self.F.parent = self.GB self.G = rt.Box() self.G.parent = self.GC self.H = rt.Box() self.H.parent = self.GA print("setup LOD")
def sample(): """Create all existing materials and showcase them.""" def try_create(mat): """Try to create a given material. If not creatable return None.""" try: return mat() except RuntimeError: return None rt.resetMaxFile(rt.Name('noPrompt')) # maximize the view (select a view with only the one viewport) rt.viewport.setLayout(rt.name("layout_1")) # show the material editor in basic mode rt.MatEditor.mode = rt.Name("basic") rt.MatEditor.open() # create a plane for the floor create_floor() # instantiate all materials that can be instantiated materials = filter(lambda x: x is not None, map(try_create, rt.material.classes)) # showcase all materials showcase_materials(list(materials))
def create_scene(): """Create and save scene_with_app_chunk.max""" rt.resetMaxFile(rt.Name('noPrompt')) # Create a teapot, a scene node and a material instance, they are all # objects of Animatable node = rt.teapot() teapot = node.baseObject mtl = rt.StandardMaterial() node.Material = mtl node.name = "MyTeapot123" # Now add some user specified strings to these objects rt.setAppdata(teapot, 112, "blah comit") rt.setAppdata(teapot, 1234, "I'm a teapot!") rt.setAppdata(teapot, 2345, u"我是一个茶壶!") rt.setAppdata(node, 5678, "Node of teapot") rt.setAppdata(node, 7890, "This is to be removed") rt.deleteAppdata(node, 7890) rt.setAppdata(mtl, 4567, "Material of teapot") rt.saveMaxFile("scene_with_app_chunk.max") print("scene with AppChunk is saved.")
def _reset_scene(self): """ Reset the current scene without prompting the user. """ rt.resetMaxFile(rt.Name("noprompt"))
# TODO code to import # in maxscript you do: # importfile "c:/temp/test.fbx" #noPrompt using:FBXIMP # and to make sure we're not adding it to the current scene you would do: # resetMaxFile #noprompt # So now for the python equivalents: from pymxs import runtime as rt rt.resetMaxFile(rt.Name("noPrompt")) rt.exportFile("c:/temp/test3.fbx",rt.Name("noPrompt"),using="FBXEXP") # yeah, so you might have guessed the using parameter, but to go from #noprompt to rt.Name("noPrompt") was non-trivial...
def demo_render(): '''Create a demo scene, adjust the perspective and render the scene''' rt.resetMaxFile(rt.Name('noPrompt')) create_spheres() maximize_perspective() render()
def main(): '''Construct a pyramid and then add colors to its faces.''' rt.resetMaxFile(rt.Name('noPrompt')) mesh = make_pyramid_mesh() color_pyramid_mesh(mesh)