这个程序将创建点,并将这些点投影到窗口空白上;x,y -坐标形成一个正弦波#变量# x x坐标在mm # y y坐标在mm # z z坐标在mm # y_steps y坐标增量之间的点# x_steps x- def Make_Points(Point_Start, Point_End, Num_Points):#提取起点Point_List = [] x = Point_Start [0] y = Point_Start [1] z = Point_Start[2] #计算每个连续路径点之间的距离x_steps = 3 point_i = [x, y, z] Point_List = [] Point_List.append (point_i) s = 1134.62 r = 107.95 < 1134.62: x - y = x_steps r_sq = r * r x_sq = x *如果x < -107.95:打破y = s - math.sqrt (r_sq-x_sq) point_i = [x, y, z] Point_List.append (point_i) x = -107.95 = 1134.62 point_i = [x, y, z] Point_List.append (point_i),而y < 1269:X += x_steps r_sq = r*r x_sq = X * X if X >= 0:打破y = s + math.sqrt (r_sq-x_sq) point_i = [x, y, z] Point_List.append (point_i)返回Point_List robolink进口* #从robodk进口robolink库导入* #从随机进口种子进口robodk机器人工具箱#只进口randint #如果需要从随机从数学开始进口√6 #如果需要参数Point_Start = [0, 1026.67,250] Point_End = [0, 1242.57,250] Num_Points = 100 #产生点,将用于创建正弦波路径点=Make_Points(Point_Start, Point_End, Num_Points) #打开与模拟器的通信RDK = Robolink() #关闭自动渲染RDK. render (False) #自动删除之前生成的项目(自动标记)list_items = RDK. itemlist()在list_items中的项目:如果item. name ().startswith(' auto '): item. delete() #在启动模拟RDK. render (True) object_curve = RDK. addcurve (POINTS) ProjectionType = projection_along_normal_recalc#可用值包括:#PROJECTION_NONE = 0 #没有曲线投影# projection_nearest = 1 #投影将是曲面上最近的点#PROJECTION_ALONG_NORMAL = 2 #投影将沿着法线进行。#投影将沿着法线进行。并根据表面法线重新计算法线。#PROJECTION_RECALC = 4 #投影将是表面上最近的点,法线将被重新计算#PROJECTION_RECALC = 5 #法线将根据最近的投影的表面法线重新计算#------------------------------------------------------------- #询问用户提供对象的特征object_features = RDK。ItemUserPick("选择具有投影特征的对象(曲线和/或点)",ITEM_TYPE_OBJECT)如果不是object_features.Valid(): quit() #要求用户提供对象的表面作为参考object_surface = RDK。ItemUserPick("Select Surface Object to project features", ITEM_TYPE_OBJECT) if not object_surface.Valid(): quit() # Create a duplicate copy of the surface object object_surface.Copy() new_object = RDK.Paste(object_surface.Parent()) new_object.setName("Recalculated Normals") new_object.setVisible(True) # Hide the objects used to build the new object with the desired curves object_features.setVisible(False) object_surface.setVisible(False) # Turn Off rendering (faster) RDK.Render(False) # Add all curves, projected as desired (iterate through all curves until no more curves are found) curve_points, name_feature = object_features.GetPoints(FEATURE_CURVE, 0) print(name_feature) curve_points_proj = RDK.ProjectPoints(curve_points, object_surface, ProjectionType) RDK.AddCurve(curve_points_proj, new_object, True, PROJECTION_NONE) # Turn On rendering (Optional) RDK.Render(True) print("Done") path_settings = RDK.AddMillingProject("AutoCurveFollow settings") prog, status = path_settings.setMillingParameters(part=new_object)