Get Elements in Tcl Variable (Large no of elements > 6 Lakh)

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hi,

 

I am trying to get all elements of a component in a Tcl variable (Elements Count > 6 Lakh) and Hypermesh is taking too long (~ 1 hours) and ends with a not responding error message.

 

eg.      catch {unset all_component_elements};
            hm_markclearall 1;
            hm_markclearall 2;
            *rejectclear;
            *clearmark elems 1
            hm_markclear elems 1;
            *createmark elems 1 'by comp' $comp
            set all_component_elements [hm_getmark elems 1];

 

Is there any other method to retrieve these elements inside Tcl variables.

I need to use this logic inside Tcl Script/Macro.

 

Thanks in Advance, for help.

Regards

Piyush

Tagged:

Answers

  • QuyNguyenDai
    QuyNguyenDai Altair Community Member
    edited March 2018

    How many elements do you have within this component?

     

  • tinh
    tinh Altair Community Member
    edited March 2018

    Hi,

    I think it was slow due to this command:

    *createmark elems 1 'by comp' $comp

    because it will highlight elements.

     

     

    From version 13 please try this command (avoid using commands with * prefix)

     set all_component_elements [hm_getvalue comps name=$comp dataname=elements]

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi,

     

    @Q.Nguyen-Dai  Elements Count in component is more than 6 lakh (~ 6,75,000).

     

    @tinh  I have tried with 'hm_' commands also. But still the result is same.

     

    Either, I am using '*createmark elems 1 'by comp' $comp' or not,  this command is not taking time.

     set all_component_elements [hm_getvalue comps name=$comp dataname=elements]    ## This command anyhow is taking too much time (~50 minutes). 

    I have tried other 'hm_ ' commands too , but no change.

     

    Thanks & Regards

    Piyush

     

  • tinh
    tinh Altair Community Member
    edited March 2018

    ah, 

    Please go to folder My Documents and delete files command.cmf and/or command.tcl

    I guess this file is too big.

    And don't output to that file:

     hm_commandfilestate 0  set all_component_elements [hm_getvalue comps name=$comp dataname=elements] 

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi,

    @tinh I have already tried deleting files in My Documents.

    The File size is not big  (~ 1 KB only).

    But still the time taken is same and Hypermesh is going into not-responding state.

     

    Is there any other method to access HM database and get all elements of a component (Element Count > 6 Lakh)

     

    Thanks & Regards

    Piyush

  • tinh
    tinh Altair Community Member
    edited March 2018

    did you try 'hm_commandfilestate 0' before getting elements?

       

    If element count is huge, maybe the only way is upgrade your RAM or Graphic card

    Could you show your computer hardware information?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi @tinh,

     

    I have blocked updating 'command.tcl' using 'hm_commandfilestate 0'. But still this thing is not working.

     

    My system configuration is :

     

    OS : Windows 7 (64-bit)

    Processor : Intel(R) Xeon(R) CPU E5-1650v3 @3.50GHz

    Ram : 8.00 GB

     

    But still not working.

     

    Regards

    Piyush

  • tinh
    tinh Altair Community Member
    edited March 2018

    how's about graphic card?

  • QuyNguyenDai
    QuyNguyenDai Altair Community Member
    edited March 2018

    Share you HM model?

  • QuyNguyenDai
    QuyNguyenDai Altair Community Member
    edited March 2018

    Hi,

     

    @Q.Nguyen-Dai  Elements Count in component is more than 6 lakh (~ 6,75,000).

     

     

    'lakh'? What's this?

    6,75,000 ???

  • tinh
    tinh Altair Community Member
    edited March 2018

    :rolleyes:/emoticons/default_rolleyes.gif' title=':rolleyes:' /> maybe, a local unit!

    anyway, it is not a big number.

     

    I just realize that if he typed the commands into command window then it is a big problem because buffer of tkcon is limited!

    @Piyush4 could you copy your code to a tcl file and run it, or add a 'puts ok' command at the end, then copy the codes to command window, it will put only 'ok' instead of tons of characters

    like this:

    set all_component_elements [hm_getvalue comps name=$comp dataname=elements]; puts ok

     

    do not type puts ok on new line, so tkcon will evaluate and print out only last command

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi

     

    @tinh Graphic Card configuration : 2GB Nvidia

                  I am running commands using Tcl File only ie I am creating script / macro.

                  Your direction of tkcon buffer was really helpful. Its working in most of the cases which slows down my script execution in Hypermesh.

     

    @Q.Nguyen-Dai Sorry, but I can't share model, that's Confidential Property of Company.

                                 'Lakh' is a unit in the Indian numbering system equal to one hundred thousand (100,000; scientific notation: 105).

                                  I need to convey that Element Count in Model / No of Elements = 675000

     

    Moreover, I got suggestion for  using '::hwat::utils::CreateMark'.  This can also help ???  

     

    Thanks & Regards

    Piyush

  • tinh
    tinh Altair Community Member
    edited March 2018

    Did you try running my below suggested command?

    set all_component_elements [hm_getvalue comps name=$comp dataname=elements]; puts ok

     

    even if you run it by sourcing file, source command will return the value of the last command in tcl file, and if it is called from tkcon, buffer will be tired.

    I tested with normal computer, it take about just half of second for 1million elems.

     

    Another probability, your tcl file has problem elsewhere, please show us your tcl file content

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi @tinh

     

    I am really thankful for your suggestion. It worked for me.

    Sorry to say but I cannot share tcl file content or any model content, as it is under confidential proprietory of Company.

     

    I just need to know  using '::hwat::utils::CreateMark can also work for such problems ?

     

    Regards

    Piyush

  • QuyNguyenDai
    QuyNguyenDai Altair Community Member
    edited March 2018

    Hi

     

    @Q.Nguyen-Dai Sorry, but I can't share model, that's Confidential Property of Company.

                                 'Lakh' is a unit in the Indian numbering system equal to one hundred thousand (100,000; scientific notation: 105).

                                  I need to convey that Element Count in Model / No of Elements = 675000

     

    Moreover, I got suggestion for  using '::hwat::utils::CreateMark'.  This can also help ???  

     

    Thanks & Regards

    Piyush

    Why write 'local numbering' in English post?

    675000 elements is NOT big model.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi @Q.Nguyen-Dai

     

    Thanks for your suggestion and help. Will keep it it mind from now.

     

    Regards

    Piyush

  • tinh
    tinh Altair Community Member
    edited March 2018

    Hi @tinh

     

    I am really thankful for your suggestion. It worked for me.

    Sorry to say but I cannot share tcl file content or any model content, as it is under confidential proprietory of Company.

     

    I just need to know  using '::hwat::utils::CreateMark can also work for such problems ?

     

    Regards

    Piyush

     

     

    So, can we conclude the reason is finally due to ouput too much data to tkcon command window?

    => you do not to show your tcl file any more.

     

    Yes, hwat::utils::CreateMark can work, same with hm_createmark, they are just tcl procs that call to hm command *createmark

    But the arguments may be different. please check reference guide

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Yes , the lack in running script was due to streaming of Large Data to tkcon command window.

     

    It can be resolved by adding command like ;puts ' ' or ;puts ok in the same line (line which is slowing down the process). 

    This would help not to display the whole data of previous command and the tcl variable can be easily populated with values (with no delay).

     

    Regards

    Piyush