Autodesk Inventor
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Curtis! Thanks for your post. (Just Kyle's fine, btw.)
Yeah, changing the component pattern name was the first thing I did when I pasted your code initially. Funny thing is that Inventor does not seem to be picking up an error with that line; it's the last line of the code that keeps bringing up the error.
Even when I paste the code you just posted (and yep, currently that pattern has 4 elements), it still takes issue with the last line of the code. The error message is still "Error on Line 10 : Method arguments must be enclosed in parentheses."
Curiouser and curiouser.
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Kyle,
Just a guess, but do you still see the error if you set your assembly to the Master LOD, and then run the rule?
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi again Curtis.
Nope, changing the LOD doesn't seem to fix it.
Hang on, I've just noticed some more information that might be helpful. I am now attaching a screenshot of both tabs of the error message.
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Kyle,
The first warning is telling us that the following line is not needed.
Dim oElement As OccurrencePatternElement
Indeed that line is just a vestige of whatever code I pulled the example from originally, and could be removed.
The second warning indicates that there is still an extra character in the last line, specifically in the word "suppressed". You might just retype it, but the problem is between the two S characters, for example: suppres_sed
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Success! It's now working.
Swordmaster was on to it. Although there was no visible error in the code, wherever the '?' appeared when I copied it to a text file, there was an issue.
The solution was to delete and retype those parts of the code, as suggested by Curtis.
Thanks to everyone who helped.
Now all I need to do is figure out how to unsuppress the elements when I change the parameter ("4" in Curits' example, but a user parameter called "Elongated_Ctrack_Location" in mine). If there's an easy way, I'd love to know, otherwise I'll have a play next time I've allow myself some Inventor playtime.
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Just change Suppressed = True to Suppressed = False. You can assign the True/False to a variable and use an If Then block to toggle the value of the variable and therefore the state of suppression.
So, something like:
Dim status As Boolean
If someParameter > 5 Then
status = True
Else
status = False
End If
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
'reference the pattern in the assembly
Dim oPattern As OccurrencePattern
'calls the pattern by name
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item(" Outside Ctrack Pattern")
'suppress the 4th element
Dim oElement As OccurrencePatternElement
oPattern.OccurrencePatternElements.Item(4).Suppres sed=status
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Mike.
Just having a good look over your suggestion. Either I've misunderstood what it's supposed to do (quite possible), or it won't quite solve my particular conundrum.
This is the rule as it is now:
DimoDocAsAssemblyDocumentoDoc=ThisApplication.ActiveDocumentDimoPatternAsOccurrencePatternoPattern=oDoc.ComponentDefinition.OccurrencePatterns.Item("Bracket Pattern")oPattern.OccurrencePatternElements.Item(Elongated_Ctrack_Posn).Suppressed=True
So pretty much where we got up to with Curtis before, except instead of defining which occurrence to suppress with a numeral in the code, it pulls a value from a user parameter (Elongated_C-track_Posn), which the user will change from job to job.
Problem is, when that parameter is changed, all occurrences previously suppressed by this rule remain suppressed, and I want them to be unsuppressed when I change that value.
What I basically want is something like:
oPattern.OccurrencePatternElements.Item(<>Elongated_Ctrack_Posn).Suppressed=False
But that's not how you do it and I probably just made a few people cringe with my bad code.
Sorry if your previous suggestion actually covers this and I'm just too out of my depth to understand it.
Thanks,
Kyle
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try this just before you suppress your specific instance:
For Each oElement In oPattern
oElement.Suppressed = True
Next
Here it is inserted into the code I posted before:
Dim status As Boolean
If someParameter > 5 Then
status = True
Else
status = False
End If
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
'reference the pattern in the assembly
Dim oPattern As OccurrencePattern
'calls the pattern by name
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item(" Outside Ctrack Pattern")
'suppress the 4th element
Dim oElement As OccurrencePatternElement
For Each oElement In oPattern
oElement.Suppressed = True
Next
oPattern.OccurrencePatternElements.Item(Elongated_ Ctrack_Posn).Suppressed=status
I didn't have time to test this, so if it doesn't work just post back.
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hey Mike, thanks for replying again.
That code looks like it should do what I want (though it looks to me like the 'for each' line should be False, not true?), but I get a rule compile error. It says:
"Rule Compile Errors in Elongated Support Suppression, in Catenary System.iam
Error on Line 9 : Expression is of type 'Inventor.OccurrencePattern', which is not a collection type."
(Line 9 is the new line of code that you suggested.)
Here is what my code looks like now:
DimoDocAsAssemblyDocumentoDoc=ThisApplication.ActiveDocumentDimoPatternAsOccurrencePatternoPattern=oDoc.ComponentDefinition.OccurrencePatterns.Item("Bracket Pattern")ForEachoElementInoPatternoElement.Suppressed=TrueNextoPattern.OccurrencePatternElements.Item(Elongated_Ctrack_Posn).Suppressed=True
Thanks for the help again. I think all this is helping me understand ilogic a little better.
-Kyle
Re: Cannot suppress pattern element using ilogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try this. I actually bothered to test it this time. ![]()
Dim oDoc As AssemblyDocument
Dim oPattern As OccurrencePattern
Dim oElements As OccurrencePatternElements
Dim oElement As OccurrencePatternElement
oDoc = ThisApplication.ActiveDocument
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item(" Bracket Pattern")
oElements = oPattern.OccurrencePatternElements
For Each oElement In oElements
oElement.Suppressed = False
Next
oPattern.OccurrencePatternElements.Item(Elongated_ Ctrack_Posn).Suppressed=True



