As far as Occurrences in an assembly definition are concerned...

As far as Occurrences in an assembly definition are concerned...

oransen
Collaborator Collaborator
793 Views
7 Replies
Message 1 of 8

As far as Occurrences in an assembly definition are concerned...

oransen
Collaborator
Collaborator

Is it true that as far as Occurrences in an assembly definition are concerned the top row of objects in the image below is the same as the bottom row of objects?

free-floating-objects.gif

 

 

I.e. get_Occurrences (also) gets hold of the occurrences inside patterns? My experiments say it is true but I'd like some official confirmation...!

 

 

 

 

0 Likes
Accepted solutions (2)
794 Views
7 Replies
Replies (7)
Message 2 of 8

philip1009
Advisor
Advisor

You can run this code to find out:

 

SyntaxEditor Code Snippet

i = 0
For Each oOcc As ComponentOccurrence In ThisDoc.Document.ComponentDefinition.Occurrences
	i += 1
Next
MessageBox.Show(CStr(i), "Title")
0 Likes
Message 3 of 8

oransen
Collaborator
Collaborator

Hi @philip1009 , thanks for the code, but I've already done that test in C++. I was wondering though if there was somewhere where this is documented or defined.

 

 

0 Likes
Message 4 of 8

philip1009
Advisor
Advisor

If you mean documenation as in a general API guide for Inventor, you can find that here when you have Inventor open:

api button.jpg

Other than that, I do know that Patterns are another collection under ComponentDefinition alongside Occurrences, so it may be necessary to peruse both collections in your code.

 

0 Likes
Message 5 of 8

oransen
Collaborator
Collaborator
Accepted solution

The API documentation is pretty bad to be honest, apart from the examples. Full of thinks like:

 

IsBanana() a function which says is this is a banana or not

 

Looks a bit as if it was written automatically, thank God for examples!

 

0 Likes
Message 6 of 8

philip1009
Advisor
Advisor

I mainly use it to find the trails down to the code I want, then again I haven't developed code for any other software so I've no idea how API documentation is supposed to look.  However I find the examples annoying as they use older VB syntax that is no longer supported such as Let and Set statements, using Err to catch errors is no longer supported, so it's annoying to have to filter almost every example, and not to mention there are lots of examples missing parentheses at critical points that you have to find and correct as well.  Thankfully I've advanced enough to not have to refer to the examples anymore.

0 Likes
Message 7 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@oransen,

 

On creating patterns in assembly, pattern elements also acts as occurrences. So, it includes get_Occurrences()

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 8 of 8

oransen
Collaborator
Collaborator

@chandra.shekar.gthanks fpor the confirmation.  🙂

0 Likes