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


Python utility.coercegeometry函数代码示例

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


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

示例1: TextObjectPoint

def TextObjectPoint(object_id, point=None):
    """Returns or modifies the location of a text object
    Parameters:
      object_id = the identifier of a text object
      point[opt] = the new text object location
    Returns:
      if point is not specified, the 3D point identifying the current location
      if point is specified, the 3D point identifying the previous location
      None if not successful, or on Error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select text")
      if rs.IsText(obj):
      rs.TextObjectPoint( obj, [0,0,0] )
    See Also:
      AddText
      IsText
      TextObjectFont
      TextObjectHeight
      TextObjectPlane
      TextObjectStyle
      TextObjectText
    """
    text = rhutil.coercegeometry(object_id, True)
    if not isinstance(text, Rhino.Geometry.TextEntity):
        return scriptcontext.errorhandler()
    plane = text.Plane
    rc = plane.Origin
    if point:
        plane.Origin = rhutil.coerce3dpoint(point, True)
        text.Plane = plane
        id = rhutil.coerceguid(object_id, True)
        scriptcontext.doc.Objects.Replace(id, text)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:35,代码来源:geometry.py

示例2: TextObjectText

def TextObjectText(object_id, text=None):
    """Returns or modifies the text string of a text object.
    Parameters:
      object_id = the identifier of a text object
      text [opt] = a new text string
    Returns:
      if text is not specified, the current string value if successful
      if text is specified, the previous string value if successful
      None if not successful, or on error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select text")
      if rs.IsText(obj): rs.TextObjectText(obj, "Rhino")
    See Also:
      AddText
      IsText
      TextObjectFont
      TextObjectHeight
      TextObjectPlane
      TextObjectPoint
      TextObjectStyle
    """
    annotation = rhutil.coercegeometry(object_id, True)
    if not isinstance(annotation, Rhino.Geometry.TextEntity):
        return scriptcontext.errorhandler()
    rc = annotation.Text
    if text:
        if not isinstance(text, str): text = str(text)
        annotation.Text = text
        id = rhutil.coerceguid(object_id, True)
        scriptcontext.doc.Objects.Replace(id, annotation)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:33,代码来源:geometry.py

示例3: TextObjectHeight

def TextObjectHeight(object_id, height=None):
    """Returns or modifies the height of a text object
    Parameters:
      object_id = the identifier of a text object
      height[opt] = the new text height.
    Returns:
      if height is not specified, the current text height
      if height is specified, the previous text height
      None if not successful, or on error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select text")
      if rs.IsText(obj):
      rs.TextObjectHeight( obj, 1.0 )
    See Also:
      AddText
      IsText
      TextObjectFont
      TextObjectPlane
      TextObjectPoint
      TextObjectStyle
      TextObjectText
    """
    annotation = rhutil.coercegeometry(object_id, True)
    if not isinstance(annotation, Rhino.Geometry.TextEntity):
        return scriptcontext.errorhandler()
    rc = annotation.TextHeight
    if height:
        annotation.TextHeight = height
        id = rhutil.coerceguid(object_id, True)
        scriptcontext.doc.Objects.Replace(id, annotation)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:33,代码来源:geometry.py

示例4: TextObjectPlane

def TextObjectPlane(object_id, plane=None):
    """Returns or modifies the plane used by a text object
    Parameters:
      object_id = the identifier of a text object
      plane[opt] = the new text object plane
    Returns:
      if a plane is not specified, the current plane if successful
      if a plane is specified, the previous plane if successful
      None if not successful, or on Error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select text")
      if rs.IsText(obj):
      plane = rs.ViewCPlane("Top")
      rs.TextObjectPlane( obj, plane )
    See Also:
      AddText
      IsText
      TextObjectFont
      TextObjectHeight
      TextObjectPoint
      TextObjectStyle
      TextObjectText
    """
    annotation = rhutil.coercegeometry(object_id, True)
    if not isinstance(annotation, Rhino.Geometry.TextEntity):
        return scriptcontext.errorhandler()
    rc = annotation.Plane
    if plane:
        annotation.Plane = rhutil.coerceplane(plane, True)
        id = rhutil.coerceguid(object_id, True)
        scriptcontext.doc.Objects.Replace(id, annotation)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:34,代码来源:geometry.py

