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
Find more posts tagged with
Thanks @akitoguc. But, it is displaying component name in table by removing space. But, I want the name to be as it is.
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.
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
@akitoguc I just want to rename component name
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
why don't you use component table in Utility tab?
@tinh Component table is not there in Abaqus profile.
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.
Thanks @Pandurang I have solved the issue.
@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.
@tinh Thanks Tinh, It works smoothly. Now, in the above codes what should be modified to add maximize, minimize and refresh button?
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.b1
And 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?
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.
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.
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.
Hi jouher,
Try
so as to suppress variable expansion, instead of
Regards,