change entity type of mark in tcl like in gui

IsabellaR
IsabellaR Altair Community Member
edited February 25 in Community Q&A

Hi,

in the Hypermesh GUI, it is a very useful feature that when I select several items of one entity type (i.e. several parts) I can click the downwards arrow on the selection bar and change the entity type (i.e. to solids). Then, the selection changes to all solids that are part of the parts I selected previously. Is there a command in tcl I can use to cause the same behavior for marks in tcl?
I.e. if I want extract from
*createmark modules 1 $myPartID
all solids contained within this mark 1 (resp. the part with id $myPartID) without having to navigate from parts to components to solids step by step?

Thanks!

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • Michael Herve
    Michael Herve
    Altair Employee
    Answer ✓

    Hello @IsabellaR,

    one of my colleague share this peice of code with me:

    proc GetCompsByPartAssembly {partAssemblyId} {

        set compIdList ""

        foreach partId  [hm_me_childrenget $partAssemblyId] {

              #if {[hm_getvalue parts id=$partId dataname=structural_type]!="Part"} {continue};# not needed

                set compIdList [concat $compIdList [hm_me_entitiesget $partId comps]]

          }

          return $compIdList

    }

    Can you please test it?

    Regards,

    Michael

Answers

  • Michael Herve
    Michael Herve
    Altair Employee

    Hello,

    there are couple of methods you can use for such steps.

    For the case you mentionned above, you don't need the mark of module, you just needto create the mark of solids:

    *createmark solids 1 by "module" Part3

    Please note that when you deal with modules (Parts and PartAssdemblies), the unique ID is generally is the recommended identifier

    In some other cases (eg, from node getting elements), commands such as *findmark may help

    Best Regards,

    Michael

  • IsabellaR
    IsabellaR Altair Community Member

    Hi Michael,

    thanks for your response. I tried it *createmark solids 1 "by module id" 1000 and it works fine. However, now I want to get from PartAssemblies to Components and this does not work. I tried the following:

    set assyIDs [list 1006 1010 1044]
    eval *createmark comps 1 "by module id" $assyIDs

    The comps mark then contains the components with ids 1006 1010 1044, not the components contained within PartAssemblies 1006 1010 1044. Any ideas how to solve this?

    Best Regards,
    Isabella

  • Michael Herve
    Michael Herve
    Altair Employee
    Answer ✓

    Hello @IsabellaR,

    one of my colleague share this peice of code with me:

    proc GetCompsByPartAssembly {partAssemblyId} {

        set compIdList ""

        foreach partId  [hm_me_childrenget $partAssemblyId] {

              #if {[hm_getvalue parts id=$partId dataname=structural_type]!="Part"} {continue};# not needed

                set compIdList [concat $compIdList [hm_me_entitiesget $partId comps]]

          }

          return $compIdList

    }

    Can you please test it?

    Regards,

    Michael

  • IsabellaR
    IsabellaR Altair Community Member

    Hi Michael,

    it works, thanks.
    However, it is not 100% what I was originally searching for - I was hoping for an option without loops, because the loops tend to make my script very slow as my model is quite big. But I can work with the solution.

    Thank you and best regards,
    Isabella

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.