TCL script : need help
Dear Sir,
I am Begineer to TCL scripting. need small help
actually i am developing a small script i.e
lets say i have few components with naming like COMPNAME_MATNAME_Txx. this script will read COMPNAME & and it will create a PSHELL property with thickness (xx) with same name. and also it will read MATNAME and it will create material with same name.
Q) i want split the original compname & matname and assign to some variable like this : set thickness [string trimleft [lindex [split $comp_name _] end] t]
how to do this one?
I have done with simple commands like (string range).please refer below picture
Thank you,
Regards,
Gopi
Answers
-
Hi
Suppose there are only 3 '_' in the name.
regexp -nocase {^([^_]+)_([^_]+)_t(.+)$} $comp_name = CompName MatName Thickness
0 -
Altair Forum User said:
Hi
Suppose there are only 3 '_' in the name.
regexp -nocase {^([^_]+)_([^_]+)_t(.+)$} $comp_name = CompName MatName Thickness
Thanks for your quick reply.
yeah i want to split according '_ . (underscore)
but how to assign to different variable using above logic?
i want to do like this: set compname xxxxxxx(logic)
set matname xxxxxxxx(logic)
set thickness [string trimleft [lindex [split $comp_name _] end] t]
getting some error please check below pic
0 -
Do you copy and paste my command?
/emoticons/default_rolleyes.gif' title=':rolleyes:' />
0 -
Please type it as it is, from regexp to the end, don't miss any character, you will get CompName MatName and Thickness
0 -
Altair Forum User said:
Please type it as it is, from regexp to the end, don't miss any character, you will get CompName MatName and Thickness
Hi ,
I tried with below command but did not get comp mat and thickness names.
regexp -nocase {^([^_]+)_([^_]+)_t(.+)$} $comp_name
can suggest me another method to split this (ex:comp1_mat1_txx). I want to split this onto three different parts i.e comp1, mat1, & xx (thickness value)
thanks in advance
0 -
You can use split, lassing, string range commands to do it.
Regexp will do it in 1 invocation.
0 -
Altair Forum User said:
You can use split, lassing, string range commands to do it.
Regexp will do it in 1 invocation.
Yeah it is very useful command. Successfully done.
Thanks @tinh
0