• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utility.coercemesh函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: MeshBooleanSplit

def MeshBooleanSplit(input0, input1, delete_input=True):
    """Performs a boolean split operation on two sets of input meshes
    Parameters:
      input0, input1 = identifiers of meshes
      delete_input[opt] = delete the input meshes
    Returns:
      list of identifiers of new meshes on success
      None on error
    """
    id = rhutil.coerceguid(input0)
    if id: input0 = [id]
    id = rhutil.coerceguid(input1)
    if id: input1 = [id]
    meshes0 = [rhutil.coercemesh(id, True) for id in input0]
    meshes1 = [rhutil.coercemesh(id, True) for id in input1]
    if not meshes0 or not meshes1: raise ValueError("no meshes to work with")
    newmeshes = Rhino.Geometry.Mesh.CreateBooleanSplit(meshes0, meshes1)
    rc = []
    for mesh in newmeshes:
        id = scriptcontext.doc.Objects.AddMesh(mesh)
        if id!=System.Guid.Empty: rc.append(id)
    if rc and delete_input:
        input = input0 + input1
        for id in input:
            id = rhutil.coerceguid(id, True)
            scriptcontext.doc.Objects.Delete(id, True)
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:nhfoley,项目名称:rhinopython,代码行数:28,代码来源:mesh.py


示例2: MeshOutline

def MeshOutline(object_ids, view=None):
    """Creates polyline curve outlines of mesh objects
    Parameters:
      objects_ids = identifiers of meshes to outline
      view(opt) = view to use for outline direction
    Returns:
      list of polyline curve id on success
    Example:
      import rhinoscriptsyntax as rs
      objs = rs.GetObjects("Select mesh objects to outline", rs.filter.mesh)
      if objs: rs.MeshOutline(objs)
    See Also:
      IsMesh
    """
    viewport = __viewhelper(view).MainViewport
    meshes = []
    mesh = rhutil.coercemesh(object_ids, False)
    if mesh: meshes.append(mesh)
    else: meshes = [rhutil.coercemesh(id,True) for id in object_ids]
    rc = []
    for mesh in meshes:
        polylines = mesh.GetOutlines(viewport)
        if not polylines: continue
        for polyline in polylines:
            id = scriptcontext.doc.Objects.AddPolyline(polyline)
            rc.append(id)
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:28,代码来源:mesh.py


示例3: MeshMeshIntersection

def MeshMeshIntersection(mesh1, mesh2, tolerance=None):
    """Calculates the intersections of a mesh object with another mesh object
    Parameters:
      mesh1, mesh2 = identifiers of meshes
      tolerance[opt] = the intersection tolerance
    Returns:
      List of 3d point arrays that define the vertices of the intersection curves
    """
    mesh1 = rhutil.coercemesh(mesh1, True)
    mesh2 = rhutil.coercemesh(mesh2, True)
    if tolerance is None: tolerance = Rhino.RhinoMath.ZeroTolerance
    polylines = Rhino.Geometry.Intersect.Intersection.MeshMeshAccurate(mesh1, mesh2, tolerance)
    if polylines: return list(polylines)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:13,代码来源:mesh.py


示例4: IsMeshClosed

def IsMeshClosed(object_id):
    """Verifies a mesh object is closed
    Parameters:
      object_id = identifier of a mesh object
    """
    mesh = rhutil.coercemesh(object_id, True)
    return mesh.IsClosed
开发者ID:nhfoley,项目名称:rhinopython,代码行数:7,代码来源:mesh.py


示例5: MeshArea

def MeshArea(object_ids):
    """Returns the approximate area of one or more mesh objects
    Parameters:
      object_ids = identifiers of one or more mesh objects
    Returns:
      a list containing 3 numbers if successful where
        element[0] = number of meshes used in calculation
        element[1] = total area of all meshes
        element[2] = the error estimate
      None if not successful
    """
    id = rhutil.coerceguid(object_ids)
    if id: object_ids = [object_ids]
    meshes_used = 0
    total_area = 0.0
    error_estimate = 0.0
    for id in object_ids:
        mesh = rhutil.coercemesh(id, True)
        if mesh:
            mp = Rhino.Geometry.AreaMassProperties.Compute(mesh)
            if mp:
                meshes_used += 1
                total_area += mp.Area
                error_estimate += mp.AreaError
    if meshes_used==0: return scriptcontext.errorhandler()
    return meshes_used, total_area, error_estimate