示例5: TextDotText

def TextDotText(object_id, text=None):
    """Returns or modifies the text on a text dot object
    Parameters:
      object_id =tThe identifier of a text dot object
      text [opt] = a new string for the dot
    Returns:
      If text is not specified, the current text dot text
      If text is specified, the previous text dot text
      None if not successful, or on error
    Example:
      import rhinoscriptsyntax as rs
      id = rs.GetObject("Select text dot")
      if rs.IsTextDot(id):
      rs.TextDotText( id, "Rhino")
    See Also:
      AddTextDot
      IsTextDot
      TextDotPoint
    """
    textdot = rhutil.coercegeometry(object_id, True)
    if isinstance(textdot, Rhino.Geometry.TextDot):
        rc = textdot.Text
        if text is not None:
            if not isinstance(text, str): text = str(text)
            textdot.Text = text
            id = rhutil.coerceguid(object_id, True)
            scriptcontext.doc.Objects.Replace(id, textdot)
            scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:29,代码来源:geometry.py

示例6: TextObjectFont

def TextObjectFont(object_id, font=None):
    """Returns of modifies the font used by a text object
    Parameters:
      object_id = the identifier of a text object
      font [opt] = the new font face name
    Returns:
      if a font is not specified, the current font face name
      if a font is specified, the previous font face name
      None if not successful, or on error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select text")
      if rs.IsText(obj): rs.TextObjectFont(obj, "Arial")
    See Also:
      AddText
      IsText
      TextObjectHeight
      TextObjectPlane
      TextObjectPoint
      TextObjectStyle
      TextObjectText
    """
    annotation = rhutil.coercegeometry(object_id, True)
    if not isinstance(annotation, Rhino.Geometry.TextEntity):
        return scriptcontext.errorhandler()
    fontdata = scriptcontext.doc.Fonts[annotation.FontIndex]
    if fontdata is None: return scriptcontext.errorhandler()
    rc = fontdata.FaceName
    if font:
        index = scriptcontext.doc.Fonts.FindOrCreate( font, fontdata.Bold, fontdata.Italic )
        annotation.FontIndex = index
        id = rhutil.coerceguid(object_id, True)
        scriptcontext.doc.Objects.Replace(id, annotation)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:35,代码来源:geometry.py

示例7: TextDotHeight

def TextDotHeight(object_id, height=None):
    """Returns or modified the font height of a text dot
    Parameters:
      object_id = identifier of a text dot object
      height[opt] = new font height
    Returns:
      If height is not specified, the current text dot height
      If height is specified, the previous text dot height
      None on error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select text dot")
      if rs.IsTextDot(obj): rs.TextDotHeight(obj, 10.0)
    See Also:
      AddTextDot
      IsTextDot
      TextDotFont
      TextDotPoint
      TextDotText
    """
    textdot = rhutil.coercegeometry(object_id, True)
    if isinstance(textdot, Rhino.Geometry.TextDot):
        rc = textdot.FontHeight
        if height and height>0:
            textdot.FontHeight = height
            id = rhutil.coerceguid(object_id, True)
            scriptcontext.doc.Objects.Replace(id, textdot)
            scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:29,代码来源:geometry.py

示例8: TextDotPoint

def TextDotPoint(object_id, point=None):
    """Returns or modifies the location, or insertion point, on a text dot object
    Parameters:
      object_id = identifier of a text dot object
      point[opt] = A new 3D point location.
    Returns:
      If point is not specified, the current 3-D text dot location
      If point is specified, the previous 3-D text dot location
      None if not successful, or on error
    Example:
      import rhinoscriptsyntax as rs
      id = rs.GetObject("Select text dot")
      if rs.IsTextDot(id):
      point = rs.TestDotPoint(id)
      rs.AddPoint( point )
      rs.TextDotPoint(id, [0,0,0])
    See Also:
      AddTextDot
      IsTextDot
      TextDotText
    """
    textdot = rhutil.coercegeometry(object_id, True)
    if isinstance(textdot, Rhino.Geometry.TextDot):
        rc = textdot.Point
        if point:
            textdot.Point = rhutil.coerce3dpoint(point, True)
            id = rhutil.coerceguid(object_id, True)
            scriptcontext.doc.Objects.Replace(id, textdot)
            scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:30,代码来源:geometry.py

