3

I am trying to get the length of a curve but I am getting the message: MissingMemberException: 'Guid' object has no attribute 'length' The same script in C# works perfectly. What is the problem with the python translation? Here is the Documentation.

PYTHON:

import rhinoscriptsyntax as rs

ln = rs.AddLine(pt1, pt2)

a = ln 
b = ln.Length

C#:

Line ln;

ln = new Line(pt1, pt2);

A = ln;
B = ln.Length;
Brian Gillespie
  • 3,213
  • 5
  • 27
  • 37
Arthur Mamou-Mani
  • 2,303
  • 10
  • 43
  • 69

1 Answers1

5

I had a quick look at the documentation. I think you should use rhinoscriptsyntax.CurveLength. AddLine returns a Guid rather than a curve object. You can pass the Guid to CurveLength.

rs.CurveLength(ln)
Gary Kerr
  • 13,650
  • 4
  • 48
  • 51
  • I was just about to post this. Clearly what's being returned is the GUID of the new line, not the line itself. – kindall Apr 09 '13 at 23:42
  • Thanks it works, what if I change to the following code: `import Rhino as Rhino ln =Rhino.Geometry.Line(pt1,pt2) a = ln b = ln.Length` In this case I get the following error message: `(ArgumentTypeException): expected Point3d, got Guid` Why do I also get a GUID in this case and not the line itself? – Arthur Mamou-Mani Apr 09 '13 at 23:47
  • 1
    The error is `ArgumentTypeException`, so I think this is saying that at least one of the arguments `pt1` and `pt2` is a Guid rather than a `Point3d` object. The exception traceback should tell you on which line of code the error occured. – Gary Kerr Apr 10 '13 at 00:08