Exemple #1
0
def TransformProfile(object, pt1, pt2):
    normal = rs.VectorSubtract(pt1, pt2)
    normal = rs.VectorUnitize(normal)

    plane = rs.PlaneFromNormal(pt1, normal)

    transformation = rs.XformRotation1((rs.WorldXYPlane), normal)
    profiletras = rs.TransformObject(object, transformation, True)
Exemple #2
0
def vrep_pose_from_plane(plane):
    """Creates a vrep-compatible transformation matrix from a Rhino/Grasshopper
    plane.

    This function might need rework as the source of the 90-deg Y rotation
    need is not entirely clear to me (related to the RFL model mismatch).
    """
    translation_matrix = rs.XformTranslation(((plane[0][0]), (plane[0][1]), plane[0][2]))
    plane_start = rs.PlaneFromFrame(rs.AddPoint(0, 0, 0), rs.AddPoint(1, 0, 0), rs.AddPoint(0, 1, 0))
    plane_end = rs.PlaneFromFrame(rs.AddPoint(0, 0, 0), rs.AddPoint(plane[1][0], (plane[1][1]), plane[1][2]), rs.AddPoint(plane[2][0], plane[2][1], plane[2][2]))
    rotation_matrix = rs.XformRotation1(plane_start, plane_end)
    matrix = rs.XformMultiply(translation_matrix, rotation_matrix)
    return [matrix.M00, matrix.M01, matrix.M02, matrix.M03,
            matrix.M10, matrix.M11, matrix.M12, matrix.M13,
            matrix.M20, matrix.M21, matrix.M22, matrix.M23]
Exemple #3
0
def SampleArrayCrv():

    obj_ids = rs.GetObjects("Select objects to array")
    if not obj_ids: return

    base_pt = rs.GetPoint("Base point")
    if not base_pt: return

    plane = rs.ViewCPlane()
    plane.Origin = base_pt

    crv_id = rs.GetObject("Select path curve")
    if not crv_id: return

    count = rs.GetInteger("Number of items", 2, 2)
    if not count: return

    if rs.IsCurveClosed(crv_id): count -= 1

    crv_t = rs.DivideCurve(crv_id, count, False, False)
    for t in crv_t:
        frame = rs.CurveFrame(crv_id, t)
        xform = rs.XformRotation1(plane, frame)
        rs.TransformObjects(obj_ids, xform, True)