Jump to content
Jeffersondhv

GUI for HyperMesh Script

Recommended Posts

Hello all,

 

When I need to have user interaction with a script I'm working on, usually I use Tk to create the user interface,

I was wondering if there's a way to generate a GUI similar to what we see for common HM functions, where all the steps and required information are displayed at the same time.

 

How can that be achieved?

 

Thanks,

Jefferson

Share this post


Link to post
Share on other sites

What I want is to have all the options and settings for the function being called to be selected and viewed all at once as any other HyperMesh function.

For example, the Automesh function displays this dashboard when selected:

 

image.thumb.png.8d1b2a41a15f2189e96875c1a5440f6b.png

 

For now what I have is based basically on yes or no questions using the tk_messageBox function and some functions like hm_getfloat and createmarkpanel to get user input. But I would like to have something more visual and easy for the user to navigate through the options and different selections the function can offer.

 

image.thumb.png.1384679eeba1b9abe56e7e98e19faefc.png

 

Can that be done? Or how could this workflow be improved?

 

Thanks,

Jefferson

Share this post


Link to post
Share on other sites

Sure, that can.

you need to make a window (using command 'toplevel'), or a frame (using command 'frame')

create buttons (using command 'button'), entry box (using command 'entry'), other widgets like labels, menus, ...

and then bring them into the toplevel window (using command 'pack', or 'grid', or 'place')

 

many Tk commands help with building GUI you can refer here:

https://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm

 

Jeffersondhv likes this

Share this post


Link to post
Share on other sites

Hi

Set w .wDemo

Destroy $w

Toplevel $w

Wm transient $w .

For {set i 1} {$i<5} {incr i} {

     Frame $w.f$i

     Label $w.f$i.lbl -text "Input $i ="

     Entry $w.f$i.ent

     Pack $w.f$i.lbl -side left -anchor w

     Pack $w.f$i.ent -side right -anchor e

     Pack $w.f$i -side top -anchor nw -fill x

}

Button $w.b -text Proceed

Pack $w.b -side top -anchor e

Share this post


Link to post
Share on other sites

Thank you.

But actually this is more like a floating box, a pop-up.

Is there any way to build it in the HM interface just like the picture I showed before?

With a pop-up it would work the same way, but I just wanted to know if that is possible so it would be easier for the user.

 

Thanks,

Jefferson

Share this post


Link to post
Share on other sites
On ‎12‎/‎20‎/‎2018 at 11:08 PM, tinh said:

Hi

Set w .wDemo

Destroy $w

Toplevel $w

Wm transient $w .

For {set i 1} {$i<5} {incr i} {

     Frame $w.f$i

     Label $w.f$i.lbl -text "Input $i ="

     Entry $w.f$i.ent

     Pack $w.f$i.lbl -side left -anchor w

     Pack $w.f$i.ent -side right -anchor e

     Pack $w.f$i -side top -anchor nw -fill x

}

Button $w.b -text Proceed

Pack $w.b -side top -anchor e

Hello Tinh ,

how i can i use the value of this "Entry $w.f$i.ent" for making node coordinate in Hypermesh.

Thanking You

Share this post


Link to post
Share on other sites
33 minutes ago, tinh said:

Hi

Use

Set X [$w.f$i.ent get]

Thank You for your reply Mr. Tinh

in  my tcl program i used a procedure for entry as shown below.

#***********************************************************************************

proc ::Execlug01LUG {args} {
set w .lugType01
destroy $w
toplevel $w
wm transient $w .    

  frame $w.f2
     #---------------------------------------
     label $w.f2.labL1 -text "L1 ="
     entry $w.f2.entL1

     pack $w.f2.labL1 -side left -anchor w
     pack $w.f2.entL1 -padx 15 -pady 2 -side left

     label $w.f2.labL2 -text "L2 ="
     entry $w.f2.entL2

     pack $w.f2.labL2 -side left -anchor w
     pack $w.f2.entL2 -padx 15 -pady 2 -side left
     pack $w.f2 -side top -anchor nw -fill x
     #---------------------------------------


button $w.b -text Model -font {Helvetica -25 bold} -height 1 -width 10 -background gray75 -foreground blue -command {hm_setpanelproc ::modelclick}
pack $w.b -side top -anchor nw -fill x

}

proc ::modelclick {args} {
set l1 [$w.f2.entL1 get]
set l2 [$w.f2.entL2 get]
*createnode 0 0 0 0 0 0;
*createnode l2 0 0 0 0 0;
*createnode l2 l1 0 0 0 0;
*createnode 0 l1 0 0 0 0;
}

 

