Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:rhinocommonsamples:getuuid [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Get an Object'​s UUID =====
 +
 +===== C# =====
 +<code c#>
 +public class GetUuidCommand : Command
 +{
 +  public override string EnglishName { get { return "​csGetUUID";​ } }
 +
 +  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 +  {
 +    ObjRef obj_ref;
 +    var rc = RhinoGet.GetOneObject(
 +      "​Select object",​ false, ObjectType.AnyObject,​ out obj_ref);
 +    if (rc != Result.Success)
 +      return rc;
 +    if (obj_ref == null)
 +      return Result.Nothing;​
 +
 +    var uuid = obj_ref.ObjectId;​
 +    RhinoApp.WriteLine("​The object'​s unique id is {0}", uuid.ToString());​
 +    return Result.Success;​
 +  }
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Class GetUuidCommand
 +  Inherits Command
 +  Public Overrides ReadOnly Property EnglishName() As String
 +    Get
 +      Return "​vbGetUUID"​
 +    End Get
 +  End Property
 +
 +  Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
 +    Dim obj_ref As ObjRef = Nothing
 +    Dim rc = RhinoGet.GetOneObject("​Select object",​ False, ObjectType.AnyObject,​ obj_ref)
 +    If rc <> Result.Success Then
 +      Return rc
 +    End If
 +    If obj_ref Is Nothing Then
 +      Return Result.[Nothing]
 +    End If
 +
 +    Dim uuid = obj_ref.ObjectId
 +    RhinoApp.WriteLine("​The object'​s unique id is {0}", uuid.ToString())
 +    Return Result.Success
 +  End Function
 +End Class
 +d Namespace
 +</​code>​
 +===== Python =====
 +<code python>
 +import rhinoscriptsyntax as rs
 +
 +obj_id = rs.GetObject("​Select object"​)
 +if obj_id <> None:
 +  print "The object'​s unique id is {0}"​.format(obj_id)
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/getuuid.txt ยท Last modified: 2015/09/14 (external edit)