def deleteExistingPlans(): if rs.IsLayer("60_PLANS"): #delete all sublayers levelLayers = rs.LayerChildren("60_PLANS") for levelLayer in levelLayers: childLayers = rs.LayerChildren(levelLayer) for childLayer in childLayers: objects = rs.ObjectsByLayer(childLayer) rs.DeleteObjects(objects) rs.DeleteLayer(childLayer) rs.DeleteLayer(levelLayer) else: return
def find_objects_on_layer(name, include_hidden=True, include_children=True): if include_hidden: show_hidden_objects_on_layer(name) to_delete = rs.ObjectsByLayer(name) if include_children: to_visit = deque(rs.LayerChildren(name)) while to_visit: name = to_visit.popleft() if include_hidden: show_hidden_objects_on_layer(name) to_delete += rs.ObjectsByLayer(name) if rs.LayerChildCount(name): to_visit.extend(rs.LayerChildren(name)) return to_delete
def show_only(layer): rs.LayerVisible("Default", True) rs.CurrentLayer("Default") for sub in rs.LayerNames(): if sub == "Default": continue if sub in conf['blocks']: rs.LayerVisible(sub, True) continue rs.LayerVisible(sub, False) for block in conf['blocks']: for blockchild in rs.LayerChildren(block): rs.LayerVisible(blockchild, True) # show parent layers, if nested (two up, max) p_layer = rs.ParentLayer(layer) if p_layer: pp_layer = rs.ParentLayer(p_layer) if pp_layer: rs.LayerVisible(pp_layer, True) rs.LayerVisible(p_layer, True) # show the target layer rs.LayerVisible(layer, True) rs.CurrentLayer(layer) rs.LayerVisible("Default", False)
def exportAllPlansToCAD(): if rs.IsLayer("6_DRAWINGS"): children = rs.LayerChildren("6_DRAWINGS") items = [] for child in children: items.append(rs.LayerName(child, False)) #level = rs.ComboListBox(items) print rs.DocumentPath() pathParts = rs.DocumentPath().split("\\") if pathParts[0] == "P:": defaultPath = pathParts[0] + "\\" + pathParts[ 1] + "\\" + pathParts[2] + "\\" + pathParts[3] folder = rs.BrowseForFolder( folder=defaultPath, message="Select Folder to export plans.", title="Export Plans") else: folder = rs.BrowseForFolder() RhinoFile = rs.DocumentName() rhinoName = RhinoFile.split(".")[0] + "_P_" for item in items: levelNum = item.split("_")[-1] fileName = "\\" + rhinoName + levelNum + ".dwg" savePath = folder + fileName #savePath = rs.SaveFileName("Save", "Autocad (*.dwg)|*.dwg||") if savePath is not None: exportPlanToCAD(item, savePath) else: print "No plans currently cut. Use CutPlans." return
def CreateReferenceLayers(self, parentPrefix, refLayers, norefLayers, colours): # get timestamp ts = time.strftime("%y%m%d_%H-%M") # create parent layer name parentLayername = parentPrefix + ts self.Message = "Referenced: " + str(parentLayername) # check if parent layer exists sc.doc = Rhino.RhinoDoc.ActiveDoc exists = rs.IsLayer(parentLayername) if exists: self.AddRuntimeMessage( self.RuntimeMessageLevel.Remark, "Parent Layer already exists! Returning valid existing layers." ) # get all children layers allchildren = rs.LayerChildren(parentLayername) # check all children layers for validity validchildren = [parentLayername + "::" + vc for vc in refLayers] realchildren = [] for c in allchildren: if c in validchildren: realchildren.append(c) # set sticky to real found child layers st[self.LNKEY] = realchildren # switch back to ghdoc sc.doc = ghdoc # return layer names return realchildren else: # switch to Rhino doc sc.doc = Rhino.RhinoDoc.ActiveDoc # create parent layer parentLayer = rs.AddLayer(parentLayername, Color.Black) # create referenced layers newLayers = [] for i, rl in enumerate(refLayers + norefLayers): lay = rs.AddLayer(rl, colours[i], parent=parentLayername) if rl in refLayers: newLayers.append(lay) # add them to the sticky st[self.LNKEY] = newLayers # switch back to ghdoc scdoc = ghdoc # return layer names/paths return newLayers
def DupAllSubLayers(layer, layerCopy): subs = rs.LayerChildren(layer) if subs: for sub in subs: color = rs.LayerColor(sub) objs = rs.ObjectsByLayer(sub) name = UniqueLayerCopyName(sub, False) addLayer = rs.AddLayer(name, color, parent=layerCopy) CopyObjectsToLayer(objs, addLayer) rs.ExpandLayer(addLayer, rs.IsLayerExpanded(sub)) DupAllSubLayers(sub, addLayer)
def getNotes(): layers = getLayerList.getLayers(includeList, excludeList) layerList = [] for layer in layers: layerList.extend(rs.LayerChildren(layer)) noteObjs = [] print(layers) #noteLayers = [x if re.search('A-ANN0-NOTE', x.split("::")[-1]) else None for x in layers] for layer in layerList: if re.search("A-ANNO-NOTE", layer.split("::")[-1]): noteObjs.extend(rs.ObjectsByLayer(layer)) return (noteObjs)
def main(): rs.EnableRedraw(enable=False) showList = sorted(getLayerList.getLayers(exclude=[".3dm", "Make2D"])) print(showList) showList.append("Select All") boxList = [(x, False) for x in showList] selectedLayer = rs.CheckListBox(boxList, message="Layer To Activate") if selectedLayer == "Select All": layers = sorted(list(set(topList))) elif selectedLayer: layers = [L[0] for L in selectedLayer if L[1] == True] else: return (None) print(layers) if isinstance(layers, str): changeColors(rs.LayerChildren(layers)) else: for layer in layers: changeColors(rs.LayerChildren(layer)) rs.EnableRedraw(enable=True)
def layerChangeEvent(sender, e): toolpaths = rs.LayerChildren("Toolpaths") layerId = "" for toolpath in toolpaths: layerId = rs.LayerId(toolpath) for textDotId in rs.ObjectsByType(8192): toolpathName = rs.TextDotText(textDotId) if rs.GetUserText(textDotId, "LayerId") == layerId: newToolpathName = toolpath.split("::")[1] print "Renaming ", toolpathName, " to ", newToolpathName rs.TextDotText(textDotId, newToolpathName)
def mergeLayers(layA, layB): """ layA is kept, layB is deleted input: (layA, layB) each is a layer, the top parent in a tree to merge with another. returns: None """ rs.EnableRedraw(False) Alayers = rs.LayerChildren(layA) Blayers = rs.LayerChildren(layB) AlayersShort = [] BlayersShort = [] for Alayer in Alayers: AlayersShort.append(rs.LayerName(Alayer, False)) for Blayer in Blayers: BlayersShort.append(rs.LayerName(Blayer, False)) uniqueLayers = list(set(BlayersShort) - set(AlayersShort)) #move unique layers for uniqueLayer in uniqueLayers: rs.ParentLayer(uniqueLayer, layA) #get duplicate name layers duppedLayers = list(set(BlayersShort) - set(uniqueLayers)) #move objects to layA twin for duppedLayer in duppedLayers: newParent = layA + "::" + duppedLayer duppedObjs = rs.ObjectsByLayer(layB + "::" + duppedLayer) for duppedObj in duppedObjs: rs.ObjectLayer(duppedObj, newParent) #if it has children, recursively move them if rs.LayerChildCount(layB + "::" + duppedLayer) > 0: mergeLayers(layA + "::" + duppedLayer, layB + "::" + duppedLayer) else: rs.DeleteLayer(layB + "::" + duppedLayer) rs.DeleteLayer(layB) rs.EnableRedraw(True) return None
def get_step_children(layer): # Get steps layers sorted by step number. # That is the num after the period: subsystemnum.stepnum sublayerdict = {} for child in rs.LayerChildren(layer): sublayermatch = re.match(layer + "::([0-9]{1,3})\.([0-9]{1,3})", child) if sublayermatch: step = int(sublayermatch.groups()[1]) if sublayerdict.has_key(step): raise Exception("dublicated step number") sublayerdict[step] = child sublayers = [] for k in sorted(sublayerdict): sublayers.append(sublayerdict[k]) return sublayers
def generate_step_images(structure): global view_aspect w_l = conf['step_img_width'] h_l = int(w_l / view_aspect) rs.CurrentLayer("Default") utils.show_blocks() utils.show_subsystems() rs.ZoomExtents() utils.hide_subsystems() utils.hide_non_subsystems() for iSub in xrange(len(structure)): subsystem = structure.keys()[iSub] v = structure[subsystem] if subsystem in conf['build_apart']: utils.hide_subsystems() rs.LayerVisible(subsystem, True) # utils.hide_non_subsystems() utils.hide_children(subsystem) for iStep in xrange(len(v)): step = v.keys()[iStep] vv = v[step] stepnumeral = str(iSub + 1) + '.' + str(iStep + 1) rs.LayerVisible(step, True) rs.UnselectAllObjects() rs.ObjectsByLayer(step, True) # create images create_image_set(stepnumeral, w_l, h_l) if subsystem in conf['build_apart']: # show all previous subsystems again rs.UnselectAllObjects() rs.InvertSelectedObjects() for sub in structure.keys(): rs.LayerVisible(sub, True) if sub == subsystem: break # images for subsystem installed finnumeral = str(iSub + 1) + '.' + str(len(v) + 1) create_image_set(finnumeral, w_l, h_l) # subsystem overview images for iSub in xrange(len(structure)): subsystem = structure.keys()[iSub] rs.UnselectAllObjects() # select subsystem and its step layers for child in rs.LayerChildren(subsystem): rs.ObjectsByLayer(child, True) finnumeral = str(iSub + 1) + '.0' create_image_set(finnumeral, w_l, h_l)
def unfilletCurve(curve): rs.EnableRedraw(False) curLay = rs.CurrentLayer() childrenLay = rs.LayerChildren(curLay) cutCrvs = [] contours = [] finalLines = [] finalLineSegs = [] tempCrv = curve if tempCrv is not None: cutCrvs.append(tempCrv) for crv in cutCrvs: contours.append(ghcomp.Explode(crv, True)[0]) for contour in contours: for i in range(0, len(contour)): if rs.IsLine(contour[i]): finalLines.append(sc.doc.Objects.AddCurve(contour[i])) finalPts = [] for line in finalLines: rs.ExtendCurveLength(line, 0, 2, 300) for i in range(0, len(finalLines) - 1): tempPt = rs.CurveCurveIntersection(finalLines[i], finalLines[i + 1]) finalPts.append(rs.AddPoint(rs.coerce3dpoint(tempPt[0][1]))) tempPt = rs.CurveCurveIntersection(finalLines[-1], finalLines[0]) finalPts.append(rs.AddPoint(rs.coerce3dpoint(tempPt[0][1]))) for i in range(0, len(finalPts) - 1): finalLineSegs.append(rs.AddLine(finalPts[i], finalPts[i + 1])) finalLineSegs.append(rs.AddLine(finalPts[-1], finalPts[0])) lastCrv = rs.JoinCurves(finalLineSegs, True) sc.doc.Views.Redraw() rs.DeleteObjects(finalPts) rs.DeleteObjects(finalLines) rs.DeleteObject(tempCrv) rs.DeleteObjects(cutCrvs) rs.EnableRedraw(True) rs.SelectObject(lastCrv)
def exportPlanToCAD(chosenLevel, path): #Make sure layer is visible rs.LayerVisible("6_DRAWINGS", True) chosenChildren = rs.LayerChildren("6_DRAWINGS::" + chosenLevel) objects = [] for chosenChild in chosenChildren: tempObjects = rs.ObjectsByLayer(chosenChild) for tempObject in tempObjects: objects.append(tempObject) if objects is None: return scaledObjects = rs.ScaleObjects(objects, [0, 0, 0], [1000, 1000, 0], copy=True) #Format Coordinate # rawCoordinate = rs.GetDocumentData("Project Info", "CAD coordinate") # coordinate = rawCoordinate.split(",") # try: # for i in range(0, 3): # coordinate[i] = float(coordinate[i]) # except: # coordinate = None # if coordinate is None: # print "CAD coordinate has an error" # # else: #move all objects # negVec = rs.VectorReverse(coordinate) # rs.MoveObjects(scaledObjects, coordinate) rs.UnitSystem(2) savePath1 = '"' + path + '"' rs.SelectObjects(scaledObjects) rs.Command('_-Export ' + savePath1 + ' _Enter') rs.DeleteObjects(scaledObjects) rs.UnitSystem(4) print "Exported" return None
"LayerPrintColor": line_data[1] } layerDict[prefix + line_data[0] + "_BOH"] = { "LayerColor": line_data[3], "LayerPrintColor": line_data[3] } else: layerDict[prefix + line_data[0]] = { "LayerColor": line_data[1], "LayerPrintColor": line_data[1] } rs.EnableRedraw(False) layers = cleanLayerList(rs.LayerNames()) # #print(layers) #print(layerDict) for layer in layers: for key, val in layerDict.items(): if layer + "::" + key in rs.LayerChildren(layer): rs.LayerColor(layer + "::" + key, rs.coercecolor(ToList(val["LayerColor"]))) rs.LayerPrintColor(layer + "::" + key, rs.coercecolor(ToList(val["LayerPrintColor"]))) rs.EnableRedraw(True)
return (rs.ObjectLayer(object).split("-")[2]) areasTable = {} hatchnames = set([]) layers = rs.LayerNames() levelLayers = [x for x in layers if re.match("^L\d+|^P\d+|^M\d+", x)] parentLayers = [x for x in levelLayers if "::" not in x] hatchLayers = [x for x in levelLayers if "HATCH" in x] requestType = rs.GetBoolean("Choose output data", ("Output", "Gross_Area", "Unit_Areas"), False) requestType = requestType[0] #Gather all the different hatch types for area analysis for layer in levelLayers: hlayers = [ x.split("::")[1] for x in rs.LayerChildren(layer) if "HATCH" in x ] if len(hlayers) > 0: sublay = ([x.split("-")[2] for x in hlayers]) hatchnames = hatchnames.union(sublay) # sort the level keys L1 = False M1 = False outputLevels = [] inputLevels = list(parentLayers) if "L1" in inputLevels: L1 = True inputLevels.remove("L1") if "M1" in inputLevels: M1 = True
print "Import EXECUTED" rs.EnableRedraw(True) return None if __name__ == "__main__": type = rs.GetInteger("", number=0) if (type == 0): exportTEN_CAD() elif (type == 1): #Import CAD importTEN_CAD() elif (type == 2): #Export All plans if rs.IsLayer("6_DRAWINGS"): children = rs.LayerChildren("6_DRAWINGS") items = [] for child in children: items.append(rs.LayerName(child, False)) level = rs.ComboListBox(items) print rs.DocumentPath() pathParts = rs.DocumentPath().split("\\") if pathParts[0] == "P:": defaultPath = pathParts[0] + "\\" + pathParts[ 1] + "\\" + pathParts[2] + "\\" + pathParts[3] folder = rs.BrowseForFolder( folder=defaultPath, message="Select Folder to export plan.", title="Export Plan") else: folder = rs.BrowseForFolder()
def show_children(layer): rs.LayerVisible(layer, True) for child in rs.LayerChildren(layer): rs.LayerVisible(child, True)
def hide_children(layer): rs.LayerVisible(layer, True) for child in rs.LayerChildren(layer): rs.LayerVisible(child, False)
def show_blocks(): for layer in conf['blocks']: rs.LayerVisible(layer, True) for child in rs.LayerChildren(layer): rs.LayerVisible(child, True)
""" def insertSafetyStop(): print >>f, "\nM5 (stop spindle)" def getLayerOrder(layerName): return rs.LayerOrder(layerName) if __name__=="__main__": filename = (rs.DocumentName().split("."))[0] + ".gcode" print "Generating gcode:", filename f = open(filename, 'w') insertHeader() toolpaths = sorted(rs.LayerChildren("Toolpaths"), key=getLayerOrder) for toolpath in toolpaths: print toolpath generateToolpath(toolpath) insertSafetyStop() f.close()
def importTEN_CAD(): savePath0 = rs.OpenFileName("Open", "Autocad (*.dwg)|*.dwg||") items = [["Units", "Meters", "Millimeters"]] defaults = [False] CADinMilli = rs.GetBoolean("Is that CAD file in meters or mm?", items, defaults)[0] explodeBlockBoo = True if savePath0 is None: return rs.EnableRedraw(False) #setup the layers rs.AddLayer("7_REF") rs.AddLayer("CAD", parent="7_REF") fileNameExt = savePath0.split('\\')[-1] fileName = fileNameExt.split('.')[0] savePath1 = '"' + savePath0 + '"' #create layer name now = datetime.date.today() dateList = [] if len(str(now.month)) > 1: month = str(now.month) else: month = "0" + str(now.month) if len(str(now.day)) > 1: day = str(now.day) else: day = "0" + str(now.day) time = str(now.year) + month + day layerName = time + "_" + fileName + "_01" children = rs.LayerChildren("7_REF::CAD") finalNums = [] for child in children: num = rs.LayerName(child, fullpath=False).split("_")[-1] try: finalNums.append(int(num)) except: finalNums.append(0) finalNums.sort() if rs.IsLayer("7_REF::CAD::" + layerName): num = int(finalNums[-1]) + 1 if len(str(num)) < 2: finalNum = "0" + str(num) else: finalNum = str(num) layerName = time + "_" + fileName + "_" + finalNum par = rs.AddLayer("7_REF") cat = rs.AddLayer("CAD", parent=par) element = rs.AddLayer(layerName, parent=cat) rs.CurrentLayer(element) #get intial list of all layers in the file currentLayers = rs.LayerNames() rs.Command('_-Import ' + savePath1 + ' _Enter') #get new layers added endLayersNames = rs.LayerNames() #newLayers = [item for item in currentLayers if item not in endLayersNames] newLayers = diff(endLayersNames, currentLayers) print newLayers for layer in newLayers: rs.ParentLayer(layer, element) objects = rs.ObjectsByLayer(layer) if rs.IsLayerEmpty(layer): rs.DeleteLayer(layer) else: for obj in objects: if rs.IsDimension(obj): rs.DeleteObject(obj) elif rs.IsHatch(obj): rs.DeleteObject(obj) #Get all the imported geometry allObjects = [] finalLayers = rs.LayerChildren(rs.CurrentLayer()) for finalLayer in finalLayers: allObjects.append(rs.ObjectsByLayer(finalLayer)) finalAllObjects = [item for sublist in allObjects for item in sublist] #Format Coordinate try: rawCoordinate = rs.GetDocumentData("Project Info", "CAD coordinate (X,Y,Z)") except: print "No CAD Coordinate specified in the Project Info" rawCoordinate = (0, 0, 0) coordinate = rawCoordinate.split(",") print "Aa" try: for i in range(0, 3): coordinate[i] = float(coordinate[i]) except: coordinate = None if coordinate is None: print "CAD coordinate has an error" else: #move all objects negVec = rs.VectorReverse(coordinate) rs.MoveObjects(finalAllObjects, negVec) if CADinMilli: rs.ScaleObjects(finalAllObjects, [0, 0, 0], [.001, .001, .001]) importGroup = rs.AddGroup(str(layerName)) rs.AddObjectsToGroup(finalAllObjects, importGroup) rs.ZoomSelected() print "Import EXECUTED" rs.EnableRedraw(True) return None
def translateLayer(layer): """ translates from Rhino Name to CAD Name input: one layer returns: new layer name """ rhinoLayerFilePath = "C:\\Users\\Tim\\Desktop\\temp\\RhinoLayersV2.csv" #Read the CSV file = open(rhinoLayerFilePath, "r") contents = file.readlines() file.close() #Variables CategoryCol = 1 RhinoLayerCol = 2 CADNameCol = 9 CADColorCol = 10 CADLineweightCol = 11 found = False layerShort = rs.LayerName(layer, False) newLayerName = "" #Check the CSV for row in contents: rowParts = row.split(",") if row.split(",")[RhinoLayerCol] == str( layerShort): #if layer name exists in CSV CADName = row.split(",")[CADNameCol] CADColor = translateColor(layer, row.split(",")[CADColorCol]) CADLineweight = row.split(",")[CADLineweightCol] #if Rhino name found but no CAD name associated with it if not CADName: CADName = "A-RHINO-" + layerShort newLayerName = CADName if len(CADLineweight) < 2: CADLineweight = 0 #Check if layer already exists. parent = rs.ParentLayer(layer) existLayers = rs.LayerChildren(parent) isExisting = False for existLayer in existLayers: #if new name already exists as a layer if rs.LayerName(existLayer, False) == CADName: layersObjs = rs.ObjectsByLayer(layer) for layersObj in layersObjs: rs.ObjectLayer(layersObj, existLayer) rs.DeleteLayer(layer) newLayerName = rs.LayerName(existLayer, False) print "Layer {} merged with existing layer {}.".format( layerShort, rs.LayerName(layer, False)) isExisting = True break #if layer does not already exist if isExisting == False: rs.LayerColor(layer, CADColor) rs.LayerPrintWidth(layer, float(CADLineweight)) newLayerName = CADName rs.RenameLayer(layer, CADName) print "Layer {} changed to layer {}.".format( layerShort, CADName) found = True break if not found: layerShort = rs.LayerName(layer, False) CADName = "A-RHINO-" + layerShort newLayerName = CADName rs.RenameLayer(layer, CADName) print "Layer {} has no matching CAD layer.".format(layerShort) return newLayerName return newLayerName
def importCAD(filePath, scaleDWG = False): explodeBlockBoo = True #setup the layers importLayerNumber = 6000 importLayerObj = layers.AddLayerByNumber(importLayerNumber, False) importLayerName = layers.GetLayerNameByNumber(importLayerNumber) #Shorten cad file name fileNameExt = os.path.basename(filePath) fileName = os.path.splitext(fileNameExt)[0] #create layer name time = utils.GetDatePrefix() iter = "01" layerName = time+"_"+fileName+"_"+iter #Check if this layer already exists while rs.IsLayer(importLayerName + "::" + time + "_" + fileName + "_" + iter): iterInt = int(iter)+1 if len(str(iterInt))<2: iter = "0" + str(iterInt) else: iter = str(iterInt) elementLayerName = importLayerName + "::" + time + "_" + fileName + "_" + iter elementLayer = rs.AddLayer(elementLayerName) rs.CurrentLayer(elementLayer) #get intial list of all layers in the file currentLayers = rs.LayerNames() rs.Command('_-Import "' + filePath + '" _IgnoreThickness=Yes _ModelUnits=Inches _Enter', False) #get new layers added endLayersNames = rs.LayerNames() newLayers = diff(endLayersNames, currentLayers) for layer in newLayers: rs.ParentLayer(layer, elementLayer) objects = rs.ObjectsByLayer(layer) if rs.IsLayerEmpty(layer): rs.DeleteLayer(layer) else: for obj in objects: if rs.IsDimension(obj): rs.DeleteObject(obj) elif rs.IsHatch(obj): rs.DeleteObject(obj) #Get all the imported geometry allObjects = [] finalLayers = rs.LayerChildren(rs.CurrentLayer()) blockNames = [] for finalLayer in finalLayers: layerObjects = rs.ObjectsByLayer(finalLayer) for layerObject in layerObjects: if rs.IsBlockInstance(layerObject): blockNames.append(rs.BlockInstanceName(layerObject)) allObjects.append(rs.ExplodeBlockInstance(layerObject, True)) else: allObjects.append(layerObject) finalAllObjects = list(flatten(allObjects)) for eachBlock in blockNames: try: rs.DeleteBlock(eachBlock) except: pass #Scale objects if scaleDWG: rs.ScaleObjects(finalAllObjects, [0,0,0], [.001, .001, .001]) #Collapse layers try: rootLay = sc.doc.Layers.FindId(rs.coerceguid(rs.LayerId(elementLayerName))) rootLay.IsExpanded = False except: pass print "Import Successful" return finalAllObjects
import rhinoscriptsyntax as rs layers = rs.CurrentLayer() def unifyColor(layer): layer_c = rs.LayerColor(layer) layer_m = rs.LayerMaterialIndex(layer) if layer_m == -1: layer_m = rs.AddMaterialToLayer(layer) rs.MaterialColor(layer_m, layer_c) rs.LayerPrintColor(layer, layer_c) if __name__ == "__main__": if rs.LayerChildCount(layers) > 0: sublayers = rs.LayerChildren(layers) for i in sublayers: print(i) unifyColor(i) else: unifyColor(layers)
import rhinoscriptsyntax as rs obj = rs.GetObject("Pick any object") rs.EnableRedraw(False) layer = rs.ObjectLayer(obj) parent = rs.ParentLayer(layer) children = rs.LayerChildren(parent) map(lambda x: rs.ObjectsByLayer(x, True), children) rs.EnableRedraw(True) # layers = rs.LayerNames() # for layer in layers: # parent = rs.ParentLayer(layer) # print "Layer:", layer, ", Parent:", parent # layers = rs.LayerNames() # if layers: # layers = rs.MultiListBox(layers, "Layers to lock") # if layers: # for layer in layers: # rs.LayerLocked(layer, True)