예제 #1
0
def get_point_list():
    '''
    Returns the object that meshes will be arrayed around.
    '''
    point_cloud = rs.GetObject('Select point cloud', rs.filter.pointcloud)
    point_list = rs.PointCloudPoints(point_cloud)
    return point_list
예제 #2
0
def vectorfield():
    cloud_id = rs.GetObject("Input pointcloud", 2, True, True)
    if cloud_id is None: return
    listpoints = rs.PointCloudPoints(cloud_id)
    base_point = rs.GetPoint("Vector field base point")
    if base_point is None: return
    for point in listpoints:
        vecbase = rs.VectorCreate(point, base_point)
        vecdir = rs.VectorCrossProduct(vecbase, (0, 0, 1))
        if vecdir:
            vecdir = rs.VectorUnitize(vecdir)
            vecdir = rs.VectorScale(vecdir, 2.0)
            AddVector(vecdir, point)
예제 #3
0
def ExportPoints(objectIds, filename):
    if (objectIds == None): return
    if (filename == None): return
    """
    Using a 'with' loop to open the file, we do not need to clean
    up or close the file when we are done, Python takes care of it.
    Here, we'll write the points with a line break, otherwise
    all the points will end up on one line.
    """
    with open(filename, "w") as file:
        for id in objectIds:
            #process point clouds
            if (rs.IsPointCloud(id)):
                points = rs.PointCloudPoints(id)
                for pt in points:
                    # convert the point list to a string,
                    # add a new line character, and write to the file
                    file.write(str(pt) + "\n")
            elif (rs.IsPoint(id)):
                point = rs.PointCoordinates(id)
                file.write(str(point) + "\n")
예제 #4
0
def ExportPoints():
    #Get the points to export
    objectIds = rs.GetObjects("Select Points",
                              rs.filter.point | rs.filter.pointcloud, True,
                              True)
    if (objectIds == None): return

    #Get the filename to create
    filter = "Text File (*.txt)|*.txt|All Files (*.*)|*.*||"
    filename = rs.SaveFileName("Save point coordinates as", filter)
    if (filename == None): return

    file = open(filename, "w")
    for id in objectIds:
        #process point clouds
        if (rs.IsPointCloud(id)):
            points = rs.PointCloudPoints(id)
            for pt in points:
                file.writeline(str(pt))
        elif (rs.IsPoint(id)):
            point = rs.PointCoordinates(id)
            file.writeline(str(point))
    file.close()
예제 #5
0
    filter=32,  # mesh
    preselect=False,
    select=False)

# ask user to select point clouds
cloud_ids = rs.GetObjects(message="Select Point Clouds",
                          filter=2,
                          preselect=True,
                          select=True)

# have the point clouds projected onto the mesh
# and each result made into another cloud
new_cloud_ids = []
for cloud in cloud_ids:

    ptsList = rs.PointCloudPoints(cloud)

    pts_proj = rs.ProjectPointToMesh(ptsList, mesh_id, [0, 0, -10])
    new_cloud_ids.append(rs.AddPointCloud(pts_proj))

list_vk = []
for cloud in new_cloud_ids:
    ptsList = rs.PointCloudPoints(cloud)

    # calculate the vector dispersion
    list_vk.append(PtCldVecDisp(ptsList))

# return results in format ready to paste into Excel
str_vk = ""
for n in list_vk:
    str_vk = str_vk + str(n)
# -----        Main          -----

# ask user to select reef mesh
mesh_id = rs.GetObject(message="Select the reef mesh",
                           filter = 32, # mesh
                           preselect = False, 
                           select = False)

# ask user to select point cloud (copied from 3d2d_helper.3dm) 
cloud_ids = rs.GetObjects(message="Select Point Cloud",
                       filter = 2, 
                       preselect = True, 
                       select = True)

# project point cloud onto grid, forming a new point cloud
cloud_ptsList = rs.PointCloudPoints(cloud_ids[0])
proj_ptsList = rs.ProjectPointToMesh(cloud_ptsList, mesh_id, [0, 0, -10])
proj_cloud_id = rs.AddPointCloud(proj_ptsList)

# clean up points (round and take highest Z-points) 
[ptsXYZ, ptsXY] = RoundPts(proj_ptsList) 
[ptsXY_clean, ptsXYZ_clean] = TakeTopZ(ptsXY, ptsXYZ)

# re-scale Z coordinates so that the lowest Z value equals zero
# and each 4 cm above that equals 1 color change (highest possible Z = 64)
ptsXYZ_scaled = scaleZ(ptsXYZ_clean)

# determine number of rows and columns of image (incl. y and x min/max) 
y_max = max_x_or_y(ptsXYZ_scaled, "y")
y_min = min_xy_or_z(ptsXYZ_scaled, "y")
x_max = max_x_or_y(ptsXYZ_scaled, "x")