🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to get the component id

Hi all,

 

 My objective was to write a program to select the components from the file and i want to print the ID's of the component which i have selected in order.

 

when i try to print those i am getting the ID's in ascending order..

 

I want those ID's in the order i have selected..

 

I selected the components using this option.

 

*createmarkpanel comps 1 'Select Components//s'
set compList [hm_getmark comps 0]

 

 

 

Thanks in Advance.

 

Karthikeyan

Find more posts tagged with

Sort by:
1 - 8 of 81

    Hello,

     

    try the following...

     

    *createmarkpanel components 1 'Select components ...'
    set compList [hm_getmark components 1]
    hm_markclear components 1

    foreach compID $compList {
        set compName [hm_getcollectorname comp $compID]
          tk_messageBox -message 'CompName (CompID): $compName ($compID)'
    }

     

    Regards,

    Mario

    Thanks for the reply..

     

    Example:

     

    Comp_1 (1234)

    Comp_2 (2345)

    Comp_3 (3456)

     

     

    But still if i select the component in a order like Comp_2, Comp_3 & Comp 1.. Still it is showing in the ascending order like Comp_1,Comp_2 & Comp_3..

     

    It should show like Comp_2, Comp_3 & Comp 1..

    tinhUser: "tinh"
    Altair Community Member
    Updated by tinh

    hi,

    using *createlistpanel instead of *createmarkpanel will return an ordered list

    Thanks for the reply

     

     

    We can use *createlistpanel only for elems, laminates, lines, nodes and surfs. But not Components. I have checked that also..

     

    Regards

    Karthikeyan

    tinhUser: "tinh"
    Altair Community Member
    Updated by tinh

    yes, that's right. I hope altairians will make it possible soon for comps

    you can repeat 'hm_getmark' to monitor changing in the mark and can get the comp list as in order

    for example

     

    set complist {}

    set repeat_on 1

    repeat_hm_getmark

    *createmarkpanel comps 1 'select comps:'

    *clearmark comps 1

    set repeat_on 0

    tk_messageBox -message $complist

     

     

    this is minimum example of proc 'repeat_hm_getmark'

    proc repeat_hm_getmark {} {

      foreach compid [hm_getmark comps 1] {

        if {[lsearch $::complist $compid]==-1} {lappend ::complist $compid}

      }

      if {$::repeat_on} {after 100 repeat_hm_getmark}

    }

    Thanks for the Reply!!!

     

    I am new to the Tcl scripting and i know how to convert from cmf to tcl and  to use some loops to do the repeated tasks..

     

    i came up with a different idea, like get the components one by one and print it on a file.

     

    set fileName 'component_id.txt'
    set fileId [open $fileName 'a+']
    set i 0
    set length 5
    while {$i < $length} {

    *createmarkpanel comps 1 'Select One Component'
    set compList [hm_getmark comps 1]

    set id [lindex $compList 0]
    puts -nonewline $fileId '$id'
    puts -nonewline $fileId ' '
    set i [expr {$i + 1}]
    }
    close $fileId
     

     

     

    But, the problem with this is it will get only 5 components from the user.. Is there anyway doing like getting the input till the user press a key, For Example 'ESC'...If he presses ESC it should come out of the loop and the file should be written with the given inputs..

    tinhUser: "tinh"
    Altair Community Member
    Updated by tinh

    yes, ofcourse you can do it

    if you press esc mean you do not select any comp more

    so hm_getmark comps 1  will return '' to complist

    so you just check complist:

     

    if {[llength $compList]==0} {break}

     

    break will terminate the loop

    Thanks!!!. It worked perfectly...