model new
[ ]
fish define abc
abc = hh * 3 + 5
end
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
model new
zone create brick size 10 3 5
fish define place_cables(num,segs)
loop local n (1,num)
local z_d = n - 0.5
command
structure cable create by-line 0.0 1.5 [z_d] 7.0 1.5 [z_d] segments [segs]
endcommand
endloop
end
[place_cables(5,7)]
[1,2,0)][ad3 = gp.near(0,2,1)][ad4 = gp.near(1,2,1)]fish define load load = gp.force.unbal(ad1)->y + gp.force.unbal(ad2)->y + gp.force.unbal(ad3)->y + gp.force.unbal(ad4)->yendfish history load ][ad2 = gp.near(
model new
fish define xxx
sum = 0
prod = 1
loop n (1,10)
sum += n
prod *= n
endloop
io.out('The sum is ' + string(sum) + ' and the product is ' + string(prod))
end
[ ]
里面:+=和*= ,他们分别是连加,连乘。
其实python里面也是类似的,这个比以前的要方便很多
以前是这样写的:
model new
fish define xxx
sum = 0
prod = 1
loop n (1,10)
sum = sum + n
prod = prod * n
end_loop
io.out('The sum is ' + string(sum) + ...
' and the product is ' + string(prod))
end
@xxx
fish define load
load = list.sum(gp.force.unbal(::ad)->y)
end
[ zone.stress(::zone.list)->xx += 500 ]