• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5

# using python script to project a surface

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.
Last version is 5.3.0 (Nov 4th) or 5.3.1 (Nov 14th)

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel

I am using 5.3.0 and my coworker (who is not experiencing this issue) is using 5.2.2.
You can try 5.2.2 here and let us know if it solves the issue. https://robodk.com/downloads/Install-Rob...v5.2.2.exe
If it does, we will investigate what happened between these versions.
Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel

I just downloaded version 5.2.2 and the script ended up projecting the curve and stopping on its own.
Can you provide the script, I will pass that down to our dev team.

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel

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-

def Make_Points(Point_Start, Point_End, Num_Points):

# 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 robodk import * # Import RoboDK robotics toolbox
from random import seed # Only if needed
from random import randint # Only if needed

# Starting Parameters
Point_Start = [130.3,-616,117]
Point_End = [354.4,-616,117]
Num_Points = 50

# Generate points that will be used to create sine wave path
POINTS = Make_Points(Point_Start, Point_End, Num_Points)

# Open communication with simulator

# 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)

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)

curve_points, name_feature = object_features.GetPoints(FEATURE_CURVE, 0)
print(name_feature)

curve_points_proj = RDK.ProjectPoints(curve_points, object_surface, ProjectionType)

# Turn On rendering (Optional)
RDK.Render(True)
print("Done")
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.
Hi,

Can you also add a small .rdk file where we can test the script?
Btw you can attach the script as a .py file.

When you select "New reply" you can press "Choose file" and then "Add attachment".

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel

Attached is a test station along with the python script as a .py file.

Here is the python script

Attached Files