mcneel / rhinocommon

RhinoCommon is the .NET SDK for Rhino5 / Grasshopper
http://wiki.mcneel.com/developer/rhinocommon
243 stars 93 forks source link

set ObjectAttributes.ObjectId ??? #64

Closed tmakin closed 12 years ago

tmakin commented 12 years ago

Hi there, I have been searching for way to manually set the object Guid before the object is added to the document. I use Guids to keep track of my internal objects and in the old sdk I used to be able to use this id when the time came to add some associated geomoetry to the rhino model. I see from the code in rhinosdkobjectattributes.cs that the set operator for objectId has been deliberatly left out. Any chance it could find its way back in?

Many thanks, Tom

https://github.com/mcneel/rhinocommon/blob/master/dotnet/rhino/rhinosdkobjectattributes.cs

    public Guid ObjectId
    {
      get
      {
        IntPtr ptr = ConstPointer();
        return UnsafeNativeMethods.ON_3dmObjectAttributes_m_uuid(ptr);
      }
      // I don't think I've ever seen a "set" case so leave out
    }
sbaer commented 12 years ago

I'm not sure I understand the need for this. Is there a reason you can't just record the Guid after the object has been added to the document?

tmakin commented 12 years ago

Hi Steve, I use a readonly Guid to track interdependence between a variety of different custom geometry objects in a structural modelling application. This readonly Guid is assigned when my object is first created and this needs to happen before the rhino object is created. So when I add the object to Rhino I have to either use an independent Guid or ditch the readonly and go and update the value later on. Going back and updating is a bit of a pain as other objects have generally already stored a reference to the original Guid before I add the geom to Rhino. I could search through everything to change al these references but it's not very elegant. Currently I embed my custom Guid as a user data string which works fine but seems to be doubling up unnecessarily. Is there a reason why this feature can't be exposed in Rhino common as it worked fine for me in the old SDK? Cheers, Tom

sbaer commented 12 years ago

The feature can be exposed, I just needed to understand why it would be necessary. Thanks, -Steve

tmakin commented 12 years ago

This now makes things much tidier for me. Many thanks.