cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Disable File, New in Creo only if connected to PDM

llie
16-Pearl

Disable File, New in Creo only if connected to PDM

All,

We would like to disable File, New in Creo 5 if the user is connected to PDM and if they are in Offline, then File New is enabled.

Has anyone figured out the code for this?

Input is much appreciated.

1 REPLY 1
sully7
13-Aquamarine
(To:llie)

This should be possible using a Bracket function.

 

I haven't tried running it myself yet, but here's some pseudocode for ProToolkit:

 

  1. Find the name of the command for File->New using a mapkey or trail file (I believe it is "ProCmdModelNew", but as we all know... command names and mapkeys might change from version-to-version of Creo)
  2. use ProCmdCmdIdFind to find the uiCmdCmdID of the function
  3. Define a bracket function in the format of  uiCmdCmdBktFn
  4. In the body of the function you define, you'll want to add handling something to the effect of:
    /*! @brief An example uiCmdCmdBktFn function to stop the command from running
    *   @details Use 'ProServerIsOnline' to determine if the server is online
    */
    int stop_the_desired_function(uiCmdCmdId command, 
                                  uiCmdValue* p_new_value, 
                                  int entering_command,
                                  void** pp_bracket_data) { 
      if (entering_command ==1) {
        // Get the current server
        wchar_t* server_alias;
        ProError err = ProServerActiveGet(&server_alias);
        if (err != PRO_TK_NO_ERROR) { return 1; } // if we don't have a server, allow action
    
        // Check if the server is set to "online"
        ProBoolean server_is_online = PRO_B_FALSE;
        err = ProServerIsOnline(server_alias, &server_is_online);
        ProWstringFree(server_alias);
        if (server_is_online == PRO_B_TRUE) {
          return 0; // stop the command from running
        }
      }
    }
  5. Add a bracket function to the desired command using ProCmdBracketFuncAdd

For some more options... check out "Manipulating Existing Commands", which should be in the following file in your Creo install: <creo_install>/protoolkit/protkdoc/manual0/Menus.html#4

 

Also, as an FYI, this process should look pretty similar in either the C++ OTK, but obviously the code would look a bit different. I haven't checked the docs, but I would assume that the Java OTK should look pretty similar as well.

 

Hope this helps!

 

Thanks,

James Sullivan

President & Founder
CadActive Technologies - www.cadactive.com
Top Tags