#***********************************************************************************

 

In this case i am not able to get the value of l1 and l2 to create the nodes. please help me

Thank You

Share this post


Link to post
Share on other sites
1 hour ago, tinh said:

You need this:

set w .lugType01

Thank You for your reply Mr. Tinh

but still getting error "can't read "w.lugType01": no such variable" when i run the following tcl file in hypermesh

#***********************************************************************************

proc ::Execlug01LUG {args} {
set w .lugType01
destroy $w
toplevel $w
wm transient $w .    

  frame $w.f2
     #---------------------------------------
     label $w.f2.labL1 -text "L1 ="
     entry $w.f2.entL1

     pack $w.f2.labL1 -side left -anchor w
     pack $w.f2.entL1 -padx 15 -pady 2 -side left

     label $w.f2.labL2 -text "L2 ="
     entry $w.f2.entL2

     pack $w.f2.labL2 -side left -anchor w
     pack $w.f2.entL2 -padx 15 -pady 2 -side left
     pack $w.f2 -side top -anchor nw -fill x
     #---------------------------------------


button $w.b -text Model -font {Helvetica -25 bold} -height 1 -width 10 -background gray75 -foreground blue -command {hm_setpanelproc ::modelclick}
pack $w.b -side top -anchor nw -fill x

}

proc ::modelclick {args} {

set w.lugType01
set l1 [$w.f2.entL1 get]
set l2 [$w.f2.entL2 get]
*createnode 0 0 0 0 0 0;
*createnode l2 0 0 0 0 0;
*createnode l2 l1 0 0 0 0;
*createnode 0 l1 0 0 0 0;
}

 

#***********************************************************************************

 

Share this post


Link to post
Share on other sites
On 12/20/2018 at 5:31 PM, tinh said:

Yes

Same codes as above and add these lines:

Wm forget $w

Hm_framework addpanel $w "My Panel"

Hm_framework drawpanel "My Panel"

 

Hi tihn,

With this addition I keep getting the following error:

 

My Panel does not exist.      
              while executing                                                   
              "error "$frame does not exist.""                                  
              ("drawpanel" arm line 11)                                         

I'm sorry for so newbie question, but I'm struggling a little to work with GUI.

 

Share this post


Link to post
Share on other sites

Ok, I just replaced "My Panel" on the drawpanel line to $w and it worked fine.

 

Now I'm trying to have in my GUI something like showed below to select entities:

image.png.76ede4d5f8450ffaae9553bb426fe408.pngimage.png.1df34e603a1bb3754f244bdc1b797fbb.png

 

How can this be achieved?

 

Thank you

Share this post


Link to post
Share on other sites

Hi

Use altair/.../hw/tcl/hw/collector/hwcollector.tcl

 

Reference help:

altair/.../hw/tcl/hw/collector/docs

 

 

But it looks a bit difference from native hm collectors, can you override

Share this post


Link to post
Share on other sites

Thanks for you answer tinh.

However I'm not clear how this should be handled to use in one of my codes.

Should I use exec to call the file or something else?

Share this post


Link to post
Share on other sites
On 1/5/2019 at 1:53 AM, Jeffersondhv said:

Thanks for you answer tinh.

However I'm not clear how this should be handled to use in one of my codes.

Should I use exec to call the file or something else?

 

Hey @tinh, can you help me with that?

Thank you.

Share this post


Link to post
Share on other sites

Read the html document in .../docs

The callback is to process events

When something happenning HM will call it with argument is event name

Share this post


Link to post
Share on other sites

I've been playing around with this collector, but I still didn't get to do what I intend. Right now when I use HmMarkTool or HmEntSelCol I can only select the entities one by one, e.g. I cannot create a bounding box in the UI to select the entities inside the box. How can this be achieved?

 

I also found this UI manager called Process Studio and I've been trying to make something work from that.

If I add a collector from that and export a TCL code, I can see the script created to generate that collector, however I'm not being able to run it properly.

So I have the following process on the script:

::hw::pmgr::${::hw::pmgr::namespace}::DisplayWnd

::hw::pmgr::${::hw::pmgr::namespace}::Exec

::hw::pmgr::${::hw::pmgr::namespace}::SetDataInDataModel

::hw::pmgr::${::hw::pmgr::namespace}::GetDataFromDataModel

::hw::pmgr::${::hw::pmgr::namespace}::OnDataModelChanged

 

From that, what do I need to define in order to get this working?

Also, what do I need to define in terms of "hw::pmgr::namespace"?

 

Thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×