Querying about some element for 1D- stress value

Vikas Kumar_22189
Vikas Kumar_22189 Altair Community Member
edited October 2020 in Community Q&A

Dear all,

 

I wants to perform query for some element not for whole model as shown in below picture.

 

image.png.40bfadeff4e11978f61dda1d28f13a9d.png

 

I am trying with this code but in this it is giving miximum value only for whole model but i want result for specific element ID. can anyone help me.

 

My code is.

                                     Model handle i got earlier as mh$t .

                                    mh$t GetQueryCtrlHandle qch$t
                                    qch$t SetDataSourceProperty result datatype Stress
                                    set set_query 'contour top 1'
                                    set set_result_component 'contour.value'
                                    set id_SelectedNode [mh$t AddSelectionSet element]
                                    mh$t GetSelectionSetHandle selection_set_handle_node$t $id_SelectedNode
                                    # selection_set_handle_node$t Add $set_query
                                    selection_set_handle_node$t Add $SpecificElem_ID ; # adding specific element which was added b4 
                                    qch$t SetSelectionSet $id_SelectedNode
                                    qch$t SetQuery 'contour.value'
                                    qch$t GetIteratorHandle i$t
                                    i$t First
                                    if { [i$t Valid] } {
                                        set contourValue [i$t GetDataList]
                                        puts 'contourValue: $contourValue'
                                    } else {
                                        set contourValue 'N/A'
                                    }

 

Thanks,

Vikas Kumar

 

Answers

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited July 2018

    Hi Vikas,

    You can pass the element Ids you want to the below procedure:

     

    proc contourValue {lst_elements} {
        hwi OpenStack
            set t [clock clicks]
            hwi GetSessionHandle session$t
            session$t GetProjectHandle project$t
            project$t GetPageHandle page$t 1
            page$t GetWindowHandle win$t 1
            win$t GetClientHandle anim$t
            anim$t GetModelHandle my_model$t [anim GetActiveModel]
            my_model$t GetQueryCtrlHandle my_query$t
            set set_id [my_model$t AddSelectionSet element]
            my_model$t GetSelectionSetHandle elem_set$t $set_id
            foreach id $lst_elements {
                elem_set$t Add 'id $id'
            }
            my_query$t SetSelectionSet $set_id
            # my_query$t SetQuery 'element.id contour.value';
            my_query$t SetQuery 'contour.value'; #only contour value
            my_query$t GetIteratorHandle my_iter$t
            set data_list ''
            for {my_iter$t First} {[my_iter$t Valid]} {my_iter$t Next} {
            lappend data_list [my_iter$t GetDataList]
            }
            puts '$data_list----data_list';
            my_model RemoveSelectionSet $set_id
        hwi CloseStack
    }

    Regards

    llyle

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited July 2018

    Hi Livil,

     

    It is Giving contour value for only one element.

    But in selection set all element id is present.

     

    Regards,

    Vikas

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited July 2018

    foreach id $lst_elements {
                elem_set$t Add 'id $id'
            }

    You'll have to add element by element. 

  • Mahesh Agrani
    Mahesh Agrani Altair Community Member
    edited April 2019

    You can pass the element Ids you want to the below procedure:

    Thanks for sharing @Livil Lyle, where to add element ids eg. 700001, 700002, 700003 etc? 

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited April 2019

    source the proc contourValue above,

     

    set lst_elems  {700001 700002 700003}

    contourValue $lst_elems

     

    I would recommend you to get more familiar with tcl programming before getting into HV automation.