+ Reply to Thread
Results 1 to 3 of 3

Thread: draw point3d scriptcontext

  1. #1

    draw point3d scriptcontext

    Hello,

    trying to draw a list of 3d point:


    [<Rhino.Geometry.Point3d object at 0x000000000000006C [-17.7536029815674,-34.3334693908691,32.9000015258789]>, <Rhino.Geometry.Point3d object at 0x000000000000006D [-11.6615104152875,-32.226620183662,32.9232406533673]>, <Rhino.Geometry.Point3d object at 0x000000000000006E [-6.05254365377602,-29.0225643337184,32.9949219452812]>, <Rhino.Geometry.Point3d object at 0x000000000000006F [-0.33322245274478,-26.0330419449284,33.0719360510503]>, <Rhino.Geometry.Point3d object at 0x0000000000000070 [6,-25,33.0999984741211]>]

    and keep on receiving this :

    Message: Multiple targets could match: AddPoints(IEnumerable[Point3f]), AddPoints(IEnumerable[Point3d])

    I've then try to specify to pu Guid as a second argument of : AddPoints() but receiving the following answer:
    I was expecting a point3f
    ...if i then convert it to point 3f the answer:
    is I was expecting point3d


    what am I doing wrong?



    Python Code:
      def Divide(curve,count):
         
          points = []
          values= Rhino.Geometry.Curve.DivideByCount(curve,count,True)
         
          for i in values:
              points.Add(curva.PointAt(i))
         
          print points
         
          if scriptcontext.doc.Objects.AddPoints(points) !=System.Guid.Empty:
              scriptcontext.doc.Views.Redraw()
              return Rhino.Commands.Result.Success
          return Rhino.Commands.Result.Failure

  2. #2
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    285
    Hi Riccardo,
    Don't you want points.Append and not points.Add? It seems you want to append points to the list...
    Also, shouldn't it be curve.PointAt and not curva.PointAt...?
    So you would have :
    for i in values:
    points.Append(curve.PointAt(i))

    Or am I totally missing what you're trying to do...?
    --Mitch

  3. #3
    Hi Mitch,

    thanks for taking time looking at my script .... and sorry for the confusion

    this is the full script for you to test

    Python Code:
      import scriptcontext
      import Rhino
      import System.Guid
       
      def getcurve():
          crv = Rhino.Input.Custom.GetObject()
          crv.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
          crv.SetCommandPrompt("Select curve")
          crv.Get()
          crv = crv.Object(0)
          crv = crv.Curve()
          return crv
       
      def Divide(curve,count):
         
          points = []
          values= Rhino.Geometry.Curve.DivideByCount(curve,count,True)
         
          for i in values:
              points.append(curve.PointAt(i))
         
          print points
         
          if scriptcontext.doc.Objects.AddPoints(points) !=System.Guid.Empty:
              scriptcontext.doc.Views.Redraw()
              return Rhino.Commands.Result.Success
          return Rhino.Commands.Result.Failure
       
       
      curve = getcurve()
      Divide(curve,4)

    i already found a solution :

    Python Code:
      import scriptcontext
      import Rhino
      import System.Guid
       
      def getcurve():
          crv = Rhino.Input.Custom.GetObject()
          crv.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
          crv.SetCommandPrompt("Select curve")
          crv.Get()
          crv = crv.Object(0)
          crv = crv.Curve()
          return crv
       
      def Divide(curve,count):
         
          points = []
          values= Rhino.Geometry.Curve.DivideByCount(curve,count,True)
         
          for i in values:
              points.append(curve.PointAt(i))
         
          print points
         
          [scriptcontext.doc.Objects.AddPoint(points[i]) for i in range(len(points))]
          scriptcontext.doc.Views.Redraw()
          return Rhino.Commands.Result.Success
       
      curve = getcurve()
      Divide(curve,4)

    but i was getting kind of stubborn with the scriptcontext.doc.Objects.AddPoints(points) .... keep on wondering what i was doing wrong...????

+ Reply to Thread

Tags for this 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