+ Reply to Thread
Results 1 to 3 of 3

Thread: rs.CurveDomain returns tuple instead of a list

  1. #1

    rs.CurveDomain returns tuple instead of a list

    Hi Steve,

    Isn't the rs.CurveDomain() supposed to return a list?

    At the moment it is returning a tuple instead.

    I'm asking because the rs.TrimCurve() example doesn't work with the tuples.

    Python Code:
      import rhinoscriptsyntax as rs
       
      curve = rs.GetObject("Select a curve to trim", rs.filter.curve)
       
      if rs.IsCurve(curve):
       
          domain = rs.CurveDomain(curve)
       
          domain[1] /= 2.0
       
          rs.TrimCurve( curve, domain )

    As tuples are immutable it throws:

    Message: 'tuple' object does not support item assignment

    Traceback:
    line 9, in <module>, "C:\Users\Win7Pisa\AppData\Local\Temp\TempScript.p y"


    Thanks,
    Grischa

  2. #2
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    285
    It is supposed to be returning a list according to the Help... I'm not sure if I would be wanting to change the numbers in place anyway - I think that would be confusing if for some reason later you wanted the domain of the curve from the variable (domain) but you had modified it... As you're trimming the curve I guess it doesn't matter though...

    I guess the workaround is to force domain to be a list and modify that.

    domain = list(rs.CurveDomain(curve))

    --Mitch

  3. #3
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,463
    Blog Entries
    19
    Hi guys,
    I just changed the CurveDomain function to return a list instead of a tuple in order to match the documentation. This will be in the next V5 beta or you can get the modified script beforehand from github at
    https://github.com/mcneel/rhinopytho...cript/curve.py

    Thanks,
    -Steve

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts