I’ve created a very useful CATIA macro to help clean up my CATIA files before I send them to my customers by automatically deleting all deactivated features. The code has two main steps:
1. Displays the number of deactivated features within a part document
2. Gives the user the option to delete all the deactivated components (minus sketches)
In fact, I often make a flowchart to map out my thought process anytime I write a custom CATIA macro from scratch. Pictured is my chart for this macro:
When I’m working on a CATIA part model making numerous changes I don’t delete anything as I am going along in case I need to go back and use what I made. My design philosophy is that it’s a lot easier and quicker to delete something than to create it from scratch. Therefore, I simply deactivate components I don’t need for now – that way I can activate them again if I find out I actually do need them later on saving me a lot of time in the process. When my model is complete and I’m ready to send the results to the customer I simply run my clean up macro which finds and deletes all of those deactivated components within the CATPart file.
This macro in CATIA is accomplished by using a process called “selection and search.” I’ve used these same technique many times and find it very helpful. In this macro example, a CATPart is the active document which I declare is the selection. I then search the selection for all deactivated components, meaning their activity status is set to false.
selection1.Search “CATPrtSearch.PartDesign Feature.Activity=FALSE”
Next, I use the Count function to display the number of deactivated features the code found and finally ask the user if they want to delete all the deactivated components using a vbyesno message box.
Download the complete code (for free!) and others from our VBA CATIA macro downloads page.
Back to read more VBA CATIA articles.