Parameters for Compass Manipulation (How to Programmatically Set these Values)

Timothy John Suhr

Parameters for Compass Manipulation (How to Programmatically Set these Values)

When doing detail design we move part with the Compass. Before start this for each session we are forced to set the compass increments for Translation and Rotation.

I would like to create an application that would permit three sets of values to be populated into these fields values (Min (See Figure 1), Max (See Figure 2), and User defined (See Figure 3)). The application would also reset the compass to default. I know that there are some API for the compass (CATI3DCompass, CATISpecAttrAccess). But I have not found one for changing its parameters.

 (See CompassChangeMin.png)

Figure 1 - Min

 (See CompassChangeMax.png)

Figure 2 - Max

 (See CompassChangeDefault.png)

Figure 3 - Default

  

I think we need to start out with something like:

CATISpecAttrAccess * CATI3DCompass = NULL;

hr = spView->QueryInterface(IID_CATISpecAttrAccess,

(void**) &CATI3DCompass);

if (FAILED(hr) || (CATI3DCompass == NULL))

{

if (!localError)

ioStatusMessages.Append(myStatusMessage);

if (!iDebug && !localError)

Can someone help in this quest?



Timothy J. Suhr

Electro-Mechanical Engineering (EME) Product Committee Co-Chair

LinkedIn Profile

Attachments

  • CompassChangeMin.png (60k)
  • CompassChangeMax.png (60.2k)
  • CompassChangeDefault.png (59.5k)

Samarinder Singh

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Timothy John Suhr)

Hi,

I asked a similar question in this thread here. I believe, there are no APIs for accessing the compass parameters.

Regards,
Samarinder

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Samarinder Singh)

I second Samarinder's response I've wanted to do the same thing for many years but no API's.

We even went so far to request this from Dassault back in R12.

Don't know however if these are exposed in RAID?

Anyone with RAID that can confirm this?

Seems like this would have been a no brainer to set the defaults to say 1in and 90deg.

Dave Frank

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Samarinder Singh)

Hi Dana,

An old NC programmer friend used to say "no brain, no pain"   It think that translates into ... "live is easier if you don't think too hard".   I think your career works better if you do ... try your best!!     

 

All kidding aside, I have been banging the "small but important" enhancments for a while. I also spend some good time on API's in the last COE requirements session.  Did you have a chance to watch that COE Web broadcast?

I think "best in class" means all the stuff you need, is included, or at least optional :)   $$

Dave


Dave Frank  *    Bell Helicopter *  Grand Prairie Texas

Advanced Computer Aided Manufacturing Systems Engineer

COE Product Co-Chairman, Digital Numerical Control

 

Dave Frank

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Dave Frank)

here is the link to the webinar

 

http://www.coe.org/p/do/sd/sid=1049&type=0


Dave Frank  *    Bell Helicopter *  Grand Prairie Texas

Advanced Computer Aided Manufacturing Systems Engineer

COE Product Co-Chairman, Digital Numerical Control

 

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Dave Frank)

So I was doing a bit of messing around with this and may have discovered the back door to setting these.

Im going to do some more investigation and I'll let you all know.

I'm thinking it is possible now for sure.

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Dana Fiorucci)

Anyone have a small example of setting the focus to the sub window in this case the compass window.

Focus needs to be set before I pass it the values.

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Dana Fiorucci)

Okay I've found a work around I have defaulting to 1in and 90deg right now going to add some user inputs and see if this still behaves.

Ahhh the joy of send keys!!!! when they work

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Timothy John Suhr)

Tim give  me a holler at [login to unmask email]

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Dana Fiorucci)

Okay here is what I've come up with.

These are catvba

I'm working on a version that allows user input for translation and rotation but it doesn't work if the user uses the mouse to click OK rather than typing the "Enter" key. The timing issue fro SendKeys is being thrown off. I've used the FindWindow WinAPI32 and can return the "Parameters for Compass Manipulation" window but SendKeys are ignored once the SetFocus or SetActiveWindow API's are used. So I'm going to try to get all the fields of the form by the FindWindowEx API.

It seems that hard coding the values is the only to get this to consistently work for now timing issue with SendKeys an all.

This one defaults to 1in and 90deg

Sub CATMain()

CATIA.DisplayFileAlerts = False

CATIA.HSOSynchronized = False

CATIA.StartCommand ("Edit Compass")

AppActivate "CATIA V5"

CATIA.HSOSynchronized = True

SendKeys "+{TAB}", True
SendKeys "{ENTER}", True
SendKeys "{TAB}", True
SendKeys "^A", True
SendKeys "{DEL}", True
SendKeys "{1}", True
SendKeys "{TAB 3}", True
SendKeys "90", True
SendKeys "{TAB 3}", True
SendKeys "{1}", True
SendKeys "{TAB 3}", True
SendKeys "90", True
SendKeys "{TAB 3}", True
SendKeys "{1}", True
SendKeys "{TAB 3}", True
SendKeys "90", True
SendKeys "{TAB 9}", True
SendKeys "{ENTER}", True

End Sub

This one resets everything to zero

Sub CATMain()

CATIA.DisplayFileAlerts = False

CATIA.HSOSynchronized = False

CATIA.StartCommand ("Edit Compass")

AppActivate "CATIA V5"

CATIA.HSOSynchronized = True

SendKeys "+{TAB}", True
SendKeys "{ENTER}", True
SendKeys "+{TAB}", True
SendKeys "{ENTER}", True

End Sub

Timothy John Suhr

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Dana Fiorucci)

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

Dana Fiorucci

RE: Parameters for Compass Manipulation (How to Programmatically Set these Values)
(in response to Timothy John Suhr)

Hi Tim,

Yes I found that any message boxes within the code would throw off the timing of the SendKeys.

Like I said I've been working on using the WinAPI32 to set the values and while I can get the Parameters for Compass Manipulation window and set the focus on it it still ignores any SendKeys once I've done so.

I do have a version that allows the user to input for translation and rotation but if the user uses the mouse to select OK it throws of the SendKeys timing but if they just hit the "Enter" key it works.