Help us to write a script to collect elements in set!

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

Hi Guys!

 

I would like to model welds and collect elements from different component to a set, but I have to many components which are connected, therefore this process is fairly slow.  I don't have any experience in scripting, but a script could accelerate my work. You can see below one example for this problem. 3 hollow section encounter at the same place and I need to collect the elements to a set from the common edges as you can see at the pictures below. I need to collect elements to sets whose nodes belong to different components. If you could write a script or give me some useful advise I will be very grateful.
Thank you for your help in advance!

 

Best regards,
Tüki

<?xml version="1.0" encoding="UTF-8"?>Capture1.PNG

<?xml version="1.0" encoding="UTF-8"?>Capture.PNG

Answers

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2017

    There are several methods to do that. I can imagine a simple method:

    • Make a node set for each component
    • Look for intersection (nodes) between sets
    • From intersection nodes, look for elements which share these nodes

    HTH,

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2017

    Thanks for your fast answers! Your method sound logic to me, but there is a problem. There are more than 300 components in my model, so creating sets for each is very slow. (giving property to each component was fun too...). I've just started to use Altair HyperMesh a month ago, so I'm a rookie. I can make node sets for each component, but I don't know how can I check for intersection nodes between sets. Then there is another problem: how can I collect elements to a sets that belong to the intersection nodes?

    Sorry for incomprehension, as I mentioned I'm new with this program.

     

    Thanks for your answer in advance!

     

    Best regards,

    Tüki

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2017

    If you can share a simple model (with some component only) so I can do the test?

  • tinh
    tinh Altair Community Member
    edited April 2017

    Hi, is it a 2D model?

    if it is a 3d, then it's not simple

    let me try ... tomorrow -_-/emoticons/default_sleep.png' srcset='/emoticons/sleep@2x.png 2x' title='-_-' width='20' />

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2020

    Yes, I can. You can see some hollow section in this model, it's just 6 components.
    Thanks for your help! :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />

    Tüki

    Unable to find an attachment - read this blog

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2017

    Hi, is it a 2D model?

    if it is a 3d, then it's not simple

    let me try ... tomorrow -_-/emoticons/default_sleep.png' srcset='/emoticons/sleep@2x.png 2x' title='-_-' width='20' />

    Hi tinh!

    It's a 3D model, but I use shell mesh, so there aren't 3D elements.

  • tinh
    tinh Altair Community Member
    edited April 2017

    It sounds good. could you try

    - shiftF3 select elems, switch 'find edges' to 'find t-con' then click button 'find edges'

    - shiftF5 turn to 'find attached', select 'find elems ... attach to elems'

    select elems>by collector > ^edges > find > save found

    - now enter entity set panel and create your set of elems > retrieve

    then delete the t-connection

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2017

    Here's the TCL script, based on tinh's ideas:

      *createmark elements 1 'displayed' *findedges1 elements 1 1 0 0 30 hm_createmark elems 1 'by comp name' '^edges' *findmark elems 1 257 1 elements 0 2 *entitysetcreate 'E_T' elements 2 *clearmark elems 1 *clearmark elems 2 *clearmark sets 1  *createmark comps 1 'displayed'  foreach i [hm_getmark comps 1] { set cname [hm_entityinfo name components $i] if {$cname == '^edges'} { continue } set set_name 'E_$cname' hm_createmark elems 1 'by set name' 'E_T' hm_createmark elems 2 'by comp id' $i *markintersection elems 1 elems 2 eval *entitysetcreate '$set_name' elems 1 } *clearmark elems 1 *clearmark elems 2

    My script will also create one element Set for each component.

    <?xml version="1.0" encoding="UTF-8"?>T-con2set.png

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2017

    Thanks for the answers!
    If I want to collect all these element into 1 set what should I do then?

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited April 2017

    Already created by my script within the set 'E_T'

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2017

    Already created by my script within the set 'E_T'

    Thanks! I'm home because of Easter, so I could not check the script yet.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2017

    Guys, I found another solution after I scrutinized your method. So here is my method in some easy steps:

    1. Tool page > find > between > find nodes between comps > find > save found
    2. Create > set > change card image to SET_GRID > select nodes > retrieve > proceed
    3. Tool page > find > find attached > find elems attached to nodes > by sets (by grid set you've just created before) > find > save found
    4. Create  > set  > elems > retrieve > proceed

    This method find all of the elements if the grids of your mesh are equivalenced.

    Thanks for help again!

    Best regards,

    Tüki