Inventor General Discussion

Inventor General Discussion

Reply
Distinguished Contributor
zdhrichard
Posts: 124
Registered: ‎05-03-2011
Message 1 of 20 (920 Views)
Accepted Solution

How to delete suppressed components by iLogic Rule

920 Views, 19 Replies
01-24-2013 06:21 AM

I have an assembly which includes lot of parts (*.ipt) or sub-assembly (*.iam).

I have some ilogic rules to control to suppress or unsuppress them.

Now for the released assembly, I want delete all suppressed components by ilogic rule.

Could anybody help me the ilogic code to get this function?

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences
oComps = ThisDoc.Document.ComponentDefinition.Occurrences
For Each oComp In oComps
If Component.IsActive(oComp.Name) = False Then oComp.Delete
Next

 

Try adding this to the end of your DeleteFeatures sub:

 

Dim oSketch As PlanarSketch
Dim oSketches As PlanarSketches
oSketches = oDoc.ComponentDefinition.Sketches
For Each oSketch In oSketches
If oSketch.Dependents.Count = 0 Then oSketch.Delete
Next
For Each oSketch In oSketches
If oSketch.Dependents.Count = 0 Then oSketch.Delete
Next

 

The reason the first code doesn't clean up all of the sketches is because it only deletes those sketches that are being consumed by the features that are being deleted.

Note that we have to run though all of your skecthes twice. This is because you have interdependencies between sketches and you cannot delete a sketch that has something else dependent on it. I'm playing around with a more elegant way to do this, but this way does work.

*Expert Elite*
mrattray
Posts: 2,502
Registered: ‎09-13-2011
Message 2 of 20 (911 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 07:26 AM in reply to: zdhrichard
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences

oComps = ThisDoc.Document.ComponentDefinition.Occurrences

For Each oComp In oComps
	If Component.IsActive(oComp.Name) = False Then oComp.Delete
Next

 

Mike (not Matt) Rattray

Distinguished Contributor
waynehelley
Posts: 137
Registered: ‎09-10-2012
Message 3 of 20 (907 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 07:44 AM in reply to: mrattray

Hi Mike, by any chance do you know how to do the same but for deleting suppressed features in the part environment?

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
*Expert Elite*
mrattray
Posts: 2,502
Registered: ‎09-13-2011
Message 4 of 20 (904 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 07:58 AM in reply to: waynehelley
Dim oFeature As PartFeature
Dim oFeatures As PartFeatures

oFeatures = ThisDoc.Document.ComponentDefinition.Features

For Each oFeature In oFeatures
	If Feature.IsActive(oFeature.Name) = False Then oFeature.Delete
Next

 

Mike (not Matt) Rattray

Distinguished Contributor
zdhrichard
Posts: 124
Registered: ‎05-03-2011
Message 5 of 20 (891 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 10:48 AM in reply to: mrattray

Thanks lot, Mike.

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
Distinguished Contributor
zdhrichard
Posts: 124
Registered: ‎05-03-2011
Message 6 of 20 (889 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 10:54 AM in reply to: mrattray

Hello MIke,

 

For deleting features, do you know how to delete the relative sketches?

 

I tested the codes, it could delete features, but the sketches are still in the tree.

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
*Expert Elite*
mrattray
Posts: 2,502
Registered: ‎09-13-2011
Message 7 of 20 (883 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 11:00 AM in reply to: zdhrichard

When I tested it the code deleted the consumed sketches as well as the feature. Can you attach the model?

Mike (not Matt) Rattray

Distinguished Contributor
zdhrichard
Posts: 124
Registered: ‎05-03-2011
Message 8 of 20 (879 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 11:23 AM in reply to: mrattray

Here is a simplified model.

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
*Expert Elite*
mrattray
Posts: 2,502
Registered: ‎09-13-2011
Message 9 of 20 (875 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 11:31 AM in reply to: zdhrichard

Did you already run your delete features sub on this part? The code doesn't do anything at all for me.

Mike (not Matt) Rattray

Distinguished Contributor
zdhrichard
Posts: 124
Registered: ‎05-03-2011
Message 10 of 20 (870 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 11:43 AM in reply to: mrattray

Yes, I did. This is the result after runing the code.

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
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.