コード例 #1
0
def main():
    rs.EnableRedraw(enable=False)

    notes = sc.doc.Notes
    if notes:
        variables = notes.split("\r")
        vardict = {}
        for variable in variables:
            var = variable.split("=")
            var = list([x.strip() for x in var])
            vardict[var[0]] = var[1]

    allLayers = rs.LayerNames()
    topList = []
    for layer in allLayers:
        if rs.LayerChildCount(layer) > 0:
            if re.search("::", layer):
                layer = layer.split("::")[0]
            if re.search("^L\d", layer) or re.search(
                    "^R\d", layer) or re.search("^M\d", layer) or re.search(
                        "^P\d",
                        layer) or re.search("^SECTION ", layer) or re.search(
                            "^ROOFPLAN", layer) or re.search("^SOLIDS", layer):
                topList.append(layer)
    topList = sorted(list(set(topList)))
    thisLayer = rs.CurrentLayer()

    topList.append("TURN ALL ON")
    destinationLayer = rs.ListBox(topList, "Layer To Activate")

    if not destinationLayer:
        print("No Layer Selected")
        return None
    elif destinationLayer == "TURN ALL ON":
        topList.remove(destinationLayer)
        for layer in topList:
            sc.doc = Rhino.RhinoDoc.ActiveDoc
            rs.LayerVisible(layer, True)
            rs.ExpandLayer(layer, False)
    else:
        topList.remove("TURN ALL ON")
        topList.remove(destinationLayer)
        rs.CurrentLayer(layer=destinationLayer)
        rs.ExpandLayer(destinationLayer, True)
        for layer in topList:
            sc.doc = Rhino.RhinoDoc.ActiveDoc
            rs.LayerVisible(layer, False)
            rs.ExpandLayer(layer, False)
    print(destinationLayer)
    rs.EnableRedraw(enable=True)
コード例 #2
0
ファイル: Deploy_Engine.py プロジェクト: vctcn93/rhinoscript
 def initLayers(self):
     #propagate required layers
     parent = get_layer_name('LOCKEDLAYERS')
     rs.AddLayer(get_layer_name('LOCKEDLAYERS'), locked=False)
     for phase in PHASES:
         lay = get_layer_name(phase)
         if not rs.IsLayer(lay): rs.AddLayer(lay, locked=False)
         else: rs.LayerLocked(lay, False)
         #rs.ParentLayer(lay,parent)
     rs.ExpandLayer(parent, False)
コード例 #3
0
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)
コード例 #4
0
def main():
    sc.doc = Rhino.RhinoDoc.ActiveDoc
    rs.EnableRedraw(enable=False)

    topList = []
    topList = sorted(getLayerList.getLayers(exclude=["3D", "3dm"]))

    thisLayer = rs.CurrentLayer()

    topList.append("TURN ALL ON")
    destinationLayer = rs.ListBox(topList, "Layer To Activate")

    if not destinationLayer:
        print("No Layer Selected")
        return None

    elif destinationLayer == "TURN ALL ON":
        topList.remove(destinationLayer)
        for layer in topList:
            sc.doc = Rhino.RhinoDoc.ActiveDoc

            rs.LayerVisible(layer, True)
            rs.ExpandLayer(layer, False)

    else:
        sc.doc = Rhino.RhinoDoc.ActiveDoc

        topList.remove("TURN ALL ON")
        topList.remove(destinationLayer)
        rs.CurrentLayer(layer=destinationLayer)
        rs.ExpandLayer(destinationLayer, True)
        for layer in topList:
            sc.doc = Rhino.RhinoDoc.ActiveDoc

            rs.LayerVisible(layer, False)
            rs.ExpandLayer(layer, False)

    print(destinationLayer)
    rs.EnableRedraw(enable=True)
コード例 #5
0
def RunCommand(is_interactive):
    config = get_sisufile()
    if not config:
        print('Sisufile not configured')
        return Rhino.Commands.Result.Failure

    layers = get_related_layers(config, derived_only=True)
    for layer in layers:
        rs.LayerVisible(layer, visible=False)
        parent = rs.ParentLayer(layer)
        rs.ExpandLayer(parent, False)  # collapse parend layer

    return Rhino.Commands.Result.Success
コード例 #6
0
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)
コード例 #7
0
ファイル: SisuLock_cmd.py プロジェクト: designunit/sisu
def RunCommand(is_interactive):
    config = sisuconfig()
    if not config:
        print('Sisufile not configured')
        return Rhino.Commands.Result.Failure

    layers = get_sisu_layers(config, derived_only=True)
    for layer in layers:
        rs.LayerLocked(layer, True)
        parent = rs.ParentLayer(layer)
        rs.ExpandLayer(parent, False)  # collapse parend layer

    print('Layers successfully locked!')
    return Rhino.Commands.Result.Success
コード例 #8
0
ファイル: SisuSync_cmd.py プロジェクト: designunit/sisu
def sync_code(code_def, sync_options):
    layer_name, layer_options = code_def['layer']
    setup_layer(layer_name, layer_options)

    draw_order = 1
    for view in code_def['view']:
        view_layer_name = layer_name + view['layerSuffix']
        render_type, render_options = view['render']

        view_layer_options = {}
        view_layer_options.update(render_options)
        view_layer_options['parent'] = layer_name
        view_layer_options['locked'] = True
        view_layer_name = setup_layer(view_layer_name, view_layer_options)

        bake_options = {}
        bake_options.update(render_options)
        bake_options.update(code_def['properties'])
        bake_options['drawOrder'] = draw_order
        objects = bake_layer(layer_name, view_layer_name, bake_options)

        draw_order += 1

    rs.ExpandLayer(layer_name, False)
コード例 #9
0
import rhinoscriptsyntax as rs
import re
import scriptcontext
import Rhino

allLayers = rs.LayerNames()
printList = []
for layer in allLayers:
    if rs.LayerChildCount(layer) > 0:
        if re.search("^L\d", layer) or re.search("^P\d", layer):
            printList.append(layer)

topList = []
for layer in printList:
    hidelayers = []
    topList = list(printList)
    topList.remove(layer)
    for hidelayer in topList:
        scriptcontext.doc = Rhino.RhinoDoc.ActiveDoc
        rs.LayerVisible(hidelayer, False)
        rs.ExpandLayer(hidelayer, False)
    rs.LayerVisible(layer, True)
    rs.MessageBox("Layer" + layer)