Creating a rectangle in TCL

Moderator: GiD Team

Post Reply
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Creating a rectangle in TCL

Post by eduardrocas »

Hello,

I would like to know which is the easiest way to create a rectangle, of specific dimensions and position, using Tcl/Tk. In GiD's graphical user interface there's the possibility of drawing a rectangle, so I'm wondering if it already exists such a function available for Tcl/Tk.

Thanks,
Eduard
User avatar
escolano
Posts: 1921
Joined: Sun Sep 05, 1982 10:51 pm

Re: Creating a rectangle in TCL

Post by escolano »

You can use for example GiD_Process to invoke the GiD tool to create a rectangle, e.g.

Code: Select all

proc MyCreateRectangle { x y width height } {
  GiD_Process Mescape Geometry Create Object Rectangle $x,$y,0 [expr $x+$width],[expr $y+$height],0 escape
}

Or you can create the four points, the four lines, and a the surface explicitly, using GiD_Process commands
or without use the GiD process loop, using the GiD-Tcl procedure GiD_Geometry (see GiD Help on customization to know its syntax)
eduardrocas
Posts: 30
Joined: Thu Dec 11, 2014 2:34 pm

Re: Creating a rectangle in TCL

Post by eduardrocas »

Great. Thanks!
SatuSalo
Posts: 1
Joined: Thu Mar 26, 2015 7:00 am

Re: Creating a rectangle in TCL

Post by SatuSalo »

The canvas widget is Tk's workhorse for 2D graphical display, and can handle both bitmap and vector graphics. It was inspired by Joel Bartlett's ezd program, which provides structured graphics in a Scheme environment. A canvas is one of the most powerful concepts in Tk. It acts as a drawing plane for lines, rectangles, ovals, polygons, text, arcs (e.g. pieslices) as well as container widget to group other widgets, and it provides the ability to group elements together for creation, deletion, moving, etc.
User avatar
amelendo
Posts: 57
Joined: Tue Sep 16, 2014 2:20 pm

Re: Creating a rectangle in TCL

Post by amelendo »

Both answer are correct depending on what you want to achieve. I think that escolano one is what eduardrocas was searching.

For creating a geometry rectangle inside GiD follow escolano answer.

For creating a rectangle on the interface of GiD, for example inside a window, follow SatuSalo answer.

Thanks both for your answers.
Post Reply