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

Wrong parameters for AddCurve method

#1
I have a script that is trying to read XYZIJK values from a CSV file and create a curve.  I think that I am arranging the list of points correctly, but the error message says that I am not.

Could somebody please let me know what I am doing wrong?

Here is the script output (I cut out a lot of lines to save space)
Code:
Saved 374 points to a list for making a curve
[
[57.876006, -130.844612, 45.042276, -0.444945, -0.691147, 0.569508],
[80.123256, -96.287262, 16.566876, -0.444945, -0.691147, 0.569508],
[84.920716, -90.68758, 11.481738, -0.444945, -0.691147, 0.569508],
[91.151761, -86.472903, 6.619512, -0.444945, -0.691147, 0.569508],
[98.503944, -83.854571, 2.224012, -0.444945, -0.691147, 0.569508],
{snip}
[183.922805, -220.500173, -62.102005, -0.528125, -0.79715, -0.292636]
]

WARNING: Invalid curve, a 3xN (or 6xN) list of points must be provided
The result of adding the new curve was RoboDK item (INVALID)


Here is the class method that is trying to make the curve:

Code:
curvePoints = list()
for n in range( len(self.csvPoints) ):
P = self.csvPoints[n]
curvePoints.append([P.x, P.y, P.z, P.i, P.j, P.k])
self.log(f'Saved {len(curvePoints)} points to a list for making a curve')

print(curvePoints)

# Get a reference to the desired work object
targetObject = RDK.Item(WorkObject, 3)
if targetObject == None:
self.log(f'Could not find a FRAME called "{WorkObject}" in the station')
return False

# Make the curve
result = RDK.AddCurve(curvePoints, targetObject, True, 0)
self.log(f'The result of adding the new curve was {result}')
#2
Are all points in the list provided as XYZijk? In other words, do they all have 6 components (X,Y,Z,i,j,k)?

Are you using the latest version of RoboDK? Can you share your RoboDK project so we can reproduce this?
#3
I created a stripped down test script that is in the attached station.  When I run it in that station it works as expected.  When I run the exact same code in the station that actually matters, it does not work.  So there is something in the station causing problems - and that station cannot leave the building.  Sorry, I know that isn't helpful.

I will just have to make the original program create a simple XYZIJK file in addition to the "real" file.  So that I can drag and drop it into RoboDK.  

Here are the two outputs from the same code reading the same file, but in different stations:


Code:
Output:
Loading points from "C:/Temp/Small Test File.csv"
Read a total of 48 lines and had errors in 6 lines
Saved 42 points to a list for making a curve
WARNING: Invalid curve, a 3xN (or 6xN) list of points must be provided
The result of adding the new curve was RoboDK item (INVALID)

Output:
Loading points from "C:/Temp/Small Test File.csv"
Read a total of 48 lines and had errors in 6 lines
Saved 42 points to a list for making a curve
The result of adding the new curve was RoboDK item (2469983002928) of type 5


Attached Files
.txt   Small Test File.csv.txt (Size: 3.29 KB / Downloads: 12)
.rdk   Curve Testing Station.rdk (Size: 1.89 KB / Downloads: 13)
#4
Can you try calling AddCurve with only the list of points? Let me know if you get a different behavior. Do not provide the reference object (which should be an object item if you want to attach the curve points to another object). You can optionally set the projection type to 0 to not alter your original points. 

You can optionally attach the object to a reference frame afterwards by calling setParent

Example:
Code:
object_curve = RDK.AddCurve(points, projection_type=0)
object_curve.setParent(reference_frame)
#5
Thank you Albert.

Doing the steps separately as you suggested seems to work. I added the step to rename the curve to match the imported CSV filename - to try and improve our book keeping.

Thank you for the help.
#6
Great, thank you for your feedback.
  




Users browsing this thread:
1 Guest(s)