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: 

How do I identify a surfacebody by it's name?

4 REPLIES 4
Reply
Message 1 of 5
jpblower
339 Views, 4 Replies

How do I identify a surfacebody by it's name?

    

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.

4 REPLIES 4
Message 2 of 5
RodrigoEiras
in reply to: jpblower
Message 3 of 5
RodrigoEiras
in reply to: jpblower

 

Maybe my previous answer was going to far from what you required. Smiley Frustrated

 

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




 

Message 4 of 5
jpblower
in reply to: RodrigoEiras

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.

Message 5 of 5
RodrigoEiras
in reply to: jpblower

 

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/

 

 

 

 

 

 

 

 

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

Post to forums  

Autodesk Design & Make Report