Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Document.ReferenceKeyManager.BindKeyToObject trouble

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
796 Views, 3 Replies

Document.ReferenceKeyManager.BindKeyToObject trouble

 

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
 }

 

 

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Well after a weeks try & error & patiently waiting for a reply on this thread I found the solution by chance & would like to share it with anybody stuck in C#, inv2010, Breps and an outdated API documentation:

 

object solutionnature = null;

 

 

Message 3 of 4
JarFu
in reply to: Anonymous

Thanks for the reporting and workaround! We've received your problem report and accepted it as an internal bug INVGEN-28967.  Will let you know once there is any update for it.



Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
Message 4 of 4
dylanTEV9W
in reply to: JarFu

I have the exact same problem tried the workaround it didn't fix the problem for me. Please fix this soon I've already wasted three hours trying to get around this issue. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report