def SingleInstanceApiCommander(operation, modifier, modifierValue): try: remote = mmRemote() remote.connect() cmd = mmapi.StoredCommands() #some commands don't follow the scheme if operation is "open": cmd.AppendSceneCommand_AppendMeshFile(modifier); elif operation is "invert" or operation is "expandToConnected" : cmd.AppendSelectUtilityCommand(operation); elif operation is "selectAll": cmd.AppendSelectCommand_All() elif operation is "complete": cmd.AppendCompleteToolCommand("accept") elif operation is "cancel": cmd.AppendCompleteToolCommand("cancel") elif operation is "selectNewPart": objects = mm.list_objects(remote) for object in objects: name = mm.get_object_name(remote,object) if "(part)" in name: selectList = [] selectList.append(object) mm.select_objects(remote, selectList) return True return False elif operation is "repairAll": cmd.AppendToolUtilityCommand("repairAll") else: cmd.AppendBeginToolCommand(operation) if modifierValue is not None: cmd.AppendToolParameterCommand(modifier,modifierValue) remote.runCommand(cmd); remote.shutdown(); return True except ex: #to do log this return False finally: remote.shutdown();
#cmd2 = mmapi.StoredCommands() #cmd2.ViewControl_SetTriangleColorMode(0) #cmd2.ViewControl_SetSurfaceNormalMode(0) #remote.runCommand(cmd2) #[RMS] this is how to change object visibility #cmd2 = mmapi.StoredCommands() #obj_list = mm.list_objects(remote) #cmd2.AppendSceneCommand_SetHidden(obj_list[0]) #cmd2.AppendSceneCommand_SetVisible(obj_list[0]) #cmd2.AppendSceneCommand_ShowAll(); #remote.runCommand(cmd2) #[RMS] this is how to save a screenshot (will write to python\examples\screenshot.png) #cmd2 = mmapi.StoredCommands() #cmd2.AppendSceneCommand_SaveScreenShot(os.path.join( os.getcwd(), "screenshot.png" )) #remote.runCommand(cmd2) #[RMS] this is how to create a pivot and link it to an object in the scene objects = mm.list_objects(remote) f = mm.mmFrame() f.origin = (1,0,0) pivot_id = mm.create_pivot(remote, f) link_ok = mm.link_pivot(remote, pivot_id, objects[0]) #done! remote.shutdown();
#remote.runCommand(cmd2) #[RMS] this is how to change the normal and color modes #cmd2 = mmapi.StoredCommands() #cmd2.ViewControl_SetTriangleColorMode(0) #cmd2.ViewControl_SetSurfaceNormalMode(0) #remote.runCommand(cmd2) #[RMS] this is how to change object visibility #cmd2 = mmapi.StoredCommands() #obj_list = mm.list_objects(remote) #cmd2.AppendSceneCommand_SetHidden(obj_list[0]) #cmd2.AppendSceneCommand_SetVisible(obj_list[0]) #cmd2.AppendSceneCommand_ShowAll(); #remote.runCommand(cmd2) #[RMS] this is how to save a screenshot (will write to python\examples\screenshot.png) #cmd2 = mmapi.StoredCommands() #cmd2.AppendSceneCommand_SaveScreenShot(os.path.join( os.getcwd(), "screenshot.png" )) #remote.runCommand(cmd2) #[RMS] this is how to create a pivot and link it to an object in the scene objects = mm.list_objects(remote) f = mm.mmFrame() f.origin = (1, 0, 0) pivot_id = mm.create_pivot(remote, f) link_ok = mm.link_pivot(remote, pivot_id, objects[0]) #done! remote.shutdown()
#cmd2 = mmapi.StoredCommands() #cmd2.AppendBeginToolCommand("select") #cmd2.ViewControl_TakeFocus(); #remote.runCommand(cmd2) #mm.begin_tool(remote, "volumeBrush") #mm.tool_utility_command(remote, "setPrimary", "drag") #mm.tool_utility_command(remote, "setSecondary", "bubbleSmooth") #mm.select_printer(remote, "replicator 2") #mm.begin_tool(remote, "remesh") #mm.set_toolparam(remote, "goalType", 2) # mmapi.mat3f param read/write #mm.begin_tool(remote, "transform"); #mat1 = to_mat3f( (0.36,0.48,-0.8, -0.8,0.6,0, 0.48,0.64,0.6) ) #mm.set_toolparam(remote, "rotation", mat1) #mat2 = mm.get_toolparam_mat3f(remote, "rotation") obj_list = mm.list_objects(remote) uuid = mm.get_object_uuid(remote, obj_list[0]) (found, id) = mm.find_object_by_uuid(remote, uuid) #done! remote.shutdown();