コード例 #1
0
 def isolateLayer(self, layerName):
     names = rs.LayerNames()
     for n in names:
         if n == layerName:
             layers = rs.LayerVisible(layerName, True)
         else:
             rs.LayerVisible(n, False)
コード例 #2
0
def Export():
    count = 0
    folder = ChooseFolderPath()
    layer_names = rs.LayerNames()
    newDefaultLayer = 'NewDefault'
    rs.AddLayer(newDefaultLayer)
    rs.CurrentLayer(newDefaultLayer)

    for l in layer_names:
        if l != newDefaultLayer:
            for t in layer_names:
                if rs.IsLayer(l):
                        if l != newDefaultLayer:
                            rs.LayerVisible(t, False)
                else:
                    print "The layer does not exist."
            rs.LayerVisible(l, True)
            if rs.CurrentLayer() == l:
                break
            """answer = rs.MessageBox("Continue?", 1 | 32)
            if answer is 2: break
            rs.Sleep(1000)"""
            Render(folder, count)
            count += 1
            rs.LayerVisible(l, False)
    for l in layer_names:
        if l != newDefaultLayer:
            rs.LayerVisible(l, False)
            rs.CurrentLayer(l)
    rs.DeleteLayer(newDefaultLayer)
コード例 #3
0
def get_polygons(layer=None):
    """Get all polygons.

    Parameters
    ----------
    layer : str, optional
        Name of a layer containing the polygons.

    Returns
    -------
    list[System.Guid]
        The identifiers of the polygons.

    """
    if layer:
        rs.EnableRedraw(False)
        # Argument names for LayerVisible command are not the same for Rhino5 and Rhino6
        # that is why we use positional instead of named arguments
        visible = rs.LayerVisible(layer, True, True)
        guids = rs.ObjectsByType(rs.filter.curve)
        guids = [guid for guid in guids if is_curve_polygon(guid)]
        guids = list(set(guids) & set(rs.ObjectsByLayer(layer)))
        rs.LayerVisible(layer, visible, True)
        rs.EnableRedraw(True)
    else:
        guids = rs.ObjectsByType(rs.filter.curve)
        guids = [guid for guid in guids if is_curve_polygon(guid)]
    return guids
コード例 #4
0
def isolateLayer(layerName):
    names=rs.LayerNames()
    rs.CurrentLayer('Default')
    for n in names:
        if n=='Default':continue
        if n==layerName:
            layers=rs.LayerVisible(layerName,True)
        else:rs.LayerVisible(n,False)
コード例 #5
0
    def set_extrusion_lines(self):
        sys.path.append(self.pluginPath)

        if rs.IsLayerVisible('MW 3D Printer Perimeter'):
            rs.LayerVisible('MW 3D Printer PointCloud', visible=False)
            rs.LayerVisible('MW 3D Printer Perimeter', visible=False)
        else:
            rs.LayerVisible('MW 3D Printer PointCloud', visible=False)
            rs.LayerVisible('MW 3D Printer Perimeter', visible=True)
コード例 #6
0
def get_meshes(layer=None):
    if layer:
        rs.EnableRedraw(False)
        visible = rs.LayerVisible(layer, visible=True, force_visible=True)
        guids = rs.ObjectsByType(rs.filter.mesh)
        guids = list(set(guids) & set(rs.ObjectsByLayer(layer)))
        rs.LayerVisible(layer, visible=visible, force_visible=visible)
        rs.EnableRedraw(True)
    else:
        guids = rs.ObjectsByType(rs.filter.mesh)
    return guids
コード例 #7
0
ファイル: Deploy_Engine.py プロジェクト: vctcn93/rhinoscript
 def isolateLayer(self, layerName):
     names = rs.LayerNames()
     rs.CurrentLayer('Default')
     for n in names:
         if n == 'Default': continue
         if n == get_layer_name('LOCKEDLAYERS'):
             rs.LayerVisible(layerName, True)
             continue
         if n == layerName:
             layers = rs.LayerVisible(layerName, True)
         else:
             rs.LayerVisible(n, False)
