How can I create an ordered set of elements in Hypermesh

Raul Garcia_21983
Raul Garcia_21983 Altair Community Member
edited May 2023 in Community Q&A

I'd appreciate is someone could let me know how to use the "element list" function for creating an ordered element set.

 

When selecting not ordered, I've got the usual options to select groups of elements to create the set but the elements are not ordered.

If I choose ordered set the only possible option to select elements seems to be this "element list" where you can only click individual elements one by one...

Any idea / suggestion on a better way create ordered sets?

 

Thanks in advance

Raul

Best Answer

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited May 2023 Answer ✓

    Hi Adriano.

     

    Yes ascending order by ID.

     

    Any ideas on where to start with a TLC script to achieve that?

     

    Thanks

    curious about why it should be an ordered set in your case.

    A regular set, created in HM will by default add the element IDs in ascending order, already.

     

    but anyway, you could use these commands and save a .tcl file to run as a script.

    # Create a new element set
    set elementSetName [hm_getstring "Set name:"]

    # Open element selection panel
    *createmarkpanel elements 1 "select elements:"

    # Get the list of elements and their IDs
    set elementIDs [hm_getmark elements 1]
    *clearmark elements 1

    # Sort the element IDs in ascending order
    set sortedElementIDs [lsort -integer $elementIDs]

    # Create an element set of type ordered List 
    set numElements [hm_marklength elements 2]
    *createentity sets cardimage=SET_ELEM name=$elementSetName
    *setvalue sets name=$elementSetName style=1
    eval "*setvalue sets name=$elementSetName ids={elems $sortedElementIDs}"
    *setvalue sets name=$elementSetName STATUS=0 5422=LIST

    # Print a message with the name of the created element set
    puts "Element set $elementSetName created successfully!"

Answers

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited May 2023

    What is your use case here?

    For creating an order, you need to give the order somehow, and usually this is by clicking in the right order.

    Could you elaborate better? Do you have a path, or something like this?

     

  • Raul Garcia_21983
    Raul Garcia_21983 Altair Community Member
    edited May 2023

    Thanks for your reply Adrian.

     

    I've got a great number of shell elements from where I need to extract a set with the elements in ascending order.

    Elements are created with the automesh function and there is no way to select them using a path or anything like it.

    Even if that were possible, there are more than 10K elements so selecting them one by one is not at option.

     

    I tough there would be a way to select a group of elements, using a window or by collector, etc and that somehow the ordered function will automatically save them in order.

     

    Hope this makes sense.

    Regards

    Raul

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited May 2023

    Thanks for your reply Adrian.

     

    I've got a great number of shell elements from where I need to extract a set with the elements in ascending order.

    Elements are created with the automesh function and there is no way to select them using a path or anything like it.

    Even if that were possible, there are more than 10K elements so selecting them one by one is not at option.

     

    I tough there would be a way to select a group of elements, using a window or by collector, etc and that somehow the ordered function will automatically save them in order.

     

    Hope this makes sense.

    Regards

    Raul

    when you mention in ascending order, you mean based on what? coordinates? or ascending by ID?

    I'd say that for any of those, a TCL script would be a best fit, as I don't see any direct option for that.

  • Raul Garcia_21983
    Raul Garcia_21983 Altair Community Member
    edited May 2023

    Hi Adriano.

     

    Yes ascending order by ID.

     

    Any ideas on where to start with a TLC script to achieve that?

     

    Thanks

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited May 2023 Answer ✓

    Hi Adriano.

     

    Yes ascending order by ID.

     

    Any ideas on where to start with a TLC script to achieve that?

     

    Thanks

    curious about why it should be an ordered set in your case.

    A regular set, created in HM will by default add the element IDs in ascending order, already.

     

    but anyway, you could use these commands and save a .tcl file to run as a script.

    # Create a new element set
    set elementSetName [hm_getstring "Set name:"]

    # Open element selection panel
    *createmarkpanel elements 1 "select elements:"

    # Get the list of elements and their IDs
    set elementIDs [hm_getmark elements 1]
    *clearmark elements 1

    # Sort the element IDs in ascending order
    set sortedElementIDs [lsort -integer $elementIDs]

    # Create an element set of type ordered List 
    set numElements [hm_marklength elements 2]
    *createentity sets cardimage=SET_ELEM name=$elementSetName
    *setvalue sets name=$elementSetName style=1
    eval "*setvalue sets name=$elementSetName ids={elems $sortedElementIDs}"
    *setvalue sets name=$elementSetName STATUS=0 5422=LIST

    # Print a message with the name of the created element set
    puts "Element set $elementSetName created successfully!"

  • Raul Garcia_21983
    Raul Garcia_21983 Altair Community Member
    edited May 2023

    Many thanks for your quick reply and support Adriano.

     

    I tried your script and it works perfectly.

     

    I just need an ordered set for post-processing results using a separate macro for which I need to feed a set "file" where the elements are shorted in ascending order by ID 

    For some reason when you create a normal set (using the non-ordered option) it stars ordering the element ID's in ascending order as you pointed out but when you have a mixed mesh of quads and trias it doesn't work for me.

     

    Regards

    Raul