当前位置: 首页>>代码示例>>Python>>正文


Python utility.coercerhinoobject函数代码示例

本文整理汇总了Python中utility.coercerhinoobject函数的典型用法代码示例。如果您正苦于以下问题:Python coercerhinoobject函数的具体用法?Python coercerhinoobject怎么用?Python coercerhinoobject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了coercerhinoobject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ObjectPrintColor

def ObjectPrintColor(object_ids, color=None):
    """Returns or modifies the print color of an object
    Parameters:
      object_ids = identifiers of object(s)
      color[opt] = new print color. If omitted, the current color is returned.
    Returns:
      If color is not specified, the object's current print color
      If color is specified, the object's previous print color
      If object_ids is a list or tuple, the number of objects modified
    """
    id = rhutil.coerceguid(object_ids, False)
    if id:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rc = rhino_object.Attributes.PlotColor
        if color:
            rhino_object.Attributes.PlotColorSource = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject
            rhino_object.Attributes.PlotColor = rhutil.coercecolor(color, True)
            rhino_object.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return rc
    for id in object_ids:
        color = rhutil.coercecolor(color, True)
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rhino_object.Attributes.PlotColorSource = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject
        rhino_object.Attributes.PlotColor = color
        rhino_object.CommitChanges()
    scriptcontext.doc.Views.Redraw()
    return len(object_ids)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:28,代码来源:object.py

示例2: ObjectPrintWidthSource

def ObjectPrintWidthSource(object_ids, source=None):
    """Returns or modifies the print width source of an object
    Parameters:
      object_ids = identifiers of object(s)
      source[opt] = new print width source
        0 = print width by layer
        1 = print width by object
        3 = print width by parent
    Returns:
      If source is not specified, the object's current print width source
      If source is specified, the object's previous print width source
      If object_ids is a list or tuple, the number of objects modified
    """
    id = rhutil.coerceguid(object_ids, False)
    if id:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rc = int(rhino_object.Attributes.PlotWeightSource)
        if source is not None:
            rhino_object.Attributes.PlotWeightSource = System.Enum.ToObject(Rhino.DocObjects.ObjectPlotWeightSource, source)
            rhino_object.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return rc
    for id in object_ids:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rhino_object.Attributes.PlotWeightSource = System.Enum.ToObject(Rhino.DocObjects.ObjectPlotWeightSource, source)
        rhino_object.CommitChanges()
    scriptcontext.doc.Views.Redraw()
    return len(object_ids)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:28,代码来源:object.py

示例3: ObjectPrintWidth

def ObjectPrintWidth(object_ids, width=None):
    """Returns or modifies the print width of an object
    Parameters:
      object_ids = identifiers of object(s)
      width[opt] = new print width value in millimeters, where width=0 means use
        the default width, and width<0 means do not print (visible for screen display,
        but does not show on print). If omitted, the current width is returned.
    Returns:
      If width is not specified, the object's current print width
      If width is specified, the object's previous print width
      If object_ids is a list or tuple, the number of objects modified
    """
    id = rhutil.coerceguid(object_ids, False)
    if id:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rc = rhino_object.Attributes.PlotWeight
        if width is not None:
            rhino_object.Attributes.PlotWeightSource = Rhino.DocObjects.ObjectPlotWeightSource.PlotWeightFromObject
            rhino_object.Attributes.PlotWeight = width
            rhino_object.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return rc
    for id in object_ids:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rhino_object.Attributes.PlotWeightSource = Rhino.DocObjects.ObjectPlotWeightSource.PlotWeightFromObject
        rhino_object.Attributes.PlotWeight = width
        rhino_object.CommitChanges()
    scriptcontext.doc.Views.Redraw()
    return len(object_ids)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:29,代码来源:object.py

示例4: ObjectMaterialSource

