Problem in contour plotting using TCL

Rachit Semalty
Rachit Semalty Altair Community Member
edited September 2022 in Community Q&A

Hi all. I was trying to plot the signed von-mises stress contour for a component named "2D" with ID 4. I did it using the hwc commands in hyperview 2021 but those commands do not work in the 2019 version. With some help online, I wrote the following code:

hwi OpenStack;
hwi GetSessionHandle ses_h;
ses_h GetProjectHandle pro_h;
pro_h GetPageHandle pg_h [pro_h GetActivePage];
pg_h GetWindowHandle win_h [pg_h GetActiveWindow];
win_h GetClientHandle cli_h;

i
cli_h AddModel $fileName
cli_h GetModelHandle mod_h [cli_h GetActiveModel];
mod_h SetResult $fileName

# isolating 2D component
set id1 [mod_h AddSelectionSet element]; 
mod_h GetSelectionSetHandle sel_s_h_e $id1; 
sel_s_h_e Add "component 4"; # component 2D has ID 4
sel_s_h_e Reverse; 
mod_h Mask $id1; 
sel_s_h_e ReleaseHandle; 

# setting the result
mod_h GetResultCtrlHandle res_h; 
res_h GetContourCtrlHandle cont_h; 
cont_h SetEnableState true; 
cli_h SetDisplayOptions "contour" true;
cont_h SetDataType "Element Stresses"; 
cont_h SetShellLayer "max";
cont_h SetDimensionEnabled shell true
cont_h SetDataComponent shell "2D";
#cont_h SetDataComponent "SignedVonMises"; 
cont_h SetAverageMode "simple"; 
cli_h Draw; # draw the contour

 

_________________________________________

 

The above script does not seem to work as no contours are plotted. Also, how may I include "signed von Mises" results in this script? Please help me correct this script. 

Also, is there any way to run hwc commands in version 2019 and lower?

Regards,

Rachit

Best Answer

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited September 2022 Answer ✓

    Hi Adriano. Thanks for your reply. I tried writing the exact name as in HV but it still does not work.

    It seems that I have not selected any component for plotting. In hwc command there was a line for marking components. But I don't think that I have selected any component in the above code. Is that the problem? If yes, then how may I select the components?

     

    Regards,

    Rachit

    You can re-use the selection set commands before contouring:

    # isolating 2D component
    set id1 [mod_h AddSelectionSet element]; 
    mod_h GetSelectionSetHandle sel_s_h_e $id1; 
    sel_s_h_e Add "component 4"; # component 2D has ID 4

     

    Just take care of the Object name, so that is not the same as before, to avoid conflicts.

    Then, for applying a contour only to the Selection Set, use this

     

    cont_h SetSelectionSet id_of_your_slection_set

     

    image

