Assembly.Component. Item property

Assembly.Component. Item property

Cris-Ideas
Advisor Advisor
1,139 Views
37 Replies
Message 1 of 38

Assembly.Component. Item property

Cris-Ideas
Advisor
Advisor

Hi,

I have found that Assembly components can be access by Item property Of ComponentOccurences.

 

My concern is if this can be used as ID of given component? Will by given Item value I will always get reference to the same instance (if exists).

 

So sing the example.

 I have an assembly with 8 parts.

in this state part8 will be referenced by Item 8 in the collection.

But if I delete part 5. Will item 8 be referencing the same part as before?

(Suppose not, but not sure).

 

Cris.

 

Cris,
https://simply.engineering
0 Likes
1,140 Views
37 Replies
Replies (37)
Message 2 of 38

Frederick_Law
Mentor
Mentor

Don't count on it.  A simple API update, migration or rebuild could change the order.

Always check the name, type of the object.  Always validate the object before using it.

Lots of security bug is because of programmer assume what they get is want they want.

0 Likes
Message 3 of 38

Cris-Ideas
Advisor
Advisor

Is the ItemByName property unique for every component in assembly?

 

Also is I grab reference to a given component and will hold it, but then this component is deleted during working on the assembly what happens with my reference?

 

Cris.

Cris,
https://simply.engineering
0 Likes
Message 4 of 38

Frederick_Law
Mentor
Mentor

File name of the item is unique if unique filename is on.

Full path of the file name is unique always.

Item name in assembly could change.

There could be ID in the object that Inventor use that is unique.  Need to check API help or use VBA debug to browse properties in the object.

Typically you cannot assume object stay the same outside the session.  ie once the assembly is closed, someone else could change the file when you open it again.

 

What are you trying to do?

0 Likes
Message 5 of 38

Cris-Ideas
Advisor
Advisor

I want:

1) I select assembly component(s)

2) I want to remember list of this selection

3) I want to reference elements from this selection set later on (in the same session between assembly is opened and closed) During this time I want to be able to reference exactly the same assembly components regardless off what happens to them during this time (they can be renamed, deleted (in such case I need to remove reference from my section set), demoted ....)

 

Generally I want to monitor visibility state of selected components starting from the moment they are added to selection set and ending on assembly close.

 

Is this understandable what I wrote?

My programming experience is quite limited.

 

Cris.

 

 

Cris,
https://simply.engineering
0 Likes
Message 6 of 38

Frederick_Law
Mentor
Mentor

In this case the selection set will keep check of all your objects.  Only if they're deleted from the assembly you'll lose the reference.

A set is a list of links to objects.

Similar to parts in assembly.  Delete the assembly doesn't delete the parts.  If you delete the part outside the assembly (in windows explorer), the assembly will not know what the part was.

 

"Keep track of Visibility" need more detail on what you want do.

You want to react when visibility change?

You want to count how many times it changed?

You want a time line of when it change?

Computer is stupid.  Like a child (I don't mean child is stupid Smiley Mad), it need step by step and exact step by step instruction.  So you need to layout your plan in more detail steps in order to program.  A simple "turn right here" for a car might require 1000s line of code.

 

I know this is a solution you come up with for your problem.

What is you "problem"?  (Ok that sounds rude Smiley Very Happy)

That could be another solution.

0 Likes
Message 7 of 38

Cris-Ideas
Advisor
Advisor

Sorry, I was not clear, obvipusly

 

When I select objects I want to remember the selection. But do not have them selected.

Or maybe I was clear only did not understand the answer.

 

My problem is basically also a problem that makes so many people mad. That is reverting assemblies to Master DVR on turning visibility on.

So I want a plug-in to fix this.

Plan is as follows:

1) I need basics of inventor API. Already have some VB basic knowledge, bud have no inventor API experience, so have basic problems with it.

2) once assembly is opened catch when component if being turned off.

3) remember reference to this component, write its DVR it is being displayed in given DVR of top level. (this may be small problem as I do not know if there is "beforeVisibilityOff" event for the component. If not than component will be turned off by plug-in.)

4) if any other component is turned off add to the list.

5) Once component is being turned on check if it is on the list if yes then:

6) check if any component in any depth of this component is on -> this means it is to be non associetive

7) If associative set representation to what it was before it was off and remove from the list

8) if not associative bring up dialogue with options witch DVR of the component is to be used

