This CATIA CATScript will search your open CATIA document for any piece of geometry you specify by name. This CATScript is perfect for scenarios like these:

Sometimes you may have a massive model with tons of geometry and you simply want to edit a certain plane. You know the exact name of the plane is “Plane.72” but you don’t remember where it is located within your specification tree and digging through every single geometrical set would simply take too much time. What do you do?catia catscript exercise

Creating a simple CATScript is an easy and quick way to get the job done. In this CATIA macro exercise you will learn to:

  • search a CATIA document
  • create an input box
  • create a message box
  • create a For…Next loop
  • use the CATIA.Start Command

Listed below are the basic steps to follow. For a challenge, try to write this code from scratch without looking at my final macro. If you’ve never written a macro from scratch before, check out my guide on how to get started writing CATIA macros.

  1. Declare the activedocument as the selection
  2. Create a variable of type string
  3. Create an input box with the result being saved in the newly create string variable
  4. Search the selection by name, which is the string variable entered by the user in the input box
  5. Count the number of items found by the search and display the result in a message box
  6. Use the Start Command to “center graph” on the geometry found in the search result

catia catscript macro

To see the complete code and compare it to what you’ve come up with, download the CATIA CATScript from the free downloads page. If you are unable to get the CATScript to work, read my article on what to do when you get stuck. Once completed you may proceed to the next exercise, how to hide geometry.