Control (focus) another HM screen based on movement in first HM.

Jouher_20929
Jouher_20929 Altair Community Member
edited October 2020 in Community Q&A

Hi,

I have to move, zoom in, zoom out my second hypermesh based on movement of mouse pointer in first hm screen. That is, the x,y,z in first hm sgould be replicated simulatanaeously in second hm.

 

This is to compare two models.

 

How can i code this. Pls help. Is it possible?

 

@tinh Do you have any idea, or code?

Answers

  • tinh
    tinh Altair Community Member
    edited March 2019

    Yes.

    Set a timer with trigger proc that get view matrix of 1st hm, send this matrix to 2nd hm. 

    2nd hm receives and display model with that view matrix

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2019

    @tinh Thanks Tin, can you explain with code briefly, if possible. what is trigger proc and how to get updated view matrix alone each time

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2019

    @tinh and zoom in zoom out is not recorded in command file. what to do?

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited March 2019

    Hi Jouher,

     

    This can be easily done in HyperView using Synchronize Windows to compare models. Unless you want to update mesh you should be able to compare models easily in HyperView. 

     

    image.png.00b8638a928ba68c24d42123aa4e479e.png

  • tinh
    tinh Altair Community Member
    edited March 2019

    Because zoom in/ zoom out not recorded in command.tcl, you cannot catch that event

    So I think periodically monitor viewmatrix, if it is changed we will send message to 2nd hm

     

    A timer is created by command 'after'

    A proc like this will self-repeated by a timer:

     

    proc ::MonitorViewMatrix {Period Callback} {

         if {![info exists ::MonitorViewMatrix(matrix)]} {

              set ::MonitorViewMatrix(matrix) [hm_winfo viewmatrix]

         }

         set matrix [hm_winfo viewmatrix]

         if {![string equal $matrix ::MonitorViewMatrix(matrix)]} {

              catch {eval $Callback}

         }

         if {[info exists ::MonitorViewMatrix(timer)]} {

              after cancel $::MonitorViewMatrix(timer)

         }

         set ::MonitorViewMatrix(timer) [after $Period [list ::MonitorViewMatrix $Period $Callback]]

    }

     

     

     

    You have to prepare a callback proc, example ::SendTo2ndHm

    Then start monitoring view changes by:

    ::MonitorViewMatrix 2000 ::SendTo2ndHm

     

     

    To send a message to 2nd hm, you should use dde facility, or socket (need administrator account)

     

    Are you familiar with client-server programming?

    Refer to dde commands in Tcl/Tk manual.

     

    Example::

    Open a server on 2nd hm:

    package require dde

    dde servername -handler eval -- HM2

    (HM2 may be changed if another already opened)

     

     

    A simple ::SendTo2ndHm on 1st hm:

    package require dde

    proc ::SendTo2ndHm args {

         dde eval -async HM2 *viewset {*}[hm_winfo viewmatrix]

    }

     

     

  • tinh
    tinh Altair Community Member
    edited March 2019

    Sorry, i forgot a claw (bold line)

     

     proc ::MonitorViewMatrix {Period Callback} {

         if {![info exists ::MonitorViewMatrix(matrix)]} {

              set ::MonitorViewMatrix(matrix) [hm_winfo viewmatrix]

         }

         set matrix [hm_winfo viewmatrix]

         if {![string equal $matrix ::MonitorViewMatrix(matrix)]} {

              catch {eval $Callback}

              set ::MonitorViewMatrix(matrix) $matrix

         }

         if {[info exists ::MonitorViewMatrix(timer)]} {

              after cancel $::MonitorViewMatrix(timer)

         }

         set ::MonitorViewMatrix(timer) [after $Period [list ::MonitorViewMatrix $Period $Callback]]

    }