コード例 #8
0
ファイル: images.py プロジェクト: stevencorrea/lasersaur
def generate_part_images(structure):
    global view_aspect
    w_l = conf['part_img_width']
    h_l = int(w_l / view_aspect)

    for iSub in xrange(len(structure)):
        subsystem = structure.keys()[iSub]
        v = structure[subsystem]
        utils.show_only(subsystem)
        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)
            for partkind, vvv in vv.items():
                rs.HideObjects(vvv)
            for partkind, vvv in vv.items():
                if len(vvv) >= 1:
                    part = vvv[0]
                    rs.ShowObject(part)
                    # create images
                    rs.RestoreNamedView(conf['persp_view'])
                    rs.ZoomExtents()
                    create_view_image(
                        conf['part_img_persp'] % (stepnumeral, partkind), w_l,
                        h_l)
                    rs.RestoreNamedView(conf['top_view'])
                    rs.ZoomExtents()
                    create_view_image(
                        conf['part_img_top'] % (stepnumeral, partkind), w_l,
                        h_l)
                    rs.RestoreNamedView(conf['front_view'])
                    rs.ZoomExtents()
                    create_view_image(
                        conf['part_img_front'] % (stepnumeral, partkind), w_l,
                        h_l)
                    rs.RestoreNamedView(conf['right_view'])
                    rs.ZoomExtents()
                    create_view_image(
                        conf['part_img_right'] % (stepnumeral, partkind), w_l,
                        h_l)
                    #
                    rs.HideObject(part)
            for partkind, vvv in vv.items():
                rs.ShowObject(vvv)
            rs.LayerVisible(step, False)
        # utils.show_children(subsystem)
        utils.show_step_children(subsystem)
    utils.show_blocks()
    utils.show_subsystems()
    rs.ZoomExtents()
コード例 #9
0
def get_meshes(layer=None):
    if layer:
        rs.EnableRedraw(False)
        # Argument names for LayerVisible command are not the same for Rhino5 and Rhino6
        # that is why we use positional instead of named arguments
        visible = rs.LayerVisible(layer, True, True)
        guids = rs.ObjectsByType(rs.filter.mesh)
        guids = list(set(guids) & set(rs.ObjectsByLayer(layer)))
        rs.LayerVisible(layer, visible, True)
        rs.EnableRedraw(True)
    else:
        guids = rs.ObjectsByType(rs.filter.mesh)
    return guids
コード例 #10
0
def get_polygons(layer=None):
    if layer:
        rs.EnableRedraw(False)
        visible = rs.LayerVisible(layer, visible=True, force_visible=True)
        guids = rs.ObjectsByType(rs.filter.curve)
        guids = [guid for guid in guids if is_curve_polygon(guid)]
        guids = list(set(guids) & set(rs.ObjectsByLayer(layer)))
        rs.LayerVisible(layer, visible=visible, force_visible=visible)
        rs.EnableRedraw(True)
    else:
        guids = rs.ObjectsByType(rs.filter.curve)
        guids = [guid for guid in guids if is_curve_polygon(guid)]
    return guids
コード例 #11
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)
コード例 #12
0
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)
コード例 #13
0
ファイル: images.py プロジェクト: stevencorrea/lasersaur
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)
コード例 #14
0
def main():
    heightRel2FFL = rs.GetReal("Cut level (relative to FFL):", number=1)
    levelsElev = setLevels.getFloorLevels()
    rs.EnableRedraw(False)
    deleteExistingPlans()
    heights = []

    for leveli in levelsElev:
        heights.append(leveli + heightRel2FFL)
    layers = rs.GetLayers()
    if layers is None:
        return
    layersToCut = []
    for layer in layers:
        if rs.LayerVisible(layer):
            layersToCut.append(layer)
    for i in range(0, len(heights)):
        for layer in layersToCut:
            rs.CurrentLayer(layer)
            if i < 9:
                levelNum = "0" + str(i + 1)
            else:
                levelNum = str(i + 1)
            cutAtPlan(heights[i], levelNum)
    rs.EnableRedraw(True)
    return None
コード例 #15
0
def unIsolateLayers():
    """Unisolate layers by unhiding layers."""

    file_name = rs.DocumentName()
    file_path = rs.DocumentPath()
    if file_name is None:
        temp_file_name = "IsolateLayers_temp.json"
    else:
        temp_file_name = file_path + 'IsolateLayers_temp_' + file_name.strip(
            '.3dm') + '.json'

    if not os.path.isfile(temp_file_name):
        print("Temp File does not exist!")
        return

    with open(temp_file_name, "r") as f:
        layers_data = json.load(f)

    layers_data = {rs.LayerName(k): v for k, v in layers_data.items()}

    sorted_layers_data = sorted(layers_data.iteritems())

    for layer_name, layer_visibility in sorted_layers_data:
        rs.LayerVisible(layer_name, layer_visibility)

    # remove TEMP FILE
    os.remove(temp_file_name)
