Paste coordinate list problem - how to debug?


#1

SOLVED, partly.
Polyline command ends when a duplicate point is encountered because this makes a closed shape.

Original question:
I have created a coordinate list from 3 columns of X,Y,Z in Excel. Rhino will draw using the coords when pressing Ctrl-V.

However Rhino is stopping with error message of
"Unknown command: w640.677366,-374.692546,-99.819431"
My question is how to debug this?

Paste from Clipboard is
! Polyline
w640.677366,-666.119886,-44.371086
w640.82707384736,-825.182079042423,0
w394.945561058404,-647.815037647826,0
w394.945561058404,-647.815037647826,0
w333.775750473092,-600.602528956317,0
w640.677366,-666.119886,-44.371086
w640.677366,-374.692546,-99.819431 FAILS here
w640.677366,-666.119886,-44.371086
w333.775750473092,-600.602528956317,0
w640.677366,-666.119886,-44.371086
w333.775750473092,-600.602528956317,0
w82.3738707361729,-355.899062282474,0
w82.3738707361729,-355.899062282474,0
w-71.3394439743399,-210.077802934351,0

I’m stumped because this has been successful previously and creating another random list in the same worksheet is OK.

I’ve tried many things - making “wX,Y,Z” string in Excel, macro to make string, multiplying by 1, --(value), truncating to 4 decimal places, rebooting…

The only thing that has worked is adding a tiny random number (~.000001) to each value!

The most frustrating thing is not knowing how to debug this problem.
Any help gratefully accepted, Mike


(Pascal Golay) #2

Hi Mike - is there a space at the end of the previous line? That would be taken as an Enter and stop the command.

-Pascal


#3

Hi Pascal,
No I don’t think that is possible because I’ve tried 2 ways;

  1. VBA shouldn’t allow any non-numeric characters because the data is in an array as Double type.
  2. In the worksheet I have tried multiplying by 1, truncating, adding 0 and a few more that space characters shouldn’t survive

The macro is
Normally this is done by this macro - ie select 3 columns, and macro constructs the string: RR is an array with XYZ values as doubles, so non-numeric characters shouldn’t be allowed.

For i = 1 to NumberOfRows
s = s & "w"
For c = 1 to 3    'XYZ
s = s & RR(i, c) & IIf(c < UBound(RR, 2) - LBound(RR, 2) + 1, ",", vbNullString)' Null at end of each line
Next
Next

In Excel:
Cell formula is =“w” & E5 & “,” & F5 & “,” & G5

I can’t see where extra spaces would infiltrate because formulae are copied down and across, so any extra characters should be in every line.

Thanks for your interest.
regards
Mike


#4

SOLVED, partly.
Polyline command ends when a duplicate point is encountered because this makes a closed shape.
Lines command has the same behaviour.

Now I just have to work out how to draw a Polyline with duplicate points.

Thanks


#5

Or maybe you should re-examine why you want a polyline with duplicate points, since this is generally a bad thing from Rhino’s point of view. I’m thinking that what you’re really drawing is one (or more) closed polylines with maybe a left over open polyline.


#6

AIW,
I never realised the default behaviour of closing shapes.
I was using the Polyline for error-checking some calcs done in Excel - Rhino is a fast way for visualisation of 3D data.
Mike


#7

@Mike_Drummond, @pascal,

what i don’t get from the above list of points, there are no consecutive duplicate coordinates so why does rhino close the polyline it anyway ? It may have to do with how line breaks are transferred from Excel by pasting from clipboard. Using Rhino UI you can create such polylines with tons of selfoverlaps without any warning.

If i copy above points in a file and read it in using python script, it creates a single open polyline. Of course this is a bad curve, the 7 duplicate points in the list (of 14 points) produce 4 duplicate polyline segments.

import rhinoscriptsyntax as rs

def DoSomething():
    
    f_filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"
    filename = rs.OpenFileName("Open points file", f_filter)
    if not filename: return

    file = open(filename, "r")
    contents = file.readlines()
    file.close()
    
    pts = []
    for line in contents:
        print line.strip()
        if line.startswith("w"):
            pts.append(line.strip()[1:])
        else:
            pts.append(line.strip())
    
    rs.AddPoints(pts)
    rs.AddPolyline(pts)
    
DoSomething()

PointList.txt (529 Bytes)

c.


#8

If the first point in the list is modified to be unique, then all points are plotted when pasted from the clipboard, so I’m sure that it is not a problem with line breaks, or Excel etc.

If the first point is not unique then the command finishes whenever a duplicate of the first point is encountered. I’ve learnt this is the default behaviour of Polyline including manually entered or picked points.

It seems the rs.AddPolyline(pts) method you used has different behaviour in that it allows duplicates to the first point.

Mike