0

Is it possible to select the faces of a solid in a PartBody by filtering them by colour using a VBA macro or any other programaticaly way? Do you have any tips on how to do this?

Thank you very much!

drypatrick
  • 437
  • 1
  • 4
  • 17
  • 2
    Perform a search with Workbench = Topology, Type = Face and whatever your target color is. Such a search will take a long time in a large model. You may want to select the body first and then search inside the selection. – C R Johnson Apr 03 '23 at 15:56
  • Sorry I misspoke, I was referring to performing this operation via a macro. Is it possible to replicate the search operation with the macro? – drypatrick Apr 04 '23 at 09:58
  • 1
    Yes, it possible to do this per macro. Best way is to record this steps per macro recorder (easiers way to get the search string for the selection) – Shrotter Apr 04 '23 at 10:12

1 Answers1

1
sQuery = "(Topology.Face & Color=Blue),all"
CATIA.ActiveDocument.Selection.Search(sQuery)

In interactive CATIA, use CTRL+F (search) and mess around until you get the search exactly right. Then click the "add to favorites" button and copy the search string out of the dialog and paste it into your code as the search query. This trick will work most every time.

You can of course alter the query string in your program if you need.

C R Johnson
  • 964
  • 1
  • 5
  • 12