Inventor Customization

Inventor Customization

Reply
*Bob S.
Message 1 of 6 (204 Views)

How to delete Occurrences that are patterned?

204 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.
*Teun Ham \(IV9 SP3\)
Message 2 of 6 (204 Views)

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.
*Bob S.
Message 3 of 6 (204 Views)

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.
*Teun Ham \(IV9 SP3\)
Message 4 of 6 (204 Views)

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.
*Bob S.
Message 5 of 6 (204 Views)

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.
Active Contributor
montylowe
Posts: 33
Registered: ‎11-07-2008
Message 6 of 6 (165 Views)

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

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.