Selection of components as per user

BG913
BG913 Altair Community Member
edited October 2020 in Community Q&A

Hi,

 

Is there a way to select components in the order the user selects ?? I checked for *createlistpanel but it isn't applicable for components, and hm_getmark always gives a result of a list which is ascending order only.

Answers

  • tinh
    tinh Altair Community Member
    edited March 2019

    Why do you need that?

    A workaround is : select elem list, and then retrieve component list that store them.

     

    Directly, I think we can hook a callback with event graphic_selection_changes

  • BG913
    BG913 Altair Community Member
    edited March 2019

    Actually for this code I really want it as a component selection rather than element. That way the user knows the entire range of selection he/she is making. Like as much as possible I want to avoid the element selection as it would be not as appealing to the user.

     

    And I'm sorry, I don't know much about graphic selection changes, haven't explored those options.

  • Pandurang
    Pandurang Altair Community Member
    edited March 2019

    please Try this:

     

    variable list1

    proc framework args \
    {
        *createmarkpanel comps 1 'Please select the components ';
        hm_framework registerproc getorderedcomps graphics_selection_changed;

       *clearmark comps 1;

    }

    proc getorderedcomps args \
    {
        
        variable list1;
        lappend list1 [noIntersect;];
        
    }

    proc noIntersect args \
    {

        variable list1;
        
        foreach item [hm_getmark comps 1] \
        {
        
            if {$item in $list1} \
            {
                continue;
            } else {set comp $item};
        
        }
        return $comp
    }

    framework
    puts $list1

  • tinh
    tinh Altair Community Member
    edited March 2019

    If user deselect a comp you need to lremove item from list1

  • Pandurang
    Pandurang Altair Community Member
    edited March 2019

    BG913

    Even if deselect component this will take care of it.. Thanks To @tinh for suggestion...

     

    Please try this updated one:

     

    variable list1

    proc framework args \
    {
        *createmarkpanel comps 1 ' ';
        hm_framework registerproc getorderedcomps graphics_selection_changed;

    }

    proc getorderedcomps args \
    {
        
        variable list1;
        set value [noIntersect]
        if {$value != ''} \
        {
            lappend list1 $value ;
        }    
        
    }

    proc noIntersect args \
    {

        variable list1;
        set marklist [hm_getmark comps 1];
        foreach item $marklist \
        {
        
            if {$item in $list1} \
            {
                continue;
            } else {set comp $item};
        
        }
        if {[info exist comp]} \
        {
            return $comp
        } else \
        {
            foreach item $list1 \
            {
        
            if {$item in $marklist} \
            {
                continue;
            } else \
            {    
                set list1 [lremove $list1 $item]
            }
        
            }
        }
    }

    framework
    puts $list1