Set oSurfBody = oSurfBodies.Item("INT")
I get a wrong type error when using this line. If I use a long to ID the solid I want it works fine. I need to use the title of the solid rather than the item number as the item number will change. Every example I can find just uses the number as if it's already known.
Can the ReferenceKeys or Attributes be a solution for you?
http://adndevblog.typepad.com/manufacturing/2012/07/reference-keys-in-inventor.html
http://adndevblog.typepad.com/manufacturing/2013/01/inventor-set-attributes-through-api.html
Maybe my previous answer was going to far from what you required.
I think if you want to access the surface by the name, you cannot enter it in the Surface Collection as you shown as Item will only accept a Long type value. I think you should try something like
For Each oSurfBody In oSurfBodies
If oSurfBody.Name="INT" Then
'Do what you want to do with the SurfaceBody
Else
End If
Next
That was the workaround. I was hoping to avoid that because I wind up having to sift through a few thousand solids each time I need to find one.
As for the getreferencekey, I simply don't understand what it's doing. It might be the answer but looking at the examples flies right over my head.
I have done some tests yesterday with attributes as they migt be a solution to a problem I have to access uniquely some elements in drawings. They seem to be easier to use than ReferenceKeys, and I think it might be a suitable solution for you too.
The idea is you can add an AttributeSet to a lot of Objects in Inventor (surfaces included) which can contain an Attribute with an identifier you can use to quickly find the object.
The most annoying thing is that adding the AttributeSet to the Object has to be done programatically. But for that Brian Ekins created the"AttributeHelper" add-On, that allows you to do that with a friendly interface.
http://modthemachine.typepad.com/my_weblog/2013/08/attribute-helper-update.html
http://modthemachine.typepad.com/my_weblog/attributes/