def ObjectMaterialSource(object_ids, source=None):
    """Returns or modifies the rendering material source of an object.
    Parameters:
      object_ids = one or more object identifiers
      source [opt] = The new rendering material source. If omitted and a single
        object is provided in object_ids, then the current material source is
        returned. This parameter is required if multiple objects are passed in
        object_ids
        0 = Material from layer
        1 = Material from object
        3 = Material from parent
    Returns:
      If source is not specified, the current rendering material source
      If source is specified, the previous rendering material source
      If object_ids refers to multiple objects, the number of objects modified
    """
    id = rhutil.coerceguid(object_ids, False)
    if id: # working with single object
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rc = int(rhino_object.Attributes.MaterialSource)
        if source is not None:
            rhino_object.Attributes.MaterialSource = System.Enum.ToObject(Rhino.DocObjects.ObjectMaterialSource, source)
            rhino_object.CommitChanges()
        return rc
    # else working with multiple objects
    if source is None: raise Exception("source is required when object_ids represents multiple objects")
    source = System.Enum.ToObject(Rhino.DocObjects.ObjectMaterialSource, source)
    for id in object_ids:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rhino_object.Attributes.MaterialSource = source
        rhino_object.CommitChanges()
    return len(object_ids)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:32,代码来源:object.py

示例5: ObjectName

def ObjectName(object_id, name=None):
    """Returns or modifies the name of an object
    Parameters:
      object_id = id or ids of object(s)
      name[opt] = the new object name. If omitted, the current name is returned
    Returns:
      If name is not specified, the current object name
      If name is specified, the previous object name
      If object_id is a list, the number of objects changed
    """
    id = rhutil.coerceguid(object_id, False)
    rhino_object = None
    rhino_objects = None
    if id:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
    else:
        rhino_objects = [rhutil.coercerhinoobject(id, True, True) for id in object_id]
        if not rhino_objects: return 0
        if len(rhino_objects)==1:
            rhino_object = rhino_objects[0]
            rhino_objects = None
    if name is None: #get the name
        if rhino_objects: raise Exception("name required when object_id represents multiple objects")
        return rhino_object.Name
    if rhino_objects:
        for rh_obj in rhino_objects:
            attr = rh_obj.Attributes
            attr.Name = name
            scriptcontext.doc.Objects.ModifyAttributes(rh_obj, attr, True)
        return len(rhino_objects)
    rc = rhino_object.Name
    if not type(name) is str: name = str(name)
    rhino_object.Attributes.Name = name
    rhino_object.CommitChanges()
    return rc
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:35,代码来源:object.py

示例6: ObjectLinetype

def ObjectLinetype(object_ids, linetype=None):
    """Returns of modifies the linetype of an object
    Parameters:
      object_ids = identifiers of object(s)
      linetype[opt] = name of an existing linetype. If omitted, the current
        linetype is returned. If object_ids is a list of identifiers, this parameter
        is required
    Returns:
      If a linetype is not specified, the object's current linetype
      If linetype is specified, the object's previous linetype
      If object_ids is a list, the number of objects modified
    """
    id = rhutil.coerceguid(object_ids, False)
    if id:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        oldindex = scriptcontext.doc.Linetypes.LinetypeIndexForObject(rhino_object)
        if linetype:
            newindex = scriptcontext.doc.Linetypes.Find(linetype, True)
            rhino_object.Attributes.LinetypeSource = Rhino.DocObjects.ObjectLinetypeSource.LinetypeFromObject
            rhino_object.Attributes.LinetypeIndex = newindex
            rhino_object.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return scriptcontext.doc.Linetypes[oldindex].Name

    newindex = scriptcontext.doc.Linetypes.Find(linetype, True)
    if newindex<0: raise Exception("%s does not exist in LineTypes table"%linetype)
    for id in object_ids:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rhino_object.Attributes.LinetypeSource = Rhino.DocObjects.ObjectLinetypeSource.LinetypeFromObject
        rhino_object.Attributes.LinetypeIndex = newindex
        rhino_object.CommitChanges()
    scriptcontext.doc.Views.Redraw()
    return len(object_ids)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:33,代码来源:object.py

示例7: ObjectLayer