コード例 #16
0
def explodeTextObjects(objs):
    new_list = []

    for obj in objs:

        if rs.IsText(obj) and rs.LayerVisible(
                rs.ObjectLayer(obj)) and ("CNC" in rs.ObjectLayer(obj)):
            # only explode Text when
            # - layer visible
            # - CNC layer

            # polylines = convertTextToPolylines(ob)
            polylines = convertTextToPolylines2(obj)

            for polyline in polylines:
                new_list.append(polyline)

#            if ("CNC" in rs.ObjectLayer(obj)):
#                # rs.GetBoolean(text, "get", True)
#                # result = rs.TextObjectFont(obj, "Machine Tool Gothic")
#
#                # rs.MessageBox('test' + rs.TextObjectText(obj))
#                # polylines = rs.ExplodeText(obj, True)
#
#                polylines = convertTextToPolylines(obj)
#
#                for polyline in polylines:
#                    new_list.append(polyline)
#            else:
#                # add unexploded text
#                new_list.append(obj)
        else:
            new_list.append(obj)

    return new_list
コード例 #17
0
ファイル: make3d.py プロジェクト: timcastelijn/rhinoscript
def filterObjects(objs):
    new_list = []
    for obj in objs:
        if rs.LayerVisible( rs.ObjectLayer(obj) ):
            # only export visible layers
            if rs.IsCurve(obj):
                new_list.append(obj)

            elif rs.IsPoint(obj):
                # convert to circle
                layer = rs.ObjectLayer(obj)
                point=rs.coerce3dpoint(obj)

                circle = rs.AddCircle(rs.WorldXYPlane(),3)

                rs.ObjectLayer(circle, layer)
                rs.MoveObject(circle, [point.X, point.Y, point.Z])
                new_list.append(circle)
                rs.DeleteObject(obj)
                # rs.DeleteObject(point)

            else:
                # remove from obj list
                rs.DeleteObject(obj)
        else:
            # remove from obj list
            rs.DeleteObject(obj)

    return new_list
コード例 #18
0
def setOutputLayerVis(_detailViewLayers=[], _udLayersOn=[]):

    # Turn all Layer Visibilities 'Off' except for the designeted layers

    sc.doc = Rhino.RhinoDoc.ActiveDoc

    layers = rs.LayerNames()

    allLayersOn = _detailViewLayers + _udLayersOn  # All the Page's DetailView Layers, as well we as the User Determined 'On'

    allLayersOn.append(str(Rhino.RhinoDoc.ActiveDoc.Layers.CurrentLayer)
                       )  # Add in the Current Active Layer

    print 'Turning on layers: {}'.format(allLayersOn)

    print '----'

    # Record the Starting State

    layerVisibilites = []  # True/False record (for resetting when done)

    for layer in layers:

        layerVisibilites.append(rs.LayerVisible(layer))

    # Set layers 'off' if they aren't on the list to stay on

    for layer in layers:

        #if list(layer.Split(":"))[-1] not in allLayersOn:

        if layer in allLayersOn:

            rs.LayerVisible(layer, True)

        else:

            rs.LayerVisible(layer, False)

    Rhino.RhinoDoc.ActiveDoc.Views.RedrawEnabled = True

    Rhino.RhinoDoc.ActiveDoc.Views.Redraw()

    sc.doc = ghdoc

    return layerVisibilites
