- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have some surfaces that I create and then split. After the split, I need to delete some of the surfaces, do another split on the remaining surfaces, and then delete some surfaces from the end result. I have tried many, many, many different ways to keep track of what faces to keep and what faces to delete but none of them have been foolproof. From the research I've done, it looks like creating reference keys is the method I should be using. Unfortunately, I cannot get the BindKeyToObject method to ever work correctly. I need some guidance, please. Here are the steps I am going through.
1) I create some surfaces by revolving a profile.
2) I iterate through the faces and create a reference key for each one.
FacesToSplit = InventorApp.TransientObjects.CreateObjectCollection
ReferenceKeys = New List(Of String)
ReferenceKeyObj = New Byte() {}
KeyContextObj = RepadPartDocument.ReferenceKeyManager.CreateKeyContext
For I = 1 To HeadSurfaceFeature.Faces.Count
FaceObject = HeadSurfaceFeature.Faces.Item(I)
FaceObject.GetReferenceKey(ReferenceKeyObj, KeyContextObj)
ReferenceKeyString = RepadPartDocument.ReferenceKeyManager.KeyToString(ReferenceKeyObj)
ReferenceKeys.Add(ReferenceKeyString)
FacesToSplit.Add(FaceObject)
Next
ContextData = New Byte() {}
RepadPartDocument.ReferenceKeyManager.SaveContextToArray(KeyContextObj, ContextData)
Dim ContextDataString As String
ContextDataString = RepadPartDocument.ReferenceKeyManager.KeyToString(ContextData)
3) I now create a Split feature. I went from having 2 faces to now having 4. I need to keep the 2 newly made faces and delete the other 2. My thought process is that I should be able to retrieve the original faces by using the BindKeyToObject method, put them in an ObjectCollection and then create a DeleteFaces feature. Here is my code to retrieve the original faces that I created reference keys for.
FacesToDelete = InventorApp.TransientObjects.CreateFaceCollection
Dim MatchType As Object = Nothing
Dim ReturnObj As Object
ReferenceKeyObj = New Byte() {}
ContextData = New Byte() {}
RepadPartDocument.ReferenceKeyManager.StringToKey(ContextDataString, ContextData)
KeyContextObj = RepadPartDocument.ReferenceKeyManager.LoadContextFromArray(ContextData)
For I = 0 To ReferenceKeys.Count - 1
ReferenceKeyString = ReferenceKeys.Item(I)
RepadPartDocument.ReferenceKeyManager.StringToKey(ReferenceKeyString, ReferenceKeyObj)
ReturnObj = RepadPartDocument.ReferenceKeyManager.BindKeyToObject(ReferenceKeyObj, KeyContextObj, MatchType)
If TypeOf ReturnObj Is Inventor.Face Then
FaceObject = CType(ReturnObj, Inventor.Face)
FacesToDelete.Add(FaceObject)
End If
Next
The problem occurs when I use the BindKeyToObject method. MatchType returns a value of 2 which means there are distinctly many, equally good solutions. I cannot determine what type ReturnObj is other than it has a count of 2 so I guess it is an array or a collection of some sort. That makes no sense to me since I thought a reference key was unique to a particular entity.
I sure could use some help here as I have spent a bunch of hours basically banging my head on my desk. Please school me on the proper use of reference keys and/or suggest a better way of keeping track of the faces I need to keep and delete.
Thanks in advance,
Darren Haverstick
Paul Mueller Company
Solved! Go to Solution.