I would like to define constants and use those constants in the definition of my model. For example: a=3 b=4 c=5 and then use those to define my model.
in sph3.s sph a 2*b 2.3*a 3*c/b
What command do I use to define a constant?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can use the fact that you're working in a Tcl interpreter to do this by saving the values as Tcl variables. By default, the MGED command line behaves in a globbing mode like a usual command line, so you'll probably want to turn that off first:
set glob_compat_mode 0
That is also achievable through the menus via File->Preferences->Special Characters->Tcl Evaluation. Once that's set, you can:
set a 3
set b 4
set c 5
in sph2 sph $a [expr 2*$b] [expr 2.3*$a] [expr 3*$c/$b]
You can actually do all that without setting glob compat mode, but you'd have to escape all the []'s and *'s:
Not very pretty, but it should work. Again, it's a full Tcl interpreter so you can pretty much do anything that is allowed in Tcl (or incrTcl for that matter since it's loaded too if you want object-oriented semantics). Those constants and expressions are not stored in the model, they are computed then and there and set on the object. Parametric expresssions are on the to-do list for the next revision of the geometry format.
Cheers!
Sean
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like to define constants and use those constants in the definition of my model. For example: a=3 b=4 c=5 and then use those to define my model.
in sph3.s sph a 2*b 2.3*a 3*c/b
What command do I use to define a constant?
You can use the fact that you're working in a Tcl interpreter to do this by saving the values as Tcl variables. By default, the MGED command line behaves in a globbing mode like a usual command line, so you'll probably want to turn that off first:
set glob_compat_mode 0
That is also achievable through the menus via File->Preferences->Special Characters->Tcl Evaluation. Once that's set, you can:
set a 3
set b 4
set c 5
in sph2 sph $a [expr 2*$b] [expr 2.3*$a] [expr 3*$c/$b]
You can actually do all that without setting glob compat mode, but you'd have to escape all the []'s and *'s:
in sph2 sph $a \[expr 2 \* $b\] \[expr 2.3 \* $a\] \[expr 3 \* $c / $b\]
Not very pretty, but it should work. Again, it's a full Tcl interpreter so you can pretty much do anything that is allowed in Tcl (or incrTcl for that matter since it's loaded too if you want object-oriented semantics). Those constants and expressions are not stored in the model, they are computed then and there and set on the object. Parametric expresssions are on the to-do list for the next revision of the geometry format.
Cheers!
Sean