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


Python utility.coerce3dpointlist函数代码示例

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


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

示例1: OrientObject

def OrientObject(object_id, reference, target, flags=0):
    """Orients a single object based on input points
    Parameters:
        object_id = String or Guid. The identifier of an object
        reference = list of 3-D reference points
        target = list of 3-D target points
        flags[opt]: 1 = copy object
                    2 = scale object
    """
    object_id = rhutil.coerceguid(object_id, True)
    from_array = rhutil.coerce3dpointlist(reference)
    to_array = rhutil.coerce3dpointlist(target)
    if from_array is None or to_array is None:
        raise ValueError("Could not convert reference or target to point list")
    from_count = len(from_array)
    to_count = len(to_array)
    if from_count<2 or to_count<2: raise Exception("point lists must have at least 2 values")

    copy = ((flags & 1) == 1)
    scale = ((flags & 2) == 2)
    xform_final = None
    if from_count>2 and to_count>2:
        #Orient3Pt
        from_plane = Rhino.Geometry.Plane(from_array[0], from_array[1], from_array[2])
        to_plane = Rhino.Geometry.Plane(to_array[0], to_array[1], to_array[2])
        if not from_plane.IsValid or not to_plane.IsValid:
            raise Exception("unable to create valid planes from point lists")
        xform_final = Rhino.Geometry.Transform.PlaneToPlane(from_plane, to_plane)
    else:
        #Orient2Pt
        xform_move = Rhino.Geometry.Transform.Translation( to_array[0]-from_array[0] )
        xform_scale = Rhino.Geometry.Transform.Identity
        v0 = from_array[1] - from_array[0]
        v1 = to_array[1] - to_array[0]
        if scale:
            len0 = v0.Length
            len1 = v1.Length
            if len0<0.000001 or len1<0.000001: raise Exception("vector lengths too short")
            scale = len1 / len0
            if abs(1.0-scale)>=0.000001:
                plane = Rhino.Geometry.Plane(from_array[0], v0)
                xform_scale = Rhino.Geometry.Transform.Scale(plane, scale, scale, scale)
        v0.Unitize()
        v1.Unitize()
        xform_rotate = Rhino.Geometry.Transform.Rotation(v0, v1, from_array[0])
        xform_final = xform_move * xform_scale * xform_rotate
    rc = scriptcontext.doc.Objects.Transform(object_id, xform_final, not copy)
    if rc==System.Guid.Empty: return scriptcontext.errorhandler()
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:50,代码来源:object.py

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

示例3: ProjectPointToSurface

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

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

示例5: PointsAreCoplanar

def PointsAreCoplanar(points, tolerance=1.0e-12):
    """Verifies that a list of 3D points are coplanar
    Parameters:
      points = list of 3D points
      tolerance[opt] = tolerance to use when verifying
    Returns:
      True or False
    Example:
      import rhinoscriptsyntax as rs
      def SurfacesAreCoplanar(srf1, srf2):
      if( not rs.IsSurface(srf1) or not rs.IsSurface(srf2) ): return False
      pts1 = rs.SurfacePoints(srf1)
      pts2 = rs.SurfacePoints(srf2)
      if( pts1==None or pts2==None ): return False
      pts1.extend(pts2)
      return rs.PointsAreCoplanar(pts1)
      
      x = rs.GetObject( "First surface to test", rs.filter.surface)
      y = rs.GetObject( "Second surface to test", rs.filter.surface)
      print SurfacesAreCoplanar(x, y)
    See Also:
      IsPoint
      IsPointCloud
      PointCoordinates
    """
    points = rhutil.coerce3dpointlist(points, True)
    return Rhino.Geometry.Point3d.ArePointsCoplanar(points, tolerance)
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:27,代码来源:pointvector.py

示例6: PointArrayClosestPoint

def PointArrayClosestPoint(points, test_point):
    """Finds the point in a list of 3D points that is closest to a test point
    Parameters:
      points = list of points
      test_point = the point to compare against
    Returns:
      index of the element in the point list that is closest to the test point
    Example:
      import rhinoscriptsyntax as rs
      cloud= rs.GetObject("Select point cloud")
      if cloud:
      point = rs.GetPoint("Point to test")
      if point:
      cloud = rs.PointCloudPoints(cloud)
      index = rs.PointArrayClosestPoint(cloud, point)
      if index is not None:
      point_id = rs.AddPoint(cloud[index])
      rs.SelectObject( point_id )
    See Also:
      CurveClosestPoint
      SurfaceClosestPoint
    """
    points = rhutil.coerce3dpointlist(points, True)
    test_point = rhutil.coerce3dpoint(test_point, True)
    index = Rhino.Collections.Point3dList.ClosestIndexInList(points, test_point)
    if index>=0: return index
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:26,代码来源:pointvector.py

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

示例8: AddPointCloud

def AddPointCloud(points, colors=None):
    """Adds point cloud object to the document
    Parameters:
      points = list of values where every multiple of three represents a point
      colors[opt] = list of colors to apply to each point
    Returns:
      identifier of point cloud on success
    Example:
      import rhinoscriptsyntax as rs
      points = (0,0,0), (1,1,1), (2,2,2), (3,3,3)
      rs.AddPointCloud(points)
    See Also:
      IsPointCloud
      PointCloudCount
      PointCloudPoints
    """
    points = rhutil.coerce3dpointlist(points, True)
    if colors and len(colors)==len(points):
        pc = Rhino.Geometry.PointCloud()
        for i in range(len(points)):
            color = rhutil.coercecolor(colors[i],True)
            pc.Add(points[i],color)
        points = pc
    rc = scriptcontext.doc.Objects.AddPointCloud(points)
    if rc==System.Guid.Empty: raise Exception("unable to add point cloud to document")
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:27,代码来源:geometry.py

