Hi
I want to keep track with the condition id of the mesh. In my problemtype, it has been kept track manually like
*set cond Surface_Load *elems *canRepeat
*loop elems *OnlyInCond
*condID *ElemsMat
*set var condID= condID+1
*end elems
Is it possible to extract condID from GiD?
On the other hand, is it possible to interact between bas file and tcl script, for example, in bas file, the information is passed to tcl
*tcl(SaveID Surface_Load *condID)
later on condID can be extracted from tcl to bas using the same way. This is my idea, I think it's possible but i'm not able to find that in the Customization Manual
Giang
condition id
Moderator: GiD Team
Re: condition id
GiD applied conditions doesn't has internally any id, it is stored as a list.
You can implictly use the list order as an id, as you have done.
At .bas level you can use direcly the *loop inner counter, named *loopvar, without another extra variable:
e.g.
About passing variables between .bas an .Tcl, it is explained in the customization manual
http://www.gidhome.com/documents/custom ... 20commands
This is the example related on the manual:
A trick to pass a string from Tcl to .bas is to set the value of an auxiliary 'General data' question (that can be hidden). It is possible to set the value from Tcl and ask this value with *gendata(<question>)
You can implictly use the list order as an id, as you have done.
At .bas level you can use direcly the *loop inner counter, named *loopvar, without another extra variable:
e.g.
Code: Select all
*set cond Surface_Load *elems *canRepeat
*loop elems *OnlyInCond
*LoopVar *ElemsMat
*end elems
http://www.gidhome.com/documents/custom ... 20commands
This is the example related on the manual:
As is explained you can assing the value returned by a *tcl procedure to a .bas variable, but it is limited to integer or real numbers, because .bas variables can't store strings.Example: In this example the *Tcl command is used to call a Tcl function defined in the problem type .tcl file. That function can receive a variable value as its argument with *variable. It is also possible to assign the returned value to a variable, but the Tcl procedure must return a numerical value.
In the .bas file:
*set var num=1
*tcl(WriteSurfaceInfo *num)
*set var num2=tcl(MultiplyByTwo *num)
In the .tcl file:
proc WriteSurfaceInfo { num } {
return [GiD_Info list_entities surfaces $num]
}
proc MultiplyByTwo { x } {
return [expr {$x*2}]
}
A trick to pass a string from Tcl to .bas is to set the value of an auxiliary 'General data' question (that can be hidden). It is possible to set the value from Tcl and ask this value with *gendata(<question>)
Re: condition id
I could communicate between bas and tcl using a global variable in tcl, e.g. create a list variable in tcl and fill it in bas, then call it out from tcl in bas
So far this approach works well without problem. However, GiD may crash if the tcl variable is the same with some GiD internal variable. But it's not likely.
Thanks for the link to the manual anyway.
Giang
So far this approach works well without problem. However, GiD may crash if the tcl variable is the same with some GiD internal variable. But it's not likely.
Thanks for the link to the manual anyway.
Giang
Re: condition id
How are you accessing a Tcl variable from the .bas?
Re: condition id
That's pretty simple. In Tcl, declare the global variable and subroutines to read/write it
then it's straightforward to use it within bas file
Code: Select all
set g_conddict [dict create]
proc SaveCond { cond_type args } {
global g_conddict
dict append g_conddict $cond_type "$args\n"
return ""
}
proc GetCond { cond_type } {
global g_conddict
if { [dict exists $g_conddict $cond_type] } {
return [dict get $g_conddict $cond_type]
} else {
return ""
}
}
Code: Select all
*tcl(SaveCond Surface_Mortar_MasterIndex *condID *cond(1))
*tcl(GetCond Surface_Mortar_MasterIndex)