Figure out if the selected Component is part of a ComponentPattern

Figure out if the selected Component is part of a ComponentPattern

chuck.yocum
Contributor Contributor
860 Views
5 Replies
Message 1 of 6

Figure out if the selected Component is part of a ComponentPattern

chuck.yocum
Contributor
Contributor

I have a ComponentPattern in my assembly.  It is the barcable that ends 747 as shown in the image.

Image 1.png

I am trying to figure out if the selected component is part of a pattern.

 

My code looks like this.

Image 2.png

 I just can't seem to figure out how to get to Element 1 or Component Pattern from the selected Component.

0 Likes
Accepted solutions (2)
861 Views
5 Replies
Replies (5)
Message 2 of 6

chuck.yocum
Contributor
Contributor
Accepted solution

 I think I figured it out.

 

Image 3.png

0 Likes
Message 3 of 6

J-Camper
Advisor
Advisor

Once you know the occurrence is a "OccurrencePatternElement", you can use the ".PatternElement" method to get the occurrence as a OccurrencePatternElement Object which has methods.

 

You need to use the "Parent" method to get into the OccurrencePattern Object.

0 Likes
Message 4 of 6

chuck.yocum
Contributor
Contributor

Are you saying my code solution is wrong?

Do you have a sample piece of code?

0 Likes
Message 5 of 6

chuck.yocum
Contributor
Contributor

I guess I should also say that if there is only one pattern with one instance then it is ok to be part of the selection set.

 

That way I am checking the count.

0 Likes
Message 6 of 6

J-Camper
Advisor
Advisor
Accepted solution

I'm not familiar with C#, I could post iLogic code for it if you want.

 

I just posted notes about how to route from "ComponentOccurrence" Object, which is a Pattern Element, to the source "ComponentPattern" Object.  Which has methods you could use for count.

 

There is also a method under the "ComponentPatternElement" Object call "Occurrences" which might limit the count to Occurrences using the same document.  If you have multiple Occurrences in the same Component Pattern, This might be more useful:

occ1 As ComponentOccurrence 

occ1 .PatternElement.Occurrences

 

0 Likes