开发者ID:nhfoley,项目名称:rhinopython,代码行数:26,代码来源:mesh.py


示例6: PullCurveToMesh

def PullCurveToMesh(mesh_id, curve_id):
    """Pulls a curve to a mesh. The function makes a polyline approximation of
    the input curve and gets the closest point on the mesh for each point on
    the polyline. Then it "connects the points" to create a polyline on the mesh
    Parameters:
      mesh_id = identifier of mesh that pulls
      curve_id = identifier of curve to pull
    Returns:
      Guid of new curve on success
      None on error
    Example:
      import rhinoscriptsyntax as rs
      mesh = rs.GetObject("Select mesh that pulls", rs.filter.mesh)
      curve = rs.GetObject("Select curve to pull", rs.filter.curve)
      rs.PullCurveToMesh( mesh, curve )
    See Also:
      IsMesh
    """
    mesh = rhutil.coercemesh(mesh_id, True)
    curve = rhutil.coercecurve(curve_id, -1, True)
    tol = scriptcontext.doc.ModelAbsoluteTolerance
    polyline = curve.PullToMesh(mesh, tol)
    if not polyline: return scriptcontext.errorhandler()
    rc = scriptcontext.doc.Objects.AddCurve(polyline)
    if rc==System.Guid.Empty: raise Exception("unable to add polyline to document")
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:27,代码来源:mesh.py


示例7: ProjectPointToMesh

def ProjectPointToMesh(points, mesh_ids, direction):
    """Projects one or more points onto one or more meshes
    Parameters:
      points = one or more 3D points
      mesh_ids = identifiers of one or more meshes
      direction = direction vector to project the points
    Returns:
     list of projected points on success
    Example:
      import rhinoscriptsyntax as rs
      mesh = rs.GetObject("Select mesh to project onto", rs.filter.mesh)
      objects = rs.GetObjects("Select points to project", rs.filter.point)
      points = [rs.PointCoordinates(obj) for obj in objects]
      # project down...
      results = rs.ProjectPointToMesh(points, mesh, (0,0,-1))
      rs.AddPoints( results )
    See Also:
      ProjectCurveToMesh
      ProjectCurveToSurface
      ProjectPointToSurface
    """
    pts = rhutil.coerce3dpointlist(points, False)
    if pts is None:
        pts = [rhutil.coerce3dpoint(points, True)]
    direction = rhutil.coerce3dvector(direction, True)
    id = rhutil.coerceguid(mesh_ids, False)
    if id: mesh_ids = [id]
    meshes = [rhutil.coercemesh(id, True) for id in mesh_ids]
    tolerance = scriptcontext.doc.ModelAbsoluteTolerance
    rc = Rhino.Geometry.Intersect.Intersection.ProjectPointsToMeshes(meshes, pts, direction, tolerance)
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:31,代码来源:pointvector.py


示例8: MeshHasVertexColors

def MeshHasVertexColors(object_id):
    """Verifies a mesh object has vertex colors
    Parameters:
      object_id = identifier of a mesh object
    """
    mesh = rhutil.coercemesh(object_id, True)
    return mesh.VertexColors.Count>0
开发者ID:nhfoley,项目名称:rhinopython,代码行数:7,代码来源:mesh.py


示例9: MeshQuadCount

def MeshQuadCount(object_id):
    """Returns the number of quad faces of a mesh object
    Parameters:
      object_id = identifier of a mesh object
    """
    mesh = rhutil.coercemesh(object_id, True)
    return mesh.Faces.QuadCount