def ObjectLayer(object_id, layer=None):
    """Returns or modifies the layer of an object
    Parameters:
      object_id = the identifier of the object(s)
      layer[opt] = name of an existing layer
    Returns:
      If a layer is not specified, the object's current layer
      If a layer is specified, the object's previous layer
      If object_id is a list or tuple, the number of objects modified
    """
    if type(object_id) is not str and hasattr(object_id, "__len__"):
        layer = __getlayer(layer, True)
        index = layer.LayerIndex
        for id in object_id:
            obj = rhutil.coercerhinoobject(id, True, True)
            obj.Attributes.LayerIndex = index
            obj.CommitChanges()
        scriptcontext.doc.Views.Redraw()
        return len(object_id)
    obj = rhutil.coercerhinoobject(object_id, True, True)
    if obj is None: return scriptcontext.errorhandler()
    index = obj.Attributes.LayerIndex
    rc = scriptcontext.doc.Layers[index].FullPath
    if layer:
        layer = __getlayer(layer, True)
        index = layer.LayerIndex
        obj.Attributes.LayerIndex = index
        obj.CommitChanges()
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:30,代码来源:object.py

示例8: ObjectColorSource

def ObjectColorSource(object_ids, source=None):
    """Returns of modifies the color source of an object.
    Paramters:
      object_ids = single identifier of list of identifiers
      source[opt] = new color source
          0 = color from layer
          1 = color from object
          2 = color from material
          3 = color from parent
    Returns:
      if color source is not specified, the current color source
      is color source is specified, the previous color source
      if color_ids is a list, then the number of objects modifief
    """
    id = rhutil.coerceguid(object_ids, False)
    if id:
        rhobj = rhutil.coercerhinoobject(id, True, True)
        rc = int(rhobj.Attributes.ColorSource)
        if source is not None:
            rhobj.Attributes.ColorSource = System.Enum.ToObject(Rhino.DocObjects.ObjectColorSource, source)
            rhobj.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return rc
    else:
        rc = 0
        source = System.Enum.ToObject(Rhino.DocObjects.ObjectColorSource, source)
        for id in object_ids:
            rhobj = rhutil.coercerhinoobject(id, True, True)
            rhobj.Attributes.ColorSource = source
            rhobj.CommitChanges()
            rc += 1
        if rc: scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:33,代码来源:object.py

示例9: ObjectLinetypeSource

def ObjectLinetypeSource(object_ids, source=None):
    """Returns of modifies the linetype source of an object
    Parameters:
      object_ids = identifiers of object(s)
      source[opt] = new linetype source. If omitted, the current source is returned.
        If object_ids is a list of identifiers, this parameter is required
          0 = By Layer
          1 = By Object
          3 = By Parent
    Returns:
      If a source is not specified, the object's current linetype source
      If source is specified, the object's previous linetype source
      If object_ids is a list, the number of objects modified
    """
    id = rhutil.coerceguid(object_ids, False)
    if id:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        oldsource = rhino_object.Attributes.LinetypeSource
        if source is not None:
            source = System.Enum.ToObject(Rhino.DocObjects.ObjectLinetypeSource, source)
            rhino_object.Attributes.LinetypeSource = source
            rhino_object.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return int(oldsource)
    source = System.Enum.ToObject(Rhino.DocObjects.ObjectLinetypeSource, source)
    for id in object_ids:
        rhino_object = rhutil.coercerhinoobject(id, True, True)
        rhino_object.Attributes.LinetypeSource = source
        rhino_object.CommitChanges()
    scriptcontext.doc.Views.Redraw()
    return len(object_ids)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:31,代码来源:object.py

示例10: ObjectDescription

def ObjectDescription(object_id):
    """Returns a short text description of an object
    Parameters:
      object_id = identifier of an object
    """
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    return rhobj.ShortDescription(False)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:7,代码来源:object.py

示例11: AddMaterialToObject

def AddMaterialToObject(object_id):
    """Adds material to an object and returns the new material's index. If the
    object already has a material, the the object's current material index is
    returned.
    Parameters:
      object_id = identifier of an object
    Returns:
      material index of the object
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject()
      if obj:
      index = rs.ObjectMaterialIndex(obj)
    See Also:
      IsMaterialDefault
      ObjectMaterialIndex
      ObjectMaterialSource
    """
    rhino_object = rhutil.coercerhinoobject(object_id, True, True)
    attr = rhino_object.Attributes
    if attr.MaterialSource!=Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject:
        attr.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject
        scriptcontext.doc.Objects.ModifyAttributes(rhino_object, attr, True)
        attr = rhino_object.Attributes
    material_index = attr.MaterialIndex
    if material_index>-1: return material_index
    material_index = scriptcontext.doc.Materials.Add()
    attr.MaterialIndex = material_index
    scriptcontext.doc.Objects.ModifyAttributes(rhino_object, attr, True)
    return material_index
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:30,代码来源:material.py