示例9: PointsAreCoplanar

def PointsAreCoplanar(points, tolerance=1.0e-12):
    """Verifies that a list of 3D points are coplanar
    Parameters:
      points = list of 3D points
      tolerance[opt] = tolerance to use when verifying
    Returns:
      True or False
    """
    points = rhutil.coerce3dpointlist(points, True)
    return Rhino.Geometry.Point3d.ArePointsCoplanar(points, tolerance)
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:10,代码来源:pointvector.py

示例10: PlaneFitFromPoints

def PlaneFitFromPoints(points):
    """Returns a plane that was fit through an array of 3D points.
    Parameters:
    points = An array of 3D points.
    Returns: 
      The plane if successful
      None if not successful
    """
    points = rhutil.coerce3dpointlist(points, True)
    rc, plane = Rhino.Geometry.Plane.FitPlaneToPoints(points)
    if rc==Rhino.Geometry.PlaneFitResult.Success: return plane
开发者ID:jehc,项目名称:rhinopython,代码行数:11,代码来源:plane.py

示例11: PointArrayTransform

def PointArrayTransform(points, xform):
    """Transforms a list of 3D points
    Parameters:
      points = list of 3D points
      xform = transformation to apply
    Returns:
      list of transformed points on success
    """
    points = rhutil.coerce3dpointlist(points, True)
    xform = rhutil.coercexform(xform, True)
    return [xform*point for point in points]
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:11,代码来源:pointvector.py

示例12: AddPoints

def AddPoints(points):
    """Adds one or more point objects to the document
    Parameters:
      points = list of points
    Returns:
      list of Guid identifiers of the new objects on success
    """
    points = rhutil.coerce3dpointlist(points, True)
    rc = [scriptcontext.doc.Objects.AddPoint(point) for point in points]
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:Agnestan,项目名称:rhinopython,代码行数:11,代码来源:geometry.py

示例13: PointArrayClosestPoint

def PointArrayClosestPoint(points, test_point):
    """Finds the point in a list of 3D points that is closest to a test point
    Parameters:
      points = list of points
      test_point = the point to compare against
    Returns:
      index of the element in the point list that is closest to the test point
    """
    points = rhutil.coerce3dpointlist(points, True)
    test_point = rhutil.coerce3dpoint(test_point, True)
    index = Rhino.Collections.Point3dList.ClosestIndexInList(points, test_point)
    if index>=0: return index
开发者ID:acormier,项目名称:rhinoscriptsyntax,代码行数:12,代码来源:pointvector.py

示例14: AddPointCloud

def AddPointCloud(points):
    """Adds point cloud object to the document
    Parameters:
      points = list of values where every multiple of three represents a point
    Returns:
      identifier of point cloud on success
    """
    points = rhutil.coerce3dpointlist(points, True)
    rc = scriptcontext.doc.Objects.AddPointCloud(points)
    if rc==System.Guid.Empty: raise Exception("unable to add point cloud to document")
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:Agnestan,项目名称:rhinopython,代码行数:12,代码来源:geometry.py

示例15: AddLeader

def AddLeader(points, view_or_plane=None, text=None):
    """Adds a leader to the document. Leader objects are planar.
    The 3D points passed to this function should be co-planar
    Parameters:
      points = list of (at least 2) 3D points
      view_or_plane [opt] = If a view is specified, points will be constrained
        to the view's construction plane. If a view is not specified, points
        will be constrained to a plane fit through the list of points
      text [opt] = leader's text string
    Returns:
      identifier of the new leader on success
      None on error
    Example:
      import rhinoscriptsyntax as rs
      points = rs.GetPoints(True, False, "Select leader points")
      if points: rs.AddLeader( points )
    See Also:
      IsLeader
      LeaderText
    """
    points = rhutil.coerce3dpointlist(points)
    if points is None or len(points)<2: raise ValueError("points must have at least two items")
    rc = System.Guid.Empty
    view = None
    if text and not isinstance(text, str): 
        text = str(text)

    if not view_or_plane:
        if len(points) == 2:
            plane = scriptcontext.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
            rc = scriptcontext.doc.Objects.AddLeader(text, plane, [Rhino.Geometry.Point2d(p.X, p.Y) for p in points])
        else:
            rc = scriptcontext.doc.Objects.AddLeader(text, points)
    else:
        plane = rhutil.coerceplane(view_or_plane)
        if not plane:
            view = __viewhelper(view_or_plane)
            plane = view.ActiveViewport.ConstructionPlane()
        points2d = []
        for point in points:
            cprc, s, t = plane.ClosestParameter( point )
            if not cprc: return scriptcontext.errorhandler()
            points2d.append( Rhino.Geometry.Point2d(s,t) )
        if text is None:
            rc = scriptcontext.doc.Objects.AddLeader(plane, points2d)
        else:
            if not isinstance(text, str): text = str(text)
            rc = scriptcontext.doc.Objects.AddLeader(text, plane, points2d)
    if rc==System.Guid.Empty: return scriptcontext.errorhandler()
    scriptcontext.doc.Views.Redraw()
    return rc
开发者ID:itrowa,项目名称:rhinoscriptsyntax,代码行数:51,代码来源:dimension.py


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