这个程序将创建点,并将这些点投影到窗口空白上;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 = (Point_End [0] - Point_Start [0]) / (Num_Points - 1) point_i = [x, y, z] Point_List = [] Point_List.append (point_i) r的范围(2):我的范围(49):x + = x_steps point_i = [x, y, z] Point_List.append (point_i)如果r = = 1:打破y + = 30 point_i = [x, y, z] Point_List.append (point_i)我的范围(49):x - = x_steps point_i = [x, y, z] Point_List.append (point_i) y + = 30 point_i = [x, y, z] Point_List.append (point_i)返回Point_List robolink进口* #从robodk进口robolink库导入* #从随机进口种子进口robodk机器人工具箱#如果需要从随机进口randint #如果需要#开始参数Point_Start = (130.3, -616117) Point_End = (354.4, -616117) Num_Points = 50 #产生点,将用于创建正弦波路径点=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_nearest #可用值包括:#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() #创建一个Surface对象的副本object_surface.Copy() new_object = RDK.Paste(object_surface.Parent()) new_object. copy ()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)