Answers

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited September 2022
    cont_h SetDataType "Element Stresses";

    This should be set to the exact name that shows in HV when you do it manually.

    "Signed VonMises...."

    The only thing you will remove is the (t) which means tensor.

  • Rachit Semalty
    Rachit Semalty Altair Community Member
    edited September 2022

    cont_h SetDataType "Element Stresses";

    This should be set to the exact name that shows in HV when you do it manually.

    "Signed VonMises...."

    The only thing you will remove is the (t) which means tensor.

    Hi Adriano. Thanks for your reply. I tried writing the exact name as in HV but it still does not work.

    It seems that I have not selected any component for plotting. In hwc command there was a line for marking components. But I don't think that I have selected any component in the above code. Is that the problem? If yes, then how may I select the components?

     

    Regards,

    Rachit

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited September 2022 Answer ✓

    Hi Adriano. Thanks for your reply. I tried writing the exact name as in HV but it still does not work.

    It seems that I have not selected any component for plotting. In hwc command there was a line for marking components. But I don't think that I have selected any component in the above code. Is that the problem? If yes, then how may I select the components?

     

    Regards,

    Rachit

    You can re-use the selection set commands before contouring:

    # isolating 2D component
    set id1 [mod_h AddSelectionSet element]; 
    mod_h GetSelectionSetHandle sel_s_h_e $id1; 
    sel_s_h_e Add "component 4"; # component 2D has ID 4

     

    Just take care of the Object name, so that is not the same as before, to avoid conflicts.

    Then, for applying a contour only to the Selection Set, use this

     

    cont_h SetSelectionSet id_of_your_slection_set

     

    image

  • Rachit Semalty
    Rachit Semalty Altair Community Member
    edited September 2022

    You can re-use the selection set commands before contouring:

    # isolating 2D component
    set id1 [mod_h AddSelectionSet element]; 
    mod_h GetSelectionSetHandle sel_s_h_e $id1; 
    sel_s_h_e Add "component 4"; # component 2D has ID 4

     

    Just take care of the Object name, so that is not the same as before, to avoid conflicts.

    Then, for applying a contour only to the Selection Set, use this

     

    cont_h SetSelectionSet id_of_your_slection_set

     

    image

    Hi Adriano. I tried using the selection set handle also. But the problem is still there. All the components are just turning grey with no contour being plotted.

    The code I used is given below:

     

    hwi OpenStack;
    hwi GetSessionHandle ses_h;
    ses_h GetProjectHandle pro_h;
    pro_h GetPageHandle pg_h [pro_h GetActivePage];
    pg_h GetWindowHandle win_h [pg_h GetActiveWindow];
    win_h GetClientHandle cli_h;

    i
    cli_h AddModel $fileName
    cli_h GetModelHandle mod_h [cli_h GetActiveModel];
    mod_h SetResult $fileName

    # isolating 2D component
    set id1 [mod_h AddSelectionSet element]; 
    mod_h GetSelectionSetHandle sel_s_h_e $id1; 
    sel_s_h_e Add "component 4"; # component 2D has ID 4
    sel_s_h_e Reverse; 
    mod_h Mask $id1; 
    sel_s_h_e Reverse; 

    # setting the result
    mod_h GetResultCtrlHandle res_h; 
    res_h GetContourCtrlHandle cont_h; 

    cont_h SetSelectionSet $id1;
    cli_h SetDisplayOptions "contour" true;
    cont_h SetDataType "Element Stresses (2D & 3D)"; 
    cont_h SetShellLayer "max";
    cont_h SetDimensionEnabled shell true
    cont_h SetDataComponent shell "SignedVonMises";
    cont_h SetAverageMode "simple";

    cont_h SetEnableState true; 
    cli_h Draw; # draw the contour

     

    Please check the above code for errors. Or if possible please write a small piece of code for plotting contour and post here.

    I have seen some code for plotting in Altair script use cases but even that does not seem to help. I must be making some mistakes somewhere.

    Regards,

    Rachit

     

  • Rachit Semalty
    Rachit Semalty Altair Community Member
    edited September 2022

    Hi Adriano. I tried using the selection set handle also. But the problem is still there. All the components are just turning grey with no contour being plotted.

    The code I used is given below:

     

    hwi OpenStack;
    hwi GetSessionHandle ses_h;
    ses_h GetProjectHandle pro_h;
    pro_h GetPageHandle pg_h [pro_h GetActivePage];
    pg_h GetWindowHandle win_h [pg_h GetActiveWindow];
    win_h GetClientHandle cli_h;

    i
    cli_h AddModel $fileName
    cli_h GetModelHandle mod_h [cli_h GetActiveModel];
    mod_h SetResult $fileName

    # isolating 2D component
    set id1 [mod_h AddSelectionSet element]; 
    mod_h GetSelectionSetHandle sel_s_h_e $id1; 
    sel_s_h_e Add "component 4"; # component 2D has ID 4
    sel_s_h_e Reverse; 
    mod_h Mask $id1; 
    sel_s_h_e Reverse; 

    # setting the result
    mod_h GetResultCtrlHandle res_h; 
    res_h GetContourCtrlHandle cont_h; 

    cont_h SetSelectionSet $id1;
    cli_h SetDisplayOptions "contour" true;
    cont_h SetDataType "Element Stresses (2D & 3D)"; 
    cont_h SetShellLayer "max";
    cont_h SetDimensionEnabled shell true
    cont_h SetDataComponent shell "SignedVonMises";
    cont_h SetAverageMode "simple";

    cont_h SetEnableState true; 
    cli_h Draw; # draw the contour

     

    Please check the above code for errors. Or if possible please write a small piece of code for plotting contour and post here.

    I have seen some code for plotting in Altair script use cases but even that does not seem to help. I must be making some mistakes somewhere.

    Regards,

    Rachit

     

    I found the problem. It is needed to load the animator handle to plot results.

     

    I used the following line of code to load animation just before creating the result handle and the code then worked fine.

    pg_h GetAnimatorHandle animh_grk; # creating the animator handle
    animh_grk Next; # first frame selected
    animh_grk Previous; # latest frame selected

     

    Thanks for your replies. They were helpful.