How to assign loads using TCL in a loop

Moderator: GiD Team

Post Reply
awa5114
Posts: 43
Joined: Thu Jan 26, 2017 5:10 pm

How to assign loads using TCL in a loop

Post by awa5114 »

I am trying to assign a varying condition to GiD model using a loop. Inside the loop is the following:

Code: Select all

set loadvalues {1.0 100.0 1000.0 100000.0}
for {set i 0} {$i<[llength $loadvalues]} {incr i} {
	GiD_Process Mescape Data Materials AssignMaterial "Dry MC" Volumes 1 2 escape
        GiD_AccessValue set condition Solid_Traction y-direction -$currentload
        }
The problem is when the loop is done I find that the loads have all been assigned:
loadcolors.JPG
loadcolors.JPG (22.42 KiB) Viewed 2456 times
instead of getting replaced.

Also in the output .dat file I am not seeing the correct loading information.

What am I doing wrong here?
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: How to assign loads using TCL in a loop

Post by escolano »

about your code
1-it doesn't has sense that the line that assign the material named "Dry MC" to the volumes 1 and 2 is inside the loop.
you are assigning again and again the same material to the same entities.
GiD_Process Mescape Data Materials AssignMaterial "Dry MC" Volumes 1 2 escape

2-you are setting the current field value 'y-direction' of a condition named 'Solid_Traction' to the values of the loop, but you are not assigning these current values to any entity, then are lost.

A GiD material is different of a GiD condition:
-each entity has one, and only one material (or id=0 to any). The entity points to the material (of a list of materials)
-you can change the values of a material and then all entities pointing this material have this new value.
-about conditions, each entity could be pointed by multiple conditions. If the condition is 'canrepeat=no' (default) then the same condition can't be applied to the same entity, the second assignment replace the previous one.
-Each assignation to an entity (geometry/mesh) store its own values, and cannot be modified. What you can do is to assign again the same condition with the new values to the same entity to replace the previous one (or if it is declared 'canrepeat=yes' must unassign and then assign the new one)
Post Reply