11-22-2021, 08:17 PM (This post was last modified: 11-22-2021, 08:19 PM by audreyv.)
I've been using a python script to generate a curve and project it onto a surface.
The python script uses the RoboDK API and curve follow project. For some reason when I run the program on RoboDK, it generates the curve but does not project the curve onto the surface. It also says that the python script just keeps running, and doesn't stop until I manually choose for it to stop.
When I send the whole station to a coworker, it works for her just fine. I was wondering if it might be the version of RoboDK or Python or what might be causing this issue.
This program will create points and project those points on a window blank; x,y - coordinates form a sine wave
# Variables
# x x-coordinate in mm
# y y-coordinate in mm
# z z-coordinate in mm
# y_steps y-coordinate increments between points
# x_steps x-
# Extract the Starting Points
Point_List = []
x = Point_Start[0]
y = Point_Start[1]
z = Point_Start[2]
# Calculate the distance between each consecutive waypoint
x_steps = (Point_End[0] - Point_Start[0])/(Num_Points - 1)
point_i = [x,y,z]
Point_List = []
Point_List.append(point_i)
for r in range(2):
for i in range(49):
x += x_steps
point_i = [x,y,z]
Point_List.append(point_i)
if r == 1:
break
y += 30
point_i = [x,y,z]
Point_List.append(point_i)
for i in range(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)
return Point_List
from robolink import * # Import the robolink library
from robodk import * # Import RoboDK robotics toolbox
from random import seed # Only if needed
from random import randint # Only if needed
# Generate points that will be used to create sine wave path
POINTS = Make_Points(Point_Start, Point_End, Num_Points)
# Open communication with simulator
RDK = Robolink()
# Turn off auto rendering
RDK.Render(False)
# Automatically delete previously generated items (Auto tag)
list_items = RDK.ItemList()
for item in list_items:
if item.Name().startswith('Auto'):
item.Delete()
# Turn rendering ON before starting the simulation
RDK.Render(True)
object_curve = RDK.AddCurve(POINTS)
ProjectionType = PROJECTION_CLOSEST
# Available values include:
#PROJECTION_NONE = 0 # No curve projection
#PROJECTION_CLOSEST = 1 # The projection will be the closest point on the surface
#PROJECTION_ALONG_NORMAL = 2 # The projection will be done along the normal.
#PROJECTION_ALONG_NORMAL_RECALC = 3 # The projection will be done along the normal. Furthermore, the normal will be recalculated according to the surface normal.
#PROJECTION_CLOSEST_RECALC = 4 # The projection will be the closest point on the surface and the normals will be recalculated
#PROJECTION_RECALC = 5 # The normals are recalculated according to the surface normal of the closest projection
#-------------------------------------------------------------
# Ask the user to provide the object with the features
object_features = RDK.ItemUserPick("Select object with the features to project (curves and/or points)", ITEM_TYPE_OBJECT)
if not object_features.Valid():
quit()
# Ask the user to provide the object with the surface used as a reference
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)
# Turn On rendering (Optional)
RDK.Render(True)
print("Done")
path_settings = RDK.AddMillingProject("AutoCurveFollow settings")
prog, status = path_settings.setMillingParameters(part=new_object)
Here's the script I have been using for projecting paths onto a surface.
After downloading 5.2.2 and running this script, it worked as it should. For the 5.3.0 version it did not work.