+ Reply to Thread
Results 1 to 5 of 5

Thread: Checking geometry type

  1. #1

    Checking geometry type

    Hi all,

    how can i check if a geometry is of a certain type (Brep, mesh, crv...)

    I know how to do it vb.net,

    VB Code:
      ...
      if TypeOf obj is Mesh Then
      ...

    but this is not working instead

    Python Code:
      if (obj.ObjectType == Rhino.DocObjects.ObjectType.Mesh):

    The error is:

    Runtime error (SyntaxErrorException): unexpected EOF while parsing
    File "", line 31
    if (obj.ObjectType == Rhino.DocObjects.ObjectType.Mesh):

    ^
    SyntaxError: unexpected EOF while parsing


    any help?

  2. #2
    I'm not sure that this is the proper way of going about it, but it works for checking RhinoCommon object types:

    Python Code:
      import Rhino as rc
       
      # x is the object to check
       
      if type(x) == rc.Geometry.NurbsCurve:
          print "You've got a curve"
         
      elif type(x) == rc.Geometry.Point3d:
          print "You've got a point"
       
      # Etc. etc..
       

  3. #3
    it works!

    I was trying this too, but i didnīt write any statement inside "if" , this was the problem. Newbies...

    thank you very much!!

  4. #4
    Cool, glad it worked out. When using the colon at the end of if statements, functions etc. you always have to indent the next line and write some code. A good tip while building up the logic of your code is to use the pass statement which essentially does nothing, but means that you won't get an error in "empty" statements, functions etc.

  5. #5
    I see... thanks again!

+ 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