Script for component table i made is not taking component names with space. it is throwing an error. similarly i want to make it editable.
@tinh @Pandurang The Script for component table, i made is not taking component names with space. it is throwing an error. similarly i want to make it editable.
::hwtk::dialog .d -title 'Abaqus Component Table'
set table [::hwtk::table [.d recess].table]
pack $table -fill both -expand true
$table columncreate cid -type int -text 'Comp ID'
$table columncreate cname -text 'Comp Name'
$table columncreate cthk -type int -text 'Thickness'
$table columncreate Mname -text 'Material Name'
*createmark comps 1 displayed
set cmp [hm_getmark comps 1]
set lnd [hm_marklength comps 1]
for {set j 1} {$j <= $lnd} {incr j} {
foreach CMP $cmp {
set lm [hm_getcollectorname comps $CMP]
set thk [hm_getthickness comps $CMP]
set Pt [hm_getvalue comps id=$CMP dataname=propertyid]
if {$Pt==0} {
set values 'cid $CMP cthk {Not Assigned} cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Pt!=0} {
set MaT [hm_getvalue props id=$Pt dataname=material.name]
*createmark materials 1 'by name' $MaT
set Mnd [hm_marklength mats 1]
if {$Mnd==0} {
set values 'cid $CMP cthk $thk cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Mnd!=0} {
set values 'cid $CMP cthk $thk cname $lm Mname $MaT';
$table rowinsert end row$j -values $values
incr j
}
}
}
}
.d post
Answers
-
Hi jouher,
Try
set values [list cid $CMP cthk {Not Assigned} cname $lm Mname {Not Assigned}];
so as to suppress variable expansion, instead of
set values 'cid $CMP cthk {Not Assigned} cname $lm Mname {Not Assigned}';
Regards,
0 -
Thanks @akitoguc. But, it is displaying component name in table by removing space. But, I want the name to be as it is.
0 -
And please suggest me how to make it editable.
0 -
You can remove spaces from component name by:
set lm [string map {' ' ''} $lm]
I think you can edit string in your hwtk::table widget by default. If you want to update the component name by editting its name in the table, you can do that by setting a callback procedure to a specific column as '-valueaccept' option:
$w columncreate cname -text 'Comp Name' -valueaccept '::SetCompName %V %P'
The callback procedure can be something like below:
proc ::SetCompName { table value prev } { # FIXME: add error handling code *renamecollector comps $prev $value return 1; }
Hope it helps.
0 -
Thanks @akitoguc. But still when i rename , it is throwing error.
My code is:
::hwtk::dialog .d -title 'Abaqus Component Table'
set table [::hwtk::table [.d recess].table]
pack $table -fill both -expand true$table columncreate cid -type int -text 'Comp ID'
$table columncreate cname -text 'Comp Name' -valueaccept '::SetCompName %V %P'
$table columncreate cthk -type int -text 'Thickness'
$table columncreate Mname -text 'Material Name'
*createmark comps 1 displayed
set cmp [hm_getmark comps 1]
set lnd [hm_marklength comps 1]
proc ::SetCompName {table value prev } {
# FIXME: add error handling code
*renamecollector comps $prev $value
return 1;
}
for {set j 1} {$j <= $lnd} {incr j} {
foreach CMP $cmp {
set lm [hm_getcollectorname comps $CMP]
regsub -all {\s} $lm {} lm
set thk [hm_getthickness comps $CMP]
set Pt [hm_getvalue comps id=$CMP dataname=propertyid]if {$Pt==0} {
set values 'cid $CMP cthk {Not Assigned} cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Pt!=0} {set MaT [hm_getvalue props id=$Pt dataname=material.name]
*createmark materials 1 'by name' $MaT
set Mnd [hm_marklength mats 1]
if {$Mnd==0} {set values 'cid $CMP cthk $thk cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Mnd!=0} {
set values 'cid $CMP cthk $thk cname $lm Mname $MaT';$table rowinsert end row$j -values $values
incr j}
}
}
}.d post
0 -
That's because of mismatch of component names; names in the table has spaces taken away, but components actually has names with spaces. Sorry I'm not clear on what you wnat to do.
0 -
@akitoguc I just want to rename component name
0 -
Altair Forum User said:
That's because of mismatch of component names; names in the table has spaces taken away, but components actually has names with spaces. Sorry I'm not clear on what you wnat to do.
I just gave names without space and ran the script. Even then I cannot edit.
0 -
why don't you use component table in Utility tab?
0 -
Please try this script ......I am able to change the name of comp through table
##########
variable table;
proc SetValueCallback {row col value } {
variable table
set id [$table cellget $row,cid]
*setvalue comps id=$id name=$value
return true
}
proc main {} {
::hwtk::dialog .d -title 'Abaqus Component Table'
set table [::hwtk::table [.d recess].table]
pack $table -fill both -expand true
$table columncreate cid -type int -text 'Comp ID'
$table columncreate cname -text 'Comp Name' -validatecommand 'SetValueCallback %I %C %V'
$table columncreate cthk -type int -text 'Thickness'
$table columncreate Mname -text 'Material Name'
*createmark comps 1 displayed
set cmp [hm_getmark comps 1]
set lnd [hm_marklength comps 1]for {set j 1} {$j <= $lnd} {incr j} {
foreach CMP $cmp {
set lm [hm_getcollectorname comps $CMP]
set thk [hm_getthickness comps $CMP]
set Pt [hm_getvalue comps id=$CMP dataname=propertyid]
if {$Pt==0} {
set values 'cid $CMP cthk {Not Assigned} cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Pt!=0} {
set MaT [hm_getvalue props id=$Pt dataname=material.name]
*createmark materials 1 'by name' $MaT
set Mnd [hm_marklength mats 1]if {$Mnd==0} {
set values 'cid $CMP cthk $thk cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Mnd!=0} {
set values 'cid $CMP cthk $thk cname $lm Mname $MaT';
$table rowinsert end row$j -values $values
incr j
}
}
}
}
.d post
}
main0 -
Altair Forum User said:
why don't you use component table in Utility tab?
@tinh Component table is not there in Abaqus profile.
0 -
Altair Forum User said:
Please try this script ......I am able to change the name of comp through table
##########
variable table;
proc SetValueCallback {row col value } {
variable table
set id [$table cellget $row,cid]
*setvalue comps id=$id name=$value
return true
}
proc main {} {
::hwtk::dialog .d -title 'Abaqus Component Table'
set table [::hwtk::table [.d recess].table]
pack $table -fill both -expand true
$table columncreate cid -type int -text 'Comp ID'
$table columncreate cname -text 'Comp Name' -validatecommand 'SetValueCallback %I %C %V'
$table columncreate cthk -type int -text 'Thickness'
$table columncreate Mname -text 'Material Name'
*createmark comps 1 displayed
set cmp [hm_getmark comps 1]
set lnd [hm_marklength comps 1]for {set j 1} {$j <= $lnd} {incr j} {
foreach CMP $cmp {
set lm [hm_getcollectorname comps $CMP]
set thk [hm_getthickness comps $CMP]
set Pt [hm_getvalue comps id=$CMP dataname=propertyid]
if {$Pt==0} {
set values 'cid $CMP cthk {Not Assigned} cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Pt!=0} {
set MaT [hm_getvalue props id=$Pt dataname=material.name]
*createmark materials 1 'by name' $MaT
set Mnd [hm_marklength mats 1]if {$Mnd==0} {
set values 'cid $CMP cthk $thk cname $lm Mname {Not Assigned}';
$table rowinsert end row$j -values $values
incr j
} elseif {$Mnd!=0} {
set values 'cid $CMP cthk $thk cname $lm Mname $MaT';
$table rowinsert end row$j -values $values
incr j
}
}
}
}
.d post
}
main@Pandurang its throwing error.
0 -
Altair Forum User said:
Thanks @Pandurang I have solved the issue.
0 -
@tinh Currently as I am using regsub, component name is displayed omitting spaces. Please see the code. I want to display name as it is .
That is, cuurently, if i remove reg sub, it shows error whilte taking comp names with spaces.
0 -
Hi Jouher
it's due to these lines:
set values 'cid $CMP cthk $thk cname $lm Mname {Not Assigned}';
you should write:
set values [list cid $CMP cthk $thk cname $lm Mname {Not Assigned}];
so $lm with spaces will be preserved
0 -
@tinh Thanks Tinh, It works smoothly. Now, in the above codes what should be modified to add maximize, minimize and refresh button?
0 -
Hi Jouher
maybe hwtk:dialog will create a transient toplevel '.d'
try using:
wm transient .d {}
or create window .d by
toplevel .d
0 -
to create a button:
::ttk:button .d.refresh -text Refresh -command p_RefreshTable
0 -
Altair Forum User said:
to create a button:
::ttk:button .d.refresh -text Refresh -command p_RefreshTable
@tinh I have tried using :
set f [.d recess]
hwtk::button $f.b1 -text 'Refresh' -command {MV}
pack $f.b1And it came. Now I have doubt that what change or command should i add so that when i click refresh button, the table should get refreshed?
0 -
maybe simply... delete your table and then recreate it!, if you don't know how to access its content /emoticons/default_rolleyes.gif' title=':rolleyes:' />
0 -
Altair Forum User said:
maybe simply... delete your table and then recreate it!, if you don't know how to access its content /emoticons/default_rolleyes.gif' title=':rolleyes:' />
@tinhPlease tell me how to convert my material name and property name columns to combo box from above code.
0 -
Hi Jouher
maybe set -type combo
when creating table column
$table columncreate Mname -text 'Material Name' -type combo
if it raises error, it will tell you which types are available
0 -
Altair Forum User said:
Hi Jouher
maybe set -type combo
when creating table column
$table columncreate Mname -text 'Material Name' -type combo
if it raises error, it will tell you which types are available
Thanks @tinh. Drop down came for each row value by giving : '-type combobox'
But, how to give values in that as per my code. Currently its blank.
0 -
Hi Jouher
create that column with option
-valuelistcommand ::p_GetMaterialList
and define the command to return list of mats
ex:
proc ::p_GetMaterialList args {
hm_entitylist mats name
}
0 -
Hi,
Can we have menu options in tk table? What i mean is can we right click on a cell and create menu buttons for it like modify, delete.
Regards
Saumya Mishra
0 -
Sure, it can.
Refer to TkTable page in Tcl/Tk docs
0 -
Hi @tinh, @Pandurang, @akitoguc & all,
How to give right click edit option to each row. I checked the commands but didnt get or understand. Can you help by seeing the above code to explain how to add rightclick option.
0 -