开发者ID:nhfoley,项目名称:rhinopython,代码行数:7,代码来源:mesh.py


示例10: MeshFaceNormals

def MeshFaceNormals(mesh_id):
    """Returns the face unit normal for each face of a mesh object
    Parameters:
      mesh_id = identifier of a mesh object
    Returns:
      List of 3D vectors that define the face unit normals of the mesh
      None on error    
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select mesh", rs.filter.mesh)
      normals = rs.MeshFaceNormals(obj)
      if normals:
      for vector in normals: print vector
    See Also:
      MeshHasFaceNormals
      MeshFaceCount
      MeshFaces
    """
    mesh = rhutil.coercemesh(mesh_id, True)
    if mesh.FaceNormals.Count != mesh.Faces.Count:
        mesh.FaceNormals.ComputeFaceNormals()
    rc = []
    for i in xrange(mesh.FaceNormals.Count):
        normal = mesh.FaceNormals[i]
        rc.append(Rhino.Geometry.Vector3d(normal))
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:26,代码来源:mesh.py


示例11: MeshFaces

def MeshFaces(object_id, face_type=True):
    """Returns the face vertices of a mesh
    Parameters:
      object_id = identifier of a mesh object
      face_type[opt] = The face type to be returned. True = both triangles
        and quads. False = only triangles
    Returns:
      a list of 3D points that define the face vertices of the mesh. If
      face_type is True, then faces are returned as both quads and triangles
      (4 3D points). For triangles, the third and fourth vertex will be
      identical. If face_type is False, then faces are returned as only
      triangles(3 3D points). Quads will be converted to triangles.
    """
    mesh = rhutil.coercemesh(object_id, True)
    rc = []
    for i in xrange(mesh.Faces.Count):
        getrc, p0, p1, p2, p3 = mesh.Faces.GetFaceVertices(i)
        p0 = Rhino.Geometry.Point3d(p0)
        p1 = Rhino.Geometry.Point3d(p1)
        p2 = Rhino.Geometry.Point3d(p2)
        p3 = Rhino.Geometry.Point3d(p3)
        rc.append( p0 )
        rc.append( p1 )
        rc.append( p2 )
        if face_type:
            rc.append(p3)
        else:
            if p2!=p3:
                rc.append( p2 )
                rc.append( p3 )
                rc.append( p0 )
    return rc
开发者ID:nhfoley,项目名称:rhinopython,代码行数:32,代码来源:mesh.py


示例12: MeshBooleanUnion

def MeshBooleanUnion(mesh_ids, delete_input=True):
    """Performs boolean union operation on a set of input meshes
    Parameters:
      mesh_ids = identifiers of meshes
      delete_input[opt] = delete the input meshes
    Returns:
      list of identifiers of new meshes
    Example:
      import rhinoscriptsyntax as rs
      input = rs.GetObjects("Select meshes to union", rs.filter.mesh)
      if input: rs.MeshBooleanUnion(input)
    See Also:
      MeshBooleanDifference
      MeshBooleanIntersection
      MeshBooleanSplit
    """
    if len(mesh_ids)<2: raise ValueError("mesh_ids must contain at least 2 meshes")
    meshes = [rhutil.coercemesh(id, True) for id in mesh_ids]
    newmeshes = Rhino.Geometry.Mesh.CreateBooleanUnion(meshes)
    rc = []
    for mesh in newmeshes:
        id = scriptcontext.doc.Objects.AddMesh(mesh)
        if id!=System.Guid.Empty: rc.append(id)
    if rc and delete_input:
        for id in mesh_ids:
            id = rhutil.coerceguid(id, True)
            scriptcontext.doc.Objects.Delete(id, True)
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:29,代码来源:mesh.py


示例13: MeshClosestPoint

