def SelectLayers(): filter_layer = rs.GetLayer(title='select layer to filter by intersection') if not filter_layer: return None, None intersect_layer = rs.GetLayer( title='select layer with intersecting geometry') if not intersect_layer: return None, None return filter_layer, intersect_layer
def save_design(coarse_pseudo_quad_mesh, layer): """Save one of the meshes based on the coarse quad mesh. Parameters ---------- mesh : CoarsePseudoQuadMesh The coarse quad mesh from which to save data. """ mesh_to_save = rs.GetString('mesh to save?', strings=[ 'coarse_pseudo_quad_mesh', 'pseudo_quad_mesh', 'polygonal_mesh' ]) guid = None if mesh_to_save == 'coarse_pseudo_quad_mesh': artist = rhino_artist.MeshArtist(coarse_pseudo_quad_mesh) guid = artist.draw_mesh(coarse_pseudo_quad_mesh) elif mesh_to_save == 'pseudo_quad_mesh': artist = rhino_artist.MeshArtist( coarse_pseudo_quad_mesh.get_quad_mesh()) guid = artist.draw_mesh() elif mesh_to_save == 'polygonal_mesh': artist = rhino_artist.MeshArtist( coarse_pseudo_quad_mesh.get_polygonal_mesh()) guid = artist.draw_mesh() if guid is not None: layer = rs.GetLayer(layer=layer) rs.ObjectLayer(guid, layer)
def iterate(): colDelta = 20 origLayer = rs.GetLayer("Select Layer to Iterate") if origLayer is None: return shortName = origLayer.split("::")[-1] parentLay = rs.ParentLayer(origLayer) nameParts = shortName.split("_") if len(nameParts) > 1: num = int(nameParts[1]) + 1 else: num = 1 if len(str(num)) == 1: newNum = "0" + str(num) else: newNum = str(num) newName = nameParts[0] + "_" + newNum lay1 = rs.CurrentLayer(origLayer) #MAterials matIndex = rs.LayerMaterialIndex(lay1) #New Color oldCol = rs.LayerColor(lay1) oldRed = rs.ColorRedValue(oldCol) oldGreen = rs.ColorGreenValue(oldCol) oldBlue = rs.ColorBlueValue(oldCol) newRed = oldRed + randCol(colDelta) if newRed > 255: newRed = 255 - (newRed - 255) if newRed < 0: newRed = abs(newRed) newGreen = oldGreen + randCol(colDelta) if newGreen > 255: newGreen = 255 - (newGreen - 255) if newGreen < 0: newGreen = abs(newGreen) newBlue = oldBlue + randCol(colDelta) if newBlue > 255: newBlue = 255 - (newBlue - 255) if newBlue < 0: newBlue = abs(newBlue) newCol = (newBlue, newGreen, newBlue) newLay = rs.AddLayer(newName, color=newCol, parent=parentLay) #print nameParts #print newName finalLayer = rs.CurrentLayer(newLay) #sc.doc.Layers.CurrentLayer.RenderMaterialIndex = 3 #c = sc.doc.Layers.CurrentLayer.RenderMaterialIndex #sc.doc.Layers.Modify( #Rhino.DocObjects.Tables.LayerTable.CurrentLayer.r #sc.doc.Views.Redraw() #b = sc.doc.Layers.CurrentLayer #print "" return
def DupLayersSublayersAndObjs(): layer = rs.GetLayer() if layer == None: return #do initial run with selected layer color = rs.LayerColor(layer) objs = rs.ObjectsByLayer(layer) parentLayer = rs.ParentLayer(layer) copyName = UniqueLayerCopyName(layer, True) layerCopy = rs.AddLayer(copyName, color, parent=parentLayer) CopyObjectsToLayer(objs, layerCopy) rs.ExpandLayer(layerCopy, rs.IsLayerExpanded(layer)) DupAllSubLayers(layer, layerCopy) rs.CurrentLayer(layerCopy)
def setup_layers(cfg): parent_layer = False if DEBUG: parent_layer = "DEBUG" if not parent_layer: parent_layer = rs.GetLayer("Please select the 'parent' layer") if parent_layer is None: exit() cfg['layer_info'] = get_layer_info(parent_layer) try: cfg['do_capture_fill'] = False if len(cfg['layer_info']['children']) == 0: raise Exception( "The selected parent layer has no sublayers. Please select a layer that has the proper sublayers defined." ) for rlyr in REQUIRED_LAYERS: if rlyr not in [lyr.Name for lyr in cfg['layer_info']['children']]: raise Exception( "The selected parent layer does not contain the required sublayer '{}'." .format(rlyr)) cfg['layer_info'][rlyr] = False for lyr in cfg['layer_info']['children']: if lyr.Name == rlyr: cfg['layer_info'][rlyr] = lyr break if FILL_LAYER_NAME in [ lyr.Name for lyr in cfg['layer_info']['children'] ]: cfg['do_capture_fill'] = True cfg['layer_info'][FILL_LAYER_NAME] = False for lyr in cfg['layer_info']['children']: if lyr.Name == FILL_LAYER_NAME: cfg['layer_info'][FILL_LAYER_NAME] = lyr break except Exception as e: big_problem( "There was a problem with the selected layer.\n{}".format(e)) cfg['layer_info']['parent'].IsVisible = True sc.doc.ActiveDoc.Layers.SetCurrentLayerIndex( cfg['layer_info']['parent'].Index, True) return
def main(): layerA = rs.GetLayer("Layer Tree to Keep") layerB = rs.GetLayer("Layer Tree to Merge") mergeLayers(layerA, layerB) return
def Reset():# リセットするときの挙動 print("Input Key = Undo") sc.sticky['count_loop'] = 0 sc.sticky['count_error'] = 0 sc.sticky['dict_distance'] = {} sc.sticky['dict_combi'] = {} sc.sticky['preview'] = [] sc.sticky['list_usedindex'] = [] sc.sticky['list_history'] = [] gc.collect()# メモリ解放 if bake:# ベイクする print("Input Key = bake") obj_bake = [Previewwall(sc.sticky["dict_combi"], i, curve, zoom) for i in sc.sticky["dict_combi"]] sc.doc = Rhino.RhinoDoc.ActiveDoc doc_layer = rs.GetLayer("ベイク先のレイヤーを選択", None, True, True)# ベイクするレイヤーを選択 sc.doc = ghdoc for wall in obj_bake: doc_obj = rs.coercerhinoobject(wall) doc_attributes = doc_obj.Attributes doc_geometry = doc_obj.Geometry sc.doc = Rhino.RhinoDoc.ActiveDoc rhino_obj = sc.doc.Objects.Add(doc_geometry, doc_attributes) rs.ObjectLayer(rhino_obj, doc_layer) sc.doc = ghdoc Reset() O = data.ind_o X = data.ind_x count_error = "✕は" + str(sc.sticky['count_error'] + 1) + "番目の候補です" len_index = len(sc.sticky['list_usedindex'])
import rhinoscriptsyntax as rs moveObjects = rs.GetObjects(message="Select Objects to Move", preselect=True, select=False) parentLayer = rs.GetLayer(title="Select Layer to move Objects to", show_new_button=True) sourceLayer = [] rs.EnableRedraw(enable=False) for obj in moveObjects: refLayer = rs.ObjectLayer(obj) if refLayer not in sourceLayer: sourceLayer.append(refLayer) rs.AddLayer(name=refLayer, color=rs.LayerColor(refLayer), parent=parentLayer) for source in sourceLayer: print(source) if refLayer == source: dup = rs.CopyObject(obj) rs.ObjectLayer(dup, layer=parentLayer + "::" + source) rs.EnableRedraw(enable=True)
import rhinoscriptsyntax as rs # !-RunPythonScript "setActiveLayer.py" layer = rs.GetLayer("Select Layer", rs.CurrentLayer(), True, True) if layer: rs.CurrentLayer(layer)