def main(): parser = argparse.ArgumentParser(prog=COMMAND, description=DESCRIPTION) parser.add_argument(dest=u"command", default=None, metavar=u"COMMAND", choices=SUBCOMMANDS, help=u"sub command.") parser.add_argument(u"--dry", dest=u"dry", action=u"store_true", default=False, help=u"dry run.") parser.add_argument(u"-D", u"--debug", dest=u"debug", action=u"store_true", default=False, help=u"debug mode.") args = parser.parse_args(lx.args()) _init_logger(u"stu", develop=args.debug) _init_logger(u"apps", develop=args.debug) logger.debug(args) if args.command == u"replace": replace_command(args.dry) elif args.command == u"openhelp": open_help() elif args.command == u"setdefault": set_default()
def main(): # todo fix me # END MAIN PROGRAM ----------------------------------------------- if __name__ == '__main__': try: # Argument parsing is available through the # lx.arg and lx.args methods. lx.arg returns # the raw argument string that was passed into # the script. lx.args parses the argument string # and returns an array of arguments for easier # processing. argsAsString = lx.arg() argsAsTuple = lx.args() main() except: lx.out(traceback.format_exc())
#python # Kindly created and shared by MonkeyBrotherJr on the Lux forums import lx from lx import eval, eval1, evalN, out, Monitor, args arguments = args() eval("tool.viewType uv") eval("tool.set xfrm.transform on") eval("tool.reset") eval("tool.setAttr xfrm.transform U %s" %arguments[0]) eval("tool.setAttr xfrm.transform V %s" %arguments[1]) eval("tool.doApply") eval("tool.set xfrm.transform off")
m.step() output = ["{0} Instances de-instanced.\n\n".format(i)] for instance_type in set(instance_types): out = "{0} {1}s".format(instance_types.count(instance_type), instance_type) output.append(out) message = "\n".join(output) modo.dialogs.alert("De-instance complete", message, dtype='info') # END MAIN PROGRAM ----------------------------------------------- if __name__ == '__main__': # Argument parsing is available through the # lx.arg and lx.args methods. lx.arg returns # the raw argument string that was passed into # the script. lx.args parses the argument string # and returns an array of arguments for easier # processing. argsAsString = lx.arg() argsAsTuple = lx.args() try: main() except: print traceback.format_exc()
#python # File: mc_lxRename_removeX.py # Author: Matt Cox # Description: Bulk renames a selection of items, removing X amount of characters from the start or the end. Based upon the user variable removeX. import lx import re lxRRemoveXString = lx.eval( "user.value mcRename.removeX ?" ) lxRRemoveXArgs = lx.args() lxRRemoveXArg = lxRRemoveXArgs[0] if lxRRemoveXString < 0: lxRRemoveXString = 0 try: lxRSelectedItems = lx.evalN('query sceneservice selection ? all') for x in lxRSelectedItems: lx.eval('select.Item %s' %str(x)) lxRMeshNameM = lx.eval('query sceneservice item.name ? %s' %str(x)) try: if lxRRemoveXArg == "start": lxRNewNameM = lxRMeshNameM[lxRRemoveXString:] else: lxRNewNameM = lxRMeshNameM[:-lxRRemoveXString] lx.eval('item.name "%s"'%(lxRNewNameM)) except: lx.eval('dialog.setup error') lx.eval('dialog.title {Error}') lx.eval('dialog.msg {Unable to rename items.}')
#python import lx from pyModo import pyModo as pym # set frame range and intialize counters f=lx.args() firstFrame = int(f[0]) lastFrame = int(f[1]) counter = firstFrame counterRot = firstFrame * 3 #get the name of the character sceneName = lx.eval("query sceneservice scene.name ? current") scenePart = sceneName.split ('_') character = scenePart[0] # get all items n = lx.eval1("query sceneservice item.N ?") # get all items allItems = pym.Scene_Get_Item_IDs_All() # enable bke pass for i in allItems: name = pym.Item_Name_Get(i) if name == 'bke': pym.Item_Select(i) lx.eval('layer.active %s type:pass' % i)
#!/usr/bin/env python import lx # You can add any tools you want to cycle through to this list. # The first tool in the list will be the default if none of them are active. # Or the last in the list if scrolling backwards. tools = (('TransformMove', 'TransformScale', 'TransformRotate')) num_tools = len (tools) backwards = False args = lx.args () if len (args) > 0: backwards = (args[0].lower() == 'prev') active_tool = -1 for tool_idx in xrange (num_tools): if lx.test ('tool.set %s on' % tools[tool_idx]): active_tool = tool_idx break next_tool = active_tool if backwards: next_tool = (active_tool - 1) % num_tools else: next_tool = (active_tool + 1) % num_tools try: lx.eval ('!!tool.set %s on' % tools[next_tool])
#python import lx class SnapZero(): def __init__(self, axe, local=False): self.axe = axe self.local = bool(int(local)) def snap(self): if self.local: lx.eval('tool.set TransformScale on') lx.eval('tool.attr xfrm.transform S{} 0.0'.format(self.axe)) lx.eval('tool.doApply') lx.eval('tool.set TransformScale off 0') else: lx.eval('vert.set {} 0.0 false false'.format(self.axe)) if __name__ == '__main__': axe = lx.args() snap = SnapZero(axe[0], axe[1]) snap.snap()
def readArguments(self): logMessage("readArguments()") self.FrStart = str(lx.args()[0]) self.FrEnd = str(lx.args()[1]) self.FrStep = str(lx.args()[2]) self.imgNameAdd = "" self.layer = "" self.imgName = "" self.imgExt = "" self.padding = "FFFF" self.passgroup = "" self.cameraname = "" self.isLayeredExr = False self.regX1 = -1 self.regX2 = -1 self.regY1 = -1 self.regY2 = -1 self.KSOMode = False self.KSOPort = 6667 self.PyModPath = "" self.width = -1 self.height = -1 self.verboseLevel = 0 self.imgNameNoVar = "" for a in range(0, len(lx.args())): if lx.args()[a].lower() == "-layeredexr": self.isLayeredExr = True if (lx.args()[a].lower() == "-layer") and (a + 1 < len(lx.args())): self.layer = lx.args()[a + 1] if (lx.args()[a].lower() == "-passgroup") and (a + 1 < len(lx.args())): self.passgroup = lx.args()[a + 1] if (lx.args()[a].lower() == "-imgname") and (a + 1 < len(lx.args())): self.imgName = lx.args()[a + 1] if (lx.args()[a].lower() == ("-imgNameNoVar").lower()) and (a + 1 < len(lx.args())): self.imgNameNoVar = lx.args()[a + 1] if (lx.args()[a].lower() == "-imgext") and (a + 1 < len(lx.args())): self.imgExt = lx.args()[a + 1] if (lx.args()[a].lower() == "-camera") and (a + 1 < len(lx.args())): self.cameraname = lx.args()[a + 1] if (lx.args()[a].lower() == "-imgnameadd") and (a + 1 < len(lx.args())): self.imgNameAdd = lx.args()[a + 1] if (lx.args()[a].lower() == "-padding") and (a + 1 < len(lx.args())): self.padding = lx.args()[a + 1] if (lx.args()[a].lower() == "-verbose") and (a + 1 < len(lx.args())): self.verboseLevel = lx.args()[a + 1] if (lx.args()[a].lower() == "-region") and (a + 4 < len(lx.args())): self.regX1 = lx.args()[a + 1] self.regX2 = lx.args()[a + 2] self.regY1 = lx.args()[a + 3] self.regY2 = lx.args()[a + 4] if (lx.args()[a].lower() == "-width") and (a + 1 < len(lx.args())): self.width = lx.args()[a + 1] if (lx.args()[a].lower() == "-height") and (a + 1 < len(lx.args())): self.height = lx.args()[a + 1] if (lx.args()[a].lower() == "-padding") and (a + 1 < len(lx.args())): self.padding = lx.args()[a + 1] if lx.args()[a].lower() == "-ksomode": self.KSOMode = True if (lx.args()[a].lower() == "-ksoport") and (a + 1 < len(lx.args())): self.KSOPort = lx.args()[a + 1] if (lx.args()[a].lower() == "-pymodpath") and (a + 1 < len(lx.args())): self.PyModPath = lx.args()[a + 1]
#python # File: mc_lxRename_case.py # Author: Matt Cox # Description: Bulk renames a selection of items, converting the entire name to another case. import lx import re lxRArgs = lx.args() lxRArg_case = lxRArgs[0].lower() if (lxRArg_case != "upper") and (lxRArg_case != "lower"): lxRArg_case = "upper" try: lxRSelectedItems = lx.evalN('query sceneservice selection ? all') lxRCurrentCount = 1 for x in lxRSelectedItems: lx.eval('select.Item %s' % str(x)) lxRMeshNameM = lx.eval('query sceneservice item.name ? %s' % str(x)) try: if lxRArg_case == "upper": lxRNewNameM = lxRMeshNameM.upper() else: lxRNewNameM = lxRMeshNameM.lower() lx.eval('item.name "%s"' % (lxRNewNameM)) lxRCurrentCount = lxRCurrentCount + 1 except:
# # To convert selected locators on scene to a new shape # # www.etereaestudios.com import lx # Enable Locators visibility, just in case it was disable lx.eval("view3d.showLocators true") try: scene_svc = lx.Service("sceneservice") # Defining arguments myform = lx.args()[0] # box, plane, circle, etc myshap = lx.args()[1] # shape default or custom # get selected layers selected_layers = lx.evalN("query sceneservice selection ? all") # drop selection so that we can work on one item at a time lx.eval("select.drop item") # create empty list to put locators in locators = [] for item in selected_layers: # select layer scene_svc.select("item",str(item))
#python import lx, modo event = lx.args()[0] # if event == ('beforeCreate'): # lx.eval("scene.closeAll") if len(lx.args()) > 1: group = lx.args()[1] if event in ('onDrop', 'onDo'): slug = modo.Scene().item(group).name.split("__")[0] modo.scene.current().removeItems(group) scenesFolder = lx.eval( "query platformservice alias ? {kit_mecco_kelvin:Scenes}") lx.eval("pref.value application.defaultScene {%s/%s.lxo}" % (scenesFolder, slug)) lx.eval("scene.new") lx.eval("pref.value application.defaultScene {}")
# add_smart_locator.py # Version 2.5 - etereaestudios.com # Authors: OOZZEE aka Keith Sheppard, MonkeybrotherJr and Cristobal Vila # With the great help of Ylaz # # To add new shaped-custom locators to scene depending on what is selected: # — If ITEM(S) are selected, add a new Locator with same Position and Rotation # — If COMPONENTS are selected, add a new Locator in the center of bounding box # — If NOTHING is selected, add a new Locator at Workplane Origin # Example: @add_new_locator.py circle 0.1 z 1 custom import lx # Defining arguments myform = lx.args()[0] # box, plane, circle, etc mysize = float(lx.args()[1]) # size in meters myaxis = lx.args()[2] # axis xyz myalig = lx.args()[3] # align true or false myshap = lx.args()[4] # shape default or custom # Enable Locators visibility, just in case it was disable lx.eval("view3d.showLocators true") try: # Function that puts locator at workplane zero def locator_at_zero(): lx.out("Nothing selected, creating locator at workplane 0,0,0")
a list with no duplicates :param udims: udims :type udims: str''' data = [] for i in udims.split(','): i = i.strip() if '-' in i: min = i.split('-')[0].strip() max = i.split('-')[1].strip() for x in xrange(int(min), int(max) + 1): data.append(x) else: data.append(int(i)) return sorted(list(set(data))) args = lx.args()[0] # User values bake_udims = lx.eval('user.value MARI_TOOLS_bake_udims ?') if args == 'unpack': selected = scene.selected for imageFolder in selected: unpack_imageFolder(imageFolder) elif args == 'bake': print 'MARITOOLS: ', udim_list(bake_udims)
# Version 1.2 - By Cristobal Vila, 2013 - With the help of other members from Luxology Forums :-) # Special thanks to MonkeybrotherJR # # To give a custom size to all channels in a selected Locators, # no matter the kind of Locators and if there are some channels greyed # # www.etereaestudios.com import lx try: scene_svc = lx.Service("sceneservice") # Define my argument: mysize = float(lx.args()[0]) # get selected layers selected_layers = lx.evalN("query sceneservice selection ? all") # drop selection so that we can work on one item at a time lx.eval("select.drop item") # create empty list to put locators in locators = [] for item in selected_layers: # select layer scene_svc.select("item",str(item)) lx.eval('select.item {%s} set' % item)
##---------------------------------------------## ###---------------METHODS END --------------------------### ## MODO SERVICES ## layerservice = lx.Service("layerservice") sceneservice = lx.Service("sceneservice") ## TAG TYPE VALUES ## MTK_TYPE = '$MTK' # Type description: ENTITY_mask, UDIM_mask, imageMap ENTITY = '$ENT' UDIM = '$UDI' CHANNEL = '$CHA' ## VARIABLES ## args = lx.args()[0] # Arguments. Only the first argument is passed. maskColorTag = "none" # Color tag for UDIM mask groups ## Store Layer index and vmaps ## layerservice.select('layer.id','main') layer_index = layerservice.query('layer.index') #select the current mesh layer layerservice.select('vmap.N', 'all') vmap_num = layerservice.query('vmap.N') # Number of vertex maps of selected mesh ################################# # USER VALUES # ################################# gamma_correction = lx.eval("user.value MARI_TOOLS_gamma ?") # Gamma correction on/off gamma_value = lx.eval("user.value MARI_TOOLS_gammavalue ?") # Gamma value from UI fileNameUser = lx.eval("user.value MARI_TOOLS_filename ?") # Filename structure
#python import lx, modo event = lx.args()[0] # if event == ('beforeCreate'): # lx.eval("scene.closeAll") if len(lx.args()) > 1: group = lx.args()[1] if event in ('onDrop', 'onDo'): slug = modo.Scene().item(group).name.split("__")[0] modo.scene.current().removeItems(group) scenesFolder = lx.eval("query platformservice alias ? {kit_mecco_kelvin:Scenes}") lx.eval("pref.value application.defaultScene {%s/%s.lxo}" % (scenesFolder,slug)) lx.eval("scene.new") lx.eval("pref.value application.defaultScene {}")
#python # File: mc_lxRename_case.py # Author: Matt Cox # Description: Bulk renames a selection of items, converting the entire name to another case. import lx import re lxRArgs = lx.args() lxRArg_case = lxRArgs[0].lower() if (lxRArg_case != "upper") and (lxRArg_case != "lower"): lxRArg_case = "upper" try: lxRSelectedItems = lx.evalN('query sceneservice selection ? all') lxRCurrentCount = 1 for x in lxRSelectedItems: lx.eval('select.Item %s' %str(x)) lxRMeshNameM = lx.eval('query sceneservice item.name ? %s' %str(x)) try: if lxRArg_case == "upper": lxRNewNameM = lxRMeshNameM.upper() else: lxRNewNameM = lxRMeshNameM.lower() lx.eval('item.name "%s"'%(lxRNewNameM)) lxRCurrentCount = lxRCurrentCount + 1 except:
# # Royal Render Render script for Modo # Author: Royal Render, Holger Schoenberger, Binary Alchemy # Version v 6.01.40 # Copyright (c) 2009-2011 Holger Schoenberger - Binary Alchemy # ###################################################################### import lx import os import sys import random lx.eval("log.toConsole true") if (not len(lx.args())>=3): print (" RR - ") print (" RR - ") print (" RR - Usage: \@modo_render_40.py first last step" ) print (" RR - Frame arguments required" ) print (" RR - ") print (" RR - ") lx.eval("app.quit") sys.exit(0) sceneName = lx.eval('query sceneservice scene.file ? current') if ((sceneName==None) or (len(sceneName)==0)): print (" ") print (" RR - ERROR: Unable to load scene file.") print (" RR - The reason could be a missing external file like a texture, reference model" ) print (" RR - Hint: If you use paths relative to the scene, disable 'local scene copy' at the rrSubmitter" )
except LookupError as e: print 'No Backdrop found for camera: %s' % camera.id else: backdrop.itemGraph('shadeLoc').connectInput(camera) def set_renderCam(camera, renderItem): """ Set render camera and adjust frame range if camera has a clip attached """ lx.eval('render.camera %s' % camera.id) set_range_from_clip(renderItem) # Commands arg = lx.args()[0] if arg == 'setRange': set_range_from_clip(renderItem) if arg == 'disableBackdrop': selected_cameras = scene.selectedByType(modo.c.CAMERA_TYPE) # disable the backdrop # if no camera is selected the current render cam is used if len(selected_cameras) == 0: disable_backdrop(scene.renderCamera) else: for camera in selected_cameras: disable_backdrop(camera) if arg == 'enableBackdrop':
backdrop = modo.Item(camera.getTags()['LBBD']) except LookupError as e: print 'No Backdrop found for camera: %s' % camera.id else: backdrop.itemGraph('shadeLoc').connectInput(camera) def set_renderCam(camera, renderItem): """ Set render camera and adjust frame range if camera has a clip attached """ lx.eval('render.camera %s' % camera.id) set_range_from_clip(renderItem) # Commands arg = lx.args()[0] if arg == 'setRange': set_range_from_clip(renderItem) if arg == 'disableBackdrop': selected_cameras = scene.selectedByType(modo.c.CAMERA_TYPE) # disable the backdrop # if no camera is selected the current render cam is used if len(selected_cameras) == 0: disable_backdrop(scene.renderCamera) else: for camera in selected_cameras: disable_backdrop(camera) if arg == 'enableBackdrop':
scene.deselect() # Create temp user value and ask user # for light name if not name: lx.eval('user.defNew LightBox.areaLight type:string life:momentary') lx.eval('user.value LightBox.areaLight value:AreaLight') lx.eval('user.def LightBox.areaLight dialogname "Light Name"') lx.eval('user.value LightBox.areaLight') name = lx.eval('user.value LightBox.areaLight ?') # renaming of locator and its light if name: # create light from preset lx.eval('preset.do %s' % preset_path) Loc = scene.selectedByType(modo.c.LOCATOR_TYPE)[0] Light = Loc.children()[0] Loc.name = '%s_LOC' % name Light.name = '%s_LIGHT' % name # Absolute file path of Lightbox FileService = lx.service.File() kit_path = FileService.ToLocalAlias('kit_LightBox:') args = lx.args()[0] if args == 'areaLight': from os import path preset_path = path.join(kit_path, 'assemblies/areaLightRig.lxp') create_from_preset(scene, preset_path)
# Version 1.2 - By Cristobal Vila, 2013 - With the help of other members from Luxology Forums :-) # Special thanks to MonkeybrotherJR # # To give a custom size to all channels in a selected Locators, # no matter the kind of Locators and if there are some channels greyed # # www.etereaestudios.com import lx try: scene_svc = lx.Service("sceneservice") # Define my argument: mysize = float(lx.args()[0]) # get selected layers selected_layers = lx.evalN("query sceneservice selection ? all") # drop selection so that we can work on one item at a time lx.eval("select.drop item") # create empty list to put locators in locators = [] for item in selected_layers: # select layer scene_svc.select("item", str(item)) lx.eval('select.item {%s} set' % item)
#!/usr/bin/env python import lx # You can add any tools you want to cycle through to this list. # The first tool in the list will be the default if none of them are active. # Or the last in the list if scrolling backwards. tools = (('TransformMove', 'TransformScale', 'TransformRotate')) num_tools = len(tools) backwards = False args = lx.args() if len(args) > 0: backwards = (args[0].lower() == 'prev') active_tool = -1 for tool_idx in xrange(num_tools): if lx.test('tool.set %s on' % tools[tool_idx]): active_tool = tool_idx break next_tool = active_tool if backwards: next_tool = (active_tool - 1) % num_tools else: next_tool = (active_tool + 1) % num_tools try: lx.eval('!!tool.set %s on' % tools[next_tool])
"N": InParam(20, 1, 512, False), # Number of turns(approx.) "R": InParam(0.1, 0.01, 32, False), # Radius of basic coil(m) (approx.) "RN": InParam(8, 6, 16, False), # RoundNess(vertex num per 1 coil.) "SP": InParam(0.0, 0.0, 8, False), # SPreading rate of radius(currently linier only.) "DR": InParam(0, 0, 1, True), # DiRection invert (1 | 0) "RC": InParam(0, 0, 1, True), # Render Curve or not(1 | 0) } MESH_NAME_SPRING = "New Spring" MESH_NAME_SPIRAL = "New Spiral" # -------------------------------------------------------------- # assemble arguments # -------------------------------------------------------------- arguments = lx.args() for arg in arguments: argParts = arg.split("=", 2) prefix = argParts[0].upper() inValue = argParts[1] if (prefix in params): params[prefix].set(inValue) LENGTH = float(params["L"].value) COIL_NUM = int(params["N"].value) RADIUS = float(params["R"].value) VERT_PER_COIL = int(params["RN"].value) RADIUS_SPREAD = float(params["SP"].value) DIRECTION_INVERT = int(params["DR"].value) RENDER_CURVE = int(params["RC"].value)
newpath = os.path.splitext(scene.filename)[0] + "camera_bake.fbx" print "Exporting to {0}".format(newpath) lx.eval("scene.saveAs {0} fbx true".format(newpath)) # Cleanup scene.removeItems(bake_cam) lx.eval("user.value sceneio.fbx.save.exportType {0}".format(export_value)) modo.dialogs.alert(title="Export Finished", message="The camera has been exported to {0}".format(newpath)) # END MAIN PROGRAM ----------------------------------------------- if __name__ == '__main__': try: # Argument parsing is available through the # lx.arg and lx.args methods. lx.arg returns # the raw argument string that was passed into # the script. lx.args parses the argument string # and returns an array of arguments for easier # processing. argsAsString = lx.arg() argsAsTuple = lx.args() main() except: lx.out(traceback.format_exc())
# Version 1.2 - By Cristobal Vila, 2013 - With the help of other members from Luxology Forums :-) # Special thanks to MonkeybrotherJR # # To scale all channels in a selected Locators, # no matter the kind of Locators and if there are some channels greyed # # www.etereaestudios.com import lx try: scene_svc = lx.Service("sceneservice") # Define my argument: myargument = lx.args()[0] # get selected layers selected_layers = lx.evalN("query sceneservice selection ? all") # drop selection so that we can work on one item at a time lx.eval("select.drop item") # create empty list to put locators in locators = [] for item in selected_layers: # select layer scene_svc.select("item",str(item)) lx.eval('select.item {%s} set' % item)