• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Active Member
    Kyle_of_Australia
    Posts: 10
    Registered: ‎01-10-2011

    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.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,943
    Registered: ‎03-08-2006

    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.

    Please use plain text.
    Active Member
    Kyle_of_Australia
    Posts: 10
    Registered: ‎01-10-2011

    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.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,943
    Registered: ‎03-08-2006

    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.

    Please use plain text.
    Active Member
    Kyle_of_Australia
    Posts: 10
    Registered: ‎01-10-2011

    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.

     

     

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,467
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Active Member
    Kyle_of_Australia
    Posts: 10
    Registered: ‎01-10-2011

    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

     

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,467
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Active Member
    Kyle_of_Australia
    Posts: 10
    Registered: ‎01-10-2011

    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

     

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,467
    Registered: ‎09-13-2011

    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

    Please use plain text.