示例9: PointCoordinates

def PointCoordinates(object_id, point=None):
    """Returns or modifies the X, Y, and Z coordinates of a point object
    Parameters:
      object_id = The identifier of a point object
      point[opt] = A new 3D point location.
    Returns:
      If point is not specified, the current 3-D point location
      If point is specified, the previous 3-D point location
    Example:
      import rhinoscriptsyntax as rs
      id = rs.GetObject("Select point", rs.filter.point)
      point = rs.PointCoordinates(id)
    See Also:
      AddPoint
      IsPoint
    """
    point_geometry = rhutil.coercegeometry(object_id, True)
    if isinstance(point_geometry, Rhino.Geometry.Point):
        rc = point_geometry.Location
        if point:
            point = rhutil.coerce3dpoint(point, True)
            id = rhutil.coerceguid(object_id, True)
            scriptcontext.doc.Objects.Replace(id, point)
            scriptcontext.doc.Views.Redraw()
        return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:25,代码来源:geometry.py

示例10: 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

示例11: __objectbbox

 def __objectbbox(object, xform):
     geom = rhutil.coercegeometry(object, False)
     if not geom:
         pt = rhutil.coerce3dpoint(object, True)
         return Rhino.Geometry.BoundingBox(pt,pt)
     if xform: return geom.GetBoundingBox(xform)
     return geom.GetBoundingBox(True)
开发者ID:jehc,项目名称:rhinopython,代码行数:7,代码来源:geometry.py

示例12: 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

示例13: TextObjectStyle

def TextObjectStyle(object_id, style=None):
    """Returns or modifies the font style of a text object
    Parameters:
      object_id = the identifier of a text object
      style [opt] = the font style. Can be any of the following flags
         0 = Normal
         1 = Bold
         2 = Italic
    Returns:
      if style is not specified, the current font style
      if style is specified, the previous font style
      None if not successful, or on Error
    """
    annotation = rhutil.coercegeometry(object_id, True)
    if not isinstance(annotation, Rhino.Geometry.TextEntity):
        return scriptcontext.errorhandler()
    fontdata = scriptcontext.doc.Fonts[annotation.FontIndex]
    if fontdata is None: return scriptcontext.errorhandler()
    rc = 0
    if fontdata.Bold: rc += 1
    if fontdata.Italic: rc += 2
    if style is not None and style!=rc:
        index = scriptcontext.doc.Fonts.FindOrCreate( fontdata.FaceName, (style&1)==1, (style&2)==2 )
        annotation.FontIndex = index
        id = rhutil.coerceguid(object_id, True)
        scriptcontext.doc.Objects.Replace(id, annotation)
        scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:Agnestan,项目名称:rhinopython,代码行数:28,代码来源:geometry.py

示例14: PointCloudHasPointColors

def PointCloudHasPointColors(object_id):
    """Verifies that a point cloud has point colors
    Parameters:
      object_id: the point cloud object's identifier
    Returns:
      True if cloud has point colors, otherwise False
    """
    pc = rhutil.coercegeometry(object_id, True)
    if isinstance(pc, Rhino.Geometry.PointCloud): return pc.ContainsColors
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:9,代码来源:geometry.py

示例15: PointCloudHasHiddenPoints

def PointCloudHasHiddenPoints(object_id):
    """Verifies that a point cloud has hidden points
    Parameters:
      object_id: the point cloud object's identifier
    Returns:
      True if cloud has hidden points, otherwise False
    """
    pc = rhutil.coercegeometry(object_id, True)
    if isinstance(pc, Rhino.Geometry.PointCloud): return pc.HiddenPointCount>0
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:9,代码来源:geometry.py


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