コード例 #19
0
ファイル: blocks.py プロジェクト: tmwarchitecture/PCPA_TOOLS
def Iterate():
    block = rs.GetObject("Select Design Option Block to iterate",
                         rs.filter.instance, True)
    if block is None: return

    try:
        prevBlockName = rs.BlockInstanceName(block)
        prevBlockLayer = rs.ObjectLayer(block)
        prevBlockLayerColor = rs.LayerColor(prevBlockLayer)

        newBlock = ReplicateBlock(block)
        newBlockName = rs.BlockInstanceName(newBlock)

        #Ensure 3_DESIGN OPTIONS already exists
        parentLayer = layers.AddLayerByNumber(3000, False)[0]
        rs.LayerVisible(parentLayer, True)

        #Create new design option layer
        #newBlockLayer = rs.AddLayer(parentLayer + "::" + newBlockName, color = utils.StepColor(prevBlockLayerColor))
        newBlockLayer = rs.AddLayer(parentLayer + "::" + newBlockName,
                                    color=utils.GetRandomColor())
        rs.LayerPrintColor(newBlockLayer, (0, 0, 0))
        rs.ObjectLayer(newBlock, newBlockLayer)

        #Save user text
        try:
            parentsUserTest = rs.GetUserText(block,
                                             'Design Option History') + "<--"
        except:
            parentsUserTest = ''
        rs.SetUserText(newBlock, 'Design Option History',
                       parentsUserTest + newBlockName)

        #Turn off prev blocks layer
        if rs.CurrentLayer() != prevBlockLayer:
            rs.LayerVisible(prevBlockLayer, False)

        result = True
    except:
        result = False
        newBlockName = ''
    utils.SaveFunctionData(
        'Blocks-Iterate',
        [__version__,
         rs.BlockInstanceName(block), newBlockName, result])
    return result
コード例 #20
0
ファイル: rhino.py プロジェクト: yijiangh/compas_fea
def plot_reaction_forces(structure, step, layer=None, scale=1.0):
    """ Plots reaction forces for the Structure analysis results.

    Parameters
    ----------
    structure : obj
        Structure object.
    step : str
        Name of the Step.
    layer : str
        Layer name for plotting.
    scale : float
        Scale of the arrows.

    Returns
    -------
    None

    """

    if not layer:
        layer = '{0}-{1}'.format(step, 'reactions')

    rs.CurrentLayer(rs.AddLayer(layer))
    rs.DeleteObjects(rs.ObjectsByLayer(layer))
    rs.EnableRedraw(False)

    rfx = structure.results[step]['nodal']['rfx']
    rfy = structure.results[step]['nodal']['rfy']
    rfz = structure.results[step]['nodal']['rfz']

    nkeys = rfx.keys()
    v = [scale_vector([rfx[i], rfy[i], rfz[i]], -scale * 0.001) for i in nkeys]
    rm = [length_vector(i) for i in v]
    rmax = max(rm)
    nodes = structure.nodes_xyz(nkeys)

    for i in nkeys:

        if rm[i] > 0.001:
            l = rs.AddLine(nodes[i], add_vectors(nodes[i], v[i]))
            rs.CurveArrows(l, 1)
            col = [
                int(j) for j in colorbar(rm[i] / rmax, input='float', type=255)
            ]
            rs.ObjectColor(l, col)
            vector = [rfx[i], rfy[i], rfz[i]]
            name = json.dumps({
                'rfx': rfx[i],
                'rfy': rfy[i],
                'rfz': rfz[i],
                'rfm': length_vector(vector)
            })
            rs.ObjectName(l, '_' + name)

    rs.CurrentLayer(rs.AddLayer('Default'))
    rs.LayerVisible(layer, False)
    rs.EnableRedraw(True)
コード例 #21
0
ファイル: IsolateLayers.py プロジェクト: vlmarch/rhino-tools
def IsolateLayers():
    """Isolate layers by hiding layers."""

    file_name = rs.DocumentName()
    file_path = rs.DocumentPath()

    # Select objects
    input_obj = rs.SelectedObjects()
    if not input_obj:
        input_obj = rs.GetObjects("Select objects on layers to isolate")
    if not input_obj: return

    # Get all layers names
    proj_layers = rs.LayerNames()
    layers_history = {rs.LayerId(l): rs.LayerVisible(l) for l in proj_layers}

    # Save temp
    if file_name is None:
        temp_file_name = "IsolateLayers_temp.json"
    else:
        temp_file_name = file_path + 'IsolateLayers_temp_' + file_name.strip(
            '.3dm') + '.json'

    with open(temp_file_name, "w+") as f:
        f.write(json.dumps(layers_history, sort_keys=True, indent=4))

    # Get objects layers
    obj_layers = [rs.ObjectLayer(o) for o in input_obj]

    layers = []
    for l in obj_layers:
        s = l.split('::')
        a = 0
        while len(s) > a:
            layers.append("::".join(s[:a + 1]))
            a += 1

    # Set current layer
    rs.CurrentLayer(layers[0])

    # Hide layers
    layers_to_hide = list(set(proj_layers) - set(layers))
    for l in layers_to_hide:
        rs.LayerVisible(l, False)
