Dana Fiorucci,
I have taken the liberty to add formating and
documentation that addmittedly is over the top. I add the
extensive commenting to aid the very new to programming. I
tried to add a message dilog after the code but before the end sub
and it behaved badly.
Attribute VB_Name = "Compass_Settings_1_90"
Sub CATMain()
'
=============================================================================
' Purpose:
'
=============================================================================
' This is an interactive CATIA vba
macro.
' This module sets the compass to
values for translation and rotation one inch and ninty
degrees.
'
=============================================================================
' Version History:
'
=============================================================================
' Date | Version | Name |
Comment
' 2013-09-12 | 0.0.0.0 |
Dana Fiorucci | New
'
=============================================================================
CATIA.DisplayFileAlerts = False
'
=============================================================================
' The CATIA prompts are disabled thanks to the DisplayFileAlerts
property of the Application object set to False.
'
=============================================================================
CATIA.HSOSynchronized = False
'
=============================================================================
' For selection performance purposes, returns or sets the HSO
synchronization in comparison with the CSO.
' Role: Precises if, for all Selection object instances, the HSO
(Highlighted ' Set of Objects) is synchronized
' in comparison with the CSO (Current Set
of Objects).
' Valid values are:
' True: In this case, Selection methods work directly with
CATIA's CSO, to reflect instantly the changes made
' in Automation Selection. This ensures correct selection
results, but may impact performance in certain cases.
' This is the default value at the beginning of a CATIA
session.
' False: In this case, Selection methods work with an internal
SO buffer, which allows faster execution when
' performing a large number of
CSO-independent Selection calls, or when performing a single
Selection call
' working on a large number of objects (usually the
Search method). This may also prevent the features from
' blinking between two user interactions.
'
=============================================================================
CATIA.StartCommand ("Edit
Compass")
' opens "Edit Compass" dialog.
'
=============================================================================
' This method starts a command and executes it untill its first
interaction. Please notice interactions such
' as selections you could add after in your macro will
not work. StartCommand is useful to execute one-shot
' (not interactive) commands, it is not safe for
interactive commands.
'
=============================================================================
AppActivate "CATIA
V5"
' Activates a "CATIA V5" application window.
'
=============================================================================
' The AppActivate statement changes the focus to the named
application or window but does not affect
' whether it is maximized or minimized. Focus
moves from the activated application window when the user
' takes some action to change the focus or close the
window. Use the Shell function to start an application
' and set the window style.
' In determining which application to activate, title is
compared to the title string of each running application.
' If there is no exact match, any application whose
title string begins with title is activated. If there is
' more than one instance of the application named by title, one
instance is arbitrarily activated.
'
=============================================================================
CATIA.HSOSynchronized =
True
' See notes above. Changing value from false to true.
SendKeys "+{TAB}",
True '
Moves to the "Resets all the increamental values" button.
SendKeys "{ENTER}",
True
' Clears values.
SendKeys "{TAB}",
True
' Moves to the "Along the U" Translation increment feild.
SendKeys "^A",
True
' Select all.
SendKeys "{DEL}",
True
' Clear field.
SendKeys ".02",
True
' Enter Value.
SendKeys "{TAB 3}",
True
' Moves to the "Along the U" Rotation increment feild.
SendKeys "2",
True
' Enter Value.
SendKeys "{TAB
3}", True
' Moves to the "Along the V" Translation increment feild.
SendKeys ".02",
True '
Enter Value.
SendKeys "{TAB 3}",
True '
Moves to the "Along the V" Rotation increment feild.
SendKeys "2",
True '
Enter Value.
SendKeys "{TAB 3}",
True ' Moves
to the "Along the W" Translation increment feild.
SendKeys ".02",
True '
Enter Value.
SendKeys "{TAB 3}",
True '
Moves to the "Along the W" Rotation increment feild.
SendKeys "2",
True
' Enter Value.
SendKeys "{TAB 9}",
True
' Moves to the "Close" button.
SendKeys "{ENTER}",
True
' Closed "Edit Compass" dialog.
'
=============================================================================
' Sends one or more keystrokes to the active window as if typed
at the keyboard. Each key is represented
' by one or more characters. To specify a single ' keyboard
character, use the character itself. For example,
' to represent the letter A, use "A" for string. To
represent more than one character, append each additional
' character to the one preceding it. To represent the
letters A, B, and C, use "ABC" for string.
' The plus sign (+), caret (^), percent sign (%), tilde (~), and
parentheses ( ) ' have special meanings to
' SendKeys. To specify one of these characters,
enclose it within braces ({}). For example, to specify the
' plus sign, use {+}. Brackets ([ ]) have no special
meaning to SendKeys, but you must enclose them in
' braces. In other applications, brackets do have a
special meaning that may be significant when dynamic
' data exchange (DDE) occurs. To specify
brace characters, use {{} and {}}.
' To specify characters that aren't displayed when you press a
key, such as ENTER or TAB, and keys that
' represent actions rather than characters, use the
codes shown below:
'
Key
Code
'
BACKSPACE
{BACKSPACE}, {BS}, or {BKSP}
'
BREAK
{BREAK}
' CAPS
LOCK
{CAPSLOCK}
' DEL or
DELETE
{DELETE} or {DEL}
' DOWN
ARROW
{DOWN}
'
END
{END}
'
ENTER
{ENTER}or ~
'
ESC
{ESC}
'
HELP
{HELP}
'
HOME
{HOME}
' INS or
INSERT
{INSERT} or {INS}
' LEFT
ARROW
{LEFT}
' NUM
LOCK
{NUMLOCK}
' PAGE
DOWN
{PGDN}
' PAGE
UP
{PGUP}
' PRINT
SCREEN
{PRTSC}
' RIGHT
ARROW {RIGHT}
' SCROLL
LOCK
{SCROLLLOCK}
'
TAB
{TAB}
' UP
ARROW
{UP}
'
F1
{F1}
'
F2
{F2}
'
F3
{F3}
'
F4
{F4}
'
F5
{F5}
'
F6
{F6}
'
F7 {F7}
'
F8 {F8}
'
F9
{F9}
'
F10
{F10}
'
F11
{F11}
'
F12
{F12}
'
F13 {F13}
'
F14
{F14}
'
F15
{F15}
'
F16
{F16}
' To specify keys combined with any combination of the SHIFT,
CTRL, and ALT keys, precede the key code
' with one or more of the following codes:
'
Key
Code
'
SHIFT
+
'
CTRL
^
'
ALT
%
' To specify that any combination of SHIFT, CTRL, and ALT should
be held down while several other keys are
' pressed, enclose the code for those keys
in parentheses. For example, to specify to hold down SHIFT
while
' E and C are pressed, use "+(EC)". To specify to hold
down SHIFT while E is pressed, followed by C without
' SHIFT, use "+EC".
' To specify repeating keys, use the form {key number}. You must
put a space between key and number. For
' example, {LEFT 42} means press the LEFT ARROW key 42
times; {h 10} means press H 10 times.
' Note: You can't use SendKeys to send keystrokes to an
application that is not designed to run in Microsoft
' Windows or Macintosh. Sendkeys also can't send the
PRINT SCREEN key {PRTSC} to any application.
'
=============================================================================
End Sub
Timothy J.
Suhr
Electro-Mechanical Engineering (EME) Product Committee
Co-Chair
LinkedIn
Profile