ObjRef compare


#1

Hello
Could someone please confirm that comparing two ObjRef works?

//I have two lists:
List<ObjRef> A = new List<ObjRef>();
List<ObjRef> B = new List<ObjRef>();

//Not important stuff like adding GetObject Options settings etc. then
ga.GetMultiple();
gb.GetMultiple();


foreach (ObjRef entry in ga.Objects()) {A.Add(entry); }

foreach (ObjRef entry in gb.Objects()) 
{if (B.Contains(entry)) { continue; }
 B.Add(entry);
}

In debug I can see that ObjectId is the same for entry and ObjRef in list A. But B.Contains(entry) is always false even though I choose the same polysurface in Rhino.

List A

  •   ObjectId	{7083dbd3-ace9-4e9a-b4c6-64896dbe2424}	System.Guid
    

List B

  •   ObjectId	{7083dbd3-ace9-4e9a-b4c6-64896dbe2424}	System.Guid

(David Rutten) #2

It will create new ObjRefs pointing to the same object. You should compare object IDs instead.


#3

Ahhh yes of course. Thanks for ultrafast reply.