コード例 #22
0
def set_layer_properties(layer, properties):
    """Set Rhino layer properties."""

    rs.LayerVisible(layer, properties.get("LayerVisible"))
    rs.LayerLocked(layer, properties.get("LayerLocked"))
    rs.LayerColor(layer, hex_to_rbg(properties.get("LayerColor")))
    rs.LayerMaterialIndex(layer, properties.get("LayerMaterialIndex"))
    rs.LayerLinetype(layer, properties.get("LayerLinetype"))
    rs.LayerPrintColor(layer, hex_to_rbg(properties.get("LayerPrintColor")))
    rs.LayerPrintWidth(layer, properties.get("LayerPrintWidth"))
コード例 #23
0
def final_view():
    """Applies rendering and redraws all objects."""
    sc.doc.Views.Redraw()
    layer('OBS')
    for l in [
            'Default', 'TOP', 'BOTTOM', 'LEFT', 'RIGHT', 'FRONT', 'BACK',
            'INTS', 'INTS_BOX'
    ]:
        rs.LayerVisible(l, False)
    [rs.ViewDisplayMode(view, 'Ghosted') for view in rs.ViewNames()]
コード例 #24
0
def RunCommand( is_interactive ):

  rs.AddLayer("_t")
  rs.CurrentLayer("_t")

  layers = rs.LayerNames()

  for layer in layers:
      if not rs.IsLayerVisible(layer):
          rs.LayerVisible(layer,True)
  return 0
コード例 #25
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=True)

    return Rhino.Commands.Result.Success
コード例 #26
0
def get_layer_properties(layer):
    """Get Rhino layer properties."""

    return {
        "LayerVisible": rs.LayerVisible(layer),
        "LayerLocked": rs.LayerLocked(layer),
        "LayerColor": rgb_to_hex(rs.LayerColor(layer)),
        "LayerMaterialIndex": rs.LayerMaterialIndex(layer),
        "LayerLinetype": rs.LayerLinetype(layer),
        "LayerPrintColor": rgb_to_hex(rs.LayerPrintColor(layer)),
        "LayerPrintWidth": rs.LayerPrintWidth(layer)
    }
コード例 #27
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)
コード例 #28
0
def draw(mesh,layer_1,layer_2):
    
    rs.EnableRedraw(False)
    
    rs.LayerVisible(layer_1, True)
    rs.LayerVisible(layer_2, True)

    objs = rs.ObjectsByLayer(layer_1)
    rs.DeleteObjects(objs)
    objs = rs.ObjectsByLayer(layer_2)
    rs.DeleteObjects(objs)    
    
    pts_objs = []
    for key, a in mesh.vertices_iter(True):
    
       pt = (a['x'], a['y'], a['z'])
       
       pts_objs.append(rs.AddPoint(pt))
       rs.ObjectColor(pts_objs[-1],a['color'] )
       
    rs.ObjectLayer(pts_objs,layer_1)
        
        
    key_index = dict((key, index) for index, key in mesh.vertices_enum())
    xyz = mesh.xyz    
    polylines = []
    for fkey in mesh.faces_iter():
        face = mesh.face_vertices(fkey,True)
        
        
        poly_pts = [xyz[key_index[k]] for k in face+[face[0]]]
        polylines.append(rs.AddPolyline(poly_pts))
        
    rs.ObjectLayer(polylines,layer_2)
    
        
        

    rs.EnableRedraw(True)
コード例 #29
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
コード例 #30
0
def RunCommand(is_interactive):
    # this script can turn off layers of your selected object
    rs.AddLayer("_t")
    rs.CurrentLayer("_t")

    layers = rs.LayerNames()
    CurObjLayNames = []

    CurObjs = rs.GetObjects("select objects to turn layers off")

    for CurObj in CurObjs:
        CurObjLayId = rs.ObjectLayer(CurObj)
        CurObjLayName = rs.LayerName(CurObjLayId, fullpath=True)
        CurObjLayNames.extend([CurObjLayName])

    for layer in layers:
        if layer in CurObjLayNames and layer != "_t":
            rs.LayerVisible(layer, False)
    return 0