- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to write a rule that automatically suppresses any and all component patterns in an assembly which have an instance value of zero. I would like to somehow scan the active assembly for any component patterns with a zero value, but I'm not sure how to do that (I've put my attempt to do so in bold below). I'm quite inexperienced with iLogic/coding. Below is the best I could come up with. Any help would be greatly appreciated!
Dim oDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition Dim oPattern As OccurrencePattern For Each oPattern In oDef.OccurrencePatterns If oPattern.value = 0 oPattern.Suppressed = True End If Next
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The OccurrencePattern object has a property called OccurrencePatternElements that you can get a Count from. Give that a try.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the reply. I tried this. Nothing is happening, so I suspect I am messing up on referencing things correctly or the syntax....
Dim oDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition Dim oPattern As OccurrencePattern For Each oPattern In oDef.OccurrencePatterns If oPattern.OccurrencePatternElements.Count = 0 Then oPattern.OccurencePatterns.Suppressed = True End If Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm not sure what you mean with: "component patterns in an assembly which have an instance value of zero." As far I know it's not possible to make patterns with zero components in each element. Also, I can't make a pattern with zero elements.
So I guess that some thing else is going on. Can you share some more information about what you are trying to do. For example a screen shot, from a browser view, or some thing that, wich shows what you like to detect?
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the reply. Right, it's not possible to make patterns with zero components. I have some component patterns in an assembly that are driven by parameters which, depending on certain dimensions, may cause the number of elements to be reduced to zero, resulting in an error ("out of range", see below, Fig. 1, circled in red*). I wish to automatically suppress the errored "zero-element" component patterns. I hope that makes more sense now.
I was hoping that the the Count property that @WCrihfield suggested would catch the value of my parameter as being zero (see example in Fig. 2) and the rule would then suppress all "zero-element" patterns. Perhaps an error trigger could be used if the zero Count wouldn't work? Thanks for considering.
Figure 1.
*"Out of range"
Figure 2.
Example of zero-valued parameter driving component pattern.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
oke that makes more sense ;-). But even if your parameter is zero the pattern will remember the last correct value. Therefore counting the number of elements will not help you. Instead, you can check the health status of the pattern. (I discovered that you need to update your assembly before checking or it will not give a correct value.)
Also suppressing the pattern is not as easy as I would like. but anyway try this.
Dim doc As AssemblyDocument = ThisDoc.Document doc.Update() For Each pat As OccurrencePattern In doc.ComponentDefinition.OccurrencePatterns If (pat.HealthStatus <> HealthStatusEnum.kUpToDateHealth) Then For Each occElement As OccurrencePatternElement In pat.OccurrencePatternElements For Each occ As ComponentOccurrence In occElement.Occurrences occ.Suppress() Next Next End If Next
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@JelteDeJong, thanks for explaining, I did not know that it would only consider the last correct value.
Your code worked perfectly! Too perfectly for my uses, in fact
The patterns I wished to suppress were nested under parent patterns, which were infected with errors up to the top level because their children patterns had errored, so the code suppressed all of them, as it should
I suppose I will try reworking how I modeled that section so that the patterns I don't want suppressed won't be thrown in with the ones I do. Thank you so much for your time, I really appreciate the help.