9) after user selects, set this representation and override any sub component that was on while top level component was off.

 

So that's the plan.

 

Currently I have a plan and gathering info. What I need:

1) plug-in template (but that's not the most important at the moment)

2) understand how to save reference to component so not to loose it in case it is renamed, copied, demoted, moved to a folder, deleted (than of course it is lost, but I do not want exception later on), replaced

 

Cris.

 

 

 

 

Cris,
https://simply.engineering
0 Likes
Message 8 of 38

Frederick_Law
Mentor
Mentor

So basically you want all components DVR set not as Master when user close the assembly.

If DVR is Master then set it to Default.

0 Likes
Message 9 of 38

Cris-Ideas
Advisor
Advisor

No.

 

Closing of the assembly has nothing to do with it.

 

I want the same DVR of the component once it is turned on that was set once it was turned off (before it is being turned on now). and the same setting for associativity.

 

Cris

Cris,
https://simply.engineering
0 Likes
Message 10 of 38

Frederick_Law
Mentor
Mentor

So you want to catch when a part/assembly 's visibility got turn on.

You don't really need to know when it turn off, you try to fix DVR after it turn back on, right?

Unless you program it to only record old state when visibility turn off.

I don't think there is an event handle for visibility change.

 

I try to see what the DVR problem is but didn't find much.

Is it a 2019 problem?

So when visibility turn off and on, DVR switch to Master?

I'm not using Inventor at work, so I can't try anything.

0 Likes
Message 11 of 38

Cris-Ideas
Advisor
Advisor

Thanks for the effort.

Last thing I would like is to discourage you.

 

 

Cris

Cris,
https://simply.engineering
0 Likes
Message 12 of 38

TONELLAL
Collaborator
Collaborator

I think you can use RefKeys.

Each RefKey identify an occurrence uniquely in the assembly, and is persistent from one session to another.

I use it for example to send properties in Excel, modify them in Excel, then send them back in the right part in Inventor. 

Message 13 of 38

Frederick_Law
Mentor
Mentor

This is how it is from the beginning.  It is annoying.

 

 

This is off topic but you might like to see, if you haven't yet:

https://www.3ders.org/articles/20180731-eth-zurich-uses-sand-3d-printing-to-build-80m2-concrete-smar...

 

0 Likes
Message 14 of 38

Cris-Ideas
Advisor
Advisor

@Frederick_Law

in deed of topic. but nice. Do you do something with it?

 

Cris.

Cris,
https://simply.engineering
0 Likes
Message 15 of 38

Cris-Ideas
Advisor
Advisor

@Frederick_Law  @TONELLAL

As for my problem,

I know it is like that from the beginning but finally I got to the point I am ready to change that.

 

Will you help me?

 

Cris.

Cris,
https://simply.engineering
0 Likes
Message 16 of 38

Frederick_Law
Mentor
Mentor

@Cris-Ideas wrote:

@Frederick_Law

in deed of topic. but nice. Do you do something with it?

 

Cris.


Nothing to do with me.  Just keep checking 3D printing development.

The video you show looks like tensioning cables.

0 Likes
Message 17 of 38

Frederick_Law
Mentor
Mentor

@Cris-Ideas wrote:

@Frederick_Law  @TONELLAL

As for my problem,

I know it is like that from the beginning but finally I got to the point I am ready to change that.

 

Will you help me?

 

Cris.


 

I'll try to play with Inventor when I get home.

0 Likes
Message 18 of 38

Cris-Ideas
Advisor
Advisor

Just do not do it for me.

Only point me in the right direction.

 

I too want to have some fun doing that.

 

Cris.

Cris,
https://simply.engineering
0 Likes
Message 19 of 38

Frederick_Law
Mentor
Mentor

I don't set associative on DVR.  I set Default view in my template.

I also have another "Design" view.  Default is how I want it to look in assemble/drawing.

Design is what I use when working on the part/assembly.  So I don't mess up Default.  I can have sketches turn on and it won't show in assembly.

I'll add views when I need, like Section.  Or other for drawing view.

I don't think changing visibility change my DVR to master.

 

Walking around the problem again.  This may not work with your workflow.

0 Likes
Message 20 of 38

Cris-Ideas
Advisor
Advisor

This is even more complexed problem with this DVR.

 

I have decided to do that.

But need some programming and coding help.

 

Cris.

Cris,
https://simply.engineering
0 Likes