Hi @jim,
Sorry I wasnât more clear. Let me try again.
Technically, a RhinoObject does not have a GUID. Again, its just a runtime object and only track runtime data, such as selection.
The GUID for a RhinoObject
is stored on itâs ObjectAttributes member. Thus, when you call RhinoObject.Id, your really just calling RhinoObject.Attributes.ObjectId. You can use either method, depending on how much you like to type.
My statement is 100% accurate.
A Rhino objectâs geometry is stored on the Rhino object. There is no other way to obtain the geometry other than by first obtaining the Rhino object and than asking it for itâs geometry.
You mentioned ObjRef, which is a reference to a RhinoObject
. Although you can create these in several ways, ObjRef
objects are mostly created by picking objects with GetObject.
An ObjRef
contains all the details of the object selection operation, including the parent object you selected, the geometry (or sub-object geometry), the pick location, and more.
To illustrate further, lets use selecting a curve as an example.
var go = new GetObject();
go.SetCommandPrompt("Select curve");
go.GeometryFilter = ObjectType.Curve;
go.SubObjectSelect = false;
go.Get(); // get one object
If the selection operation was successful, you can obtain the ObjRef
created by GetObject
like this:
var objRef = go.Object(0); // Get the one object
If all you care about is the curve, then you can obtain the selected Curve geometry like this:
var curve = objRef.Curve();
Behind the scenes, ObjRef.Curve is doing this on your behalf:
var rhinoObject = objRef.Object();
if (null != rhinoObject && rhinoObject is CurveObject curveObject)
return curveObject.CurveGeometry();
else
return null;
Notice how the curve is obtained from the owning RhinoObject
.
You can also obtain the selected Curve
geometry like this:
var rhinoObject = objRef.Object();
if (null != rhinoObject && null != rhinoObject.Geometry)
return rhinoObject.Geometry as Curve;
return null;
So, three different ways to obtain the Curve
geometry. Which method you use depends on what you are trying to do.
And, if you want the selected Rhino objectâs GUID, you can do this:
var objectId = objRef.ObjectId;
Which, under the hood, just does this:
var rhinoObject = objRef.Object();
if (null != rhinoObject)
return rhinoObject.Attributes.ObjectId;
else
return Guid.Empty;
Again, several ways to get there.
Well, of course. This act plays out in any type of programming and it not unique to Rhino.
Yes, I agree.
Let me know if any of this helps.
â Dale