+ Reply to Thread
Results 1 to 5 of 5

Thread: Problems with PlaneFromPoints?

  1. #1

    Problems with PlaneFromPoints?

    Hello! Hello! Can you help me in this example script?
    import rhinoscriptsyntax as rs

    corners = rs.GetRectangle()

    if corners:

    rs.ViewCPlane( rs.PlaneFromPoints(corners[0], corners[1], corners[3]))

    It gives:
    Message: unable to coerce Origin=29.8916742188048,129.979956229813,0 XAxis=1,0,0, YAxis=0,1,0, ZAxis=0,0,1 into a view

    Traceback:
    line 16, in __viewhelper, "C:\Users\dotto\AppData\Roaming\McNeel\Rhinoceros\ 5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\view.py"
    line 724, in ViewCPlane, "C:\Users\dotto\AppData\Roaming\McNeel\Rhinoceros\ 5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\view.py"

    What's wrong?
    Thank you very much indeed!
    Silva

  2. #2
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    286
    Hi,

    It would be good to know what you want. GetRectangle() will always operate in the active viewport's CPlane, so in a sense, you already have what you are trying to get... you don't need to use GetRectangle() to do this, rs.ViewCPlane() with no arguments will return the plane of the active viewport directly.

    --Mitch
    Last edited by Mitch; 07-05-2012 at 10:47 AM.

  3. #3
    Hi Mitch,
    The problem is that when you pass 3 points to PlaneFromPoints as in the example, it gives the error "unable to coerce Origin=....." This happens also with the example on the Help. So my question is: If I have the coords of 3 not aligned points how do I have to call this function to get the plane? Thanks a lot
    silva

  4. #4
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    286
    Hi,

    It seems to be working correctly here. The following works:
    python Code:
      import rhinoscriptsyntax as rs
      pt1=[0,0,0]
      pt2=[10,0,0]
      pt3=[10,10,0]
      plane=rs.PlaneFromPoints(pt1,pt2,pt3)
      print plane

    as well as this:
    python Code:
      import rhinoscriptsyntax as rs
      corners = rs.GetRectangle()
      if corners:
          plane=rs.PlaneFromPoints(corners[0], corners[1], corners[3])
      print plane

    The error message you're seeing is not coming from PlaneFromPoints, it's coming from ViewCPlane. ViewCPlane takes 2 arguments - a view and a plane. If you do not supply the view, it defaults to the current active view, but in order to comply with Python syntax if you want to pass the second argument (the plane) you need to either pass the first argument for the view, or assign the default to the second with plane=:

    Python Code:
      import rhinoscriptsyntax as rs
      corners = rs.GetRectangle()
      if corners:
          planefp=rs.PlaneFromPoints(corners[0], corners[1], corners[3])
      newPlane=rs.ViewCPlane(plane=planefp)
      # or : newPlane=rs.ViewCPlane(None,planefp)
      # or: newPlane=rs.ViewCPlane(view=None,plane=planefp)
      # or: newPlane=rs.ViewCPlane(view=rs.CurrentView(),plane=planefp)
      # but not : newPlane=rs.ViewCPlane(planefp)
      print planefp, newPlane

    Does that make sense?

    --Mitch
    Last edited by Mitch; 07-05-2012 at 12:51 PM.

  5. #5
    Yes! I see. Thanks a lot
    Silva

+ 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