def MeshClosestPoint(object_id, point, maximum_distance=None):
    """Returns the point on a mesh that is closest to a test point
    Parameters:
      object_id = identifier of a mesh object
      point = point to test
      maximum_distance[opt] = upper bound used for closest point calculation.
        If you are only interested in finding a point Q on the mesh when
        point.DistanceTo(Q) < maximum_distance, then set maximum_distance to
        that value
    Returns:
      Tuple containing the results of the calculation where
        element[0] = the 3-D point on the mesh
        element[1] = the index of the mesh face on which the 3-D point lies
      None on error
    Example:
      import rhinocriptsyntax as rs
      obj = rs.GetObject("Select mesh", rs.filter.mesh)
      point = rs.GetPoint("Pick test point")
      intersect = rs.MeshClosestPoint(obj, point)
      if intersect: rs.AddPoint(intersect)
    See Also:
      MeshFaceCount
      MeshFaces
    """
    mesh = rhutil.coercemesh(object_id, True)
    point = rhutil.coerce3dpoint(point, True)
    tolerance=maximum_distance if maximum_distance else 0.0
    face, closest_point = mesh.ClosestPoint(point, tolerance)
    if face<0: return scriptcontext.errorhandler()
    return closest_point, face
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:30,代码来源:mesh.py


示例14: MeshArea

def MeshArea(object_ids):
    """Returns approximate area of one or more mesh objects
    Parameters:
      object_ids = identifiers of one or more mesh objects
    Returns:
      list containing 3 numbers if successful where
        element[0] = number of meshes used in calculation
        element[1] = total area of all meshes
        element[2] = the error estimate
      None if not successful
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select mesh", rs.filter.mesh )
      if obj:
      area_rc = rs.MeshArea(obj)
      if area_rc: print "Mesh area:", area_rc[1]
    See Also:
      MeshVolume
    """
    id = rhutil.coerceguid(object_ids)
    if id: object_ids = [object_ids]
    meshes_used = 0
    total_area = 0.0
    error_estimate = 0.0
    for id in object_ids:
        mesh = rhutil.coercemesh(id, True)
        if mesh:
            mp = Rhino.Geometry.AreaMassProperties.Compute(mesh)
            if mp:
                meshes_used += 1
                total_area += mp.Area
                error_estimate += mp.AreaError
    if meshes_used==0: return scriptcontext.errorhandler()
    return meshes_used, total_area, error_estimate
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:34,代码来源:mesh.py


示例15: JoinMeshes

def JoinMeshes(object_ids, delete_input=False):
    """Joins two or or more mesh objects together
    Parameters:
      object_ids = identifiers of two or more mesh objects
      delete_input[opt] = delete input after joining
    Returns:
      identifier of newly created mesh on success
    Example:
      import rhinoscriptsyntax as rs
      objs = rs.GetObjects("Select meshes to join", rs.filter.mesh)
      if objs and len(objs)>1: rs.JoinMeshes(objs, True)
    See Also:
      JoinCurves
      JoinSurfaces
    """
    meshes = [rhutil.coercemesh(id,True) for id in object_ids]
    joined_mesh = Rhino.Geometry.Mesh()
    for mesh in meshes: joined_mesh.Append(mesh)
    rc = scriptcontext.doc.Objects.AddMesh(joined_mesh)
    if delete_input:
        for id in object_ids:
            guid = rhutil.coerceguid(id)
            scriptcontext.doc.Objects.Delete(guid,True)
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:25,代码来源:mesh.py


示例16: IsPointOnMesh

def IsPointOnMesh(object_id, point):
    """Verifies a point is on a mesh
    Parameters:
      object_id = identifier of a mesh object
      point = test point
    Returns:
      True if successful, otherwise False.  None on error.
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select a mesh")
      if rs.IsMesh(obj):
      point = rs.GetPointOnMesh(strObject, "Pick a test point")
      if point:
      if rs.IsPointOnMesh(obj, point):
      print "The point is on the mesh"
      else:
      print "The point is not on the mesh"
    See Also:
      IsMesh
      MeshClosestPoint
    """
    mesh = rhutil.coercemesh(object_id, True)
    point = rhutil.coerce3dpoint(point, True)
    max_distance = Rhino.RhinoMath.SqrtEpsilon
    face, pt = mesh.ClosestPoint(point, max_distance)
    return face>=0
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:26,代码来源:mesh.py


