+ Reply to Thread
Results 1 to 4 of 4

Thread: Working between RhinoCommon and python RhinoScriptSyntax

  1. #1

    Working between RhinoCommon and python RhinoScriptSyntax

    Hi,

    So I've had to write some code that uses RhinoCommon and python RhinoScript. My question is how do I get the two to work together?

    I get that rs.coercecurve() for example, will use a curve's GUID to get its RhinoDoc info.

    What I can't figure out is how to go the other way. Say I have a Brep, How do I get it's GUID?

    I'm sure there is a simple answer but I haven't been able to find it

    Thanks
    Ian

  2. #2
    Hi Ian,

    if you want to get a Rhino Common Object from a GUID, take a look at this post.
    http://python.rhino3d.com/threads/22...ct-from-a-Guid

    Genereally a Brep object is totally virtual and does not exist in the Rhino Document before you specifically add it to the document. Before it is added to the document it does not have a guid.
    (Just like a Grasshopper Object, which doesn't exist before it is "baked")

    So you cannot retrieve a guid from a "virtual" object. The only way to retrieve a guid is by adding the object to the document.

    I hope that helps.

    - Martin
    Last edited by Martin; 05-31-2011 at 11:54 AM.

  3. #3
    Hi Ian,

    here's an example code:
    python Code:
      import rhinoscriptsyntax as rs
      import Rhino
      import scriptcontext
       
      def TestScript():
         
          #Create the Object   
          PointObject = Rhino.Geometry.Point3d(3.3, 4.98, 5.35)
         
          #Get the Document
          doc = scriptcontext.doc
         
          #Add the PointObject to the Document
          guid = doc.Objects.AddPoint(PointObject)
       
       
      # call function defined above
      # Here we check to see if this file is being executed as the "main" python
      # script instead of being used as a module by some other python script
      # This allows us to use the module which ever way we want.
      if( __name__ == '__main__' ):
          TestScript()

  4. #4
    Thanks Martin,
    The sample code made everything clear.

    Ian

+ 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