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

    Autodesk Inventor Customization

    Reply
    *Bob S.

    How to delete Occurrences that are patterned?

    153 Views, 5 Replies
    05-25-2005 05:52 AM
    The following snippet of code deletes all invisible components from an
    assembly, but fails with a runtime error if the component is in a pattern.

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    oOccurrence.Delete
    End If
    Next

    I managed to change it for now to just skip over the patterned components
    by adding a check as in the following:

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    If oOccurrence.PatternElement Is Nothing Then
    oOccurrence.Delete
    End If
    End If
    Next

    However, what I really want to do is delete those occurences. I imagine
    I might have to make them independent or something first. Can someone
    point me in the right direction here on what I have to do in order to
    delete them?

    Bob S.
    Please use plain text.
    *Teun Ham \(IV9 SP3\)

    Re: How to delete Occurrences that are patterned?

    05-25-2005 06:38 AM in reply to: *Bob S.
    A simple question, but...

    ...a pattern can exist of multiple components (each pattern element can
    contain multiple parts/subassemblies).
    What if only one component of a pattern element is invisible?

    Making that pattern element "independant" will make ALL components in that
    element independant. Any change in the pattern afterwards will not affect
    the component that was removed from the pattern.

    One question: why do you want to remove/delete those parts? If it's for the
    quantity, you could consider checking the "reference" of those parts.

    If oOccurence.Visible = False Then
    oOccurence.Reference = False
    End If

    Cheers,

    Teun

    "Bob S." wrote in message
    news:4855712@discussion.autodesk.com...
    The following snippet of code deletes all invisible components from an
    assembly, but fails with a runtime error if the component is in a pattern.

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    oOccurrence.Delete
    End If
    Next

    I managed to change it for now to just skip over the patterned components
    by adding a check as in the following:

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    If oOccurrence.PatternElement Is Nothing Then
    oOccurrence.Delete
    End If
    End If
    Next

    However, what I really want to do is delete those occurences. I imagine
    I might have to make them independent or something first. Can someone
    point me in the right direction here on what I have to do in order to
    delete them?

    Bob S.
    Please use plain text.
    *Bob S.

    Re: How to delete Occurrences that are patterned?

    05-25-2005 07:11 AM in reply to: *Bob S.
    This is part of a macro that does a save as of the assembly, opens the
    new assembly invisibly, grounds all components and then deletes all
    components that are not visible, then exports that to a step file for
    our CNC and CMM people. They get bogged down if I include all the
    extraneous stuff they have no use for, like Gage labels, Toolball XYZ
    Labels, Go/No-Go feelers with handles and cable reels, etc, etc.
    I thought I had it all working fine until I ran it on one of my designs
    that happened to have a component pattern in it of parts I turned off in
    order to be deleted. So given the intended result, it really does not
    matter about patterns and such, since the result is a dumb step file.

    "Teun Ham (IV9 SP3)" wrote in message news:4855771@discussion.autodesk.com...
    A simple question, but...

    ...a pattern can exist of multiple components (each pattern element can
    contain multiple parts/subassemblies).
    What if only one component of a pattern element is invisible?

    Making that pattern element "independant" will make ALL components in that
    element independant. Any change in the pattern afterwards will not affect
    the component that was removed from the pattern.

    One question: why do you want to remove/delete those parts? If it's for the
    quantity, you could consider checking the "reference" of those parts.

    If oOccurence.Visible = False Then
    oOccurence.Reference = False
    End If

    Cheers,

    Teun

    "Bob S." wrote in message
    news:4855712@discussion.autodesk.com...
    The following snippet of code deletes all invisible components from an
    assembly, but fails with a runtime error if the component is in a pattern.

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    oOccurrence.Delete
    End If
    Next

    I managed to change it for now to just skip over the patterned components
    by adding a check as in the following:

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    If oOccurrence.PatternElement Is Nothing Then
    oOccurrence.Delete
    End If
    End If
    Next

    However, what I really want to do is delete those occurences. I imagine
    I might have to make them independent or something first. Can someone
    point me in the right direction here on what I have to do in order to
    delete them?

    Bob S.
    Please use plain text.
    *Teun Ham \(IV9 SP3\)

    Re: How to delete Occurrences that are patterned?

    05-25-2005 07:36 AM in reply to: *Bob S.
    If that's the case, you can make all elements independant and delete all
    invisible components.

    Also, you might want to take a look at this:
    http://www.mcadforums.com/forums/viewtopic.php?t=3073

    Cheers,

    Teun

    "Bob S." wrote in message
    news:4855838@discussion.autodesk.com...
    This is part of a macro that does a save as of the assembly, opens the
    new assembly invisibly, grounds all components and then deletes all
    components that are not visible, then exports that to a step file for
    our CNC and CMM people. They get bogged down if I include all the
    extraneous stuff they have no use for, like Gage labels, Toolball XYZ
    Labels, Go/No-Go feelers with handles and cable reels, etc, etc.
    I thought I had it all working fine until I ran it on one of my designs
    that happened to have a component pattern in it of parts I turned off in
    order to be deleted. So given the intended result, it really does not
    matter about patterns and such, since the result is a dumb step file.

    "Teun Ham (IV9 SP3)" wrote in
    message news:4855771@discussion.autodesk.com...
    A simple question, but...

    ...a pattern can exist of multiple components (each pattern element can
    contain multiple parts/subassemblies).
    What if only one component of a pattern element is invisible?

    Making that pattern element "independant" will make ALL components in that
    element independant. Any change in the pattern afterwards will not affect
    the component that was removed from the pattern.

    One question: why do you want to remove/delete those parts? If it's for the
    quantity, you could consider checking the "reference" of those parts.

    If oOccurence.Visible = False Then
    oOccurence.Reference = False
    End If

    Cheers,

    Teun

    "Bob S." wrote in message
    news:4855712@discussion.autodesk.com...
    The following snippet of code deletes all invisible components from an
    assembly, but fails with a runtime error if the component is in a pattern.

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    oOccurrence.Delete
    End If
    Next

    I managed to change it for now to just skip over the patterned components
    by adding a check as in the following:

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    If oOccurrence.PatternElement Is Nothing Then
    oOccurrence.Delete
    End If
    End If
    Next

    However, what I really want to do is delete those occurences. I imagine
    I might have to make them independent or something first. Can someone
    point me in the right direction here on what I have to do in order to
    delete them?

    Bob S.
    Please use plain text.
    *Bob S.

    Re: How to delete Occurrences that are patterned?

    05-25-2005 07:48 AM in reply to: *Bob S.
    Teun,

    Thanks! That looks like just what I want to incorporate.

    Bob S.

    "Teun Ham (IV9 SP3)" wrote in message news:4855896@discussion.autodesk.com...
    If that's the case, you can make all elements independant and delete all
    invisible components.

    Also, you might want to take a look at this:
    http://www.mcadforums.com/forums/viewtopic.php?t=3073

    Cheers,

    Teun

    "Bob S." wrote in message
    news:4855838@discussion.autodesk.com...
    This is part of a macro that does a save as of the assembly, opens the
    new assembly invisibly, grounds all components and then deletes all
    components that are not visible, then exports that to a step file for
    our CNC and CMM people. They get bogged down if I include all the
    extraneous stuff they have no use for, like Gage labels, Toolball XYZ
    Labels, Go/No-Go feelers with handles and cable reels, etc, etc.
    I thought I had it all working fine until I ran it on one of my designs
    that happened to have a component pattern in it of parts I turned off in
    order to be deleted. So given the intended result, it really does not
    matter about patterns and such, since the result is a dumb step file.

    "Teun Ham (IV9 SP3)" wrote in
    message news:4855771@discussion.autodesk.com...
    A simple question, but...

    ...a pattern can exist of multiple components (each pattern element can
    contain multiple parts/subassemblies).
    What if only one component of a pattern element is invisible?

    Making that pattern element "independant" will make ALL components in that
    element independant. Any change in the pattern afterwards will not affect
    the component that was removed from the pattern.

    One question: why do you want to remove/delete those parts? If it's for the
    quantity, you could consider checking the "reference" of those parts.

    If oOccurence.Visible = False Then
    oOccurence.Reference = False
    End If

    Cheers,

    Teun

    "Bob S." wrote in message
    news:4855712@discussion.autodesk.com...
    The following snippet of code deletes all invisible components from an
    assembly, but fails with a runtime error if the component is in a pattern.

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    oOccurrence.Delete
    End If
    Next

    I managed to change it for now to just skip over the patterned components
    by adding a check as in the following:

    For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Visible = False Then
    If oOccurrence.PatternElement Is Nothing Then
    oOccurrence.Delete
    End If
    End If
    Next

    However, what I really want to do is delete those occurences. I imagine
    I might have to make them independent or something first. Can someone
    point me in the right direction here on what I have to do in order to
    delete them?

    Bob S.
    Please use plain text.
    Active Contributor
    Posts: 33
    Registered: ‎11-07-2008

    Re: How to delete Occurrences that are patterned?

    03-15-2011 08:13 AM in reply to: *Bob S.

    Was there a solution for this issue? If so do you mind sharing Thanks

    Please use plain text.