Access parts quickly?

Access parts quickly?

Anonymous
Not applicable
955 Views
7 Replies
Message 1 of 8

Access parts quickly?

Anonymous
Not applicable
I am trying to write a program where I will often be needing to change values on
components. When the program starts up I iterate thru the assembly tree and get all the
component names, and some of the settings and store them in a treeview control.

My question is,....

When I go to modify a component, short of iterating thru the whole assembly tree and
comparing the name I have in the treeview against the documents component names until I
come to the right one, is there a quicker easier way?

It sure would be nice if the "Inventor.AssemblyDocument" contained a complete component
listing without having to go down thru all the subs, and we could access it with
.item(componentname). It would of course have to have the subassembly name(s) prefixing
the actual component name.

--
Kent
0 Likes
956 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
To access a specific component in an assembly you'll need to traverse
through the entire assembly. There are two other alternatives that I think
will accomplish what you want. Since you're editing a part or subassembly,
you probably really don't care about obtaining a specific occurrence, but
just the document that an occurrence references. Assuming you have the
filename of the file you want to edit, you can instead traverse through the
FileReferences of the assembly. The program will be similar to traversing
through the occurrences, but will not need to traverse through so many
objects. For example, if I have an assembly that contains two plates and
one hundred sets of bolts and nuts, the occurrence count is 202, while the
file reference count is 4. This is because all of the bolt occurrences are
referencing the same file, and the same with the nut occurrences.

The other option, and the simplest, is to just iterate through the open
documents using the Application.Documents object. This provides access to
all documents currently open within Inventor. Even those that were opened
as a result of being referenced within another document.

-Brian

"Kent Keller" wrote in message
news:[email protected]...
> I am trying to write a program where I will often be needing to change
values on
> components. When the program starts up I iterate thru the assembly tree
and get all the
> component names, and some of the settings and store them in a treeview
control.
>
> My question is,....
>
> When I go to modify a component, short of iterating thru the whole
assembly tree and
> comparing the name I have in the treeview against the documents component
names until I
> come to the right one, is there a quicker easier way?
>
> It sure would be nice if the "Inventor.AssemblyDocument" contained a
complete component
> listing without having to go down thru all the subs, and we could access
it with
> .item(componentname). It would of course have to have the subassembly
name(s) prefixing
> the actual component name.
>
> --
> Kent
>
>
>
>
0 Likes
Message 3 of 8

Anonymous
Not applicable
Unfortunately I do care about the specific occurrence. Basically I am trying to
access parts and manipulate them based on their color. I set up a Treeview control
with components being listed by color. I was hoping I could just access the children
nodes of a color and use the string containing its name to access the actual
component. Sounds like this isn't possible. Iterating thru everything every time I
do something just seems like it is going to be way to slow.

Someone suggested using class collections to hold the colors and have it access
another class collection of the parts. Probably a little over my head, but I am
starting to look into it.

--
Kent Keller
http://kwikmcad.topcities.com/

"Brian Ekins" wrote in message
news:[email protected]...
> To access a specific component in an assembly you'll need to traverse
> through the entire assembly.
>Since you're editing a part or subassembly,
> you probably really don't care about obtaining a specific occurrence, but
> just the document that an occurrence references.
0 Likes
Message 4 of 8

Anonymous
Not applicable

Hi!

Since Inventor 2017 you can right click a component and click on a button that automatically shows you where the part is located on the document tree. Hope this helped!

0 Likes
Message 5 of 8

Owner2229
Advisor
Advisor

Seriously? 16,5 years later?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 6 of 8

Anonymous
Not applicable

I would be glad to help anyone with Inventor at any day and age no matter the time or date. He still might not know 15 years later who knows?

0 Likes
Message 7 of 8

Owner2229
Advisor
Advisor

The star (*) in front of the username means it's an archived account, which means the user is no longer a member of this forum. So I don't think he really cares anymore.

Also, your answer was off-topic. He asked how to access an occurrence programmatically (by color), so he can change some of it's values.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 8 of 8

Anonymous
Not applicable

Oh ok. Yea sorry about that. Thanks for letting me know so I won't do this in the future.

0 Likes