Jump to content
tlewis3348

Adding buttons to the Utility Menu without administrator access

Recommended Posts

The post here explains that in order to add buttons to the utility menu, files in the Program Files directory need to be changed. However, I have to request special access from our IT department to get the administrator privileges required to modify files in the Program Files directory. This would make changing the utility menu extremely inconvenient. Is there a way that I can tell HyperMesh to reference a file in the default working directory for creating the utility menu?

 

 

Share this post


Link to post
Share on other sites
11 hours ago, tlewis3348 said:

The post here explains that in order to add buttons to the utility menu, files in the Program Files directory need to be changed. However, I have to request special access from our IT department to get the administrator privileges required to modify files in the Program Files directory. This would make changing the utility menu extremely inconvenient. Is there a way that I can tell HyperMesh to reference a file in the default working directory for creating the utility menu?

 

 

Hi,

No need to keep tcl files in Program files everytime, you can keep it in some personal location and mention full path while creating button.

*createbutton(5,"SaveFile TCL",15,0,10,GREEN,"Save file using TCL macro", "EvalTcl","E:\vipin\savefile.tcl") 

 

Then keep userpage.mac in hypermesh working directory(by default My Documents).

Share this post


Link to post
Share on other sites

I have the following code saved in "userpage.mac" in my working directory:

// HWVERSION_2017.2_Jul 25 2017_20:5:5
/////////////////////////////////////////////////////////////////////////////// 
// Filename: userpage.mac
// Purpose:  Macro menu 'User' page definitions.
// Version:  HyperWorks
// Altair Copyright:
/////////////////////////////////////////////////////////////////////////////// 
 
//	User Page Widget Definitions
//
//	Note: Since relative row locations are used, the menu page is built from
//		  the bottom up.
//

//	The following templex test is used to see if the Tcl support buttons
//  should be added.

//{ if ( getenv("HM_DEBUG") == "ON" ) }

	*createbutton(5, "TkCon ...",   -1, 0, 10, BUTTON, "Launch the Tk Console.", EvalTcl, "tkcon.tcl")
	*createbutton(5, "GUI Toolkit ...", -1, 0, 10, BUTTON, "Launch the GUI Toolkit.", LaunchWidgetTour)
	*createbutton(5, "ProDebug", 0, 0, 10, BUTTON, "Connect to the TclPro debugger.", ConnectToDebugger)
	*createbutton(3, "Add Washer",   0, 0, 10, BUTTON, "Adds a washer to the existing hole in the mesh.", "EvalTcl", "macroAddWasher.tcl")
	*createbutton(5,"SaveFile TCL",15,0,10,GREEN,"Save file using TCL macro", "EvalTcl","E:\vipin\savefile.tcl")

//{ endif }


//	User Page Macro Definitions

///////////////////////////////////////////////////////////////////////////////
*beginmacro("ConnectToDebugger")
	//  Purpose:	To connect to a remotely running ProDebug session.
	// 
	//  Note:  		The pathname to the 'prodebug.tcl' script may need to be 
	//				modified to	reflect your installation of TclPro.

	*evaltclstring("source /Program\ Files/tclPro1.4/win32-ix86/bin/prodebug.tcl; debugger_init;",0)
*endmacro()

///////////////////////////////////////////////////////////////////////////////
*beginmacro("LaunchWidgetTour")
	//  Purpose:	Launch the HyperWorks Widget Tour dialog.

 	*evaltclstring("::hwt::WidgetTour",1)
*endmacro()

However, when I start HyperMesh, this is what I see on the User Page:

 

Screenshot_1.png.017c3d9fc3ae0b2d0fadcef15501ddb3.png

 

The point is that as far as I can tell, HyperMesh is ignoring the userpage.mac file that I have saved in my start-in/working directory. Is there something I'm missing?

Share this post


Link to post
Share on other sites

As far as I can tell, I don't have that environment variable set. Here are all the environment variables that I have:

 

Screenshot_1.png.23c4da8783208449a69afe7145b0b332.png

 

Do I need to set HW_CONFIG_PATH to my working directory? I thought it was sufficient to just set the "start-in" path on the shortcut used. Furthermore, clearly the working directory is correct when HyperMesh starts, so I'm still not sure why HyperMesh is ignoring my userpage.mac file.

Share this post


Link to post
Share on other sites

Move your custom macros under 

//	User Page Macro Definitions

it will appear.

 

 

 

 

// HWVERSION_2017.2_Jul 25 2017_20:5:5
/////////////////////////////////////////////////////////////////////////////// 
// Filename: userpage.mac
// Purpose:  Macro menu 'User' page definitions.
// Version:  HyperWorks
// Altair Copyright:
/////////////////////////////////////////////////////////////////////////////// 
 
