How to "Open Sub-Tree" on the selected feature?

Cliff Johnson, Cliff

How to "Open Sub-Tree" on the selected feature?

Hi Everyone, how are you?

Today I was asked to see if it is possible to make a sub-tree manager for users who use this feature of CATIA a lot.

Open Sub-Tree does not appear to be a command that can be run with StartCommand. 

Do I really have to use WINAPI to do this? 

How to ask questions 

Little Cthulhu

RE: How to "Open Sub-Tree" on the selected feature?
(in response to Cliff Johnson, Cliff)

Hi.

Context commands differ from normal ones from CAA standpoint. I'm afraid WinAPI approach you've suggested is the only thing you can do with Automation.

Cliff Johnson, Cliff

RE: How to "Open Sub-Tree" on the selected feature?
(in response to Little Cthulhu)

I have finished this tool and it is a fun example of the Rube Goldberg world of WINAPI programming of Catia. 


Outline of the algorithm:

  1. Guess what the sub-windows will be called for the current document
  2. Find the CATIA window handle
  3. Find the handle of the document window in CATIA and get its dimensions
  4. do EnumChildWindows to find all the current sub-window instance handles
  5. Center-Graph on the selected feature
  6. Do a screen capture in the middle-ish area of the screen 
  7. Search the screen capture for a 8 orange pixels in a row
  8. Move the mouse to that position on the screen and simulate a left button click
  9. send the keystroke shortcut for "Open Sub Tree" (Hopefully is the same for everyone).
  10. Search again for all the sub tree windows and identify the new one
  11. if the feature already has a sub-tree record in the database, restore the window name and position
  12. If the feature does not have a sub tree record in the database, rename the sub-tree, insert a record for it and set a timer for 2 minutes
  13. In two minutes, record the position and size of the sub tree as the user has placed it. 

    EASY! 



How to ask questions