示例12: ObjectGripLocations

def ObjectGripLocations(object_id, points=None):
    """Returns or modifies the location of all grips owned by an object. The
    locations of the grips are returned in a list of Point3d with each position
    in the list corresponding to that grip's index. To modify the locations of
    the grips, you must provide a list of points that contain the same number
    of points at grips
    Parameters:
      object_id = identifier of the object
      points [opt] = list of 3D points identifying the new grip locations
    Returns:
      if points is not specified, the current location of all grips
      if points is specified, the previous location of all grips
      None if not successful
    """
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    if not rhobj.GripsOn: return scriptcontext.errorhandler()
    grips = rhobj.GetGrips()
    if grips is None: return scriptcontext.errorhandler()
    rc = [grip.CurrentLocation for grip in grips]
    if points and len(points)==len(grips):
        points = rhutil.coerce3dpointlist(points, True)
        for i, grip in enumerate(grips):
            point = points[i]
            grip.CurrentLocation = point
        scriptcontext.doc.Objects.GripUpdate(rhobj, True)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:AsherBond,项目名称:rhinopython,代码行数:27,代码来源:grips.py

示例13: PointCloudPointColors

def PointCloudPointColors(object_id, colors=[]):
    """Returns or modifies the point colors of a point cloud object
    Parameters:
      object_id: the point cloud object's identifier
      colors: list of color values if you want to adjust colors
    Returns:
      List of point cloud colors
    """
    rhobj = rhutil.coercerhinoobject(object_id)
    if rhobj:
        pc = rhobj.Geometry
    else:
        pc = rhutil.coercegeometry(object_id, True)
    if isinstance(pc, Rhino.Geometry.PointCloud):
        rc = None
        if pc.ContainsColors:
            rc = [item.Color for item in pc]
        if colors is None:
            pc.ClearColors()
        elif len(colors) == pc.Count:
            for i in range(pc.Count):
                pc[i].Color = rhutil.coercecolor(colors[i])
        if rhobj:
            rhobj.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:howllone,项目名称:rhinopython,代码行数:26,代码来源:geometry.py

示例14: PointCloudHidePoints

def PointCloudHidePoints(object_id, hidden=[]):
    """Returns or modifies the hidden points of a point cloud object
    Parameters:
      object_id: the point cloud object's identifier
      hidden: list of hidden values if you want to hide certain points
    Returns:
      List of point cloud hidden states
    """
    rhobj = rhutil.coercerhinoobject(object_id)
    if rhobj:
        pc = rhobj.Geometry
    else:
        pc = rhutil.coercegeometry(object_id, True)
    if isinstance(pc, Rhino.Geometry.PointCloud):
        rc = None
        if pc.ContainsHiddenFlags:
            rc = [item.Hidden for item in pc]
        if hidden is None:
            pc.ClearHiddenFlags()
        elif len(hidden) == pc.Count:
            for i in range(pc.Count):
                pc[i].Hidden = hidden[i]
        if rhobj:
            rhobj.CommitChanges()
            scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:howllone,项目名称:rhinopython,代码行数:26,代码来源:geometry.py

示例15: UnselectObjectGrips

def UnselectObjectGrips(object_id):
    """Unselects an object's grips. Note, the grips will not be turned off.
    Parameters:
      object_id = identifier of the object
    Returns:
      Number of grips unselected on success
      None on failure
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select object")
      if rs.ObjectGripsSelected(obj): rs.UnselectObjectGrips(obj)
    See Also:
      EnableObjectGrips
      ObjectGripCount
      UnselectObjectGrip
    """
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    if not rhobj.GripsOn: return scriptcontext.errorhandler()
    grips = rhobj.GetGrips()
    if grips is None: return scriptcontext.errorhandler()
    count = 0
    for grip in grips:
        if grip.Select(False)==0: count += 1
    if count>0:
        scriptcontext.doc.Views.Redraw()
        return count
    return scriptcontext.errorhandler()
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:27,代码来源:grips.py


注:本文中的utility.coercerhinoobject函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。