//    User Page Widget Definitions
//
//    Note: Since relative row locations are used, the menu page is built from
//          the bottom up.
//

//    The following templex test is used to see if the Tcl support buttons
//  should be added.

//{ if ( getenv("HM_DEBUG") == "ON" ) }

    *createbutton(5, "TkCon ...",   -1, 0, 10, BUTTON, "Launch the Tk Console.", EvalTcl, "tkcon.tcl")
    *createbutton(5, "GUI Toolkit ...", -1, 0, 10, BUTTON, "Launch the GUI Toolkit.", LaunchWidgetTour)
    *createbutton(5, "ProDebug", 0, 0, 10, BUTTON, "Connect to the TclPro debugger.", ConnectToDebugger)

//{ endif }


//    User Page Macro Definitions
*createbutton(5, "Add Washer", -1, 0, 10, BUTTON, "Adds a washer to the existing hole in the mesh.", "EvalTcl", "macroAddWasher.tcl")
*createbutton(5,"SaveFile TCL",-1,0,10,GREEN,"Save file using TCL macro", "EvalTcl","E:\vipin\savefile.tcl")
///////////////////////////////////////////////////////////////////////////////
*beginmacro("ConnectToDebugger")
    //  Purpose:    To connect to a remotely running ProDebug session.
    // 
    //  Note:          The pathname to the 'prodebug.tcl' script may need to be 
    //                modified to    reflect your installation of TclPro.

    *evaltclstring("source /Program\ Files/tclPro1.4/win32-ix86/bin/prodebug.tcl; debugger_init;",0)
*endmacro()

///////////////////////////////////////////////////////////////////////////////
*beginmacro("LaunchWidgetTour")
    //  Purpose:    Launch the HyperWorks Widget Tour dialog.

     *evaltclstring("::hwt::WidgetTour",1)
*endmacro()

Sahithya and tlewis3348 like this

Share this post


Link to post
Share on other sites
17 hours ago, vipin said:

Move your custom macros under 


//	User Page Macro Definitions

it will appear.

 

That seems odd. How does a comment affect the functionality of the code?

 

17 hours ago, Imoto said:

It's working fine with Start-in directory in my PC and my colleag's PC.
I tested with attached userpage.mac.

userpage.mac

 

That works as well. This seems very confusing. Why does this file work, but the one I was using previously didn't?

Share this post


Link to post
Share on other sites

It's because you put your code within this condition

so if hm is not running in debug mode, you will not see your button

 

//{ if ( getenv("HM_DEBUG") == "ON" ) }
vipin likes this

Share this post


Link to post
Share on other sites
13 hours ago, tinh said:

It's because you put your code within this condition

so if hm is not running in debug mode, you will not see your button

 


//{ if ( getenv("HM_DEBUG") == "ON" ) }

 

Doesn't the double slash at the beginning of that line comment out the condition though? Or am I misunderstanding something about how comments are interpreted?

Share this post


Link to post
Share on other sites
27 minutes ago, tlewis3348 said:

 

Doesn't the double slash at the beginning of that line comment out the condition though? Or am I misunderstanding something about how comments are interpreted?

 

Are you working with TCL language? If yes, the comment line should begin with

Share this post


Link to post
Share on other sites
56 minutes ago, Q.Nguyen-Dai said:

 

Are you working with TCL language? If yes, the comment line should begin with

 

I am working with whatever language is used for the .mac files in HyperMesh. It's not exactly clear to me what language it is, but I do know it's not TCL (which uses the extension .tcl for its files). The code I was originally using came directly from the program files directory. Here is the path on my system: C:\Program Files\Altair\2017\hm\bin\win64\userpage.mac. It seemed quite clear to me that this file is using "//" to comment out lines that should not be executed. Therefore, I tried to comment out the if-statement. However, clearly, I'm missing something since I did not actually comment out the line like I thought I had.

Share this post


Link to post
Share on other sites

I think language in *.mac file is neither tcl nor C, just a kind of script that hm will process

// is comment but if it's followed by special directives, hm can process ;)

Share this post


Link to post
Share on other sites
On 6/8/2018 at 9:55 PM, tinh said:

I think language in *.mac file is neither tcl nor C, just a kind of script that hm will process

// is comment but if it's followed by special directives, hm can process ;)

 

Wow! That seems like a terrible idea. It seems like that encourages users to never comment their code because it can cause their code to have problems.

Share this post


Link to post
Share on other sites

don't worry, the code with "*" will be process as macro command

just the code without * will be able to process as directives

 

as macro commands have many limits, you should forget it soon and change to use tcl/tk to build GUI and implement

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...