示例17: PullPoints

def PullPoints(object_id, points):
    """Pulls an array of points to a surface or mesh object. For more
    information, see the Rhino help file Pull command
    Parameters:
      object_id = the identifier of the surface or mesh object that pulls
      points = list of 3D points
    Returns:
      list of 3D points
    Example:
      import rhinoscriptsyntax as rs
      surface = rs.GetObject("Select surface that pulls", rs.filter.surface)
      objects = rs.GetObjects("Select points to pull", rs.filter.point)
      points = [rs.PointCoordinates(obj) for obj in objects]
      results = rs.PullPoints( surface, points )
      rs.AddPoints( results )
    See Also:
      PullCurve
    """
    id = rhutil.coerceguid(object_id, True)
    points = rhutil.coerce3dpointlist(points, True)
    mesh = rhutil.coercemesh(id, False)
    if mesh:
        points = mesh.PullPointsToMesh(points)
        return list(points)
    brep = rhutil.coercebrep(id, False)
    if brep and brep.Faces.Count==1:
        tolerance = scriptcontext.doc.ModelAbsoluteTolerance
        points = brep.Faces[0].PullPointsToFace(points, tolerance)
        return list(points)
    return []
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:30,代码来源:pointvector.py


示例18: MeshFaceVertices

def MeshFaceVertices(object_id):
    """Returns the vertex indices of all faces of a mesh object
    Parameters:
      object_id = identifier of a mesh object
    Returns:
      A list containing tuples of 4 numbers that define the vertex indices for
      each face of the mesh. Both quad and triangle faces are returned. If the
      third and fourth vertex indices are identical, the face is a triangle.
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select mesh", rs.filter.mesh)
      faceVerts = rs.MeshFaceVertices( obj )
      if faceVerts:
      for count, face in enumerate(faceVerts):
      print "face(", count, ") = (", face[0], ",", face[1], ",", face[2], ",", face[3], ")"
    See Also:
      IsMesh
      MeshFaceCount
      MeshFaces
    """
    mesh = rhutil.coercemesh(object_id, True)
    rc = []
    for i in xrange(mesh.Faces.Count):
        face = mesh.Faces.GetFace(i)
        rc.append( (face.A, face.B, face.C, face.D) )
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:26,代码来源:mesh.py


示例19: MeshFaceCount

def MeshFaceCount(object_id):
    """Returns the total face count of a mesh object
    Parameters:
      object_id = identifier of a mesh object
    """
    mesh = rhutil.coercemesh(object_id, True)
    return mesh.Faces.Count
开发者ID:nhfoley,项目名称:rhinopython,代码行数:7,代码来源:mesh.py


示例20: MeshNakedEdgePoints

def MeshNakedEdgePoints(object_id):
    """Identifies the naked edge points of a mesh object. This function shows
    where mesh vertices are not completely surrounded by faces. Joined
    meshes, such as are made by MeshBox, have naked mesh edge points where
    the sub-meshes are joined
    Parameters:
      object_id = identifier of a mesh object
    Returns:
      List of boolean values that represent whether or not a mesh vertex is
      naked or not. The number of elements in the list will be equal to
      the value returned by MeshVertexCount. In which case, the list will
      identify the naked status for each vertex returned by MeshVertices
      None on error
    Example:
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select mesh", rs.filter.mesh)
      vertices = rs.MeshVertices( obj )
      naked = rs.MeshNakedEdgePoints( obj )
      for i, vertex in enumerate(vertices):
      if naked[i]: rs.AddPoint(vertex)
    See Also:
      IsMesh
      MeshVertexCount
      MeshVertices
    """
    mesh = rhutil.coercemesh(object_id, True)
    rc = mesh.GetNakedEdgePointStatus()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:28,代码来源:mesh.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utility.coerceplane函数代码示例发布时间:2022-05-26
下一篇:
Python utility.coerceguid函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap