Message 1 of 4
Document.ReferenceKeyManager.BindKeyToObject trouble

Not applicable
05-17-2011
12:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Fighting with the transient nature of faces I ran in to a few probs trying to use the API documentation on the ReferenceKeyManager Interface, that seems a little out of touch regarding parameters. This is my best go trying to implement the example from the docs into C# in an iteration over 6 faces that changes. The actual parameters seems to differ from the documentation, thus a few code changes, but this works fine through the first iteration, but breaks when the number of faces change after the first iteration & then calling the BindKeyToObject giving me an argumentexception : Parameter is incorrect. The keyContext seems to be dynamic, but I asume that´s how it´s supposed to be. myDoc & myComp are trivial, & the solutionnature is unique also in the iteration that breaks. As I understand this should be the correct procedure to reference faces that change.
Any clues? Thx in advance! ( WIN 7 64b, INV 2010, VS C# 2010 )
List<byte[]> refKeys = new List<byte[]>(); List<byte[]> contextDatas = new List<byte[]>(); for (int i = 1; i <= 6; i++) { byte[] refKey = new byte[0]; byte[] contextData = new byte[0]; int keyContext = myDoc.ReferenceKeyManager.CreateKeyContext(); myComp.SurfaceBodies[1].Faces[i].GetReferenceKey(ref refKey, keyContext); myDoc.ReferenceKeyManager.SaveContextToArray(keyContext, ref contextData); refKeys.Add(refKey); contextDatas.Add(contextData);
} for (int i = 0; i <= 5; i++)
{ byte[] contextData = contextDatas[i]; byte[] refKey = refKeys[i]; int keyContext = myDoc.ReferenceKeyManager.LoadContextFromArray(ref contextData); object solutionnature; Face theFace = (Face)myDoc.ReferenceKeyManager.BindKeyToObject(ref refKey, keyContext, out solutionnature); // CODE THAT MAKES A SKETCH DEFINED BY THE FACE & MAKES A FEATURE THAT CHANGES THE FACE
}