Inventor General Discussion

Inventor General Discussion

Reply
Active Member
Kyle_of_Australia
Posts: 10
Registered: ‎01-10-2011
Message 11 of 33 (1,186 Views)

Re: Cannot suppress pattern element using ilogic

10-08-2012 07:01 PM in reply to: Curtis_Waguespack

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.

*Expert Elite*
Curtis_Waguespack
Posts: 2,878
Registered: ‎03-08-2006
Message 12 of 33 (1,183 Views)

Re: Cannot suppress pattern element using ilogic

10-08-2012 07:14 PM in reply to: Kyle_of_Australia

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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
Kyle_of_Australia
Posts: 10
Registered: ‎01-10-2011
Message 13 of 33 (1,176 Views)

Re: Cannot suppress pattern element using ilogic

10-08-2012 07:42 PM in reply to: Curtis_Waguespack

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.

*Expert Elite*
Curtis_Waguespack
Posts: 2,878
Registered: ‎03-08-2006
Message 14 of 33 (1,170 Views)

Re: Cannot suppress pattern element using ilogic

10-08-2012 08:04 PM in reply to: Kyle_of_Australia

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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
Kyle_of_Australia
Posts: 10
Registered: ‎01-10-2011
Message 15 of 33 (1,156 Views)

Re: Cannot suppress pattern element using ilogic

10-08-2012 08:48 PM in reply to: Curtis_Waguespack

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.

 

 

*Expert Elite*
mrattray
Posts: 2,481
Registered: ‎09-13-2011
Message 16 of 33 (1,136 Views)

Re: Cannot suppress pattern element using ilogic

10-09-2012 05:02 AM in reply to: Kyle_of_Australia

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).Suppressed=status

 

Mike (not Matt) Rattray

Active Member
Kyle_of_Australia
Posts: 10
Registered: ‎01-10-2011
Message 17 of 33 (1,116 Views)

Re: Cannot suppress pattern element using ilogic

10-24-2012 02:10 AM in reply to: mrattray

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

 

*Expert Elite*
mrattray
Posts: 2,481
Registered: ‎09-13-2011
Message 18 of 33 (1,109 Views)

Re: Cannot suppress pattern element using ilogic

10-24-2012 09:36 AM in reply to: Kyle_of_Australia

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.

 

Mike (not Matt) Rattray

Active Member
Kyle_of_Australia
Posts: 10
Registered: ‎01-10-2011
Message 19 of 33 (1,102 Views)

Re: Cannot suppress pattern element using ilogic

10-24-2012 06:18 PM in reply to: mrattray

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

 

*Expert Elite*
mrattray
Posts: 2,481
Registered: ‎09-13-2011
Message 20 of 33 (1,094 Views)

Re: Cannot suppress pattern element using ilogic

10-25-2012 05:22 AM in reply to: Kyle_of_Australia

Try this. I actually bothered to test it this time. :smileyhappy:

 

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

 

Mike (not Matt) Rattray

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.