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: 

Selecting items by either name and index

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
400 Views, 2 Replies

Selecting items by either name and index

Is there a rule to which "Item" can be chosen by both text and index? For example, the following works:

 

Set oBOMView = oAssy.ComponentDefinition.BOM.BOMViews.Item("Structured")

 

But this does not:

 

itemName = drawDoc.Sheets(1).DrawingViews.Item("TOP VIEW").Name

 

I've been looking all over, but it's hard to search given the ubuquity of the search words. Any help would be appreciated.

 

Thanks,

Mike

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

Hi Mike,

 

Yes, there is a rule. Here is definition of Item property in BOMViews object

 

BOMViews.Item Property

Parent Object: BOMViews

Description

Returns the specified BOMView object from the collection.

Syntax

BOMViews.Item( Index As Variant ) As BOMView

Parameters

NameDescription
IndexInput Variant value that specifies the BOMView to return. This can be either a numeric value indicating the index of the item in the collection or it can be a string indicating the name of a BOMView. If an out of range index or a name of a non-existent BOMView is provided, an error will occur.

 

You can see Index is declared as variant type,and in description is written that can be a numeric value or string.

 

But, look at next Item property:

 

DrawingViews.Item Property

Parent Object: DrawingViews

Description

Returns the specified object from the collection.

Syntax

DrawingViews.Item( Index As Long ) As DrawingView

Parameters

NameDescription
IndexInput Long value that specifies the index of the to return.

In this property value can be only Long.

 

You can write you own function which return index as long type, no matter what is input (string or number)

 

Message 3 of 3
Anonymous
in reply to: 16101972

Thanks for the explanation. I'm not sure why I hadn't seen that before. I think I will also follow your suggestion about creating my own function. I've got a lot of hard coded indices that would be better off with a string value.

 

Thanks again,

Mike

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

Post to forums  

Autodesk Design & Make Report