TCL Console Command for filtering through Metadata

Martina Blazheska
Martina Blazheska Altair Community Member
edited October 2023 in Community Q&A

Hello, I am working in HyperMesh by importing geometry as Parts, all of which have metadata. The metadata is stored specifically in the Parts and not in the Components belonging to said parts. I need to be able to select and place under the user mark the Parts which have a certain value for a certain metadata name.

For example. if in the metadata I have several sets of data as such:

<metadata_name>: <metadata_value>

I need to be able to access all the parts which have XYZ as metadata_value.

So far, I have experimented with hm_getusermark, hm_getvalue and hm_getmetadata, but I can't seem to get these commands to do what I want. 

I feel like this is a pretty specific question that requires some level of familiarity with TCL Query Commands and I would be really happy to hear some opinions.

Answers

  • Michael Herve
    Michael Herve
    Altair Employee
    edited October 2023

    Hello Martina Blazheska,

     

    you should be able to use hm_metadata for extracting information

    I defined in HyperMesh two metadata: a string that I labeled "test" and a double that I labeled "value" 

    Using the following commands, I get the information as a list of list:

     

    *createmark surfs 1 2

    hm_metadata findbymark surfs 1

    --> {surfs 2 test string srfse} {surfs 2 value int 2}

     

    Then you could use  foreach loop to store metadata information in a tcl array:

     

    foreach md $metadata {

         set SurfMetadata([lindex $md 2].[lindex $md 1].value) [lindex $md 4]

    }

    parray SurfMetadata

    -->

    SurfMetadata(test.2) = srfse

    SurfMetadata(test.5) = newstring

    SurfMetadata(value.2) = 2

    SurfMetadata(value.5) = 36

     

     

    Unsing the array, you can then easily filter out the metadate:

    - by surface:

    foreach md [array name SurfMetadata *.5] { puts "$md [lindex $SurfMetadata($md)]" }

    -->

    value.5 36

    test.5 newstring

     

    - or for a given metadata

    foreach md [array name SurfMetadata test.*] { puts "$md [lindex $SurfMetadata($md)]" }

    --> 

    test.2 srfse

    test.5 newstring

     

    Does that help?

     

    Best Regards,

    Michael

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.